File: eval.cdb

package info (click to toggle)
cadabra 1.46-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,244 kB
  • sloc: cpp: 33,188; ansic: 2,724; makefile: 329; yacc: 180; sh: 157; python: 45; lex: 38; lisp: 19
file content (86 lines) | stat: -rw-r--r-- 2,041 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Testing of component evaluation.
#

@reset.
\alpha::Integer(0..3).
obj:= C_{\alpha};
rul:= { C_{0} -> r**2,
        C_{1} -> f(r),
		  C_{2} -> r**(-2),
		  C_{3} -> r };
evl:= @eval![@(obj)]( @(rul) );
tst:= { C_{0} -> r**2, C_{1} -> f(r), C_{2} -> r**(-2), C_{3} -> r } - @(evl);
@collect_terms!(%);
@assert(tst);

@reset.
{\alpha,\beta}::Indices(values={0,1,2,3}).
obj:= C_{\alpha} C_{\alpha};
rul:= { C_{0} -> r**2,
        C_{1} -> f(r),
		  C_{2} -> r**(-2),
		  C_{3} -> r };
evl:= @eval![@(obj)]( @(rul) );
tst:= r**2 * r**2 + f(r) * f(r) + r**(-2) * r**(-2) + r * r - @(evl);
@collect_terms!(%);
@assert(tst);

# For documentation on the algorithm, see the 'components.tex' file in the
# 'docs' directory.

@reset.
{m,n,p}::Indices.
{m,n,p}::Integer(0..3).
A_{m} B_{m n} C_{n};
rule:= { A_{0} -> 3,
         A_{2} -> q,
         B_{0 1} -> a,
         B_{2 1} -> 2 a,
         C_{1} -> c,
         C_{2} -> d };
@indexmatch(%)( @(rule) );
# This should return a map
#    {m,n} -> {0,1}, {2,1}
# indicating for which index values there is a match.

@reset.
{\alpha,\beta}::Indices("vector", position=fixed).
{\alpha,\beta}::Integer(0..3).
g_{\alpha\beta}::Metric.
obj:= C_{\alpha} C^{\alpha};
@rewrite_indices!(%)( C_{\alpha} )( g^{\alpha\beta} );
rul:= { C_{0} -> r**2,
        C_{1} -> f(r),
		  C_{2} -> r**(-2),
		  C_{3} -> r,
        g^{0 0} -> -1,
        g^{1 1} -> 1,
        g^{2 2} -> 1,
        g^{3 3} -> 1 };
evl:= @eval![@(obj)]( @(rul) );
tst:= -r**2 * r**2 + f(r) * f(r) + r**(-2) * r**(-2) + r * r - @(evl);
@collect_terms!(%);
@assert(tst);



A_m (B_n C_n (D_k D_k + 1) + 3) P_m;


@reset.
{t, r, \phi, \theta}::Coordinate.
{m,n,p,q}::Indices(values={t,r,\phi,\theta}).
g_{m n}::Metric.

SSrule:= { g_{t t}          -> -f(r),
           g_{r r}          -> 1/f(r),
           g_{\theta\theta} -> r**2,
           g_{\phi\phi}     -> r**2 \sin(\theta)**2,
           g_{m n} -> 0 };

obj:= det(g_{m n});
@eval(%)( @(SSrule) );
@maxima(%);
tst:= - r**2 \sin(\theta)**2 - @(obj);
@collect_terms!(%);
@assert(tst);