# wolfram alpha doesn't plot implicit function with range

Recently I read an article in a magazine describing how an inverse graphing calculator on this page adds domains and ranges to implicit functions. Unfortunately the page is down and I can't see it for myself, so I tried to plot one of the formulas in wolfram alpha,

(y-x)^2 + (y^2 - 6*y + 8 + sqrt(y^4 - 12*y^3 + 52*y^2 - 96*y + 64))^2=0


but it doesn't plot it, it just shows an empty graph. It does however show the correct solution:

for 2 <= x <= 4, y=x


I also tried plotting it in geogebra and some online things that can handle implicit functions but they also just give empty graphs. Is it too complicated? Is the formula correct? And if so why doesn't it plot the equation?

• What do you mean by "Is the formula correct?"? Correct with respect to what? – trang1618 Sep 26 '16 at 20:24
• I mean that the formula does what I expect it to do, y=x in 2<=y<=4. Wolfram Alpha says what I expect of the formula, but perhaps it could be wrong. – The PJ Sep 26 '16 at 20:28

Most numerical implicit function plotters actually depend on recognizing changes of sign. Basically, if you want to plot $f(x,y) = 0$, you start by sampling a bunch of points $f(x_i,y_j)$, and you know that if this has opposite signs at two neighbouring points, there should be a piece of the curve somewhere between them. But if you have a function such that $f(x,y) \ge 0$ for all $x,y$, unless you are lucky enough to hit exactly on a point where $f(x,y) = 0$ you will only see positive values, and you will never detect the presence of a curve. That's the case here, since your function is the sum of two squares.

• Good to know! Do you know how to explain @grixor 's observation that replacing $\sqrt{y^4 - 12y^3 + 52y^2 - 96y + 64} \to \vert y^2-6y+8\vert$ allows WA to graph it? – GFauxPas Sep 26 '16 at 21:17
• My guess is that WA is sampling points on the diagonal $x=y$. In principle, when $2 \le y \le 4$ this should give you $f(y,y) = 0$. However, in numerical evaluation roundoff error is likely to produce a result that is slightly nonzero. But when you use the simplification, numerical evaluation of $y^2 - 6 y + 8 - |y^2 - 6 y + 8|$ will produce an exact $0$ result. – Robert Israel Sep 26 '16 at 21:24
• the function f(x,y) = x^2 +y^2 only cuts the x-y plane once, so, my question is like with this one piece how do u get the curve ? – Buraian Jul 16 '20 at 23:50
• In this case it's $(y-x)^2 + (something)^2$ where $something = 0$ when $x=y$ and $y^2-6y+8\le 0$. That's a line segment, not just a point. – Robert Israel Jul 17 '20 at 1:42

In Mathematica, the command

ContourPlot[Log[(y - x)^2 + (y^2 - 6 y + 8 +
Sqrt[y^4 - 12 y^3 + 52 y^2 - 96 y + 64])^2],
{x, 1, 5}, {y, 1, 5}, PlotPoints -> 50, MaxRecursion -> 5]


produces this output:

Changing ContourPlot to Plot3D gives

ContourPlot on the original relation will not work well even if we don't explicitly try to obtain the level set at $f(x,y) = 0$:

ContourPlot[(y - x)^2 + (y^2 - 6 y + 8 +
Sqrt[y^4 - 12 y^3 + 52 y^2 - 96 y + 64])^2,
{x, 1, 5}, {y, 1, 5}, PlotPoints -> 50, MaxRecursion -> 5, Contours -> 20]


gives

This suggests there is something going on, but a more sensitive step size in the level sets is needed. Clearly, a major part of the problem is not just the fact that $f(x,y) \ge 0$, but also that in the region outside $[2,4]^2$, the function increases quite rapidly. Together, these properties of the function conspire to prevent the detection of the level set.

However, a simple command

Reduce[(y - x)^2 + (y^2 - 6 y + 8 +
Sqrt[y^4 - 12 y^3 + 52 y^2 - 96 y + 64])^2 == 0, {x, y}, Reals]


gives the output

2 <= x <= 4 && y == x


which still fails to plot in ContourPlot, but is easily plotted with RegionPlot:

RegionPlot[2 <= x <= 4 && y == x, {x, 1, 5}, {y, 1, 5}]


gives

This is because RegionPlot uses different algorithms.

• Strangely enough does your "reduce" query not produce the output you told it would, it only produces two x=... outputs, while the query as described in the original question does produce the output "reduce" should give. – The PJ Sep 26 '16 at 21:44

Since $a^2 + b^2 \geq 0 \ \forall\ a,b \in \mathbb{R}$, $a^2 + b^2 =0$ when $a = b = 0$. You get this when $x = y$ and $y^2 - 6y+8 + |y^2 - 6y+8|=0.$

Update: I think it's mainly because they don't simplify square root of a square. If you change your sqrt to $|y^2 - 6y+8|$, you get this new plot in WolframAlpha

• I believe his question is regarding why this solution set isn't graphed by graphing software. – GFauxPas Sep 26 '16 at 20:41
• GFauxPas is right, the question is why it isn't graphed, not how it works. Thanks for the answer anyways. – The PJ Sep 26 '16 at 20:44
• @GFauxPas Ah I see. Thank you for clarifying! I'm not sure about wolframalpha, but desmos.com/calculator shows the correct graph. – trang1618 Sep 26 '16 at 20:47
• @grixor Thanks, now I can plot the formulas to play with them, I was unaware of the existence of Desmos, but now I am. The answer from Robert Israel explains why it doesn't work with wolfram alpha. – The PJ Sep 26 '16 at 20:53