translator: fix the finding of free lisp vars in LET forms
[maxima.git] / share / tensor / tetrad.dem
blob8964ec0b56b0dfce35590b48de86258b2e34e590
1 /* Copyright (C) 2004 Viktor T. Toth <http://www.vttoth.com/>\r
2  *\r
3  * This program is free software; you can redistribute it and/or\r
4  * modify it under the terms of the GNU General Public License as\r
5  * published by the Free Software Foundation; either version 2 of\r
6  * the License, or (at your option) any later version.\r
7  *\r
8  * This program is distributed in the hope that it will be\r
9  * useful, but WITHOUT ANY WARRANTY; without even the implied\r
10  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\r
11  * PURPOSE.  See the GNU General Public License for more details.\r
12  *\r
13  * Derive the Schwarzschild solution in a tetrad base\r
14  *\r
15  */\r
16 if get('ctensor,'version)=false then load(ctensor);\r
17 ("\r
19 Derive and verify Schwarzschild's solution in a tetrad base.")$\r
20 init_ctensor();\r
21 ct_coords:[t,r,d,c]$\r
22 ("We use dimension 4. The four base vectors arranged in matrix form:")$\r
23 fri:matrix(\r
24   [sqrt(f(r)),  0,  0,       0],\r
25   [0,  sqrt(h(r)),  0,       0],\r
26   [0,           0,  r,       0],\r
27   [0,           0,  0,r*sin(d)]);\r
28 ("The problem is simple enough for automatic simplification:")$\r
29 (ctrgsimp:true,ratwtlvl:false,ratfac:true,cframe_flag:true)$\r
30 cmetric();\r
31 ("Compute the Ricci rotation coefficients")$\r
32 christof(true);\r
33 ("And the Riemann tensor in tetrad base")$\r
34 lriemann(true);\r
35 ("Now compute the Ricci tensor")$\r
36 ricci(true);\r
37 ("For a vacuum metric, the components of the Ricci tensor must be 0")$\r
38 ("We begin by adding ric1,1 and ric2,2 which yields a simple equation:")$\r
39 ric[2,2]+ric[1,1];\r
40 ("Some algebraic manipulation yields a solution for f(r) in terms of h(r):")$\r
41 factor(%th(2));\r
42 num(%);\r
43 %/f(r)/h(r);\r
44 distrib(%);\r
45 first(%)=-last(%);\r
46 integrate(%,r);\r
47 solve(%,f(r));\r
48 ("We can choose the constant to be 1 by rescaling the metric:")$\r
49 solf:subst(1,num(last(%th(2)[1])),last(%th(2)[1]));\r
50 ("We substitute the solution for f(r) into ric3,3:")$\r
51 ric[3,3];\r
52 ("Further algebraic manipulation helps get a solution for h(r):")$\r
53 ratsimp(%th(2));\r
54 subst(solf,f(r),%);\r
55 ratsimp(%);\r
56 num(%);\r
57 %,diff;\r
58 ode2(%,h(r),r);\r
59 exp(first(%))=exp(last(%));\r
60 solve(%,h(r));\r
61 ("We rename the constant to get the result in the usual form:")$\r
62 solh:ratsimp(subst(1/2/m,exp(%c),last(%th(2)[1])));\r
63 ("Now substitute the solutions back into our base vectors:")$\r
64 subst(solf,f(r),fri);\r
65 fri:subst(solh,h(r),%);\r
66 ("And compute the metric, which is the standard Schwarzschild metric:")$\r
67 cmetric(true);\r
68 ("We're done... now let us verify our solution.")$\r
69 ("We begin with recomputing the Ricci rotation coefficients:")$\r
70 christof(true);\r
71 ("And the Riemann tensor:")$\r
72 lriemann(true);\r
73 ("And last, the Ricci tensor, which should indicate an empty spacetime:")$\r
74 ricci(true);\r
76 /* End of demo -- comment line needed by MAXIMA to resume demo menu */\r