Homework 4

Physics 725: Special and General Relativity
Thornton 425, San Francisco State University
(c) 2014 Andisheh Mahdavi
Fall 2014, MWF 9:10AM
Homework 4 Due 10/6 9:10AM
While I may have consulted with other students in the class regarding this homework, the solutions presented
here are my own work. I understand that to get full credit, I have to show all the steps necessary to arrive at the
answer, and unless it is obvious, explain my reasoning using diagrams and/or complete sentences.
Name
Signature:
1. (10 points) Hartle 6.6
2. (10 points) Hartle 6.10
3. (10 points) Hartle 7.2
4. (10 points) Hartle 7.4
5. (10 points) Hartle 7.5
6. (20 points) Hartle 7.9
7. (10 points) Hartle 7.11
8. (10 points) Hartle 7.12
9. (10 points) Hartle 7.20. Use a similar ParametricPlot3D command to that used in the egg problem to plot
the surface. Your command should look like
ParametricPlot3D[{rho[r] Cos[p], rho[r] Sin[p], z[r]},{p,0,2 Pi},{r,??,??}]
Where you’re supposed to deduce/derive rho[r] and z[r] from the problem, and choose appropriate limits
for r . What happens at r < 2M?
Crash Course on Differential Equations with Mathematica
In Mathematica, you can differentiate functions in sev- equation—here we can use (0,2):
eral ways. The following shows different ways of getting It turns out that this is exactly the special solution we
the first and second derivatives of t 2 :
made above. Note that there is no line break between
In[1]:= f@t_D := t ^ 2
the /. and the NDSolve.
D@f@tD, tD
D@f@tD, 8t, 2<D
f ’@tD
f ’’@tD
Out[2]=
2t
Out[3]=
2
Out[4]=
2t
Out[5]=
2
In[9]:=
Out[9]=
numericalsolution = g@tD .
NDSolve@8eq1, g@0D Š 0, g ’@0D Š 1<, g, 8t, 0, 2<D@@1DD
Plot@numericalsolution, 8t, 0, 2<D
Plot@specialsolution, 8t, 0, 2<D
InterpolatingFunction@880., 2.<<, <>D@tD
0.8
0.6
So you can use either primes (entered as single quotes
in Mathematica) or the D[]function to do it. Note that
the sole use of the colon (:) expression is to permanently define a function. You won’t use the colon for
equations that you need to solve. For these, the syntax
is different. As an example, to define a second order
differential equation for d 2 g /dt 2 = −dg /dt and label
it eq1:
Out[10]= 0.4
eq1 = g ’’@tD Š -g ’@tD
analyticsolution = g@tD . DSolve@eq1, g, tD@@1DD
0.6
In[6]:=
Out[6]=
g¢¢ @tD Š -g¢ @tD
Out[7]=
-ã-t C@1D + C@2D
Using DSolve gives you the most general solution Mathematica can find for the differential equation. Note the
special syntax of the first line: to define an equation
to be solved, you need to use a double equal sign.
Then the single equal sign tells us to call that equation eq1. Also pay attention to the syntax of the
DSolve line: the function and variables need to match;
e.g. if we had f (x) instead of g (t), we would say
f[x]/.DSolve[eq1,f,x][[1]] .
The C’s are the constants of integration. Here’s how
you’d fill them in:
In[8]:=
Out[8]=
0.2
0.5
1.0
1.5
2.0
0.5
1.0
1.5
2.0
0.8
Out[11]= 0.4
0.2
You can take the derivative of a numerical solution, just
like any other function, by using D[]. However, it must
be done on a line by itself. Here’s how to plot the numerical solution and its derivative on the same graph:
In[32]:=
Out[32]=
deriv = D@numericalsolution, tD
Plot@8numericalsolution, deriv<, 8t, 0, 2<D
InterpolatingFunction@880., 2.<<, <>D@tD
1.0
specialsolution = analyticsolution . C@1D ® 1 . C@2D ® 1
1 - ã-t
You’re not always going to be able to find an analytic
solution to a differential equation (and certainly not the
one in the third part of the warp ship problem). When
we do numerical solutions of differential equations, we
need to specify boundary conditions. In this case, we’ll
specify the condition that g vanish at t = 0 and that
its first derivative equal 1 at t = 0. We also need
to specify the interval in t over which to integrate the
0.8
0.6
Out[33]=
0.4
0.2
0.5
1.0
1.5
2.0
H* Define system of 2nd order differential equations *L
eq1 = x ''@tD Š Sin@y@tDD ^ 5
eq2 = y ''@tD == Cos@x@tDD ^ 5
H* Solve them *L
sol = NDSolve@8eq1, eq2, x@0D Š 1, y@0D Š 1, x '@0D Š 0, y '@0D Š 0<, 8x@tD, y@tD<, 8t, 0, 50<D@@1DD;
H* This plots x vs. y *L
ParametricPlot@8x@tD, y@tD< . sol, 8t, 0, 50<, AspectRatio ® 1D
H* Calculate the derivative with respect to time *L
deriv = D@sol, tD;
H* This plots x vs. xdot *L
ParametricPlot@8x@tD . sol, x '@tD . deriv<, 8t, 0, 50<, AspectRatio ® 1D
Out[513]=
x¢¢ @tD Š Sin@y@tDD5
Out[514]=
y¢¢ @tD Š Cos@x@tDD5
2
20
Out[516]=
40
60
80
100
60
80
100
-2
-4
4
3
Out[518]= 2
1
20
40