Ask Your Question
1

plotting bug

asked 2017-11-09 18:08:00 +0100

this post is marked as community wiki

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

I wanted to plot this function:

f(x) = x^2 + 1/x

and I plotted it using this command:

plot(f, (x, -100, 100))

and when I plotted it I got a wrong plot:

https://sagecell.sagemath.org/?z=eJxL06jQVLBVqIgzUtBWMNSv4OXi5SrIyS_RSNNR0KjQUdA1NDDQUQASmpoA34YJmA==&lang=sage (see in sagecell)

edit retag flag offensive close merge delete

Comments

Can you say exactly what command you used? Probably it wasn't wrong, but had a very high y-axis because 1/x has an asymptote. Try using ymax=10 as a keyword in your plot.

kcrisman gravatar imagekcrisman ( 2017-11-09 21:11:35 +0100 )edit

Sorry I forgot to say the plotting command I used ; I edited the post.

Kamal gravatar imageKamal ( 2017-11-10 09:53:20 +0100 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2017-11-10 18:32:23 +0100

Emmanuel Charpentier gravatar image

updated 2017-11-10 18:35:36 +0100

Cheaper (less points) and clearer (more concentrated about the origin, uncluttered by axes, explicitely shows the singularity) :

f(x)=x^2+1/x
plot(f,(-10,10),detect_poles="show",axes=False,plot_points=100)

See it in Sagecell

edit flag offensive delete link more

Comments

Just a small variation.

sage: plot(f, (-9, 9), detect_poles="show", plot_points=99, ymin=-99, ymax=99, axes=False)
slelievre gravatar imageslelievre ( 2017-11-16 02:59:51 +0100 )edit
0

answered 2017-11-10 12:42:42 +0100

tmonteil gravatar image

updated 2017-11-10 12:43:38 +0100

I am not sure about your problem (you did not tell what was wrong in the picture), but in case you want to see the vertical asymptote around zero, you can require Sage to plot more points as follows:

f(x) = x^2 + 1/x
plot(f, (x, -100, 100), plot_points=100000)

See http://sagecell.sagemath.org/?z=eJxL0...

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-11-09 18:08:00 +0100

Seen: 699 times

Last updated: Nov 10 '17