1
$\begingroup$

Possible Duplicate:
Plotting multivariable integration

I am trying to plot an inverse function. If I do something like this:

 g[x_] := Sin[x]

 F[x_] := NIntegrate[g[y], {y, 0, x}]

 ParametricPlot[{F[x], x}, {x, 0, 2 Pi}]

I get the following error message

"NIntegrate::nlim: y = x is not a valid limit of integration. >>"

However, I also get a plot which is correct. Am I doing something wrong or should I just ignore the error message?

$\endgroup$
  • 4
    $\begingroup$ Change F[x_] to F[x_?NumericQ]. $\endgroup$ – b.gates.you.know.what Jan 22 '13 at 19:36
  • $\begingroup$ I changed F[x_] to F[x_?NumericQ], but the result was the same. $\endgroup$ – Steve Jan 23 '13 at 22:39
  • $\begingroup$ @Steve The result was the same, because you probably still have the older definition in memory. Use ClearAll[f] before making the new definition. $\endgroup$ – Sjoerd C. de Vries Jan 28 '13 at 14:51
1
$\begingroup$

Do you really mean you want the inverse function of Sin[x]? Then why not just ArcSin[y]? Or if you want to Solve for it:

Solve[Sin[x] == y, x]
Simplify[%, C[1] == 0]

{{x -> ConditionalExpression[\[Pi] - ArcSin[y] + 2 \[Pi] C[1], 
    C[1] \[Element] Integers]}, {x -> 
   ConditionalExpression[ArcSin[y] + 2 \[Pi] C[1], 
    C[1] \[Element] Integers]}}
{{x -> \[Pi] - ArcSin[y]}, {x -> ArcSin[y]}}

Plot[{ArcSin[y], \[Pi] - ArcSin[y]}, {y, -1, 1},
 Frame -> True]

enter image description here

Of course, the inverse function is multivalued and those are just two branches.

$\endgroup$
1
$\begingroup$

Just showing you what @b.gatessucks told you in his comment earlier:

g[x_] := Sin[x]
f[x_?NumericQ] := NIntegrate[g[y], {y, 0, x}]
ParametricPlot[{f[x], x}, {x, 0, 2 Pi}, AspectRatio -> 1]

Mathematica graphics

1) Two warnings: Many times this "trick" doesn't work because you've already defined your function. Do a ClearAll or start a fresh Mma session.

2) Remember to start your symbols with lowercase.

This post may help you too.

$\endgroup$

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