0
$\begingroup$

This is my Mathematica code,

Get["EDCRGTCcode.m", Path -> {NotebookDirectory[]}]
n = 5;
coord = {t, y1, y2, y3, z};
met = DiagonalMatrix[(L^2 Exp[2 A[z]])/
    z^2 {-g[z, B], 1, Exp[B^2 z^2], Exp[B^2 z^2] , 1/g[z, B]}];
RGtensors[met, coord]
A[z_] = -a z^2;
g[z_, B_] = 
  1 - Integrate[z^3 Exp[-B^2 z^2 - 3 A[z]], {z, 0, z}]/
   Integrate[z^3 Exp[-B^2 z^2 - 3 A[z]], {z, 0, zh}];
csq = (-(-gdd[[1, 1]]) gdd[[3, 3]] gdd[[4, 4]]) /. z -> zs;
 L = 1; a = 0.15; zh = 1;
t[z1_?NumericQ, z2_?NumericQ, B_, pm_] := 
 pm NIntegrate[
   Sqrt[ (csq gdd[[5, 5]])/(
    gdd[[1, 1]] (gdd[[3, 3]] gdd[[4, 4]] gdd[[1, 1]] - csq))], {z, z2,
     zh, z1}, Method -> "LocalAdaptive", Exclusions -> {z - zh == 0}]
plot = Quiet@
   ParametricPlot[{{z1, Re[t[z1, 0.2, 0.2, 1]]}, {z1, 
      Re[t[z1, 0.2, 0.2, -1]]}}, {z1, 1, 2}, 
    PlotStyle -> {Blue, Blue}, PlotRange -> {{0, 2}, {-2, 2}}, 
    AspectRatio -> 1/2];
Show[plot]

The plot is coming up like this.

this

Though it explicitly depends on $z_2$ and $B$, there is no change in the plot behaviour as I'm changing the $z_2$ and $B$ values.

This is the output for $z_2=0.2$ and $B=0.2$,

In[12]:= Table[{{z1, Re[t[z1, 0.2, 0.2, 1]]}, {z1, 
   Re[t[z1, 0.2, 0.2, -1]]}}, {z1, 1, 2, 1/4}]

Out[12]= {{{1, 0.}, {1, 0.}}, {{5/4, 0.}, {5/4, 0.}}, {{3/2, 0.}, {3/
   2, 0.}}, {{7/4, 0.}, {7/4, 0.}}, {{2, 0.}, {2, 0.}}}

This is the output for $z_2=1.5$ and $B=0.1$,

In[13]:= Table[{{z1, Re[t[z1, 1.5, 0.1, 1]]}, {z1, 
   Re[t[z1, 1.5, 0.1, -1]]}}, {z1, 1, 2, 1/4}]

Out[13]= {{{1, 0.}, {1, 0.}}, {{5/4, 0.}, {5/4, 0.}}, {{3/2, 0.}, {3/
   2, 0.}}, {{7/4, 0.}, {7/4, 0.}}, {{2, 0.}, {2, 0.}}}

Don't know why; all the values are coming 0.

Could anybody help me find where I'm making a mistake, or is there any error in the code?

$\endgroup$
4
  • 1
    $\begingroup$ When Plot doesn't work the first thing I try is replacing that with Table which will show me some of the values. That usually exposes why it isn't working. Can you edit your post to show the output after replacing ParametricPlot[...] with Table[{{z1,Re[t[z1,0.2,0.2,1]]},{z1,Re[t[z1,0.2,0.2,-1]]}},{z1,1,2,1/4}] with your current values for za2` and B and then with the changed values for z2 and B? If the step size of 1/2 in the Table doesn't expose the problem then it may need a different step size. $\endgroup$
    – Bill
    Commented Jun 6 at 14:12
  • $\begingroup$ Thanks for your suggestion. I'll edit my post. $\endgroup$ Commented Jun 7 at 4:21
  • $\begingroup$ Thanks for the edit. So Plot really is getting zeros. Another edit t[z1_?NumericQ,z2_?NumericQ, B_, pm_]:=(Print[pm*Sqrt[(csq gdd[[5,5]])/(gdd[[1,1]](gdd[[3,3]] gdd[[4,4]] gdd[[1,1]]-csq))]];pm NIntegrate[Sqrt[(csq gdd[[5,5]])/(gdd[[1,1]](gdd[[3,3]] gdd[[4,4]]gdd[[1,1]]-csq))],{z,z2,zh,z1},Method->"LocalAdaptive",Exclusions->{z-zh==0}]) to show what NIntegrate is really getting. Might tell people where you are getting EDCRGTCcode.m so they think they can trust getting that. Can't tell, don't know, maybe should be A[z_]:= and g[z_,B_]:= instead of just A[z_]= and g[z_,B_]= $\endgroup$
    – Bill
    Commented Jun 7 at 13:23
  • $\begingroup$ I've tried it, but a similar thing is happening. EDCRGTCcode.m is a package for GR-related calculations. $\endgroup$ Commented Jun 10 at 6:27

0