-1
$\begingroup$

I have the following code:

$Assumptions -> {b = 1, Element[r, reals], r > 0}


gtt[r_] := -((r + b)/(r - 3 b))^((-3/2)) (r^2 + 6 b r + 21 b^2)
grr[r_] := ((r + b)/(r - 3 b))^(3/2) (r^2 + 6 b r + 21 b^2)^-1
g[r_] := -(((r + b)/(r - 3 b))^(3/2) (r - 3 b)^2)^2

B[r_] := ((gtt[r])^-1 (grr[r])^-1 Sqrt[-g[r]])
p[r_] = D[B[r], r]
q[r_] := ((grr[r])^-1 Sqrt[-g[r]])
z[r] = Integrate[-(gtt[r])^-1, r]
ParametricPlot[{{V[r]}, {z[r]}}, {r, -100, 100}]

V[r_] = 3/4 (B[r])^-2 (gtt[r])^2 (p[r])^2 - 
1/2 (B[r])^-1 (gtt[r])^2 D[p[r], r] - 
1/2 (B[r])^-2 (gtt[r]) D[q[r], r] p[r]

I have two questions:

$1:$ I evaluated the integral (I will not post the result as it was very long and complicated), but when I tried to use the limits(r to infinity), the integral would not evaluate, however when I just gave the command to integrate without the limits it gave me a result. Why did this happen and will it be the correct result?

$2:$ I want to use ParametricPlot to plot $V[z]$ but so far I am unsuccessful and I am unsure if it is because of a problem with the integral or because I am implementing ParametricPlot incorrectly. What I tried is this

ParametricPlot[{{V[r]},{z[r]}},{r,-100,100}]

I also tried it the other way around but either way I get a graph appearing but nothing being plotted on it. Also the range of the graph is always between 1 and -1.

Does anyone have any idea?

Thank you!

$\endgroup$
  • $\begingroup$ Please show your code. It will make it easier for people to check it and suggest solutions. The ParametricPlot command is not correct as written. It requires two functions, say $x(t)$ and $y(t)$, to produce an $xy$ plot with parameter $t$. Your $V(r)$ also contains the undefined functions $B$ and $p$. $\endgroup$ – Themis Dec 17 '18 at 12:16
  • 2
    $\begingroup$ Is the code given in terms of `Mathematia' syntax? If not, please provide a MMA code. $\endgroup$ – Tugrul Temel Dec 17 '18 at 18:38
  • 2
    $\begingroup$ \frac{3}{4} is no Mathematica code! $\endgroup$ – Ulrich Neumann Dec 17 '18 at 20:42
  • $\begingroup$ I.e., what they're saying is they'd be happy to help, but they want you to do your part, which means: (a) present all your code as Mathematica code; e.g., ` \frac{r + b}{r - 3 b}` is LaTeX; (r+b)/(r-3 b) is Mathematica; (b) fix the unmatched parentheses in g[r_]; and (c) give the exact code for the definite integral (i.e., with the limits) that you say wouldn't evaluate. $\endgroup$ – theorist Dec 20 '18 at 4:26
  • $\begingroup$ Hello, sorry I was away for a week and so have been unable to update. I have chaged that now I hope it is a little clearer $\endgroup$ – Claire.Bear Dec 24 '18 at 11:45
1
$\begingroup$

You seriously need to go through the documentation. There are some very trivial mistakes (maybe typo!)

Apart from that, only tricks you need here is to use Re for V[r] and scale it properly to make it look good.

b = 1
gtt[r_] := -((r + b)/(r - 3 b))^((-3/2)) (r^2 + 6 b r + 21 b^2)
grr[r_] := ((r + b)/(r - 3 b))^(3/2) (r^2 + 6 b r + 21 b^2)^-1
g[r_] := -(((r + b)/(r - 3 b))^(3/2) (r - 3 b)^2)^2
B[r_] := ((gtt[r])^-1 (grr[r])^-1 Sqrt[-g[r]])
p[r_] = D[B[r], r];
q[r_] := ((grr[r])^-1 Sqrt[-g[r]])
z[r_] = Integrate[-(gtt[r])^-1, r];
V[r_] = 3/4 (B[r])^-2 (gtt[r])^2 (p[r])^2 
        - 1/2 (B[r])^-1 (gtt[r])^2 D[p[r], r] 
        - 1/2 (B[r])^-2 (gtt[r]) D[q[r], r] p[r];

ParametricPlot[Re@{V[r]/10^5, z[r]}, {r, -100, 100}]

enter image description here

$\endgroup$
  • $\begingroup$ Thank you so much, I am very new to mathematica, I only began using it this month so I have a lot to learn! Just so I know, what trivial mistakes to you mean exactly? $\endgroup$ – Claire.Bear Jan 3 at 15:17
  • $\begingroup$ @Claire.Bear, its fine. We all have our first time. My first question was eventually removed after some time (it was dumb :p). I got some error when I copied your initial question (for example you used reals not Reals) and I wrote the lines from scratch. But probably they are typos - so don't worry. Always keep your eyes open for Caps and brackets. Enjoy :) $\endgroup$ – Sumit Jan 4 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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