2
$\begingroup$

I'm trying to plot the figure-eight curve.

g1 = Plot[y = Sqrt[x^2 - x^4], {x, -1, 1}]        
g2 = Plot[y = -Sqrt[x^2 - x^4], {x, -1, 1}]        
Show[g1, g2 ]

Can someone tell me why it is not working please?

$\endgroup$

closed as off-topic by MarcoB, user9660, Jason B., Öskå, Edmund Mar 4 '16 at 0:58

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." – MarcoB, Community, Jason B., Öskå, Edmund
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Remove the last piece in Show[] and try again. $\endgroup$ – J. M. is away Oct 29 '15 at 0:18
  • 1
    $\begingroup$ How about: Plot[{Sqrt[x^2 - x^4], -Sqrt[x^2 - x^4]}, {x, -2, 2}] $\endgroup$ – bill s Oct 29 '15 at 0:18
  • $\begingroup$ How is it still not working? $\endgroup$ – J. M. is away Oct 29 '15 at 0:30
  • 3
    $\begingroup$ Try Show[g1, g2, PlotRange -> All] $\endgroup$ – m_goldberg Oct 29 '15 at 0:48
  • $\begingroup$ Show[g1, g2, PlotRange -> All] that Work! thank you! $\endgroup$ – seito Oct 29 '15 at 2:06
2
$\begingroup$

What you probably want is

g1 = Plot[y = Sqrt[x^2 - x^4], {x, -1, 1}];
g2 = Plot[y = -Sqrt[x^2 - x^4], {x, -1, 1}];
Show[g1, g2, PlotRange -> All]

plot

$\endgroup$
1
$\begingroup$
g1 = Plot[y = Sqrt[x^2 - x^4], {x, -1, 1}, PlotRange -> {{-1, 1}, {-.5, .5}}];

g2 = Plot[y = -Sqrt[x^2 - x^4], {x, -1, 1}, PlotRange -> {{-1, 1}, {-.5, .5}}];

Show[g1, g2]

Show only works on frames of the same size and range

$\endgroup$
  • $\begingroup$ why do I have to use PlotRange to make it work I don't understand. event with g1=Plot[f1, {x,-1,1},{y,-.5,.5}] and g1=Plot[f2,{x,-1,1},{y,-.5,.5}] and Show[g1,g2] it's still not work $\endgroup$ – seito Oct 29 '15 at 2:09
  • $\begingroup$ PlotRange controls the frame size regardless of values plotted.Remember Show requires frames to be the same size and range. $\endgroup$ – Anon 22 Oct 29 '15 at 4:35
-2
$\begingroup$

Just put semicolons after the first and second lines.

But you seem to be unfamiliar with Mathematica's syntax. Much better is the approach in the comment from @bill s.

$\endgroup$

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