Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
0

How to plot correctly these two simple exponential functions?

asked 10 years ago

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=x1/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=21/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.

Preview: (hide)

Comments

1

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

tmonteil gravatar imagetmonteil ( 10 years ago )

1 Answer

Sort by » oldest newest most voted
2

answered 10 years ago

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)
Preview: (hide)
link

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 ( 10 years ago )

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 ( 10 years ago )

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: 10 years ago

Seen: 928 times

Last updated: Sep 30 '14