Ask Your Question

# plotting bug

asked 2017-11-09 11:08:00 -0500 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 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.

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

## 2 answers

Sort by » oldest newest most voted

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

more

## Comments

Just a small variation.

sage: plot(f, (-9, 9), detect_poles="show", plot_points=99, ymin=-99, ymax=99, axes=False)


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)

more

## Your Answer

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

Add Answer

## Stats

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

Seen: 122 times

Last updated: Nov 10 '17