Ask Your Question
0

How to plot correctly these two simple exponential functions?

asked 2014-09-30 08:55:58 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

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.

edit retag flag offensive close merge delete

Comments

1

What is your mathematical definition of x^(1/X) ?

tmonteil gravatar imagetmonteil ( 2014-09-30 10:18:47 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2014-09-30 10:17:36 +0200

god.one gravatar image

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)
edit flag offensive delete link more

Comments

I 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.

Masacroso gravatar imageMasacroso ( 2014-09-30 15:11:21 +0200 )edit

Try imag, imag_part or imaginary, they should do the trick. And remember to use help or ? often to find out what a function does.

god.one gravatar imagegod.one ( 2014-10-01 07:17:39 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2014-09-30 08:55:58 +0200

Seen: 783 times

Last updated: Sep 30 '14