1a). Are the vectors v1={1, -2, 3, 4} , v2= {-2, 0, 3, 6}, v3= {4, -4, 3, 2} linearly independent? Why or why not?
We must make a linear combination of these vectors and see if there is a nontrivial
solution. If there is a nontrivial solution then these vectors are linearly dependent.
Array@Λ, 3D
Solve::svars : Equations may not give solutions for all "solve" variables.
88Λ@1D ® - 2 Λ@3D, Λ@2D ® Λ@3D<<
Since we have a nontrivial solution, where we can vary only Λ[3] (nontrivial solu-
tion) for this system of equations based on our vectors, these vectors are linearly
dependent
8mat, rhs< = EqToMat@sysofeqs, Array@Λ, 3DD
MatrixForm@matD
1 -2 4
-2 0 -4
3 3 3
4 6 2
MatrixForm@RowReduce@matDD
1 0 2
0 1 -1
0 0 0
0 0 0
This is another way to show that the vector are linearly dependent, using a matrix
method instead of solving a system.
w - 2.3 x + 2 y + 3.4 z 6
NullSpace::matrix : Argument 8-2.3, -2, -3.4, 1< at position 1 is not a non-empty rectangular matrix.
NullSpace@8- 2.3, - 2, - 3.4, 1<D
The plane equations are our constraints and the length function is what we want to
minimize.
planes =
ContourPlot3D@82 x + 3 y + 2 z 10, 5 x - 2 y + 7 z 0<, 8x, - 10, 10<, 8y, - 10, 10<, 8z, - 10, 10<D
10-10
5
0 -5
-5
0
-10
10
5
10
-5
-10
constraint1 = 2 x + 3 y + 2 z - 10
- 10 + 2 x + 3 y + 2 z
constraint2 = 5 x - 2 y + 7 z
5x-2y+7z
length = x2 + y2 + z2
x2 + y2 + z2
x2 + y2 + z2 - H- 10 + 2 x + 3 y + 2 zL Λ1 - H5 x - 2 y + 7 zL Λ2
x y z
: - 2 Λ1 - 5 Λ2 0, - 3 Λ1 + 2 Λ2 0, - 2 Λ1 - 7 Λ2 0>
x 2 + y2 + z 2 x2 + y 2 + z 2 x2 + y2 + z2
x y
: - 2 Λ1 - 5 Λ2 0, - 3 Λ1 + 2 Λ2 0,
x 2 + y2 + z 2 x2 + y 2 + z 2
z
- 2 Λ1 - 7 Λ2 0, - 10 + 2 x + 3 y + 2 z 0, 5 x - 2 y + 7 z 0>
x 2 + y2 + z 2
13 3 110 450 50
:Λ1 ® , Λ2 ® - ,x® ,y® ,z® >
167 2171 167 167 167
110 450 50
: , , >
167 167 167
xyz N
-5
-10
10
0
-10
-5
-5 0
5
-10 10
This plot shows the geometric interpretation of the problem we just solved. The inter-
section of these two planes is a line, and we found the point of that line that is
closest to the origin. We can see the red sphere of the intersection line.
3. Find all solutions to z 7 + 2 z 5 - 3 z 2 + 5 z + 1 0 Make a plot which shows the location of the roots in the
complex plane.
zsol = NSolveAz7 + 2 z5 - 3 z2 + 5 z + 1 0, zE
Length@zsolD
Here are our roots to the polynomial and we can see that there are seven of them. In
fact, the computer has counted seven as well.
zs = z . zsol
Transpose@8Re@zsD, Im@zsD<D
ListPlot@Transpose@8Re@zsD, Im@zsD<D,
PlotStyle ® PointSize@0.025D, AxesLabel ® 8"Re", "Im"<D
Im
1.5
1.0
0.5
Re
-1.0 -0.5 0.5
-0.5
-1.0
-1.5
2Π Sin@ ΘD2
4. Calculate the value of the integral Int = Ù0 â Θ using residues (use of Residues[...] is OK).
5+3 Cos@ ΘD
Specify the contour you are using by drawing a sketch. Explain your reasoning.
Sin@ΘD2
f =
5 + 3 Cos@ΘD
Sin@ΘD2
5 + 3 Cos@ΘD
fΘ = TrigToExp@fD
2
Iã-ä Θ - ãä Θ M
-
3
4 I5 + Iã-ä Θ + ãä Θ MM
2
fz = fΘ . 9ãä Θ ® z, ã-ä Θ ® 1 z=
1 2
I - zM
z
-
3 1
4 I5 + I + zMM
2 z
2
ä I- 1 + z2 M
2 z2 I3 + 10 z + 3 z2 M
We are looking for the instances where the denominator of intz is equal to zero.
1
:8z ® - 3<, :z ® - >, 8z ® 0<, 8z ® 0<>
3
1
:- 3, - , 0, 0>
3
1
We want the residues inside the unit circle. That will - and zero.
3
res2 = Residue@intz, 8z, pole2<D
4ä
9
5ä
-
9
ä
-
9
Using our residue theorem where the integral is equal to the sum of the residues
inside the unit circle multiplied by 2 Π.
2 Π ä sumres
2Π
9
Sin@ΘD2
IntegrateB , 8Θ, 0, 2 Π<, PrincipalValue ® TrueF
5 + 3 Cos@ΘD
2Π
9
We use the principal value method to verify the sum of residues method, and we get
the same answer.
5. Two identical masses are attached to three springs between two fixed walls, as shown in the figure
below.
k1 k2 k1
m m
a) Construct the Lagrangian , and set up the equations of motion for this system
<< VariationalMethods`
Clear@tD
The potential energy has three terms, one for each spring.
1 1 1
potentialEnergy = k1 x1@tD2 + k2 H x1@tD - x2@tDL2 + k1 x2@tD2
2 2 2
1 1 1
k1 x1@tD2 + k2 Hx1@tD - x2@tDL2 + k1 x2@tD2
2 2 2
1 1
kineticEnergy = m x1 '@tD2 + m x2 '@tD 2
2 2
1 1
m x1¢ @tD2 + m x2¢ @tD2
2 2
Lagrangian = kineticEnergy - potentialEnergy
1 1 1 1 1
- k1 x1@tD2 - k2 Hx1@tD - x2@tDL2 - k1 x2@tD2 + m x1¢ @tD2 + m x2¢ @tD2
2 2 2 2 2
euleqs = EulerEquations@Lagrangian, 8x1@tD, x2@tD<, tD
8- Hk1 + k2L x1@tD + k2 x2@tD - m x1¢¢ @tD 0, k2 x1@tD - Hk1 + k2L x2@tD - m x2¢¢ @tD 0<
b) Calculate the normal mode frequencies for the vibrations of this system.
Then we construct the matrix out of the coefficients of equations of motion. Then
eigenvalues of the matrix are the Ω2 , the normal frequencies squared.
Then we construct the matrix out of the coefficients of equations of motion. Then
eigenvalues of the matrix are the Ω2 , the normal frequencies squared.
Hk1+k2L k2
-
m m
modesmat = k2 Hk1+k2L
-
m m
k1 + k2 k2 k2 k1 + k2
:: ,- >, :- , >>
m m m m
normalmodes = Eigenvalues@modesmatD
k1 k1 + 2 k2
: , >
m m
Sqrt@normalmodesD
k1 k1 + 2 k2
: , >
m m
Here are the normal mode frequencies for the vibrations of this system.
We can easily find the power series approximation, with the handy powerss function
provided in the handbook.
y¢¢ @xD
- y@xD - x2 y¢ @xD +
5
5 x2 25 x4 5 x5 25 x6 325 x7 4625 x8 2125 x9 13 675 x10 85 375 x11 323 375 x12
1+ + + + + + + + + + a@0D +
2 24 4 144 504 8064 18 144 48 384 399 168 6 386 688
5 x3 5 x4 5 x5 35 x6 25 x7 275 x8 5275 x9 3425 x10 4525 x11 106 625 x12
x+ + + + + + + + + + a@1D
6 12 24 72 112 2016 24 192 36 288 76 032 1 368 576
vars = Table@a@iD, 8i, order, deg<D; H* a@0D, a@1D,.. a@order-1D are parameters *L
params = Table@a@iD, 8i, 0, order - 1<D;
subps = dexp . yv ® Function@xv, Evaluate@psDD; H* plug it into the de *L
subps = Normal@Series@subps, 8xv, pt, deg<DD;
eqs = Table@Coefficient@subps, Hxv - ptL, iD == 0, 8i, 0, deg - order<D;
H* set each coefficient0 *L
If@verbose, Print@"DE = ", de, " order = ", order,
"\nTrial solution= ", ps, "\nplug in power series:\n",
subps, "\neqs for coefficients= ", TableForm@eqsDD;
Print@"\nparams= ", params, "\nvariables= ", varsDD;
ss = ps . First@Solve@eqs, varsDD;
sv = Table@Map@Factor, Hss . a@iD ® 1L . Thread@params ® 0DD, 8i, 0, order - 1<D;
sv.paramsF
1
iniconds = :Hpss . x ® 0L 3, HD@pss, xD . x ® 0L >
2
1
:a@0D 3, a@1D >
2
asol = Solve@iniconds, 8a@0D, a@1D<D Flatten
1
:a@0D ® 3, a@1D ® >
2
Apparently the initial conditions solve themselves for the parameters a[0] and a[1].
pss . asol
5 x2 25 x4 5 x5 25 x6 325 x7 4625 x8 2125 x9 13 675 x10 85 375 x11 323 375 x12
3 1+ + + + + + + + + + +
2 24 4 144 504 8064 18 144 48 384 399 168 6 386 688
1 5 x3 5 x4 5 x5 35 x6 25 x7 275 x8 5275 x9 3425 x10 4525 x11 106 625 x12
x+ + + + + + + + + +
2 6 12 24 72 112 2016 24 192 36 288 76 032 1 368 576
b) Construct a plot of the solution to the boundary value problem y[0]=1, y[2]=1 (Although you could use a
shooting method, there is an easier way.)
odesol = NDSolve@8ode 0, y@0D 1, y@2D 1<, y@xD, 8x, 0, 2<D Flatten
Plot@y@xD . odesol, 8x, 0, 2<, PlotStyle ® 8Thick, Red<, AxesLabel ® 8"x", "yHxL"<D
yHxL
1.0
0.8
0.6
0.4
x
0.5 1.0 1.5 2.0
c) what are the possible types of asymptotic behavior as x -> ¥ for solutions of this equation?
Needs@"MMHTools`DETools`"D
yz = ChangeVariable@ode, x ® 1 z, y, y, x, zD
2 1
- y@zD + y¢ @zD + z3 y¢ @zD + z4 y¢¢ @zD
5 5
ClassifyODE@yz, y, z, 0, FalseD
asymptotic@ode, y, x, 3, FalseD
1
Power::infy : Infinite expression encountered.
0
this de does not have an
irregular singular point at Infinity; use frobenius
5 x3
ã 3 7 1 1 1 1 1
:: , 1+ + - >, :1, 1 + + + >>
2 3 2 x 3 2 x
x 30 x 2x 6x 2x
7. Gravitational stability of 3 masses. Consider three objects of unit mass which are constrained to move
1
in a plane and interact via an attractive inverse square force law with a potential V(r)= - , where r is the
r
distance between the masses. The initial condition is that all the masses are stationary, and mass #1 is at
{0, 0} , mass#2 is at {0,-1} and mass#3 is at {3,0} .
a) write the Lagrangian for this system.
<< VectorAnalysis`
Clear@VD
1
V@r1_, Θ1_, r2_, Θ2_D := -
r12 + r22 - 2 r1 r2 Cos@Θ1 - Θ2D
Π
:80, 0<, :1, - >, 83, 0<>
2
potEn = V@r1@tD, Θ1@tD, r2@tD, Θ2@tDD +
V@r2@tD, Θ2@tD, r3@tD, Θ3@tDD + V@r3@tD, Θ3@tD, r1@tD, Θ1@tDD
1
- -
2 2
r1@tD - 2 Cos@Θ1@tD - Θ2@tDD r1@tD r2@tD + r2@tD
1
-
r1@tD2 - 2 Cos@Θ1@tD - Θ3@tDD r1@tD r3@tD + r3@tD2
1
The potential depends on the distance and in this case using the polar coordinates
distance formula
1 1 1 1 1 1
kinEn = r1 '@tD2 + Θ1 '@tD2 + r2 '@tD2 + Θ2 '@tD2 + r3 '@tD2 + Θ3 '@tD2
2 2 2 2 2 2
1 1 1 1 1 1
r1¢ @tD2 + r2¢ @tD2 + r3¢ @tD2 + Θ1¢ @tD2 + Θ2¢ @tD2 + Θ3¢ @tD2
2 2 2 2 2 2
The kinetic energy for each mass has two terms, one for r coordinate and one for the
Θ coordinate.
lagrange = kinEn - potEn
1
+
2 2
r1@tD - 2 Cos@Θ1@tD - Θ2@tDD r1@tD r2@tD + r2@tD
1
+
r1@tD2 - 2 Cos@Θ1@tD - Θ3@tDD r1@tD r3@tD + r3@tD2
1 1
+ r1¢ @tD2 +
2
r2@tD2 - 2 Cos@Θ2@tD - Θ3@tDD r2@tD r3@tD + r3@tD2
1 1 1 1 1
r2¢ @tD2 + r3¢ @tD2 + Θ1¢ @tD2 + Θ2¢ @tD2 + Θ3¢ @tD2
2 2 2 2 2
b) Write the equations of motion. What is the total energy of the system?
eqsofmotion =
EulerEquations@lagrange, 8r1@tD, r2@tD, r3@tD, Θ1@tD, Θ2@tD, Θ3@tD<, tD FullSimplify
- r1@tD + Cos@Θ1@tD - Θ2@tDD r2@tD
: +
32
Ir1@tD - 2 Cos@Θ1@tD - Θ2@tDD r1@tD r2@tD + r2@tD2 M
2
The total energy of the system is initially potential. Initial kinetic energy is
zero, so we can find the initial potential energy as the total energy of the system.
potEn0 = V@rΘpos@@1, 1DD, rΘpos@@1, 2DD, rΘpos@@2, 1DD, rΘpos@@2, 2DDD +
V@rΘpos@@2, 1DD, rΘpos@@2, 2DD, rΘpos@@3, 1DD, rΘpos@@3, 2DDD +
V@rΘpos@@3, 1DD, rΘpos@@3, 2DD, rΘpos@@1, 1DD, rΘpos@@1, 2DDD
4 1
- -
3 10
c) Solve the equations for the given initial conditions and make an animation of the motion. (Watch out for
extra curly brackets.) Use different colored dots to represent the objects. Play the animation at 20
frames/second. An interesting question that you are invited to speculate on is : will the particles ever
become separated by an infinite distance?
Printed by Mathematica for Students
Final09.nb 13
c) Solve the equations for the given initial conditions and make an animation of the motion. (Watch out for
extra curly brackets.) Use different colored dots to represent the objects. Play the animation at 20
frames/second. An interesting question that you are invited to speculate on is : will the particles ever
become separated by an infinite distance?
Our initial conditions are the given inital points and zero velocities.
traj = Table@
Graphics@88Green, Disk@H8Hr1@tD . numsol@@1DDL, HΘ1@tD . numsol@@2DDL< . rΘtoxyL, 0.2D<,
8Purple, Disk@H8Hr2@tD . numsol@@3DDL, HΘ2@tD . numsol@@4DDL< . rΘtoxyL, 0.2D<,
8Black, Disk@H8Hr3@tD . numsol@@5DDL, HΘ3@tD . numsol@@6DDL< . rΘtoxyL, 0.2D<<,
PlotRange ® 88- 1, 10<, 8- 3, 3<<D, 8t, 0, 6.6, 0.01<D;
ListAnimate@traj, 20D
Seeing how the black dot leaves the screen at the end of the animation, the particle
might be able to be separated by an infinite distance.
8. (grads) An electron is confined to a spherical cavity of radius R. ( This is actually a realistic model for
Printed by Mathematica for Students Ñ2
electrons in some liquids). The equation for its stationary energy states is - 2 m Ñ2 Ψ E Ψ. The wave
function must vanish at the boundary and be finite at the origin.
a) Using dimensional reasoning , predict the dependence of the ground state energy on the radius of the
cavity.
14 Final09.nb
8. (grads) An electron is confined to a spherical cavity of radius R. ( This is actually a realistic model for
Ñ2
electrons in some liquids). The equation for its stationary energy states is - 2 m Ñ2 Ψ E Ψ. The wave
function must vanish at the boundary and be finite at the origin.
a) Using dimensional reasoning , predict the dependence of the ground state energy on the radius of the
cavity.
Needs@"Units`"D
Needs@"PhysicalConstants`"D
Needs@"MMHTools`DimTools`"D
The symbols 8c, kB, Ñ, g, G, me, amu, Me, Ms, Na, Ε0, Μ0, e, Σ, Rgas<
have been assigned SI unit specifiers
Kilogram Meter2 Ñ
:Meter R, m Kilogram, >
Second
Kilogram Meter2 Ñ
:Meter R, Kilogram m, >
Second
b) For the case of no angular dependence, find the lowest 3 energy levels and the corresponding radial
wave functions. Normalize the wave functions and plot them ( let R->1). Do this problem analytically, not
numerically.
<< VectorAnalysis`
SetCoordinates@Spherical@r, Θ, ΦDD
Spherical@r, Θ, ΦD
Laplacian@Ψ@rDD
r2
Printed by Mathematica for Students
Final09.nb 15
- Ñ2 2
DSolveB Ψ '@rD + Ψ ''@rD En Ψ@rD, Ψ@rD, rFF FullSimplify Flatten
2m r
En m
- 2 r - 2 2 -En m r
Ñ2
ã 4 - En m C@1D + 2 ã Ñ Ñ C@2D
:Ψ@rD ® >
4 - En m r
Our boundary condition and normalization condition can determine our constants.
Ψ = HΨ@rD . ΨsolL
En m
- 2 r - 2 2 -En m r
Ñ2
ã 4 - En m C@1D + 2 ã Ñ Ñ C@2D
4 - En m r
SolveAAssumingAEn < 0 && Ñ > 0 && m > 0, IntegrateAΨ2 , 8r, 0, 1<E E 1, C@2DE
Integrate::idiv :
2 2 -En m r 2 2 -En m r
-
ã Ñ C@1D2 -En m Ñ C@1D C@2D ã Ñ Ñ2 C@2D2
Integral of - - does not converge on 80, 1<.
r2 2 En m r 2 8 En m r2
Integrate::idiv :
En m 2 2 r 2
-2 2 r -
Ñ2
ã 4 -En m C@1D + 2 ã Ñ Ñ C@2D
Integral of does not converge on 80, 1<.
r2
Solve::tdep :
The equations appear to involve the variables to be solved for in an essentially non-algebraic way.
Integrate::idiv :
En m 2 2 r 2
-2 2 r -
Ñ2
ã 4 -En m C@1D + 2 ã Ñ Ñ C@2D
Integral of does not converge on 80, 1<.
r2
General::stop : Further output of Integrate::idiv will be suppressed during this calculation.
Solve::tdep :
The equations appear to involve the variables to be solved for in an essentially non-algebraic way.
En m 2
-2 2 r - 2 2 -En m r
Ñ2
ã 4 - En m C@1D + 2 ã Ñ Ñ C@2D
1
SolveBà - â r 1, C@2DF
0 16 En m r2
9. A potential is zero for Abs[x]>1 and for Abs[x]<1, it has a triangular form as shown in the figure.
The Schrö dinger equation in reduced units for this potential is -Ψ''[x]+V[x] Ψ[x] = e Ψ[x] . For bound states,
¥
Ψ must be normalizable : Ù-¥ Ψ* Ψ â x = 1.
a) for the case V0=5, estimate the ground state energy.
Clear@ΨD
Clear@VD
VHxL
x
-2 -1 1 2
-1
-2
-3
-4
-5
- 5 H1 + xL - 1 £ x £ 0
5 H- 1 + xL 0 < x £ 1 Ψ@xD e Ψ@xD + Ψ¢¢ @xD
0 True
Πx
To estimate the ground state energy let us use estimated wavefunction Ψ HxL = A CosB F
a
Integrate@
10.Buffon needle problem. Consider a sheet of lined paper with parallel lines one unit apart. Drop a stick
one unit in length at random where random means random orientation angle and random position. Do this
many times. What is the probability that the stick does not intersect a line? Answer this question with a
simulation. Write a function called Buffon[ntry_,maxgraph_] which will generate ntry sticks Graph
whose center position is a random number between 0 and 1, and whose orientation angle is a random
number between 0 and 2 Π. Display a picture of two red parallel lines one unit apart, and the first
maxgraph black line segments (the sticks); plotting them all leads to a messy black porcupine, so keep
maxgraph around 50 or 70. Keep track of the number of line segments which cross either of the parallel
lines. Run the simulation with ntry=5000 or so times and estimate the probabilities of intersection and non-
intersection.
Clear@"Global`*"D
Buffon@ntry_, maxgraph_D :=
Block@8hΘs, points, boundaries, numcross, ys, yscross, probcross, probnocross<,
hΘs = Table@8RandomReal@D, RandomReal@2 ΠD<, 8ntry<D;
points = hΘs . 8h_, Θ_< ® 88- 1 2 Cos@ΘD, h - 1 2 Sin@ΘD<, 81 2 Cos@ΘD, h + 1 2 Sin@ΘD<<;
ys = points . 88x1_, y1_<, 8x2_, y2_<< ® 8y1, y2< Flatten; yscross = 8<;
Do@If@ys@@iDD ³ 1 ÈÈ ys@@iDD £ 0, AppendTo@yscross, ys@@iDDDD, 8i, Length@ysD<D;
numcross = Length@yscrossD; probcross = numcross ntry;
probnocross = 1 - probcross; Print@probcrossD; Print@probnocrossD; boundaries =
Graphics@88Thick, Red, Line@88- 3, 1<, 83, 1<<D<, 8Thick, Red, Line@88- 3, 0<, 83, 0<<D<<D;
Show@boundaries, Graphics@Table@Line@8points@@iDD<D, 8i, maxgraph<DDD D
1583
2500
917
2500
Our output is the probability of crossing the lines, the probability of not cross the
lines, and a picture of the first fifty trials.
Buffon2@ntry_D :=
Block@8hΘs, points, boundaries, numcross, ys, yscross, probcross, probnocross<,
hΘs = Table@8RandomReal@D, RandomReal@2 ΠD<, 8ntry<D;
points = hΘs . 8h_, Θ_< ® 88- 1 2 Cos@ΘD, h - 1 2 Sin@ΘD<, 81 2 Cos@ΘD, h + 1 2 Sin@ΘD<<;
ys = points . 88x1_, y1_<, 8x2_, y2_<< ® 8y1, y2< Flatten; yscross = 8<;
Do@If@ys@@iDD ³ 1 ÈÈ ys@@iDD £ 0, AppendTo@yscross, ys@@iDDDD, 8i, Length@ysD<D;
numcross = Length@yscrossD; probcross = numcross ntry;
probnocross = 1 - probcross; Return@probcrossDD
Adjusting the Buffon program to return only the probability of crossing the lines, I
can take the mean of a large number of 10000 trials sets.
509 321
800 000
159 173
N
250 000
0.636692
509 321
N
800 000
0.636651
And I can conclude that the probability of crossing the lines is 0.636651 or 63.6651
%
100 - 63.6651
36.3349