0
$\begingroup$

My program is

B := {B1[t, x, y, z], B2[t, x, y, z], B3[t, x, y, z]};

g := {{1+ Φ[t, x, y, z],               B[[1]],              B[[2]],       B[[3]] },
     {           B[[1]], 1/(1+ Φ[t, x, y, z]),                   0,            0 },
     {           B[[2]],                    0, 1/(1+ Φ[t, x, y, z],            0 },
     {           B[[3]],                    0,                   0, 1/(1+ Φ[t, x, y, z]}};

 xx = {t, x, y, z}; 

TaylorExpantion[h_] :=
Block[{res},
    res = ReplaceAll[h, Φ[t, x, y,z] :> ε Φ[t, x, y,z];
    res = ReplaceAll[res, B[[1]] -> ε^2 B[[1]]];
    res = ReplaceAll[res, B[[2]] -> ε^2 B[[2]]];
    res = ReplaceAll[res, B[[3]] -> ε^2 B[[3]]];
Simplify[Normal[Series[res, {ε, 0, 2}]] /. ε -> 1]
    ]

InverseMetric[g_] :=
Block[{res},
    res = Inverse[g];
    res = TaylorExpantion[res]
    ]

ChristoffelSymbol[g_, xx_] :=
Block[{d, res},
    d = 4;
    res = Table[(1/2)*(D[g[[m, n]], xx[[l]]] + D[g[[m, l]], xx[[n]]]
                      -D[g[[n, l]], xx[[m]]]),  
                                    {m, 1, d}, {n, 1, d}, {l, 1, d}];
    res = TaylorExpantion[res]
    ]

RicciTensor[g_, xx_] :=
Block[{d, Chr, res},
    d = 4; Chr = ChristoffelSymbol[g, xx]; ig = InverseMetric[g];
    res = Table[Sum[D[ig[[l, s]]*Chr[[s, m, n]], xx[[l]]]
                  - D[ig[[l, s]]*Chr[[s, m, l]], xx[[n]]], {s, 1, d}, {l, 1,d}]
                + Sum[ig[[a, b]]*Chr[[b, m, n]]*ig[[l, s]]*Chr[[s, l, a]]
                     -ig[[a, b]]*Chr[[b, m, l]]*ig[[l, s]]*Chr[[s, n, a]], 
                              {s, 1, d}, {l, 1, d}, {a, 1, d}, {b, 1, d}],                                                                          
                                                    {m, 1, d}, {n, 1, d}];
 res = TaylorExpantion[res]
 ]

Now the problem is when I print one component of Ricci Tensor (i.e Part[RicciTensor[g,xx],1,2]]), the derivatives of the Φ and B does not treated as perturbations, as should be due to the ReplaceAll. How can I make the program to make the replacement f(x)->ε f(x) for the function and all the derivatives. I don't want to use res = ReplaceAll[h, f_[t, x, y,z] :> ε f[t, x, y,z];, because Φ and B are first and second order in perturbation respectively.

$\endgroup$
1

1 Answer 1

1
$\begingroup$

The following should do the trick:

ReplaceAll[h, x:(Φ|Derivative[_][Φ])[t, x, y,z] :> ε x[t, x, y,z]]

(and similar for B).

Or alternatively (and much inline of the actual operation that you are trying to perform:

ReplaceAll[h, Φ :> Function[{t,x,y,z}, ε Φ[t, x, y,z]]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.