Ask Your Question

plotting bug

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

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 21:11:35 +0200 )edit

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

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

2 Answers

Sort by ยป oldest newest most voted

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

Emmanuel Charpentier gravatar image

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

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-16 02:59:51 +0200 )edit

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

tmonteil gravatar image

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

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 18:08:00 +0200

Seen: 554 times

Last updated: Nov 10 '17