First time here? Check out the FAQ!

Ask Your Question
1

plotting bug

asked 7 years ago

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)

Preview: (hide)

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

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

Kamal gravatar imageKamal ( 7 years ago )

2 Answers

Sort by » oldest newest most voted
0

answered 7 years ago

tmonteil gravatar image

updated 7 years ago

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...

Preview: (hide)
link
1

answered 7 years ago

Emmanuel Charpentier gravatar image

updated 7 years ago

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

Preview: (hide)
link

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 ( 7 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

1 follower

Stats

Asked: 7 years ago

Seen: 937 times

Last updated: Nov 10 '17