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.

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?

share|improve this question
4  
Change F[x_] to F[x_?NumericQ]. –  b.gatessucks Jan 22 '13 at 19:36
    
I changed F[x_] to F[x_?NumericQ], but the result was the same. –  Steve Jan 23 '13 at 22:39
    
@Steve The result was the same, because you probably still have the older definition in memory. Use ClearAll[f] before making the new definition. –  Sjoerd C. de Vries Jan 28 '13 at 14:51
add comment

marked as duplicate by Jens, Sjoerd C. de Vries, rcollyer, rm -rf Jan 28 '13 at 15:29

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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