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.Thu, 30 Sep 2021 17:43:58 +0200How to correctly plot x^(1/3)https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/sage: plot(x**(1/3))
This command produces a graph that looks like this:
![image](https://i.imgur.com/cfzNJQH.png)
I was expecting a graph like this:
![image](https://i.imgur.com/7AhRgTD.png)Sat, 25 Apr 2020 13:53:08 +0200https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/Comment by rburing for <p>sage: plot(x**(1/3))</p>
<p>This command produces a graph that looks like this:</p>
<p><img alt="image" src="https://i.imgur.com/cfzNJQH.png"></p>
<p>I was expecting a graph like this:</p>
<p><img alt="image" src="https://i.imgur.com/7AhRgTD.png"></p>
https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=51006#post-id-51006What do you expect to get instead?Sat, 25 Apr 2020 14:31:05 +0200https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=51006#post-id-51006Comment by gg for <p>sage: plot(x**(1/3))</p>
<p>This command produces a graph that looks like this:</p>
<p><img alt="image" src="https://i.imgur.com/cfzNJQH.png"></p>
<p>I was expecting a graph like this:</p>
<p><img alt="image" src="https://i.imgur.com/7AhRgTD.png"></p>
https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=51011#post-id-51011I was expecting [this](https://imgur.com/7AhRgTD)Sat, 25 Apr 2020 16:02:09 +0200https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=51011#post-id-51011Answer by rburing for <p>sage: plot(x**(1/3))</p>
<p>This command produces a graph that looks like this:</p>
<p><img alt="image" src="https://i.imgur.com/cfzNJQH.png"></p>
<p>I was expecting a graph like this:</p>
<p><img alt="image" src="https://i.imgur.com/7AhRgTD.png"></p>
https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?answer=51013#post-id-51013SageMath sometimes chooses complex cube roots, which explains this behavior.
There's not much you can do about this internal choice. But you can do this:
plot(sgn(x)*abs(x)^(1/3),(x,-13,13))
![cube root graph](/upfiles/15878242194796636.png)Sat, 25 Apr 2020 16:18:15 +0200https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?answer=51013#post-id-51013Comment by gg for <p>SageMath sometimes chooses complex cube roots, which explains this behavior.</p>
<p>There's not much you can do about this internal choice. But you can do this:</p>
<pre><code>plot(sgn(x)*abs(x)^(1/3),(x,-13,13))
</code></pre>
<p><img alt="cube root graph" src="/upfiles/15878242194796636.png"></p>
https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=51015#post-id-51015How you arrive at this function `sgn(x)*abs(x)^(1/3)`?Sat, 25 Apr 2020 17:08:30 +0200https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=51015#post-id-51015Comment by rburing for <p>SageMath sometimes chooses complex cube roots, which explains this behavior.</p>
<p>There's not much you can do about this internal choice. But you can do this:</p>
<pre><code>plot(sgn(x)*abs(x)^(1/3),(x,-13,13))
</code></pre>
<p><img alt="cube root graph" src="/upfiles/15878242194796636.png"></p>
https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=51016#post-id-51016See https://en.wikipedia.org/wiki/Sign_functionSat, 25 Apr 2020 17:57:42 +0200https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=51016#post-id-51016Comment by rburing for <p>SageMath sometimes chooses complex cube roots, which explains this behavior.</p>
<p>There's not much you can do about this internal choice. But you can do this:</p>
<pre><code>plot(sgn(x)*abs(x)^(1/3),(x,-13,13))
</code></pre>
<p><img alt="cube root graph" src="/upfiles/15878242194796636.png"></p>
https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=51017#post-id-51017To get the real cube root of $-x$ (where $x>0$) you just have to add a minus sign in front of the real cube root of $x$; that's what this does.Sat, 25 Apr 2020 18:01:27 +0200https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=51017#post-id-51017Answer by Masacroso for <p>sage: plot(x**(1/3))</p>
<p>This command produces a graph that looks like this:</p>
<p><img alt="image" src="https://i.imgur.com/cfzNJQH.png"></p>
<p>I was expecting a graph like this:</p>
<p><img alt="image" src="https://i.imgur.com/7AhRgTD.png"></p>
https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?answer=51040#post-id-51040Another way is to use the method `x.nth_root(3)` for real numbers `x`.
Using this
sage: plot(lambda x: RR(x).nth_root(3), (-1, 1))
gives the desired plot.Sun, 26 Apr 2020 13:51:45 +0200https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?answer=51040#post-id-51040Answer by slelievre for <p>sage: plot(x**(1/3))</p>
<p>This command produces a graph that looks like this:</p>
<p><img alt="image" src="https://i.imgur.com/cfzNJQH.png"></p>
<p>I was expecting a graph like this:</p>
<p><img alt="image" src="https://i.imgur.com/7AhRgTD.png"></p>
https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?answer=51008#post-id-51008[Edited after the question was updated, clarifying
it is not "why does the graph not start at zero",
but "why is the negative part missing".]
Together with the unsatisfactory plot, the command
sage: plot(x^(1/3))
gives some warnings:
verbose 0 (3797: plot.py, generate_plot_points)
WARNING: When plotting, failed to evaluate function at 100 points.
verbose 0 (3797: plot.py, generate_plot_points)
Last error message: 'can't convert complex to float'
They give a clue as to what goes wrong.
By default, `plot` plots on the interval $[-1, 1]$ using
200 points regularly spaced along that interval to evaluate
the function being plotted.
The warning that it "failed to evaluate function at 100 points",
and the plot it produces, reveal that it failed to get a point
to plot for all the negative values.
Here is how Sage computes powers one-third of negative numbers,
depending on whether they are rational or floating-point:
sage: a = (-1)^(1/3)
sage: a
(-1)^(1/3)
sage: b = (-1.)^(1/3)
sage: b
0.500000000000000 + 0.866025403784439*I
And here is what happens when trying to convert them to floats
(`plot` does that):
sage: float(a)
---------------------------------------------------------------------------
Traceback (most recent call last)
...
TypeError: can't convert complex to float
During handling of the above exception, another exception occurred:
TypeError: unable to simplify to float approximation
sage: float(b)
Traceback (most recent call last)
...
TypeError: unable to convert 0.500000000000000 + 0.866025403784439*I
to float; use abs() or real_part() as desired
To plot the real-cube-root function, i.e. the composition inverse
of the $(x \mapsto x^3)$ bijection, there are various options.
One is indicated in @rburing's answer, and uses the sign and
the absolute value to work around this limitation in Sage.
It is actually part of the SageMath FAQ, see:
- [SageMath FAQ: How do I plot the cube root (or other odd roots) for negative input?](http://doc.sagemath.org/html/en/faq/faq-usage.html#how-do-i-plot-the-cube-root-or-other-odd-roots-for-negative-input)
One other option is to plot $x = y^3$ instead of $y = x^(1/3)$.
This can be done using a parametric plot:
sage: parametric_plot((lambda t: t^3, lambda t: t), (-1, 1))
![parametric plot: cube root from minus one to one](https://i.imgur.com/MXs9VLf.png)
This can also be done using an implicit plot since
the desired graph is the locus where $x - y^3$ is zero:
sage: implicit_plot(lambda x, y: x - y^3, (-1, 1), (-1, 1))
![implicit plot: cube root from minus one to one](https://i.imgur.com/1bsv6tM.png)
By default implicit plot comes with a frame instead of axes.
One can add axes:
sage: implicit_plot(lambda x, y: x - y^3, (-1, 1), (-1, 1), axes=True)
![parametric plot: cube root from minus one to one, with axes](https://i.imgur.com/ffmdvqf.png)
One can additionally remove the frame:
sage: implicit_plot(lambda x, y: x - y^3, (-1, 1), (-1, 1), axes=True, frame=False)
![parametric plot: cube root from minus one to one, with axes, no frame](https://i.imgur.com/tLMvDhW.png)Sat, 25 Apr 2020 14:57:14 +0200https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?answer=51008#post-id-51008Comment by gg for <p>[Edited after the question was updated, clarifying
it is not "why does the graph not start at zero",
but "why is the negative part missing".]</p>
<p>Together with the unsatisfactory plot, the command</p>
<pre><code>sage: plot(x^(1/3))
</code></pre>
<p>gives some warnings:</p>
<pre><code>verbose 0 (3797: plot.py, generate_plot_points)
WARNING: When plotting, failed to evaluate function at 100 points.
verbose 0 (3797: plot.py, generate_plot_points)
Last error message: 'can't convert complex to float'
</code></pre>
<p>They give a clue as to what goes wrong.</p>
<p>By default, <code>plot</code> plots on the interval $[-1, 1]$ using
200 points regularly spaced along that interval to evaluate
the function being plotted.</p>
<p>The warning that it "failed to evaluate function at 100 points",
and the plot it produces, reveal that it failed to get a point
to plot for all the negative values.</p>
<p>Here is how Sage computes powers one-third of negative numbers,
depending on whether they are rational or floating-point:</p>
<pre><code>sage: a = (-1)^(1/3)
sage: a
(-1)^(1/3)
sage: b = (-1.)^(1/3)
sage: b
0.500000000000000 + 0.866025403784439*I
</code></pre>
<p>And here is what happens when trying to convert them to floats
(<code>plot</code> does that):</p>
<pre><code>sage: float(a)
---------------------------------------------------------------------------
Traceback (most recent call last)
...
TypeError: can't convert complex to float
During handling of the above exception, another exception occurred:
TypeError: unable to simplify to float approximation
sage: float(b)
Traceback (most recent call last)
...
TypeError: unable to convert 0.500000000000000 + 0.866025403784439*I
to float; use abs() or real_part() as desired
</code></pre>
<p>To plot the real-cube-root function, i.e. the composition inverse
of the $(x \mapsto x^3)$ bijection, there are various options.</p>
<p>One is indicated in <a href="/users/24971/rburing/">@rburing</a>'s answer, and uses the sign and
the absolute value to work around this limitation in Sage.
It is actually part of the SageMath FAQ, see:</p>
<ul>
<li><a href="http://doc.sagemath.org/html/en/faq/faq-usage.html#how-do-i-plot-the-cube-root-or-other-odd-roots-for-negative-input">SageMath FAQ: How do I plot the cube root (or other odd roots) for negative input?</a></li>
</ul>
<p>One other option is to plot $x = y^3$ instead of $y = x^(1/3)$.</p>
<p>This can be done using a parametric plot:</p>
<pre><code>sage: parametric_plot((lambda t: t^3, lambda t: t), (-1, 1))
</code></pre>
<p><img alt="parametric plot: cube root from minus one to one" src="https://i.imgur.com/MXs9VLf.png"></p>
<p>This can also be done using an implicit plot since
the desired graph is the locus where $x - y^3$ is zero:</p>
<pre><code>sage: implicit_plot(lambda x, y: x - y^3, (-1, 1), (-1, 1))
</code></pre>
<p><img alt="implicit plot: cube root from minus one to one" src="https://i.imgur.com/1bsv6tM.png"></p>
<p>By default implicit plot comes with a frame instead of axes.</p>
<p>One can add axes:</p>
<pre><code>sage: implicit_plot(lambda x, y: x - y^3, (-1, 1), (-1, 1), axes=True)
</code></pre>
<p><img alt="parametric plot: cube root from minus one to one, with axes" src="https://i.imgur.com/ffmdvqf.png"></p>
<p>One can additionally remove the frame:</p>
<pre><code>sage: implicit_plot(lambda x, y: x - y^3, (-1, 1), (-1, 1), axes=True, frame=False)
</code></pre>
<p><img alt="parametric plot: cube root from minus one to one, with axes, no frame" src="https://i.imgur.com/tLMvDhW.png"></p>
https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=51018#post-id-51018what's the difference between `plot` and `implicit_plot`?Sat, 25 Apr 2020 19:32:10 +0200https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=51018#post-id-51018Comment by gg for <p>[Edited after the question was updated, clarifying
it is not "why does the graph not start at zero",
but "why is the negative part missing".]</p>
<p>Together with the unsatisfactory plot, the command</p>
<pre><code>sage: plot(x^(1/3))
</code></pre>
<p>gives some warnings:</p>
<pre><code>verbose 0 (3797: plot.py, generate_plot_points)
WARNING: When plotting, failed to evaluate function at 100 points.
verbose 0 (3797: plot.py, generate_plot_points)
Last error message: 'can't convert complex to float'
</code></pre>
<p>They give a clue as to what goes wrong.</p>
<p>By default, <code>plot</code> plots on the interval $[-1, 1]$ using
200 points regularly spaced along that interval to evaluate
the function being plotted.</p>
<p>The warning that it "failed to evaluate function at 100 points",
and the plot it produces, reveal that it failed to get a point
to plot for all the negative values.</p>
<p>Here is how Sage computes powers one-third of negative numbers,
depending on whether they are rational or floating-point:</p>
<pre><code>sage: a = (-1)^(1/3)
sage: a
(-1)^(1/3)
sage: b = (-1.)^(1/3)
sage: b
0.500000000000000 + 0.866025403784439*I
</code></pre>
<p>And here is what happens when trying to convert them to floats
(<code>plot</code> does that):</p>
<pre><code>sage: float(a)
---------------------------------------------------------------------------
Traceback (most recent call last)
...
TypeError: can't convert complex to float
During handling of the above exception, another exception occurred:
TypeError: unable to simplify to float approximation
sage: float(b)
Traceback (most recent call last)
...
TypeError: unable to convert 0.500000000000000 + 0.866025403784439*I
to float; use abs() or real_part() as desired
</code></pre>
<p>To plot the real-cube-root function, i.e. the composition inverse
of the $(x \mapsto x^3)$ bijection, there are various options.</p>
<p>One is indicated in <a href="/users/24971/rburing/">@rburing</a>'s answer, and uses the sign and
the absolute value to work around this limitation in Sage.
It is actually part of the SageMath FAQ, see:</p>
<ul>
<li><a href="http://doc.sagemath.org/html/en/faq/faq-usage.html#how-do-i-plot-the-cube-root-or-other-odd-roots-for-negative-input">SageMath FAQ: How do I plot the cube root (or other odd roots) for negative input?</a></li>
</ul>
<p>One other option is to plot $x = y^3$ instead of $y = x^(1/3)$.</p>
<p>This can be done using a parametric plot:</p>
<pre><code>sage: parametric_plot((lambda t: t^3, lambda t: t), (-1, 1))
</code></pre>
<p><img alt="parametric plot: cube root from minus one to one" src="https://i.imgur.com/MXs9VLf.png"></p>
<p>This can also be done using an implicit plot since
the desired graph is the locus where $x - y^3$ is zero:</p>
<pre><code>sage: implicit_plot(lambda x, y: x - y^3, (-1, 1), (-1, 1))
</code></pre>
<p><img alt="implicit plot: cube root from minus one to one" src="https://i.imgur.com/1bsv6tM.png"></p>
<p>By default implicit plot comes with a frame instead of axes.</p>
<p>One can add axes:</p>
<pre><code>sage: implicit_plot(lambda x, y: x - y^3, (-1, 1), (-1, 1), axes=True)
</code></pre>
<p><img alt="parametric plot: cube root from minus one to one, with axes" src="https://i.imgur.com/ffmdvqf.png"></p>
<p>One can additionally remove the frame:</p>
<pre><code>sage: implicit_plot(lambda x, y: x - y^3, (-1, 1), (-1, 1), axes=True, frame=False)
</code></pre>
<p><img alt="parametric plot: cube root from minus one to one, with axes, no frame" src="https://i.imgur.com/tLMvDhW.png"></p>
https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=51039#post-id-51039So, its a function to plot relations rather than function. ThanksSun, 26 Apr 2020 11:53:52 +0200https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=51039#post-id-51039Comment by slelievre for <p>[Edited after the question was updated, clarifying
it is not "why does the graph not start at zero",
but "why is the negative part missing".]</p>
<p>Together with the unsatisfactory plot, the command</p>
<pre><code>sage: plot(x^(1/3))
</code></pre>
<p>gives some warnings:</p>
<pre><code>verbose 0 (3797: plot.py, generate_plot_points)
WARNING: When plotting, failed to evaluate function at 100 points.
verbose 0 (3797: plot.py, generate_plot_points)
Last error message: 'can't convert complex to float'
</code></pre>
<p>They give a clue as to what goes wrong.</p>
<p>By default, <code>plot</code> plots on the interval $[-1, 1]$ using
200 points regularly spaced along that interval to evaluate
the function being plotted.</p>
<p>The warning that it "failed to evaluate function at 100 points",
and the plot it produces, reveal that it failed to get a point
to plot for all the negative values.</p>
<p>Here is how Sage computes powers one-third of negative numbers,
depending on whether they are rational or floating-point:</p>
<pre><code>sage: a = (-1)^(1/3)
sage: a
(-1)^(1/3)
sage: b = (-1.)^(1/3)
sage: b
0.500000000000000 + 0.866025403784439*I
</code></pre>
<p>And here is what happens when trying to convert them to floats
(<code>plot</code> does that):</p>
<pre><code>sage: float(a)
---------------------------------------------------------------------------
Traceback (most recent call last)
...
TypeError: can't convert complex to float
During handling of the above exception, another exception occurred:
TypeError: unable to simplify to float approximation
sage: float(b)
Traceback (most recent call last)
...
TypeError: unable to convert 0.500000000000000 + 0.866025403784439*I
to float; use abs() or real_part() as desired
</code></pre>
<p>To plot the real-cube-root function, i.e. the composition inverse
of the $(x \mapsto x^3)$ bijection, there are various options.</p>
<p>One is indicated in <a href="/users/24971/rburing/">@rburing</a>'s answer, and uses the sign and
the absolute value to work around this limitation in Sage.
It is actually part of the SageMath FAQ, see:</p>
<ul>
<li><a href="http://doc.sagemath.org/html/en/faq/faq-usage.html#how-do-i-plot-the-cube-root-or-other-odd-roots-for-negative-input">SageMath FAQ: How do I plot the cube root (or other odd roots) for negative input?</a></li>
</ul>
<p>One other option is to plot $x = y^3$ instead of $y = x^(1/3)$.</p>
<p>This can be done using a parametric plot:</p>
<pre><code>sage: parametric_plot((lambda t: t^3, lambda t: t), (-1, 1))
</code></pre>
<p><img alt="parametric plot: cube root from minus one to one" src="https://i.imgur.com/MXs9VLf.png"></p>
<p>This can also be done using an implicit plot since
the desired graph is the locus where $x - y^3$ is zero:</p>
<pre><code>sage: implicit_plot(lambda x, y: x - y^3, (-1, 1), (-1, 1))
</code></pre>
<p><img alt="implicit plot: cube root from minus one to one" src="https://i.imgur.com/1bsv6tM.png"></p>
<p>By default implicit plot comes with a frame instead of axes.</p>
<p>One can add axes:</p>
<pre><code>sage: implicit_plot(lambda x, y: x - y^3, (-1, 1), (-1, 1), axes=True)
</code></pre>
<p><img alt="parametric plot: cube root from minus one to one, with axes" src="https://i.imgur.com/ffmdvqf.png"></p>
<p>One can additionally remove the frame:</p>
<pre><code>sage: implicit_plot(lambda x, y: x - y^3, (-1, 1), (-1, 1), axes=True, frame=False)
</code></pre>
<p><img alt="parametric plot: cube root from minus one to one, with axes, no frame" src="https://i.imgur.com/tLMvDhW.png"></p>
https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=51020#post-id-51020Suppose we want to visualise the set of points $(x, y)$
where $x^2 + y^2 = 1$. This cannot be put in the form
$y = f(x)$. But one can think of it as the set of points
where $x^2 + y^2 - 1$ is zero, and so plot it as
sage: implicit_plot(lambda x, y: x^2 + y^2 - 1, (-1, 1), (-1, 1))
It is called an implicit plot because instead of the plot
of a function, it is the plot of some relation between
$x$ and $y$. Some pieces of the plot could be put
in the form $y = f(x)$ or $x = g(y)$, but these functions
remain implicit here, as we only use some relation
between $x$ and $y$ to get the plot.Sat, 25 Apr 2020 20:50:41 +0200https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=51020#post-id-51020Answer by Sébastien for <p>sage: plot(x**(1/3))</p>
<p>This command produces a graph that looks like this:</p>
<p><img alt="image" src="https://i.imgur.com/cfzNJQH.png"></p>
<p>I was expecting a graph like this:</p>
<p><img alt="image" src="https://i.imgur.com/7AhRgTD.png"></p>
https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?answer=51009#post-id-51009Another option is to specify the `xmin`, `xmax`, `ymin`, `ymax` or just one of them:
sage: plot(x**(1/3), ymin=0)Sat, 25 Apr 2020 15:13:23 +0200https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?answer=51009#post-id-51009Comment by gg for <p>Another option is to specify the <code>xmin</code>, <code>xmax</code>, <code>ymin</code>, <code>ymax</code> or just one of them:</p>
<pre><code>sage: plot(x**(1/3), ymin=0)
</code></pre>
https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=51012#post-id-51012Specifying these arguments still doesn't plot the correct graph.Sat, 25 Apr 2020 16:03:54 +0200https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=51012#post-id-51012Comment by Sébastien for <p>Another option is to specify the <code>xmin</code>, <code>xmax</code>, <code>ymin</code>, <code>ymax</code> or just one of them:</p>
<pre><code>sage: plot(x**(1/3), ymin=0)
</code></pre>
https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=51014#post-id-51014I thought you were unhappy with the fact that the y axis was broken. Indeed, these options do not change the range of the domain of the function which is drawn. If that was the issue, then rburing's answer is the way to go.Sat, 25 Apr 2020 16:51:49 +0200https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=51014#post-id-51014Comment by cybervigilante for <p>Another option is to specify the <code>xmin</code>, <code>xmax</code>, <code>ymin</code>, <code>ymax</code> or just one of them:</p>
<pre><code>sage: plot(x**(1/3), ymin=0)
</code></pre>
https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=53921#post-id-53921So why does a simple graphing calculator do the correct graph but Sage can't?Thu, 15 Oct 2020 03:02:25 +0200https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=53921#post-id-53921Comment by Sébastien for <p>Another option is to specify the <code>xmin</code>, <code>xmax</code>, <code>ymin</code>, <code>ymax</code> or just one of them:</p>
<pre><code>sage: plot(x**(1/3), ymin=0)
</code></pre>
https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=53935#post-id-53935because the default values corresponds better to what people expectThu, 15 Oct 2020 21:33:43 +0200https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=53935#post-id-53935Answer by kcrisman for <p>sage: plot(x**(1/3))</p>
<p>This command produces a graph that looks like this:</p>
<p><img alt="image" src="https://i.imgur.com/cfzNJQH.png"></p>
<p>I was expecting a graph like this:</p>
<p><img alt="image" src="https://i.imgur.com/7AhRgTD.png"></p>
https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?answer=59208#post-id-59208After many, *many* years, we finally have [`real_nth_root` as well](https://sagecell.sagemath.org/?z=eJwryMkv0ShKTcyJzyvJiC_KB_IqdBSMNXUUQLSuoY6CoaYmAPcqCwU=&lang=sage&interacts=eJyLjgUAARUAuQ==). From the documentation:
sage: plot(real_nth_root(x, 3), (x, -1, 1))
![plot of cube root for real input](/upfiles/16330161976795622.png)
See [Trac 12074](https://trac.sagemath.org/ticket/12074) for some of the story.Thu, 30 Sep 2021 17:36:55 +0200https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?answer=59208#post-id-59208Comment by tmonteil for <p>After many, <em>many</em> years, we finally have <a href="https://sagecell.sagemath.org/?z=eJwryMkv0ShKTcyJzyvJiC_KB_IqdBSMNXUUQLSuoY6CoaYmAPcqCwU=&lang=sage&interacts=eJyLjgUAARUAuQ=="><code>real_nth_root</code> as well</a>. From the documentation:</p>
<pre><code>sage: plot(real_nth_root(x, 3), (x, -1, 1))
</code></pre>
<p><img src="/upfiles/16330161976795622.png" alt="plot of cube root for real input"></p>
<p>See <a href="https://trac.sagemath.org/ticket/12074">Trac 12074</a> for some of the story.</p>
https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=59209#post-id-59209Nice !Thu, 30 Sep 2021 17:43:58 +0200https://ask.sagemath.org/question/51005/how-to-correctly-plot-x13/?comment=59209#post-id-59209