Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

How can I plot a function defined by an integral.

More specific, I have the following equation:

$$ T = \frac{1}{\pi}\int\sqrt{\sin^2\;\arccos\left(-\frac{E}{2}\right)-\sin^2\frac{ϕ}{2}}^{-1}\mathrm{d}ϕ $$

Translating to Mathematica input:

T[E_]:=(1/Pi)*NIntegrate[(Sin[ArcCos[-E]/2]^2 - Sin[ϕ/2]^2)^(-0.5), {ϕ, 0, ArcCos[E]/2}]

Now I need to plot TxE. How do I do it?

share|improve this question

closed as off-topic by Pickett, Michael E2, belisarius, RunnyKine, Öskå Aug 25 at 22:35

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Pickett, Michael E2, belisarius, RunnyKine, Öskå
If this question can be reworded to fit the rules in the help center, please edit the question.

1  
You have many trivial problems in your code such as NIntegral instead of NIntegrate, missing square brackets and parenthesis instead of square brackets. Those you should be able to fix yourself if you pay attention to the documentation on those functions. You are on the right site, though. –  Pickett Aug 25 at 18:37
    
hmm why not? Im trying to plot the function in mathematica –  Geo Aug 25 at 18:37
    
@Picket, My code is just fine, i just added it here without correct words. I will edit it correctly. –  Geo Aug 25 at 18:38
    
@Geo If it works for you in Mathematica, better copy and paste it so you don't introduce errors. –  Pickett Aug 25 at 18:39
1  
Using e rather than your E, you can avoid doing any numerical integration by using Integrate to symbolically integrate your expression, and then using Simplify with Assumptions -> e >= -1, to obtain (2 Sqrt[2] EllipticF[ArcCos[e]/4, 2/(1 + e)])/(Sqrt[1 + e] \[Pi]). I used Mathematica 10 to do this. –  Stephen Luttrell Aug 25 at 19:58

1 Answer 1

Summarizing all of the comments:

Clear[T]

T[e_?NumericQ] := (1/Pi)*NIntegrate[
   1/Sqrt[Sin[ArcCos[-e]/2]^2 - Sin[\[Phi]/2]^2],
   {\[Phi], 0, ArcCos[e]/2}]

Plot[
 {Re[T[e]], Im[T[e]], Abs[T[e]]},
 {e, -2, 2},
 PlotRange -> All,
 WorkingPrecision -> 25,
 PlotLegends -> "Expressions",
 Frame -> True,
 Axes -> False]

enter image description here

EDIT: With the revised formula from your latest edit:

Clear[T]

T[e_?NumericQ] := (1/Pi)*NIntegrate[
   Sqrt[Sin[ArcCos[-e/2]]^2 - Sin[\[Phi]/2]^2],
   {\[Phi], 0, ArcCos[e]/2}]

Plot[
 {Re[T[e]], Im[T[e]], Abs[T[e]]},
 {e, -2, 2},
 PlotRange -> All,
 WorkingPrecision -> 25,
 PlotLegends -> "Expressions",
 Frame -> True,
 Axes -> False]

enter image description here

Perhaps you also meant to change the limits of integration?

Clear[T]

T[e_?NumericQ] := (1/Pi)*NIntegrate[
   Sqrt[Sin[ArcCos[-e/2]]^2 - Sin[\[Phi]/2]^2],
   {\[Phi], 0, ArcCos[e/2]}]

Plot[
 {Re[T[e]], Im[T[e]], Abs[T[e]]},
 {e, -2, 2},
 PlotRange -> All,
 WorkingPrecision -> 25,
 PlotLegends -> "Expressions",
 Frame -> True,
 Axes -> False]

enter image description here

share|improve this answer
    
uh the first one is the correct. I thought that it should diverge at e=1 but seems it won't. thanks sir. –  Geo Aug 25 at 22:48

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