Ask Your Question

plotting bug

asked 2017-11-09 11:08:00 -0600

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: (see in sagecell)

edit retag flag offensive close merge delete


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 14:11:35 -0600 )edit

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

Kamal gravatar imageKamal ( 2017-11-10 02:53:20 -0600 )edit

2 answers

Sort by ยป oldest newest most voted

answered 2017-11-10 11:32:23 -0600

Emmanuel Charpentier gravatar image

updated 2017-11-10 11:35:36 -0600

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


See it in Sagecell

edit flag offensive delete link more


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-15 19:59:51 -0600 )edit

answered 2017-11-10 05:42:42 -0600

tmonteil gravatar image

updated 2017-11-10 05:43:38 -0600

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)


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


Asked: 2017-11-09 11:08:00 -0600

Seen: 109 times

Last updated: Nov 10 '17