# 化學數學（一） The Mathematics for Chemists (I) (Fall Term, 2004) (Fall Term, 2005) (Fall Term, 2006) Department of Chemistry National Sun Yat-sen University.

## Presentation on theme: "化學數學（一） The Mathematics for Chemists (I) (Fall Term, 2004) (Fall Term, 2005) (Fall Term, 2006) Department of Chemistry National Sun Yat-sen University."— Presentation transcript:

Chapter 3 Vector Algebra and Analysis
Definition Scalar (dot) product Vector (cross) product Scalar and vector fields Applications

Content covered in the textbook: Chapter 16
Assignment: pp : 15,17,18,24,25,30,32,35,40,41, 43,47,48,55,58,60

Definition (naïve) B a a=AB A
Vectors are a class of quantities that require both magnitude and direction for their specification. a Terminal point Terminal point A a=AB B Initial point Initial point Unit vector: a vector of unit length. Null vector: a vector of zero length. (its direction is meaningless.)

Examples of Vectors Position, velocity, angular velocity, acceleration
Force, torque, momentum, angular momentum Electric and magnetic fields, electric and magnetic dipole moments,

Vector Algebra a b Equality: a b a+b Addition: a b a+b -b a-b
Subtraction: Scalar multiplication: a 1.5a -a -0.5a

Example Show that the diagonals of a parallelogram bisect each other.
We need to show that the midpoints of OD and AB coincide. O a b A B D C C’

Classroom Exercise Show that the mean of the position vectors of the vertices of a triangle is the position vector of the centroid of the triangle. O A B C a b X B O A C a b X C’ C’’

Components and Decomposition
θ a O N P x y i j a axi ayj x=(2,3),y=(4.2,-5.6)

Components and Decomposition (in 3D Space)
axi azk ayj

Vector Algebra Restated

Example

The Center of Mass (Gravity)

Dipole Moments -q r1 r Dependence of reference frame: q r2
If the total charge Q is zero (e.g., in a molecule), then Total dipole moment:

Electric dipole moments

Symmetry and Dipole Moment
The total dipole moment of a tetrahedron: r4 r1=(a,a,a), r2=(a,-a,-a), r3=(-a,a,-a), r4=(-a,-a,a) r1 r2 r3

Base Vectors Orthogonal basis: axi azk ayj Nonorthogonal basis:

Classroom Exercise

Scalar Differentiation of a Vector
B O a(t) a(t+Δt) Δa

Parametric Representation of a Curve
x y z r(t) C a b t

Position, Velocity, Momentum, Acceleration Newton’s Second Law
Speed: Linear momentum: Kinetic energy: Acceleration: Newton’s second law:

Classroom Exercise Write the expression of momentum in terms of the planar polar coordinates

The Scalar (Dot) Product
Proof: θ a b O B A

Example

θ a b O B A b b θ a θ O a O If Classroom exercise

Orthogonal and Coincident

Cartesian Base Vectors
Orthogonality: axi azk ayj Normalization (unit length):

Force and Work

Force and Work: General Case
B O r(t) r+Δr Δr F(r) F(r+Δr)

Charges in an Electric Field
θ μ E

Magnetic Moment in a Magnetic Field
θ m B

HOW DO YOU KNOW THEY ARE PARALLEL WITH EACH OTHER?

The Vector (Cross) Product
A new vector can be constructed from two given vectors: a b θ bsinθ Its magnitude: Its direction: v a b A B C=AxB Right-hand rule:

Important properties v -v Anti-commutative: b Nonassociative: a
(Proof to be given later) Classroom exercise: If the cross product of two vectors is a zero vector, they must be parallel or antiparallel to each other.

In Cartesian Basis axi azk ayj

Example

Classroom Exercise Calculate the cross product of above two vectors using

Application: Moment of Force (Torque)
θ d A

An Electric Dipole in an Electric Field
-q q r1 r2 O μ E T

A Magnetic Dipole in a Magnetic Field
r B -qm qm r1 r2 O m B T

Angular Velocity In a plane: v ω r O General case: θ rsinθ O r v ω

Exercise Classroom exercise

Exercise

Angular Momentum ω r p θ r O A d A special case: ω is perpendicular r:
(moment of inertia)

Conservation of Angular Momentum
If T=0, angular momentum is conserved. m B T For nuclear spins: NMR measures how fast a nuclear spin precesses.

Scalar and Vector Fields

The Gradient of a Scalar Field
Vector differential operator The gradient of a scalar field is a vector.

f(r+dr) f(r) dr Gradient is a convenient vector expression of the derivative of multi-variable functions.

Force is the negative of the gradient of the potential energy.

q1 q2 r q1 r E

The Divergence of a Vector Field
Laplacian operator Laplace’s Equation

Examples: Divergence The divergence is a measure of flux density:
the amount of ‘something’ flowing out of a unit volume per second.

The Curl of a Vector Field

Classroom Exercise

Physical Meaning of curl (rot)
The curl of a velocity field is angular velocity field (x2).

Example: Curl The curl of the velocity filed is a measure of the circulation of fluid around the point.

Supplementary (Not Required)
You may win 5 points for filling in the details here!

Major Theorems in Integration
Fundamental: b a L S Green: Stokes: V S Gauss:

Major Theorems in Integration
b a L S V S (Stokes’s theorem) The general form: ∂M M

Classroom Exercise? Find out the result of the following integration by using Gauss’s theorem: 1 x y z

The Maxwell Equations Electrostatics Electrodynamics
Related to the light speed c In a medium:

Vector Spaces … Inner product space Inner (scalar) product:
Norm (length):

You as a vector in a high dimensional space
Name Gender Birth date Birth place ID Student ID Height Weight Favorite drink Favorite music ….

Operations of Vectors in Fortran
Array Loop: Dot/cross product Gradient Divergence Curl General vector spaces Subroutine

Dot Product of Vectors Write a program to calculate the dot product of any two vectors. C Program for calculating dot product of any two vectors c program dotpro1 parameter(n1=3) real a1(n1),a2(n1) write(6,*)'Input three components of first vector:' read(5,*)(a1(i),i=1,n1) write(6,*)'Input three components of second vector:' read(5,*)(a2(i),i=1,n1) dot=0. DO 10,I = 1,n1 dot=dot+a1(i)*a2(i) CONTINUE print *,'The dot product is ', dot print *,'Next calculation (0/1)?' read(5,*)i if(i.eq.1) goto 1 stop end

Cross Product of Vectors
Write a program to calculate the cross product of any two vectors. C Program for calculating cross product of any two vectors c program crossp1 parameter(n1=3) real a1(n1),a2(n1),crossp(n1) write(6,*)'Input three components of first vector:' read(5,*)(a1(i),i=1,n1) write(6,*)'Input three components of second vector:' read(5,*)(a2(i),i=1,n1) CROSSP(1)=a1(2)*a2(3)-a1(3)*a2(2) CROSSP(2)=a1(3)*a2(1)-a1(1)*a2(3) CROSSP(3)=a1(1)*a2(2)-a1(2)*a2(1) print *,'The cross product is \n', (crossp(i),i=1,3) print *,'Next calculation (0/1)?' read(5,*)i if(i.eq.1) goto 1 stop end

Cross Product of Vectors
Write a program to calculate the following vector operations. C Program for calculating cross product of any three vectors program crossp2 parameter(n1=3) real a1(n1),a2(n1),a3(n1),crossp(n1) real tmp(n1) write(6,*)'Input three components of first vector:' read(5,*)(a1(i),i=1,n1) write(6,*)'Input three components of second vector:' read(5,*)(a2(i),i=1,n1) write(6,*)'Input three components of third vector:' read(5,*)(a3(i),i=1,n1) tmp1=0.0 tmp2=0.0 DO 10,I = 1,n1 tmp1=tmp1+a1(i)*a2(i) tmp2=tmp2+a1(i)*a3(i) CONTINUE do 20 i=1,n1 CROSSP(i)=tmp2*a2(i)-tmp1*a3(i) continue print *,'The cross product is \n', (crossp(i),i=1,3) print *,'Next calculation (0/1)?' read(5,*)i if(i.eq.1) goto 1 stop end

Write a program to calculate the gradient of a scalar function.

C Program for calculating the gradient of any scalar function
program grdt1 parameter(n1=3) real grt(n1) write(6,*) 'please input the position (x,y,z):' read(5,*)x,y,z dx=0.001 dy=0.001 dz=0.001 x2=x+dx y2=y+dy z2=z+dz f1=x*sin(x+y)+2.0*y*z*exp(x)+3.0*z*z f2=x2*sin(x2+y)+2.0*y*z*exp(x2)+3.0*z*z fx=(f2-f1)/dx f2=x*sin(x+y2)+2.0*y2*z*exp(x)+3.0*z*z fy=(f2-f1)/dy f2=x*sin(x+y)+2.0*y*z2*exp(x)+3.0*z2*z2 fz=(f2-f1)/dz grt(1)=fx grt(2)=fy grt(3)=fz print *,'The gradient at (', x,y,z, ') is \n', (grt(i),i=1,3) print *,'Calculating the gradient of next point (0/1)?' read(5,*)i if(i.eq.1) goto 1 stop end

The Divergence of a Vector Field
Write a program to calculate the divergence of a vector field.

C Program for calculating the divergence of any vector field
program divg1 parameter(n1=3) real vecf(n1) write(6,*) 'please input the position (x,y,z):' read(5,*)x1,y1,z1 dx=0.0001 dy=0.0001 dz=0.0001 x2=x1+dx y2=y1+dy z2=z1+dz vx1=x1*x1 vx2=x2*x2 divgx=(vx2-vx1)/dx vy1=x1*cos(x1+x1*y1+x1*y1*z1) vy2=x1*cos(x1+x1*y2+x1*y2*z2) divgy=(vy2-vy1)/dy vz1=2.*y1+6.*z1+exp(-y1*z1) vz2=2.*y1+6.*z2+exp(-y1*z2) divgz=(vz2-vz1)/dy divg=divx+divy+divz print *,'The divergence at (', x,y,z, ') is \n', divg print *,'Calculating the gradient of next point (0/1)?' read(5,*)i if(i.eq.1) goto 1 stop end

The Curl of a Vector Field
Write a program to calculate the rot of a vector field.

Using Subroutines (Go to Chapter 2)

Cross Product of Vectors
Write a program to calculate the following vector operations by calling subroutine for calculating cross product of two vectors.

C Program for calculating cross product of any two vectors
program crossp1 parameter(n1=3) real a1(n1),a2(n1),crossp(n1) write(6,*)'Input three components of first vector:' read(5,*)(a1(i),i=1,n1) write(6,*)'Input three components of second vector:' read(5,*)(a2(i),i=1,n1) CROSSP(1)=a1(2)*a2(3)-a1(3)*a2(2) CROSSP(2)=a1(3)*a2(1)-a1(1)*a2(3) CROSSP(3)=a1(1)*a2(2)-a1(2)*a2(1) print *,'The cross product is \n', (crossp(i),i=1,3) print *,'Next calculation (0/1)?' read(5,*)i if(i.eq.1) goto 1 stop end C Subroutine for calculating cross C product of any two vectors C subroutine(a,b,c,n) real a(n),b(n),c(n) c(1)=a1(2)*a2(3)-a1(3)*a2(2) c(2)=a1(3)*a2(1)-a1(1)*a2(3) c(3)=a1(1)*a2(2)-a1(2)*a2(1) return end

C Program for calculating the cross
C product of any number of vectors program crossp parameter(n=3,n1=3) real a1(n),a2(n),a3(n),TMP1(1),TMP2(N) open(20,file=‘crossp.1’,err=9999) read(20,*)(a1(i),i=1,n) read(20,*)(a2(i),i=1,n) read(20,*)(a3(i),i=1,n) close(20) call vcross(a2,a3,tmp1,n) call vcross(a1,tmp1,tmp2,n) open(30,file=‘crossp.2’,err=9999) write(30,*)(tmp2(i),i=1,n) CLOSE(30) STOP END C Subroutine for calculating cross C product of any two vectors C subroutine(a,b,c,n) real a(n),b(n),c(n) c(1)=a1(2)*a2(3)-a1(3)*a2(2) c(2)=a1(3)*a2(1)-a1(1)*a2(3) c(3)=a1(1)*a2(2)-a1(2)*a2(1) return end

Cross Product of Vectors
Write a program to calculate the following vector operations by calling subroutine for calculating cross product of two vectors.

C Subroutine for calculating cross C product of any two vectors C
C Program for calculating the cross C product of any number of vectors program crossp6 parameter(n=3) real a1(n),a2(n),a3(n),a4(n),a5(n),a6(n),a7(n) real TMP1(1),TMP2(N),TMP3(N),TMP4(N) real TMP5(n),TMP6(n) open(20,file=‘crossp6.1’,err=9999) read(20,*)(a1(i),i=1,n) read(20,*)(a2(i),i=1,n) read(20,*)(a3(i),i=1,n) read(20,*)(a4(i),i=1,n) read(20,*)(a5(i),i=1,n) read(20,*)(a6(i),i=1,n) read(20,*)(a7(i),i=1,n) close(20) call vcross(a6,a7,tmp1,n) call vcross(a5,a6,tmp2,n) call vcross(a3,a4,tmp3,n) call vcross(tmp1,tmp2,tmp4,n) call vcross(tmp3,tmp4,tmp5,n) call vcross(a1,tmp5,tmp6,n) open(30,file=‘crossp6.2’,err=9999) write(30,*)(tmp6(i),i=1,n) CLOSE(30) STOP END C Subroutine for calculating cross C product of any two vectors C subroutine(a,b,c,n) real a(n),b(n),c(n) c(1)=a1(2)*a2(3)-a1(3)*a2(2) c(2)=a1(3)*a2(1)-a1(1)*a2(3) c(3)=a1(1)*a2(2)-a1(2)*a2(1) return end

General Vector Spaces Write a subroutine to calculate the inner product of two vectors in any dimension.

C Program for calculating dot product of any two vectors
program dotpro1 parameter(n1=3) real a1(n1),a2(n1) write(6,*)'Input three components of first vector:' read(5,*)(a1(i),i=1,n1) write(6,*)'Input three components of second vector:' read(5,*)(a2(i),i=1,n1) dot=0. DO 10,I = 1,n1 dot=dot+a1(i)*a2(i) CONTINUE print *,'The dot product is ', dot print *,'Next calculation (0/1)?' read(5,*)i if(i.eq.1) goto 1 stop end C subroutine for calculating dot product of any two vectors subroutine vdot(a,b,n) real a(n),b(n) dot=0. DO 10,I = 1,n1 dot=dot+a(i)*b(i) CONTINUE return end

C program for calculating the inner product of two vectors
program innerp1 parameter(n=10) do 10 i=1,n a1(i)=i*1.2 a2(i)=-2.*+i*i continue call vdot(a1,a2,dot,n) print *,'The inner product of two vectors is \n', dot stop end C subroutine for calculating inner product of any two vectors subroutine vdot(a,b,dot,n) real a(n),b(n) dot=0. DO 10,I = 1,n1 dot=dot+a(i)*b(i) CONTINUE return

Similar presentations