ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 01 Oct 2014 00:17:39 -0500How to plot correctly these two simple exponential functions?http://ask.sagemath.org/question/24334/how-to-plot-correctly-these-two-simple-exponential-functions/ Im trying to plot this function $f=x^{1/x}$ with this code:
> x = var('x')
> f = x^(1/x)
> show(f)
>plot(f,x,-5,5)
but SAGE says that 'negative number cannot be raised to a fractional power'??? This make no sense to me, SAGE cant do this easy task? Really??
Because I dont believe it at all I tried to check the same with the function $g=2^{1/x}$
This time dont shows any error but the plot was completely wrong. If some one can help me I will appreciate it a lot. Yes, I tried to find the solution on the documentation but I dont encountered anything so helpful. Thank you in advance.
Tue, 30 Sep 2014 01:55:58 -0500http://ask.sagemath.org/question/24334/how-to-plot-correctly-these-two-simple-exponential-functions/Comment by tmonteil for <p>Im trying to plot this function $f=x^{1/x}$ with this code:</p>
<blockquote>
<p>x = var('x')</p>
<p>f = x^(1/x)</p>
<p>show(f)</p>
<p>plot(f,x,-5,5)</p>
</blockquote>
<p>but SAGE says that 'negative number cannot be raised to a fractional power'??? This make no sense to me, SAGE cant do this easy task? Really??</p>
<p>Because I dont believe it at all I tried to check the same with the function $g=2^{1/x}$</p>
<p>This time dont shows any error but the plot was completely wrong. If some one can help me I will appreciate it a lot. Yes, I tried to find the solution on the documentation but I dont encountered anything so helpful. Thank you in advance.</p>
http://ask.sagemath.org/question/24334/how-to-plot-correctly-these-two-simple-exponential-functions/?comment=24338#post-id-24338What is your mathematical definition of x^(1/X) ?Tue, 30 Sep 2014 03:18:47 -0500http://ask.sagemath.org/question/24334/how-to-plot-correctly-these-two-simple-exponential-functions/?comment=24338#post-id-24338Answer by god.one for <p>Im trying to plot this function $f=x^{1/x}$ with this code:</p>
<blockquote>
<p>x = var('x')</p>
<p>f = x^(1/x)</p>
<p>show(f)</p>
<p>plot(f,x,-5,5)</p>
</blockquote>
<p>but SAGE says that 'negative number cannot be raised to a fractional power'??? This make no sense to me, SAGE cant do this easy task? Really??</p>
<p>Because I dont believe it at all I tried to check the same with the function $g=2^{1/x}$</p>
<p>This time dont shows any error but the plot was completely wrong. If some one can help me I will appreciate it a lot. Yes, I tried to find the solution on the documentation but I dont encountered anything so helpful. Thank you in advance.</p>
http://ask.sagemath.org/question/24334/how-to-plot-correctly-these-two-simple-exponential-functions/?answer=24337#post-id-24337 Hi,
sage is correct saying that a negative number cannot be raised to a fractional power IF you want to plot it. For example
f(-2)=-1/2*sqrt(-2)
f(2)=sqrt(2)
The first one is imaginary, the other one real, so you cannot plot both in the same 2D plot. You could use the abs() function to avoid this problem. Another thing is
sage: f(x).limit(x=0,dir='+')
0
sage: f(x).limit(x=0,dir='-')
+Infinity
so that your plot for either f or g will have a huge peak which will suppress the rest of the plot. Try the following:
sage: f1(x)=x^(1/x)
sage: f2(x)=(-x)^(1/x)
sage: p1=plot(f1(x),0,5)
sage: p2=plot(f2(x),-5,-0.5)
sage: show(p1+p2)
Tue, 30 Sep 2014 03:17:36 -0500http://ask.sagemath.org/question/24334/how-to-plot-correctly-these-two-simple-exponential-functions/?answer=24337#post-id-24337Comment by god.one for <p>Hi,</p>
<p>sage is correct saying that a negative number cannot be raised to a fractional power IF you want to plot it. For example</p>
<pre><code>f(-2)=-1/2*sqrt(-2)
f(2)=sqrt(2)
</code></pre>
<p>The first one is imaginary, the other one real, so you cannot plot both in the same 2D plot. You could use the abs() function to avoid this problem. Another thing is</p>
<pre><code>sage: f(x).limit(x=0,dir='+')
0
sage: f(x).limit(x=0,dir='-')
+Infinity
</code></pre>
<p>so that your plot for either f or g will have a huge peak which will suppress the rest of the plot. Try the following:</p>
<pre><code>sage: f1(x)=x^(1/x)
sage: f2(x)=(-x)^(1/x)
sage: p1=plot(f1(x),0,5)
sage: p2=plot(f2(x),-5,-0.5)
sage: show(p1+p2)
</code></pre>
http://ask.sagemath.org/question/24334/how-to-plot-correctly-these-two-simple-exponential-functions/?comment=24358#post-id-24358Try imag, imag_part or imaginary, they should do the trick. And remember to use help or ? often to find out what a function does.Wed, 01 Oct 2014 00:17:39 -0500http://ask.sagemath.org/question/24334/how-to-plot-correctly-these-two-simple-exponential-functions/?comment=24358#post-id-24358Comment by Masacroso for <p>Hi,</p>
<p>sage is correct saying that a negative number cannot be raised to a fractional power IF you want to plot it. For example</p>
<pre><code>f(-2)=-1/2*sqrt(-2)
f(2)=sqrt(2)
</code></pre>
<p>The first one is imaginary, the other one real, so you cannot plot both in the same 2D plot. You could use the abs() function to avoid this problem. Another thing is</p>
<pre><code>sage: f(x).limit(x=0,dir='+')
0
sage: f(x).limit(x=0,dir='-')
+Infinity
</code></pre>
<p>so that your plot for either f or g will have a huge peak which will suppress the rest of the plot. Try the following:</p>
<pre><code>sage: f1(x)=x^(1/x)
sage: f2(x)=(-x)^(1/x)
sage: p1=plot(f1(x),0,5)
sage: p2=plot(f2(x),-5,-0.5)
sage: show(p1+p2)
</code></pre>
http://ask.sagemath.org/question/24334/how-to-plot-correctly-these-two-simple-exponential-functions/?comment=24343#post-id-24343I want to plot the imaginary part, how I can do it then? I search for something similar to Re or Im functions but I not encountered. And thank you very much for the info.Tue, 30 Sep 2014 08:11:21 -0500http://ask.sagemath.org/question/24334/how-to-plot-correctly-these-two-simple-exponential-functions/?comment=24343#post-id-24343Answer by Masacroso for <p>Im trying to plot this function $f=x^{1/x}$ with this code:</p>
<blockquote>
<p>x = var('x')</p>
<p>f = x^(1/x)</p>
<p>show(f)</p>
<p>plot(f,x,-5,5)</p>
</blockquote>
<p>but SAGE says that 'negative number cannot be raised to a fractional power'??? This make no sense to me, SAGE cant do this easy task? Really??</p>
<p>Because I dont believe it at all I tried to check the same with the function $g=2^{1/x}$</p>
<p>This time dont shows any error but the plot was completely wrong. If some one can help me I will appreciate it a lot. Yes, I tried to find the solution on the documentation but I dont encountered anything so helpful. Thank you in advance.</p>
http://ask.sagemath.org/question/24334/how-to-plot-correctly-these-two-simple-exponential-functions/?answer=24342#post-id-24342I want to plot the imaginary part, how I can do it then? I search for something similar to Re or Imfunctions but I not encountered. Tue, 30 Sep 2014 08:10:56 -0500http://ask.sagemath.org/question/24334/how-to-plot-correctly-these-two-simple-exponential-functions/?answer=24342#post-id-24342