ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 19 Aug 2017 02:16:15 +0200Implicit plot with squaring and absolute value produces empty plothttps://ask.sagemath.org/question/38563/implicit-plot-with-squaring-and-absolute-value-produces-empty-plot/ The following code:
sage: x,y = var('x y')
sage: implicit_plot(x, (x,-2,2), (y,-2,2))
produces a plot of a straight line along the coordinate y-axis as expected (it should plot the curve $x = 0$).
However, this very similar code:
sage: implicit_plot(x^2, (x,-2,2), (y,-2,2))
produces a plot with nothing on it, even though it *should* plot the curve $x^2 = 0$ which is clearly the same as the above curve.
This problem seems to persist with any function $f(x, y)$, i.e., in the following code,
f(x, y) = [some expression involving x and y]
sage: implicit_plot(f(x, y), [x scale], [y scale])
sage: implicit_plot(f(x, y)^2, [x scale], [y scale])
the second line produces a nonempty plot while the third line produces an empty plot. Replacing `f(x,y)^2` with `abs(f(x,y))` or even `abs_symbolic(f(x,y))` has the same effect: they all produce empty plots.
The problem persists when one replaces `implicit_plot` with `implicit_plot3d`.
What's going on? Is this a bug?Fri, 18 Aug 2017 00:36:31 +0200https://ask.sagemath.org/question/38563/implicit-plot-with-squaring-and-absolute-value-produces-empty-plot/Comment by dan_fulea for <p>The following code:</p>
<pre><code>sage: x,y = var('x y')
sage: implicit_plot(x, (x,-2,2), (y,-2,2))
</code></pre>
<p>produces a plot of a straight line along the coordinate y-axis as expected (it should plot the curve $x = 0$).</p>
<p>However, this very similar code:</p>
<pre><code>sage: implicit_plot(x^2, (x,-2,2), (y,-2,2))
</code></pre>
<p>produces a plot with nothing on it, even though it <em>should</em> plot the curve $x^2 = 0$ which is clearly the same as the above curve.</p>
<p>This problem seems to persist with any function $f(x, y)$, i.e., in the following code,</p>
<pre><code>f(x, y) = [some expression involving x and y]
sage: implicit_plot(f(x, y), [x scale], [y scale])
sage: implicit_plot(f(x, y)^2, [x scale], [y scale])
</code></pre>
<p>the second line produces a nonempty plot while the third line produces an empty plot. Replacing <code>f(x,y)^2</code> with <code>abs(f(x,y))</code> or even <code>abs_symbolic(f(x,y))</code> has the same effect: they all produce empty plots.</p>
<p>The problem persists when one replaces <code>implicit_plot</code> with <code>implicit_plot3d</code>.</p>
<p>What's going on? Is this a bug?</p>
https://ask.sagemath.org/question/38563/implicit-plot-with-squaring-and-absolute-value-produces-empty-plot/?comment=38571#post-id-38571Looking in the code via `??implicit_plot` we get the relevant lines...
if options['fill'] is True:
# many further lines
if not is_Expression(f):
return region_plot(lambda x, y: f(x, y) < 0, xrange, yrange,
borderwidth=linewidths, borderstyle=linestyles,
incol=incol, bordercol=bordercol,
**options)
else:
return region_plot(f < 0, xrange, yrange, borderwidth=linewidths,
borderstyle=linestyles,
incol=incol, bordercol=bordercol,
and it is hard to arrange $f<0$ passing a square to the `region_plot`...Fri, 18 Aug 2017 23:36:34 +0200https://ask.sagemath.org/question/38563/implicit-plot-with-squaring-and-absolute-value-produces-empty-plot/?comment=38571#post-id-38571Comment by Doeke for <p>The following code:</p>
<pre><code>sage: x,y = var('x y')
sage: implicit_plot(x, (x,-2,2), (y,-2,2))
</code></pre>
<p>produces a plot of a straight line along the coordinate y-axis as expected (it should plot the curve $x = 0$).</p>
<p>However, this very similar code:</p>
<pre><code>sage: implicit_plot(x^2, (x,-2,2), (y,-2,2))
</code></pre>
<p>produces a plot with nothing on it, even though it <em>should</em> plot the curve $x^2 = 0$ which is clearly the same as the above curve.</p>
<p>This problem seems to persist with any function $f(x, y)$, i.e., in the following code,</p>
<pre><code>f(x, y) = [some expression involving x and y]
sage: implicit_plot(f(x, y), [x scale], [y scale])
sage: implicit_plot(f(x, y)^2, [x scale], [y scale])
</code></pre>
<p>the second line produces a nonempty plot while the third line produces an empty plot. Replacing <code>f(x,y)^2</code> with <code>abs(f(x,y))</code> or even <code>abs_symbolic(f(x,y))</code> has the same effect: they all produce empty plots.</p>
<p>The problem persists when one replaces <code>implicit_plot</code> with <code>implicit_plot3d</code>.</p>
<p>What's going on? Is this a bug?</p>
https://ask.sagemath.org/question/38563/implicit-plot-with-squaring-and-absolute-value-produces-empty-plot/?comment=38576#post-id-38576This leads one to investigate a similar phenomenon:
region_plot(x==0, (-2, 2), (-2, 2), axes=False)
produces a line on the coordinate y-axis, but
region_plot(x^2==0, (-2, 2), (-2, 2), axes=False)
produces an empty plot.Sat, 19 Aug 2017 02:16:15 +0200https://ask.sagemath.org/question/38563/implicit-plot-with-squaring-and-absolute-value-produces-empty-plot/?comment=38576#post-id-38576