MAT 232 Ch. 4

36 days ago by kcrisman

Section 4.1

We will talk a lot about vectors.

v = vector([1,2,3]) 
       
plot(v) 
       

Here is an example of how to visualize vectors added to other vectors.

var('s,t') @interact def _(V = matrix([[1],[5],[0]]), W = matrix([[0],[1],[1]]),X = matrix([[0],[0],[0]]),show_plane=False ): x = vector([X[0,0],X[1,0],X[2,0]]) v = vector([V[0,0],V[1,0],V[2,0]]) w = vector([W[0,0],W[1,0],W[2,0]]) G = Graphics() G += v.plot(thickness=5) G += w.plot(color='green',thickness=5) for i in [-3..3]: for j in [-3..3]: G += line([(i*v[0]+j*w[0]+x[0],i*v[1]+j*w[1]+x[1],i*v[2]+j*w[2]+x[2]),(i*v[0]+(j+1)*w[0]+x[0],i*v[1]+(j+1)*w[1]+x[1],i*v[2]+(j+1)*w[2]+x[2])],alpha=.5,color='red') G += line([(j*v[0]+i*w[0]+x[0],j*v[1]+i*w[1]+x[1],j*v[2]+i*w[2]+x[2]),((j+1)*v[0]+i*w[0]+x[0],(j+1)*v[1]+i*w[1]+x[1],(j+1)*v[2]+i*w[2]+x[2])],alpha=.5,color='red') if show_plane: G += parametric_plot3d(s*v+t*w+x,(s,-3,3),(t,-3,3),color='red',alpha=.5) show(G+point([0,0,0],color='purple',size=20)+x.plot(color='purple',thickness=5)) 
       
show_plane 

Click to the left again to hide and once more to show the dynamic interactive window

Vectors have norms.

v.norm() 
       
sqrt(14)
sqrt(14)
u = v/v.norm() u.norm() 
       
1
1

Section 4.2

Vectors have dot products.

vector([1,2,3]).dot_product(vector([-3,0,1])) 
       
0
0
vector([1,2,3]) * vector([-3,0,1]) 
       
0
0

Dot product zero means perpendicular ("orthogonal", in general)!

v1 = vector([1,2,3]) v2 = vector([1,1,-1]) v3 = vector([1,0,-1/3]) v4 = vector([0,1,-2/3]) v5 = vector([-2,2,-2/3]) v6 = vector([-1,-2,5/3]) v1.plot()+v2.plot(color='green')+v3.plot(color='green')+v4.plot(color='green')+v5.plot(color='green')+v6.plot(color='green') 
       
v1*v2;v1*v3;v1*v4;v1*v5;v1*v6 
       
0
0
0
0
0
0
0
0
0
0

There are many ways for things to be orthogonal.  Interestingly, we have some polynomials that are, if you consider the inner product to be $\int_{-1}^1 f(x)g(x)dx$.

for i in range(4): show(expand(legendre_P(i,x))) 
       



for i in range(4): for j in range(i+1,4): f(x) = legendre_P(i,x) g(x) = legendre_P(j,x) html("$$\int_{-1}^1 \left(%s\\right) \left(%s\\right)\; dx = %s$$"%(latex(f(x)),latex(g(x)),integrate(legendre_P(i,x)*legendre_P(j,x),(x,-1,1)))) 
       










Or you can try some complex vectors.  They multiply differently in the inner product if correctly done, though we won't go that direction.

vector([i,0])*vector([i,0]) 
       
-1
-1
vector([1+i,2]) * vector([1-i,4]) 
       
10
10
vector([1,i]) * vector([1,i]) 
       
0
0
V = vector([1/sqrt(2),i/sqrt(2)]) 
       
V.hermitian_inner_product(V) 
       
1
1

The functions $\sin(kx)$ and $\cos(\ell x)$ are also all orthogonal on $[0,2\pi]$.

@interact def _(i=([1..5]),j=([1..5])): html("The integral $$\int_0^{2\pi} \sin(%s x)\sin(%s x)\; dx$$"%(i,j)) html("is $%s$"%latex(integrate(sin(i*x)*sin(j*x),(x,0,2*pi)))) html("The integral $$\int_0^{2\pi} \cos(%s x)\sin(%s x)\; dx$$"%(i,j)) html("is $%s$"%latex(integrate(cos(i*x)*sin(j*x),(x,0,2*pi)))) 
       

Click to the left again to hide and once more to show the dynamic interactive window

Let's do some orthogonal projection.

@interact def _(V = matrix([[1,7]]),W = matrix([[-4,2]])): V = vector(V.list()) W = vector(W.list()) ProjVW = (V*W)/(W*W)*W OC = V - ProjVW show(plot(ProjVW,color='green',zorder=5)+plot(V,color='green')+plot(W)+line([V.list(),ProjVW.list()],color='black',linestyle='--')+plot(OC,color='black',linestyle='--'),aspect_ratio=1) 
       

Click to the left again to hide and once more to show the dynamic interactive window

Well, what about in more than two dimensions?

@interact def _(V = matrix([[3,-1,2]]),W = matrix([[1,2,3]])): V = vector(V.list()) W = vector(W.list()) ProjVW = (V*W)/(W*W)*W OC = V - ProjVW show(plot(ProjVW,color='green',zorder=5)+plot(V,color='green')+plot(W)+line([V.list(),ProjVW.list()],color='black',linestyle='--')+plot(OC,color='black',linestyle='--'),aspect_ratio=1) 
       

Click to the left again to hide and once more to show the dynamic interactive window