0

I have the following parametric equation $$ x^2-a=0 $$ where $a$ is a given parameter. I would like to plot the nonnegative real root ($\sqrt{a}$) using NSolve as $a$ varies from $0$ to $1$. Can someone please teach me how to do this in Mathematica 10 Student Edition? Thank you very much!

I tried

Plot[NSolve[
  x^2 - a == 0 && Element[x, Reals] == True && x >= 0, {x}], {a, 0, 1}]

but the output was empty.

p.s. My actual equation is much more complicated and I don't have an analytical solution, hence NSolve.

Kim Jong Un
  • 103
  • 4
  • 1
    Plot[x /. Solve[x^2 - a == 0, {x}], {a, 0, 1}] – Dr. belisarius Dec 17 '14 at 06:00
  • A useful method to understand why a plot is empty, replace Plot with Table and adjust the plot range to give enough values. Changing your code to Table[NSolve[x^2 - a == 0 && Element[x, Reals] == True && x >= 0, {x}], {a, 0, 1, 1/4}] will perhaps show you WHY it isn't working. – Bill Dec 17 '14 at 08:23
  • The Bill's answer is pedagogic, but I would prefer to give you a direct answer. If you try your code for NSolvewith some numeric a value, say, a=1you will see the following: a = 1; NSolve[x^2 - a == 0 && Element[x, Reals] == True && x >= 0, x]yields the following: {{x -> 1.}}. This is what you get under the operator Plot. For this reason Plotreturns and empty thing. One workaround is to use the belisarius construct given above. – Alexei Boulbitch Dec 17 '14 at 09:24
  • @Community I think, this question is off-topic, since it is based on a simple syntax error. – Alexei Boulbitch Dec 17 '14 at 09:25
  • @AlexeiBoulbitch I would rather say it's a duplicate of this http://mathematica.stackexchange.com/a/18706/193 – Dr. belisarius Dec 17 '14 at 11:43

0 Answers0