Vector Algebra

©Fernando Caracena 30 September 2012

The purpose of this section is to show the usefulness of various vector operations.  We begin the discussion with the problem: given two vectors A and B, which are not parallel, find the orthogonal, unit vectors (e1,e2 ,e3), which define the three dimensional space that includes the plane defined by A and B and its normal, beginning with the unit vector e1=A/|A|. We have the freedom to choose the plane defined by A and B as the space defined by the orthonormal basis vectors e1  and e2, that is

A=e1 *Ax                                               (1a)

B= e1 *Bx + e2 *By   .                              (1b)

The third unit vector  e3 is defined by the cross product of A and B (Fig. 1).

Fig. 1 Vector product of A and B defines a unit vector in 3D

Products of two vectors

In this discussion we use the two types of products defined for any two vectors: the scalar product, which yields a number; and the vector, or cross, product, which yields a vector, which is orthogonal to the two vectors involved.

The rule for the scalar (or dot) product is as follows for any two vectors (A and B):

 

 

AB=Ax Bx+AyBy+AzBz.   (2a)

also                    

AB=|A|*|B| cos(θ),      (2b)

where θ is the angle between the two vectors, and the magnitude of a vector is given by

|A| = √(AA).                 (2c)

The cross (or vector product) is defined as follows:

B = e1 (ABz-ABz)+e2 (ABx-ABz)+e3 (ABy-ABx),   (3a)

;also, the magnitudes of the vector product and vectors are related as,

|B|=|A|*|B| sin(θ).                                                   (3b)

Fig. 2 Orthogonal bases vectors generated from two given non-parallel vectors. The first, e1, is red, the second, e2, green and the third, e3, blue.

Note that the basis vectors are orthogonal, unit vectors:

e1e1=1,  e1e2=0 and e1e3=0

e2e1=0,  e2e2=1 and e2e3=0

e3e1=0,  e3e2=0 and e3e3=1  ,

 

which follow the following rules for their cross products:

e1×e1= 0 ,  e1×e2= e3 e1×e3=-e ;

e2×e1= -e3 ,  e2×e2= 0 ,  e2×e3= e;

e3×e1= e2 ,  e3×e2= -e1 e3×e3=0 .

Fig. 2 gives an example of the graphical solution to the above stated problem for the following two vectors, which are initially defined in terms of the orthogonal, unit vectors,u1, u2, u3 :

A = 1/3u1+u2 + 5/3u3

and

= u1- 1/3u2 + u.

The old vector space in which A and B were initially defined (u1, u2, u3) is decomposition into  a new vector space into a new on defined by a set of new basis vectors, e1,e2 ,e3, which are drawn in the colors red, green and blue respectively, a unit circle is drawn in the e1, eplane in the color red. The python code for generating Fig. 2 is presented in Listing 1.

Although the python script cuts through the calculations like a hot knife through butter, sometimes a long hand calculation is best for learning the meanings of the vector operations.  For your convenience, the magnitude of A is computed below

AA=1/9 + 1 + 25/9=35/9

|A|= √(35/9)

=1/3 *√35

e1 =A/|A|

e1 =[1/3u1+u2 + 5/3u3]/(1/3 * √35)

e1 =[u1 +3 *u2 +5 u3]/√35

The vector A expressed in terms of the new basis is

A=1/3 *√35 * e1      .

Problem: Show that the cross product of A and B is the following:

A x B = (2/9) * [7u1+6u2 - 5u3 ] .

 

Vector Identities

Because of the antisymmetric structure of the cross product (3a), it follows that

B x A = - A x B                                                                     (4a)

and

A x A = 0.                                                                            (4b)

It is left to the reader to prove the following identities from definitions of the scalar (2a) and cross product:

A •B x C= A1(B2C3-B3C2)+A2(B3C1-B1C3)+A3(B1C2-B2C1).        (5a)

The above is known as the triple scalar product, the value of which is the same for all cyclic permutation of the vectors(ABC, CAB, BCA) and interchanges of the dot and cross operators:

A x B •C = A •B x C ;                                                             (6a)

BC x A= A •B x C ;                                                             (6b)

C A x B = A •B x C ;                                                            (6b)

and reverses sign for anti-cyclic permutations(ACB, BAC, CBA); 

B A x C = -A •B x .                                                          (6c)

The triple vector product evaluates as follows:

A x B x C = (AC) B - (AB) C .                                              (7a)

Further not that the sum of the three cyclic permutations of (7a) are identically zero,

A x B x C + x A x B + B x C x A =0.                                    (7b)

Finally. we often have to evaluate the scalar product of two cross products,

(A x B) (C x D)=(AC) (BD) - (AD)(BC).                         (8)  

Using the above identities, you will be able to solve a lot of problems involving vectors.

Closing message

Some of the modern scripting languages, such as python, allow you to do scalar products and cross products on vectors defined by you. You do not have to get into the details of those products. You have only to define the vectors in question. This means that you can operate in code rather than doing the math operations manually. Using such languages, you can do many vector operations per second in a three dimensional setting to create animations.

Current teaching techniques emphasize doing a lot of details by hand, hoping that you will learn by some kind of osmosis through rote learning. Here we have pursued a different tack: learn the abstractions and program them directly in a suitable language that is easy to run and ubiquitous to visualize the results. Doing the hand calculations is worthwhile, the first time, just to get the hang of the concepts; but thereafter, I say that you should use the computer as a powerful tool in doing mathematics and physics rather than killing yourself doing a lot of hand calculations.

Listing 1

#_________________________________________________________

ipython --pylab
from pylab import *
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.gca(projection='3d')

ax.set_xlim3d(-1, 1.5)
ax.set_ylim3d(-1, 1.5)
ax.set_zlim3d(-1, 1.5)

ax.set_xlabel('X axis')
ax.set_ylabel('Y axis')
ax.set_zlabel('Z axis')
x=2.
y=2.
z=2.
plot([-x, x],[-y,y],[-z,z],color='w')

a=array([1, 3, 5])/3.
b=array([ 3, -1, 3])/3.
c=cross(a,b)

x=a[0]
y=a[1]
z=a[2]
plot([0., x],[0.,y],[0.,z],color='r')
x=b[0]
y=b[1]
z=b[2]
plot([0., x],[0.,y],[0.,z],color='g')
x=c[0]
y=c[1]
z=c[2]
plot([0., x],[0.,y],[0.,z],color='b')
aa=sqrt(dot(a,a))
ba=sqrt(dot(b,b))
#_____________________________________________________
# Compute the angle between them
L=dot(a,b)/aa/ba #The cosine of hte angle between them.
# Find the angle theta by inverting the cosine:
theta=math.acos(L) #Solution is in radians.
print theta*180./math.pi # Print angle in degrees:
#______________________________________________________

#Define the first orthonormal vector
e1=a/aa
#______________________________________________________
#Define the third orthonormal vector
e3=cross(a,b) #/aa/ba/sin(math.acos(L))
e3=e3/sqrt(dot(e3,e3))
#______________________________________________________
#Find the second orthonormal vector from:
e2=cross(e3,e1)
# In the new coordinate system the vectors are redefined as ap and bp:
x=e1[0]
y=e1[1]
z=e1[2]
plot([0, x],[0,y],[0,0],color='k')
plot([x, x],[y,y],[0,z],color='k')
plot([0, x],[0,y],[0,z],color='r')
x=e2[0]
y=e2[1]
z=e2[2]
plot([0, x],[0,y],[0,0],color='k')
plot([x, x],[y,y],[0,z],color='k')
plot([0, x],[0,y],[0,z],color='g')

x=e3[0]
y=e3[1]
z=e3[2]
plot([0, x],[0,y],[0,0],color='k')
plot([x, x],[y,y],[0,z],color='k')
plot([0, x],[0,y],[0,z],color='b')

#Draw a circle through the ends of e1 and e2:

ang = arange (0.0 , 100.0 , 1.0)  #100 points along the circumference

# are defined by an angular array.

ang=2*math.pi*ang/100. #, which is wrapped into the range 0 to 2*pi.

#Compute x, y, z coordinates along that circle:

x=e1[0]*cos(ang)+e2[0]*sin(ang)

y=e1[1]*cos(ang)+e2[1]*sin(ang)

z=e1[2]*cos(ang)+e2[2]*sin(ang)

plot(x,y,z,color='r')   #Plot the circle as red.

 

#_____________________________________________________________

This entry was posted in mathematics, physics, programming, python, vectors. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *