#linear-algebra

2 messages · Page 67 of 1

vast torrent
#

Yes

#

Even if the matrix is real

wintry steppe
#

Ive never did something like that

Good to know, thank you very much guys! @vast torrent @sonic osprey

gray dust
#

@wintry steppe for future reference don't double post

wintry steppe
#

@gray dust
Sorry, i dont know whats the dofference between linearalgebra and the questions section...
Can i ask questions in #linear-algebra or is it just for discussions and all questions need to be posted here?

#

diff..*

gray dust
#

if you know what topic your question belongs to, you should post in the related channel (so yes linalg q's go to #linear-algebra). the question channels are for if you don't know where your q belongs or if the related channel is currently occupied

wintry steppe
#

@gray dust
Gotcha, won't do it again, thanks!

gray dust
#

yep vvWink

boreal crescent
#

where am i going wrong wtf

#

first column of the B matrix is the coordinate vector of T(v1), where v1 is the first element of the basis

#

T(t^2) = 4 - 6t + 3t^2

dusky epoch
#

your B is ordered

#

as t^2, t, 1

#

it's written that way

boreal crescent
#

ohhh

dusky epoch
#

3t^2 - 6t + 4

boreal crescent
#

yea got it

#

damn

lilac kindle
#

No idea what im doing

dusky epoch
#

$\pdv{u}{x} = \pdv{u}{\xi} \pdv{\xi}{x} + \pdv{u}{\eta} \pdv{\eta}{x} = \pdv{u}{\xi} + \pdv{u}{\eta}$

stoic pythonBOT
dusky epoch
#

$\pdv{u}{y} = \pdv{u}{\xi} \pdv{\xi}{y} + \pdv{u}{\eta} \pdv{\eta}{y} = a\pdv{u}{\xi} + b\pdv{u}{\eta}$

stoic pythonBOT
lilac kindle
#

I dont know how you got that

dusky epoch
#

multivar chain rule

lilac kindle
#

I thought x had to be dependent on E for chain rule to work

dusky epoch
#

what's E

lilac kindle
#

The weird E

dusky epoch
#

there's no E here

#

$\xi$ is "xi"

stoic pythonBOT
dusky epoch
#

$\eta$ is "eta"

stoic pythonBOT
lilac kindle
#

Ah, thanks i will try and solve it now

dusky epoch
#

u = u(xi, eta) = u(xi(x,y), eta(x,y))

lilac kindle
#

Wait, why do you have u = u(xi, eta)

#

I dont see that

dusky epoch
#

bc you're making a change of variables

#

so you want to express u as a function of xi and eta

#

your new vars

lilac kindle
#

So rearrange to x = xi - ay?

dusky epoch
#

no you don't need to do that

lilac kindle
#

I cant see how you merged them together

dusky epoch
#

,,,

#

forget it

lilac kindle
#

Ok, thank you

wintry steppe
#

given a subset - does it have to include the zero vector in order to be a subspace?
suppose i have:

#

$ \mathbb{W} \subseteq \mathbb{R}^4$
is $W = \{(a b c d)| a^2 + b^2 + c^2 + d^2 > 0 \}$ a subspace?

stoic pythonBOT
wintry steppe
#

(a b c d)* ...

dusky epoch
#

given a subset - does it have to include the zero vector in order to be a subspace?
yes it does, otherwise it'll fail to be closed under addition guaranteed

#

or under scaling

wintry steppe
#

because in this subset - i could do
0 0 0 0 + 0 0 0 0 and it would be = to 0 0 0 0 which is not in the subset because 0^2 + 0^2 ... is not > 0 , right? @dusky epoch

dusky epoch
#

the zero vector isn't in your subset

#

it's literally the only vector you're excluding

wintry steppe
#

yes i know so it lacks the zero vector and its not a subspace but i need to circle only one option- i have:
not a subspace because it lacks closure to addition /
scalar multiplication / both

#

@dusky epoch
so if it does not have the zero vector ---> it lacks closure to addition?

dusky epoch
#

if it doesn't have the zero vector it's always guaranteed to lack closure under scaling bc 0v = 0

#

in this particular case your subset also lacks closure under addition because you can take any nonzero vector v and write v + (-v) = 0 because -v isn't zero either and so is in your subset

queen tundra
#

Any good material on tensor product, tensor dot product and tensor double dot product?

severe magnet
#

Let $V$ be a $K$-vectorspace and $F:V \to V$ be a linear transformation with $F^2=-F$. Show that $V=Ker(F) \oplus Im(F)$. $\$ proof: "$\subseteq$" Let $x \in V$. We have two cases to look at: $\$ 1.case: $F(x)=0 \implies x \in Ker(F)$ and since we know that $0 \in Im(F)$ we know that $x = x+0 \in Ker(F) \oplus Im(F)$. $\$ 2.case: $F(x)=w \neq 0$ $\ \iff F^2(x)=F(w) \ \iff -F(x) = F(w) \ \iff F(w+x) = 0 \implies w+x \in Ker(F \circ F) \supseteq Ker(F)$ (proven in another exercise). We also know $w \in Im(F) \implies -w \in Im(F)$ (since Im(F) is a subspace of V). Thus we know $x \in Ker(F) \oplus Im(F)$ in all cases.

#

Is this correct so far?

stoic pythonBOT
lone flume
#

I don't understand why you need to invoke the $\text{Ker}(F^2)$, I mean, you have that $F(w+x)=0$ so $w+x\in\text{Ker}(F)$ and since $w\in\text{Im}(F)$, we have that $x=x+w+(-w)\in\text{Ker}(F)\oplus\text{Im}(F)$.

stoic pythonBOT
severe magnet
#

I just wrote that since I used F twice but yea it is trivial that is right

#

since we know $ker(F^2) = ker(F)$ we know that Im F $\cap$ Ker F = $\lbrace 0 \rbrace$

stoic pythonBOT
lone flume
#

Your proof is correct as I see it

severe magnet
#

thank you for the input 🙂

wintry steppe
#

hi i need to prove/disprove this statement:
if L1 is an eigenvalue of matrix A and L2 is an eigenvalue of matrix B
then L1*L2 is an eigenvalue of at least one of these matrices: AB , BA
i dunno where to even start :(

vast torrent
#

Well you agree it's definitely true if AB or BA share an eigenvector of A and B, right?

wintry steppe
#

how do we know this?

vast torrent
#

Write out the definition of eigenvalue and eigenvector

wintry steppe
#

of I mean, yeah sure if they share an eigenvector, but what if not ?

vast torrent
#

I'm on medication rn that makes me sleepy so

#

I'm on low power mode

wintry steppe
#

we agreed that if AB and BA share an eigenvector with A and B it's true, but that's not the proof in fact i think it's not part of it

vast torrent
#

@wintry steppe i found online that the answer is false. You just need a counterexample where the eigenspaces don't share a common vector

#

So just experiment with 2x2s

#

I searched online bc i couldn't think of any reason why the statement should be true if the matrices considered don't share eigenvectors

#

And i didn't feel like trying to make a counterexample

wintry steppe
#

thank you!!

#

ill try and think of one

vast torrent
#

It shouldn't be too hard because

#

Most matrices don't share eigenvectors

#

So most ones you try should work

#

Btw my tutor taught me a trick in creating counterexamples

#

Want to hear

#

@wintry steppe he said

#

Fix most of the entries as constants, 0, 1,-1

#

And then you can vary one or two entries

#

By introducing a parameter t

#

And then after you matrix multiply

#

If you didn't find your counterexample

#

You can vary the parameter without having to multiply the matrices together each time

pallid rampart
#

Need help with this proof:
Let V be a complex vector space, p be a polynomial with complex coefficients, and T:V->V a linear transformation. Prove that a complex number a is an eigenvalue of p(T) then a=p(λ) for some eigenvalue λ of T

dusky epoch
#

hmm

#

let's see

#

so ker(p(T) - aI) is nontrivial

pallid rampart
#

Yeah

dusky epoch
#

hm.

pallid rampart
#

Um

#

If p=a_0-a+a_1x+...+a_nx^n, then we can find a root

#

then is this root an eigenvalue of T

#

megathink just my wild guess

dusky epoch
pallid rampart
#

I think you'll have to do that, since the next exercise says

#

Show that this is not true of V is a real vector space

#

and all C is replaced with R

#

Got it @dusky epoch

dusky epoch
#

oh :?

#

do tell

pallid rampart
#

4.8 is just basic polynomial factorization over C

#

for some λ1, ..., λn

pallid rampart
#

Btw if you're interested ig, the example I gave was

#

V=R^2, T(x,y)=(-2y,x), p(z)=z^2+1, then -1 is an eigenvalue for p(T), but obviously no real value of λ satisfy p(λ)=-1

thorn prairie
#

Guys, on matrixes ( A + B ) ^-1 equals A^-1 + B^-1?

quartz compass
#

if they're equal, you can multiply both sides by (A+B) and get the identity

thorn prairie
#

What?

quartz compass
#

take this equation: ( A + B ) ^-1 = A^-1 + B^-1

#

multiply both sides by (A+B)

thorn prairie
#

But i asked if they are equal

#

Not that i want to prove they are

quartz compass
#

I'm saying assume it

#

for the sake of contradiction

#

there are other ways, take B=0

thorn prairie
quartz compass
#

(A+B) is invertible but B isn't so it doesn't make sense

thorn prairie
#

basically i want to proove this

#

if i can multiply them seperately with -1

#

then its easy

#

left side is A + B

#

and right side is also A + B

#

also I^-1 equals I?

torn hornet
#

well verify it

thorn prairie
#

how?

#

i think it is

torn hornet
#

how do inverses work

thorn prairie
#

inverse is the ^-1?

torn hornet
#

yes, but what is its defination

thorn prairie
#

um A*A^-1

#

gives I

torn hornet
#

yeah

#

so using this, is the inverse of I I

thorn prairie
#

so basically I and I^-1 i guess are the same

#

right?

torn hornet
#

yes

#

since I*I=I

thorn prairie
#

ok so i found these equations

#

im struggling with what to do on this one

torn hornet
#

for this problem you need this information:

thorn prairie
#

it tells me that

#

A is a nxn matrix

#

with A^4 = 0

#

sorry these are new to me

torn hornet
#

yeah, its like power series

thorn prairie
#

and like no where on my notes i wrote about A^2 , A^3 etc

torn hornet
#

Suppose $A$ and $B$ are square matrices of the same dimention, and are invertible. Denote the inverse $A^{-1}$ and $B^{-1}$. what is the inverse $AB$

stoic pythonBOT
thorn prairie
#

what?

quartz compass
#

this is like your third problem you've posted

#

one at a time

thorn prairie
#

Im sorry i do the terms on greek so im trying to translate

#

i solved the others

torn hornet
#

yeah, answer what i asked

#

this will lead u to proving ur problem

thorn prairie
#

ok my only issue

#

is what denote means

torn hornet
#

umm, it just means im naming the inverses that

thorn prairie
#

if what you are asking is what AB^-1 gives its B^-1*A^-1

torn hornet
#

yeah

#

good

#

Now can you use this information on the problem u sent

#

the first one lol

thorn prairie
#

i solved that one haha

#

thanks

torn hornet
#

the one u posted like, 5 mins ago?

thorn prairie
#

i solved everything i sent besides the last picture

#

with the I - A ^-1

torn hornet
#

ok well then

quartz compass
#

use parenthesis

#

it's just annoying lol

torn hornet
#

yeah lol

#

anyhow

#

just use the defination of an inverse

#

i.e do they multiply to the identity

thorn prairie
#

identity is I?

torn hornet
#

yeah

thorn prairie
#

well the left part

#

will give me I - A^-1

torn hornet
#

paranthesis pls

thorn prairie
#

I - (A)^-1

#

haha what

torn hornet
#

ok so first

#

$(A+B)^{-1} \neq A^{-1}+B^{-1}$

quartz compass
#

I seriously doubt you solved those previous problems

thorn prairie
#

Its so funny whenever i have questions in math

stoic pythonBOT
torn hornet
#

which mero showed to u like

#

2 different ways

thorn prairie
#

@torn hornet You gotta be shittin me. those 2 are unequal?

thorn robin
#

yeah I'm positive he did something illegal to find the inverse of A^{-1} + B^{-1}

thorn prairie
#

I asked before if those are equal and i was getting philosophical responses so i guessed they are

torn hornet
#

yeah ok u didnt prove problem 1

#

no u got a proof

#

lmfao

quartz compass
#

wew

thorn prairie
#

yeah i guess its wrong

quartz compass
#

don't guess, prove

torn hornet
#

he did not give u philosophical responses mate, he told u the reasoning as to why its false

#

which you should pay attention to

thorn prairie
#

well tbh on my notes nowere i see those e2 being equal so yeah

torn hornet
#

can you tell my why these two arent equal

#

again if $B=A^{-1}$, then $AB=BA=I$

stoic pythonBOT
torn hornet
#

this fact should be how you do all problems

thorn prairie
#

but youre assuming

torn hornet
#

assuming what?

thorn prairie
#

if B = A^-1

gray dust
#

not even a nitpick

torn hornet
#

yeah idk how to respond to that except

#

this is how math works

#

lol

thorn prairie
#

Honestly you dont get how hard is to understand the math terms youre saying which i do them in another language

torn hornet
#

english aint my first langauge either

gray dust
#

listen. if $A$ is invertible, ie $A\inv$ exists, by definition $A\inv A=AA\inv=I$

thorn prairie
#

yes but i dont do english terms at all. What does that has to do with what im saying

#

@gray dust yes we are aware of what you sent

stoic pythonBOT
torn hornet
#

ok but do you understand this defination

thorn prairie
#

no wait

gray dust
#

john just said "let B be the inverse of A" so that he didn't have to keep typing A^-1

thorn prairie
#

oh okay. I didnt understand thats what you meant

torn hornet
#

anyhow moving on

thorn prairie
#

Just so we are on the same page

#

for which problem youre talking rn?

torn hornet
#

apply this defination to prove things right

#

first i want you to understand this properly

thorn prairie
#

i understood it

torn hornet
#

so i said $(A+B)^{-1}\neq A^{-1}+B^{-1}$

stoic pythonBOT
torn hornet
#

right, can you prove this

#

using the defination

thorn prairie
#

ok

gray dust
#

defination?

torn hornet
#

defination of inverses that is

gray dust
#

definition vvWink

torn hornet
#

bruh

thorn prairie
#

ok so for this problem

torn hornet
#

Prove what i just said first

#

otherwise you wont get anywhere

thorn prairie
#

the unequality?

torn hornet
#

yes

thorn prairie
#

it makes sense since on the left part you add 2 matrixes then you find the inverse of that lets say C matrix where on the right side you find the inverse of both A and B then add them so it will be a different result

torn hornet
#

i mean intuition is good, but lemme just right this out for you

gray dust
#

write vvLurking

torn hornet
#

If it were true, i.e $(A+B)^{-1}=A^{-1}+B^{-1}$, then by definition of inverse $(A+B)(A^{-1}+B^{-1})=I$, but this expands to $2I+AB^{-1}+BA^{-1}=I$, which is clearly not always true

stoic pythonBOT
thorn prairie
#

i see

torn hornet
#

in your problem, you have $(I-A)^{-1}=I+A+A^2+A^3$. can you use the definition of an inverse here

stoic pythonBOT
thorn prairie
#

umm

torn hornet
#

We are saying the inverse of I-A is I+A+A^2+A^3 yeah

thorn prairie
#

so i multiply left side with (I-A)?

torn hornet
#

yes

thorn prairie
#

and that gives me...

#

I?

torn hornet
#

I on left

#

what about right

thorn prairie
#

So if A^4 = 0

#

that means A = 0 i guess

torn hornet
#

no

thorn prairie
#

so i get I on right side as well

#

A^4 isnt AAA*A?

torn hornet
#

there are non-zero matrices whose powers can be zero

thorn prairie
#

oh i see

torn hornet
#

$A=\begin{pmatrix} 0 &0 \ 1 & 0 \end{pmatrix}$, whats $A^2$

thorn prairie
#

then how does A^4 = 0 help me

stoic pythonBOT
thorn prairie
#

its 0

torn hornet
#

yeah

#

anyhow, expand (I+A+A^2+A^3)(I-A)

thorn prairie
#

oh i multiply both sides

#

ok let me see

torn hornet
#

(matrices who hava a power that is 0 are called nilpotent matrices btw)

thorn prairie
#

ok so basically i get on the right side

#

I - A^4

#

so I

torn hornet
#

yep

thorn prairie
#

alright cool

#

one down

torn hornet
#

So since (I+A+A^2+A^3)(I-A) is I, I-A and the other thing are inverses

#

(note just muliplying both sides of the eqn wont prove it)

thorn prairie
#

why not

#

i say A part = that

#

then B part

torn hornet
#

$-x=x \implies (-x)^2=x^2\implies x^2=x^2 \implies 1=1$

stoic pythonBOT
torn hornet
#

does not tell us anything about the validitiy of the first identity does it

thorn prairie
#

whats this

torn hornet
#

False premises can lead to truths, so showing your identity implies I=I is not a proof

#

is my poiny

#

point

thorn prairie
#

oh i see

torn hornet
#

so instead say that (I-A)(I+A+A^2+A^3)=I, hence these are inverses

thorn prairie
#

so what was the point of telling my to multiply both sides with I - A

torn hornet
#

i just wanted you to multiply those two things lol

thorn prairie
#

so i know that the right side is inverse

#

to I - A

torn hornet
#

indeed

thorn prairie
#

so (I - A)^-1 = that right side

torn hornet
#

mhm

thorn prairie
#

ok one down finally

#

so now

#

what i did before was wrong

#

so i cant do anything on left part

torn hornet
#

lets do what we discussed, try showing multiplying those two is the identity

thorn prairie
#

ok so i multiply both wiith the inverse of the left side

#

so i get an I on the left side

#

and right side gives something that doesnt help me

torn hornet
#

so this one is a bit trickier

thorn prairie
#

wait

#

with the logic applied

#

your logic for the previous one is wrong

#

nvm

#

the logic on the previous one is correct

torn hornet
#

remember $(MN)^{-1}=N^{-1}M^{-1}$

stoic pythonBOT
thorn prairie
#

but we cant apply it here

torn hornet
#

this will significantly simplify your problem

thorn prairie
#

hm

#

um i dont have any matrix multiplication here

#

with the -1 on top of them

torn hornet
#

well, what im saying is

#

try inverting both sides

thorn prairie
#

ok so

#

left side is A^-1 + B^-1

torn hornet
#

ye

thorn prairie
#

um right side

#

A+B?

torn hornet
#

not quite

#

remember how to invert when matrices are being multiplied

#

do that here

thorn prairie
#

i cant see it

#

i multiply right side

#

with like (A+B)^-1?

#

sorry A+B

torn hornet
#

$[A(A+B)^{-1}B]^{-1}$

stoic pythonBOT
torn hornet
#

is the RHS right

#

now how do we invert product of matrices

thorn prairie
#

yeah we can multiply with that

#

its

#

B^-1*(A+B)*A^-1

torn hornet
#

yes

#

now this should be much easier to simplify yeah

thorn prairie
#

so its B^-1 + A^-1

torn hornet
#

exact;y

thorn prairie
#

so basically i prooved

#

that the inverse of the right side

#

is equal to the inverse of the left side

#

thus the normal ones equal as well?

torn hornet
#

mhm, and inverses are one-to-one so yeah

thorn prairie
#

ah i see. Lovely

#

i just realised

#

that probably most of these excersises im not supposed to do them

torn hornet
#

still good practice

thorn prairie
#

since its first time im seeing them

#

yeah. But i have like exercices to do with Cola rank nula nullity and stuff like that and then go to calculus to do sequences

#

anyways if youd be kind to help with the last one

torn hornet
#

yeah sure

thorn prairie
#

ok il send it but let me try it first

#

so i apply the same logic?

torn hornet
#

should be

thorn prairie
#

ok done

#

so inverses are equal with both being B^-1 * A + B^T

#

so normal ones equal

torn hornet
#

yep

thorn prairie
#

lovely

#

btw quick question

#

is it efficient to use det to find inverse of a table bigger than 2x2?

#

or should i do the A | I ~ I| A^-1

#

since they only taught us the det for 2x2 not bigger matrixes

#

for example for exercises where i just need to tell if a matrix is inverse or not and not to calculate it

#

it would be way easier to find the det

#

and see if its != of 0

torn hornet
#

theres several ways to find inverse, i would say its easier to do the A|I ~ I|A^[-1} by hand

thorn prairie
#

rather than trying to find the inverse table the other way until you find a 0 line

torn hornet
#

gaussian elimination is usually efficient

thorn prairie
#

somewhere i heard of Gaus i think

gray dust
#

gauss is very nice for inversion

#

though if i see a fair amount of zeros in a row or col then i don't mind taking the minors

solar osprey
#

If we want to prove the converse of this. Can we say that since for every w that belongs to B we have that w belongs to span then V is subset of span(B). Then since B is a subset of V then span(B) is a subspace of V hence span(B) is a subset of V. Hence the equality

cursive narwhal
#

You are trying to prove the following:

If each v in V can be uniquely expressed as a linear combination of vectors in beta, then beta is a basis for V.

Clearly, $L(\beta) \subset V$. Since $v \in V \implies v \in L(\beta)$, it follows that $V \subset L(\beta)$. This proves that $\beta$ spans $V$. Now, you just need to show linear independence.

Now, if we have $a_1u_1+a_2u_2 + .... +a_nu_n = 0$, then $a_1 = a_2 =...=a_n = 0$ certainly satisfies that equality. In fact, they are the unique scalars that satisfy that equality. This proves that $\beta$ is linearly independent. That shows that $\beta$ is a basis for $V$.

stoic pythonBOT
cursive narwhal
#

@solar osprey

solar osprey
#

thank you dude

empty copper
#

Hotaro Oreki from Hyouka

cursive narwhal
#

Also, note that equivalences don't have converses. What you meant was the converse of the forward implication.

thorn prairie
#

Let F be a 5 × 5 table whose space produced by its columns is not R5. What can you say about its core?

#

Can someone help with this one?

dusky epoch
#

uh

#

did you... translate this from another language

thorn prairie
#

its matrix 5x5

#

yes..

dusky epoch
#

what did you translate it from

#

i'm pretty sure that you meant kernel rather than core

thorn prairie
#

greek

dusky epoch
#

okay nevermind idk why i asked that

#

w/e

#

it's kernel

thorn prairie
#

about tis core

#

i think it means

#

about the nullspace

#

the dimension of NulF

#

correct?

dusky epoch
#

ok if you wanna use the word nullspace so be it

#

so you have a 5 by 5 matrix whose column space isn't R^5

#

i.e. whose rank is less than 5

wintry steppe
#

is this channel taken? :v

dusky epoch
#

i'd err on the safe side and say yes

wintry steppe
#

ok

pallid rampart
#

Translated from Greek pepe_hmm

thorn prairie
#

@dusky epoch so what can i say about the kernel?

#

that its less than 5?

dusky epoch
#

no, you can say that the kernel is nontrivial

#

i.e. has something other than 0 in it

wintry steppe
#

i need to find orthogonal basis for this one

#

is it
-3
1
0

and

0
0
1
?

pallid rampart
#

That is an orthogonal basis

wintry steppe
#

thanks

pallid rampart
#

Now make it an orthonormal basis

dusky epoch
#

problem doesn't say to do that tho does it

wintry steppe
#

lol

#

no

#

in order to complete a set of vectors to an orthogonal basis
do i complete to a basis (with the standard basis) and then do gramshmidt ?

dusky epoch
#

that's one way of doing it ig

#

are the vectors you start with orthogonal?

wintry steppe
#

i start with one

#

lol

#

so basically ye, but what if they arent? i need to do gram shmidt before also

shrewd slate
#

If U is a subspace of V, but U ≠ V. Can it have the same number of dimensions; more specifically, can its basis be the same length?

#

I’m thinking no

#

Yeah nvm it’s very clearly no

slender seal
#

hey how do you define a line?

pallid rampart
#

If its finite dimensional

agile gyro
#

dim(U) = dim(V) <=> U = V

quaint heart
#

Iff it's finite dimensional

#

Not just if

pallid rampart
#

How do you define same dimension in infinite dimensional vector space?

#

The cardinality of the basis?

#

Also, is orthonormal basis kind of generalization of the standard basis?

#

Since the vectors are pairwise orthogonal and each has length 1

quaint heart
#

Yeah cardinality of the basis obviously

#

Lol saying a generalization of the standard basis is dumb

#

What does the standard basis for a k dimensional vector space V even mean @pallid rampart

pallid rampart
#

That was what I meant

#

It doesn't make sense to talk about standard basis

#

So we have orthonormal basis which is pretty nice to work with

quaint heart
#

I think it just let's you do geometry

upbeat mauve
#

I dont understand how this solution gets -3

#

Can someone explain please this is determinants

dusky epoch
#

laplace expansion along third row

#

do the chessboard pattern thingy and you'll find that the 3 in position (3,4) is on a minus square

#
[ + - + - + ]
[ - + - + - ]
[ + - + - + ]
[ - + - + - ]
[ + - + - + ]
upbeat mauve
#

Oh ty

versed topaz
#

If T has an eigenvalue of multiplicity > 1, does its minimal polynomial necessarily have a repeated root?

dusky epoch
#

no

versed topaz
#

Okay, it didn't sound true

#

Ty

dusky epoch
#

take T to be the identity transformation

#

its minpoly is x-1

versed topaz
#

Lol duh

formal bridge
#

Not sure how to prove this

pallid rampart
#

🤔 is this linear algebra?

formal bridge
#

yeah maybe, the class is abstract linear algebra so could very well be both

#

ill go there though, more on the abstract algebra side

wintry steppe
brittle juniper
#

you're asked to find θ so you should try to at least make θ appear out of all this info

#

for example, you can have a look at ||u+v||²

wintry steppe
#

Does this somehow relate to the defenition of dot product?

nimble egret
#

yes

wintry steppe
#

Oh ok so i can square both sides of eq1 and expand dot product

nimble egret
#

try it and see if you get somewhere useful

pallid rampart
#

\|\|u\|\|

#

will work

wintry steppe
#

arcos(-2||u||/||v||)

#

i feel i might have missed something

quartz compass
#

|u| and |v| are related

#

so you can simplify that

#

@wintry steppe

wintry steppe
#

Oh, so then arcos(-1) = pi

#

Thank you guys, i appreciate it

quartz compass
#

yeah yw

#

geometrically it should hopefully be obvious to confirm

wintry steppe
#

Yeah now i notice for u+v to have same mag as u, v must travell back 2||u|| in opposite dir

idle osprey
#

Hi can someone please explain how one would find a basis for R3[x] when you have a basis A=2, B=3, C=5, D=-5 of a vector subspace of R3[x]
The vector subspace in this case is U={p(x) € R3[x] | p'(0) = p(1)} and we also know that R3[x] is a vector space of polynomials of max coefficients 3

torn ermine
#

Quick question: Is a matrix diagonalisable iff it is a normal matrix?

short root
#

Good question

torn ermine
#

... and the answe is? 😛

#

<@&286206848099549185>

pallid rampart
#

For this we only need to assume that (e_1,...,e_n) is an orthogonal basis right?

#

doesn't need to be orthonormal

#

Oh wait nvm

#

We need orthonormal

#

But how should I interpret this theorem?

#

What's the intuition for inner product?

pallid rampart
#

It's not R^2, it's the subset of R^2 with integer entries

coral tinsel
#

I'm writing a calculator for a factory game, and I need to figure out how I came to an answer so I can abstract it and put it in a program

pallid rampart
#

@real plaza yes

#

I was just correcting the fact that you said "since R^2 only takes integers"

#

which is not true

half ice
#

Oh fuq you're playing satisfactory

coral tinsel
#

yeap

half ice
#

What does the answer represent?

coral tinsel
#

what ingredients that iron ingot constitutes

half ice
#

How's update 3? I haven't had much time to play

coral tinsel
#

I haven't even build coal yet

#

down a rabbit hole with this calculator

half ice
#

Sadly representing this with a matrix is eh

#

A tree is the better way, if that makes any sense

coral tinsel
#

Can't

#

Directed cycles, also two-product recipes

half ice
#

... There's two product recipes now?

#

Oooh

coral tinsel
#

Everybody's math is screwed up

half ice
#

Oh wow that's interesting

coral tinsel
half ice
#

What's that on the right? Oil?

coral tinsel
#

Fuel

half ice
#

IC

coral tinsel
#

Pipes btw

half ice
#

What's your goal? Just to reduce everything down to most basic elements?

coral tinsel
#

Yup

half ice
#

Those cycles do screw everything up, as you can arbitrarily waste resources now. You might want to just ignore them

#

Or come up with a good rule on how they should be used

coral tinsel
#

Which I thought matrix operations could do

#

But I p much forgot how to matrix

#

tho this is Haskell so it won't be crazy to define everything from scratch

half ice
#

I mean you could have a massive vector of every product in the game, then creating a product is the same as multiplying that vector by some matrix

coral tinsel
#

sparse matrices

half ice
#

But you're looking to do this backwards, and these matricies won't have inverses lol

#

Or, they might actually. They'll all be mostly 1

coral tinsel
#

yup

half ice
#

Congrats on knowing Haskell

#

That's a skill

coral tinsel
#

*relearning Haskell after writing almost no code for 2 years

half ice
#

That inverse matrix idea might actually be pretty good, but it still won't really explain how to deal with cycles

#

Is there a "best strategy" on how to use those alternates?

coral tinsel
#

as in which ones to use and which ones not to?
some people have their rankings

#

but I was wanting to preserve the alternates data

half ice
#

@coral tinsel
The problem is you're introducing something that isn't invertible into the system. If I gave you my final product, you can't possibly tell me what I started with, because you can't know how many times I used the cyclic alternates

#

Even if you knew exactly which recipes I used

coral tinsel
#

They incur a fuel cost each iteration

#

I intend to add energy cost too....

#

It suddenly feels like the second law of thermodynamics and quantum non-determinacy are involved...

#

Did I mention that I was going to use RREF?

gloomy arrow
nimble egret
#

What's you justification for the last one

#

It might be linearly dependent

#

But I can't see the dependence immediately

#

And I don't have paper

gloomy arrow
#

I said that the last ones are linearly dependent because the amount of vectors is greater then the entries of the vectors

nimble egret
#

Oh lmoa

#

True

#

Yeah

#

Looks fine

#

Since the first two are linearly independent

#

They span R2 and so the third is necessarily in their span and stuff

#

Ok

#

Yeah

gloomy arrow
#

First 2?

#

I said the second one is lineraly dependent because in includes the zero vector

nimble egret
#

Yeah, that's fine

#

I mean first two vectors in e

#

Zero vector, you can adjust the coefficients

#

To satisfy the definition of linear dependence

gray dust
#

this all looks fine

gloomy arrow
#

OKay thank you. I might come back frequently to have my answers double checked

gray dust
#

but it never hurts to also show some work, just in case you get smth wrong and i need to check what you did

gloomy arrow
#

Oh yes I will show my work next time

copper cobalt
#

does nayone know min plus algebra

gloomy arrow
nimble egret
#

This one

#

Is pretty easy to check

#

Just do the multiplication with your result

#

And see if you get [6, 18]

gloomy arrow
#

Yup, I got it

#

Thanks

#

This would just be the idenity matrix multiplied by negative 8 right?

gray dust
#

don't forget we have rotation by an angle of pi too

nimble egret
#

The negative does that doesnt it?

gloomy arrow
#

Yeah the negative would account for the rotation

gray dust
#

you're right it does

gloomy arrow
#

Alright, this will be my final question. I was able to reduce this to RREF. I have all 0s in the last row, and ones on the diagonal up top

#

So its one to one because there is no free variable

#

And i forgot what onto is

gray dust
#

onto <-> surjective

gloomy arrow
#

I uh, dont know what that means

#

I dont think our professor used the term surjective

gray dust
#

that's interesting

#

take a look at the size of A. it tells me that T is a linear map from R^3 to R^4

gloomy arrow
#

Right

#

3 columns 4 rows

#

So it means that every image is a transformation of a vector?

gray dust
#

uhh not sure what you're getting at

gloomy arrow
#

Me neither

gray dust
#

i mean for any function T, we call T(x) the image of x under T

#

anyway your rref shows that the columns of A are linearly independent

#

so the span of A's column vectors which in this case is also the image of T is a 3d subspace in R^4

gloomy arrow
#

We havent gotten into spaces and subspaces yet

#

But I see what youre saying

gray dust
#

a 3d hyperplane in 4d space if you like. point is, the dimension of this plane is 1 less than the "ambient" space

gloomy arrow
#

Okay but how does that relate to onto

gray dust
#

first you'd have to recall what a function's domain and codomain are

#

as well as what injective/surjective functions are

gloomy arrow
#

I know what domain and codomain are

#

not injective or surjective

gray dust
#

and you know the difference between codomain & image?

gloomy arrow
#

Yeah

gray dust
#

say f is a function from X to Y. we say f is surjective aka onto if for all y in Y, there exists at least one x in X such that f(x)=y

gloomy arrow
#

But when would it not be equal

#

Example wise

gray dust
#

$\fxn{f}{\bR}{\bR}{x}{x^2}$

stoic pythonBOT
gray dust
#

dom(f) is the set of reals, codom(f) is also the set of reals

#

we definitely have -1 in codom(f) but there doesn't exist anything in dom(f) that gets mapped to -1

gloomy arrow
#

ohhhh i see

gray dust
#

now let's say

#

$\fxn{g}{\bR}{[0,\infty)}{x}{x^2}$

stoic pythonBOT
gloomy arrow
#

Thats onto because we dont have to worry about the negative numbers

gray dust
#

say f is a function from X to Y. we say f is surjective aka onto if for all y in Y, there exists at least one x in X such that f(x)=y
an easier to digest rephrasing of this is, every element in Y is the image (under f) of at least one element in X

gloomy arrow
#

But for the example with the matrix wouldnt every Y be an image? I cant really think of a counter example

gray dust
#

hold on what's dom(T) and codom(T)?

gloomy arrow
#

domain would be R4

#

co domain would be R3

#

Wait no

#

Other way around

#

Domain would be R3 and co domain would be R4

gray dust
#

ok and through RREF you showed that the columns of A are linearly independent

gloomy arrow
#

yes

vital raft
#

could somebody help me with a quick question

#

are you guys busy

#

?

gray dust
#

A has 3 lin indep columns so this leads to T's image being a 3d hyperplane in R4

gloomy arrow
#

Right

#

But not every thing in R4 would be something from R3

#

Right?

#

I mean what would be a quick way of checking

gray dust
#

sure, clearly there exist vectors in R4 that aren't the image of smth in R3 under T

#

for me it's enough to do the RREF to show A's cols are lin indep thus the dimension of T's image is 3 which is one less than the dimension of codom(T)

gloomy arrow
#

So therefore its not onto

gray dust
#

T isn't onto

gloomy arrow
#

Gotchu

#

Thanks

gray dust
#

you're welcome vvWink

vital raft
#

rokabe

#

could you help me real quick

#

?

gray dust
#

just post, don't ask for me specifically

vital raft
#

oh sorry

#

but anyways

#

is y=4x^2 (parabola) considered increasing faster than y=5x+10

#

?

gray dust
vital raft
#

my bad

gray dust
#

no worries

gray dust
#

@wintry steppe yeah no

wintry steppe
#

ok thanks

sturdy raven
#

if u say so

limber sierra
#

you mean

#

the columns of the matrix are linearly independent?

#

yes

sturdy raven
#

well if you were to find the zero matrix of a singular non-zero element that is any given position in any size matrix then you would see to be proven correct

limber sierra
#

write, say, $\begin{pmatrix}1&0&0\0&0&1\0&1&0\end{pmatrix} = \lambda_1\begin{pmatrix}1\0\0\end{pmatrix} + \lambda_2\begin{pmatrix}0\0\1\end{pmatrix} + \lambda_3\begin{pmatrix}0\1\0\end{pmatrix} = \begin{pmatrix}\lambda_1 \ 0 \ 0\end{pmatrix} + \begin{pmatrix}0\0\\lambda_2\end{pmatrix} + \begin{pmatrix}0\\lambda_3\0\end{pmatrix} = \begin{pmatrix}\lambda_1\\lambda_3\\lambda_2\end{pmatrix}$

stoic pythonBOT
limber sierra
#

linear independence should be obvious from here

#

yeah but this technique generalizes (at least to finite matrices)

#

just do induction or w/e

#

theres probably a better way than induction but

#

idk what you know

wintry steppe
#

I'm confused how to approach 38.2

#

I understand 38.1 because its the basis vectors which is easy

#

but I don't understand how to do it when i'm writing it in terms of the basis vectors

limber sierra
#

you need to solve $\lambda_1 \begin{bmatrix}2\1\end{bmatrix} + \lambda_2 \begin{bmatrix}5\3\end{bmatrix} = \begin{bmatrix}1\0\end{bmatrix}$

stoic pythonBOT
limber sierra
#

and similar for $= \begin{bmatrix}0\1\end{bmatrix}$ (but different values of $\lambda_1, \lambda_2$)

stoic pythonBOT
cursive narwhal
#

You have two equations with e_1 and e_2 as unknowns

limber sierra
#

huh

#

e_1 and e_2 are the standard basis

#

theyre not unknowns

cursive narwhal
#

Yea sure but you could treat them as 'unknowns' and work from the equations in part (i), no?

#

Like, eliminate e_1, find e_2, then find e_1 using the expression for e_2

limber sierra
#

oh sure

#

that definitely works too

#

in any case, you're just solving a system of linear equations

#

my technique would just have you write $\lambda_1 \begin{bmatrix}2\1\end{bmatrix} + \lambda_2 \begin{bmatrix}5\3\end{bmatrix} = \begin{bmatrix}2\lambda_1 + 5\lambda_2\\lambda_1 + 3\lambda_2\end{bmatrix} = \begin{bmatrix}1\0\end{bmatrix}$

stoic pythonBOT
limber sierra
#

and hence you need to solve the system $2\lambda_1 + 5\lambda_2 = 1, \lambda_1 + 3\lambda_2 = 0$

stoic pythonBOT
wintry steppe
#

Oh I see because the [1,0] was already known

#

makes sense

limber sierra
#

(and then do a similar thing but for [0,1])

wintry steppe
#

but how would I do it with @cursive narwhal method

cursive narwhal
#

There's no specific method over here

#

It's almost the same as namington's method

limber sierra
#

well i'd probably take $c_2 = 5e_1 + 3e_2$ and subtract $3c_1$ from both sides

stoic pythonBOT
limber sierra
#

$c_2 = c_2 - 3c_1 = 5e_1 + 3e_2 - 3c_1 = 5e_1 + 3e_2 - 3(2e_1 + e_2) = -e_1$

#

hence $e_1 = -c_2 + 3c_1$

#

and use that to solve the other equation

#

lmao ignore that

stoic pythonBOT
wintry steppe
#

well i'd probably take $c_2 = 5e_1 + 3e_2$ and subtract $3c_1$ from both sides
why do we subtract 3c1 from both sides

stoic pythonBOT
limber sierra
#

sorry just realized im an idiot

#

had to fix my work

#

uh i subtracted 3c_1 because it eliminates the 3e_2

#

do you know how to solve systems of linear equations?

#

this is just elimination

wintry steppe
#

oh it makes sense now

#

thank you

wintry steppe
#

how would I do 39.4

restive shuttle
#

im so lost at this conceptual problem

normal canyon
#

Is it not exist @restive shuttle

restive shuttle
#

i think i have a solution now

normal canyon
#

What’s the answer

#

@restive shuttle

restive shuttle
#

ima write it up first, 1 sec

#

Since A and B are invertible, they have nullity 0. The product of two invertible matrices is also invertible. So AB and BA also have nullity 0. Therefore by rank-nullity theorem, the rank of both AB and BA is n.

#

@normal canyon

normal canyon
#

So it’s false?

restive shuttle
#

yea

pallid rampart
#

Um

#

B is not invertible

restive shuttle
#

gg

restive shuttle
#

I don't know how to go forward on this. I got that the rank(A) = rank(B) = 2 by rank nullity theorem

#

and rank(AB) = 0, since AB = 0

dusky epoch
#

the nullspaces of A and B both have dimension 1 and their column spaces both have dimension 2 and for AB = 0 you need the col space of B to be contained in the nullspace of A

#

and that's impossible

restive shuttle
#

why does the col space of B have to be contained in the nullspace of A for AB = 0

dusky epoch
#

you want ABv = 0 for all v

#

Bv is an element of B's col space by defn

coral ferry
#

i've looked at a lot of linear algebra books like strang, lang and hoffman kunze

#

but i don't find them to be both comprehensive and also clear

#

do you guys have any recommendations?

#

im a first year uni student btw, i guess pure maths linear algebra is the flavour im learning

sonic osprey
#

These are pretty much the standards, what exactly didn't you like about them?

coral ferry
#

i tried hoffman kunze but i didnt find it to be that clear

#

strang was great but it wasn't very proof based

sonic osprey
#

Hm, from what I've read of it Hoffman Kunze is pretty clear

#

You just might not be super used to reading math textbooks?

coral ferry
#

yea that's probably it

#

very precise

sonic osprey
#

They're pretty different from reading anything else and things are never really clear at first

#

You have to struggle with and think about things before they become clear

coral ferry
#

yea

#

should i just keep at it with hoffman kunze?

sonic osprey
#

Take your pick

#

That's what I usually recommend

coral ferry
#

alright thank you

bold blade
#

okay sorry this is a dumb question but its like 4am and ive been doing linear for so long

#

how do u get from

#

here to

#

here

#

is it a property?

dusky epoch
#

i'm p sure this is false as stated

#

unless there's some missing context

bold blade
#

yea theres context ;ol ill send the full thing

dusky epoch
#

ah so {v1, v2, v3} is an orthonormal basis

bold blade
#

um.. sure

#

honestly dont rly understand this stuff conceptually which i know is bad but my schedule this quarter sucks and the teacher doesnt rly go deep in theory so i just memorize how to do stuff

#

okay wait it is . aproperty

quartz compass
#

the cross product takes two vectors and gives you a new vector perpendicular to both of those given by the right hand rule

#

the length of that new vector is the product of lengths of the input vectors, times the sine of the angle between them

#

if you know this, it's enough to get the direction and magnitude and answer your question, any of this new to you @bold blade ?

bold blade
#

yea i learned that stuff in calc 3 but im taking it at the same time

#

i didnt end up actually needing it for this question tho..

#

i just took column vectors to find the basis

#

i was just confused bc there were no numbers but its the same process i guess

quartz compass
#

if you didn't "need it for this question" then I don't know how you could have answered it

#

this isn't a property on its own

#

it's something that comes from the cross product with angle of 90 degrees between the vectors and the vectors having length 1

lone plover
#

Well I have a transformation of rotation followed by an enlargement

#

2sqrt3 -2
2 2sqrt3

#

and to find the SF, the mark scheme found the determinant, then said that SF is 4, and the determinant of that matrix is 16

#

and it didnt really explain the reasoning for the SF being 4

#

^Wondering if anyone can help clarify

vast torrent
#

What's "SF"?

spiral sonnet
#

What does R^4 mean? R is the real number symbol.

pallid rampart
#

R^4 means the set of tuples (x, y, z, w), where x,y,z,w are in R

vast torrent
#

Often implied with it is a way to add the tuples or multiply the tuples by numbers, component-wise

#

@spiral sonnet

#

But not always

buoyant hemlock
#

can some1 explain how they got from the first line to the second, like it makes sense when I look at it but thats only by intuition, is there a formalized way to make the transition of sums to vector/matrix representations

lone plover
#

What's "SF"?
@vast torrent scale factor

rain lotus
#

the geometric interpretation of the determinant is: if you take the square made by the standard basis (or hypercube, in n dimensions) it gets distorted when you apply the matrix, and the area/volume changes by some factor. that factor is the determinant. so when you have a rotation and a scaling, the determinant is the scaling factor of the area, which is the square of the scaling factor of a basis vector

limber sierra
#

ok?

earnest juniper
#

If I have a matrix and want to reverse 2 segments (parts) of that matrix . Is there a better approach to reverse only a smaller part if they intersect?
Both start and end are inclusive as shown in the example below.

Example:
We have the matrix [1, 2, 3, 4, 5] and want to reverse from position 1 > 4 ( becomes [4, 3, 2, 1, 5] ) and then 3 > 5 so it should become [4, 3, 5, 1, 2] as the final result.

rain lotus
#

@limber sierra i was trying to answer the question asked by @lone plover

limber sierra
#

ah, sure

#

@earnest juniper so you mean a permutation? not sure how matrices relate here

lone plover
#

Ah ok

earnest juniper
#

No idea, it's a list of numbers.

limber sierra
#

im not really sure what this means:

Is there a better approach to reverse only a smaller part if they intersect?

#

like, do you just want the programming method?

earnest juniper
#

The problem is that I cannot use the normal reverse methods as I'm limited in the time.

limber sierra
#

limited in time? like computational time?

earnest juniper
#

I'm learning competitive programming and I'm solving a couple of things now, so in competitive programming I have a time limit that I cannot exceed.

#

Yes, the computational time (time taken to execute operations).

limber sierra
#

ok, that clears up what youre asking

earnest juniper
#

So I'm looking for a better approach to these flips/reverses.

limber sierra
#

i recall there being an O(n) algorithm for exactly this, but i cant recall it off hand

#

gimme a minute to think

earnest juniper
#

Okie.

limber sierra
#

so for context i know python has a .reverse() list method, which is O(n) in the length of the sublist, but i'm unable to find good pseudocode for that

#

here's the source code:

#
static void
reverse_slice(PyObject **lo, PyObject **hi)
{
    assert(lo && hi);

    --hi;
    while (lo < hi) {
        PyObject *t = *lo;
        *lo = *hi;
        *hi = t;
        ++lo;
        --hi;
    }
}

static PyObject *
listreverse(PyListObject *self)
{
    if (Py_SIZE(self) > 1)
        reverse_slice(self->ob_item, self->ob_item + Py_SIZE(self));
    Py_RETURN_NONE;
}```
#

as far as i can tell, here's the explanation:

#
1. Keep track of 2 indices, initially set to the start and end of the list.
2. Swap the elements at these indices.
3. increment the left index, decrement the right index.
4. Repeat from 2 while the right index > the left index.```
#

in this case, you'd start these indices at the start and end of the subarray

#

but same gist

earnest juniper
#

I'll need to do 2 * 10^11 reverses, how much will that method take?

limber sierra
#

if i'm understanding it correctly, this algorithm takes n/2 iterations, so 10^11 iterations

#

i'm not aware of if there's a faster direct method

earnest juniper
#

Is that for each reverse or for all of these reverses?

limber sierra
#

to do 2*10^11 reverses

#

er wait

#

sorry misunderstood what you meant

#

these are separate reverses? hmmm

#

well, it still takes n/2 time for each reverse, so k*10^11 where k is the average length of a reversed subarray

#

roughly

earnest juniper
#

Array Size (1 ≤ N ≤ 100)
Reverses (1 ≤ K ≤ 2 * 10^9)

limber sierra
#

this doesnt seem particularly efficient, unfortunataly; there may be a better way

#

like i doubt theres a faster way than what python is implementing, since otherwise python would use it

#

oh wait hold on

#

do you know your arrays are always initialized in ascending order?

#

like do all your arrays start as 1 2 3 4 5 6 ...

earnest juniper
#

Yes, that is guaranteed.

limber sierra
#

ah, that makes this easier

sonic osprey
#

I think his question was more that, if we knew we had to do multiple reverses, is there some way we could save time rather than just doing each reverse after the other

limber sierra
#

zoph the answer to that question is "no if you don't know the original setup of the array at all"

#

but since the array is in natural ascending order like that, there's probably some tricks you can use

earnest juniper
#

I couldn't find these "tricks", so I was wondering maybe I could use another brain to help me 😂

sonic osprey
#

I'm not sure why the array being in ascending order matters here?

limber sierra
#

yeah, i'll think about it but it's been a while since i programmed anything tricky like this

sonic osprey
#

okay, things are easier to compute

limber sierra
#

zoph it means we dont need to keep track of each element's value

sonic osprey
#

yeah yeah okay

#

maybe just ping Horse tbh

limber sierra
#

i mean i want to look at this as a cycle composition now

#

lmao

#

thats probably not the best answer but

#

its what my mind jumps to

#

let me see if thats practical actually

#

using the cycle composition algorithm

#

hm, nah, the only way i can think of using the cycle composition algorithm here would probably be O(n^2) (or perhaps O(nlogn))

#

yeah, sorry, this is a bit above my programming paygrade

earnest juniper
#

Thanks for trying, is there possibly someone else that's more familiar with these things? (time, tricks, etc.)

limber sierra
#

well, as zopherus said

#

@pastel harbor

#

if you wouldnt mind ❤️

#

if you're wondering what my cycle idea was, it exploited the property that a "reversing" permutation from a to b can be written as the cycle starting with (a b ...); sadly the only way i could think of to make use of this property required nested for loops, which wouldnt work so fast

#

there's probably a cleaner way in haskell, of all things

earnest juniper
#

Alright, I'll provide as much details as possible that can help obtain the trick behind this question.

#

1: The starting array is sorted from 1 until 100
2: The reverse operation consists of 2 parts:
2.1: Reverse all elements in positions X1 .... X2
2.2: Then, reverse all elements in positions Y1 .... Y2

When repeating the reverse step you're repeating Step 2 in the same order with the same numbers every time.

#

Does that help? [@limber sierra]

#

The reverse operation is done on the same indices every single time.

limber sierra
#

oh interesting

pastel harbor
#

oh

#

hi

#

looks like I'm not too late to this

limber sierra
#

your services have been conscripted

#

lmao

earnest juniper
#

Yeah, awesome timing :P

pastel harbor
#

ok so the question you have

#

is to reverse twice in an array?

#

or are you trying to generalize

#

to k reverses

#

if the question is for k

earnest juniper
#

I basically repeat Step 2 K times.

pastel harbor
#

you can generalize with a fenwick/segment tree

#

yeah, then you can use a segment tree or fenwick tree

#

to keep track of the endpoints

#

and it reduces to a prefix sum problem

#

let me explain

#

notice that you only need to know the endpoints

earnest juniper
#

You mean X2 and Y2?

pastel harbor
#

I mean X1, X2, Y1, Y2

earnest juniper
#

Alright.

pastel harbor
#

so what you can do is

#

mark X1 with a +1

#

X2 with a -1

#

now the prefix sum indicates

#

whether an element is reversed or not

#

[0, 1, 0, 0, -1, 0]

#

prefix sum is [0, 1, 1, 1, 0, 0]

earnest juniper
#

Ok.

pastel harbor
#

so now you can extend this logic

#

you can apply all of your reverses in bulk

#

and then finally extract the resultant array

#

tbh

#

wait

earnest juniper
#

But at each step, I need to do the X first then Y after.

pastel harbor
#

yes

#

I think there might be a simpler way where you don't even need this, let me think if that is possible

earnest juniper
#

Oki.

pastel harbor
#

I mean the second reverse doesn't really matter

#

because the question is basically saying 2K reverses in total then

#

is that right?

earnest juniper
#

But the second reverse is reversing a different segment with different endpoints, doesn't that make a difference?

pastel harbor
#

are you saying

#

that X1 and X2

#

are the same in each step

earnest juniper
#

Yes, that's correct.

pastel harbor
#

oh

#

then this is much simpler

#

I was solving for different X1 X2 in each step

#

that is still solvable in n log n

earnest juniper
#

When repeating the reverse step you're repeating Step 2 in the same order with the same numbers every time.

pastel harbor
#

right, my bad

#

one sec, I should be able to devise something simple

earnest juniper
#

Alright.

pastel harbor
#

ok

#

you can just make cases

#

and do it in linear time

#

if they don't intersect

earnest juniper
#

I thought the first case can be if there's no intersection.

pastel harbor
#

and if they intersect

#

if they intersect

#

take section from the front

#

of length equal to intersection

#

if this exceeds half intersection point

#

then you will need to recursively repeat

#

I could write some code tomorrow when I'm up 👀

#

what language do you find easy to read?

earnest juniper
#

I need to hand over the thing now, can you just explain the last part one more time?

#

I'm working with C++.

pastel harbor
#

ok, so

#

let x1, x2 be 1, 5

earnest juniper
#

Alright.

pastel harbor
#

y1, y2 be 3, 7

#

3 to 5 is intersection

#

this means

#

after the first swap

#

you will have elements from

#

x1 to x1 + (intersection length)

#

inside that region

#

now, you will have x2 to y2 as the other points

#

note that in this case x2 to y2 is smaller

#

you will need to make different cases here as well

#

based on whether it is larger or smaller

#

this is what I meant where you do the x1 + intersection length as well

#

you will need to make two cases there

#

here the 3 will still come into the intersection

#

because intersection is larger

#

you must consider smaller intersection as separate case

#

anyway, if you handle all these cases

#

you can get a linear solution

#

but this is just pain tbh

#

for n = 100

#

no one cares,

#

you can just write the dumb n^2

#

and it will still run in under a second

earnest juniper
#

But K can be up to 10^9, doesn't that make a difference?

pastel harbor
#

oh