Ask Your Question

unaccurate plot of a circle

asked 2013-03-19 07:39:36 -0500

mathematicboy gravatar image

updated 2015-01-14 07:26:18 -0500

FrédéricC gravatar image


I want to plot a circle centered at the origin and radius sqrt(2). When I type:


in sage 5.4, the graph obtained is really unaccurated.

However, for the circle of radius sqrt(3) works fine. Does anybody know why?

Of course I know there are several ways to plot a circle, but i want do do like this for showing my pupils some applications of integral calculus.

I think it is important to have a "plot" command working properly, since it is extensively used in teaching.

edit retag flag offensive close merge delete

3 answers

Sort by » oldest newest most voted

answered 2013-03-19 09:27:50 -0500

calc314 gravatar image

This is a common numerical problem when plotting as the function approaches a vertical asymptote.

Raising the number of points plotted will make the picture nicer.

var('x y')

Generally, to plot a circle, it might be best to use implicit_plot.

var('x y')
edit flag offensive delete link more


Yes, implicit plotting is the way to go.

kcrisman gravatar imagekcrisman ( 2013-03-19 10:14:16 -0500 )edit

answered 2013-03-19 14:48:41 -0500

mathematicboy gravatar image

Thank you for your answers.

Of course there are several ways to fix it, but my point is that I don't understand why it works with sqrt(3) and don't with sqrt(2). It seems a problem in accuracy. And it leads to a maybe not good algorithm for painting.

I think this kind of simple examples can transmit a poor image of Sage to pupils. Moreover, if you simply google "plot sqrt(2-x^2)" you obtain a more precise graph. And if you use an obsolete software like Mathematica 4.2 you obtain an ugly graph, but precise at extreme points. And maybe in older versions the result is the same, but i can't check it.

My point of view in this question is not to find alternatives to do a simple task when a command is not working properly in comparison to other softwares. Since it is an easy question there are several alternatives, but believe me, not all pupils are able to find them. My purpose is to ask if someone knows why the command is behaving like this and more interesting, if is there any plan to change it.

Sorry for my answer, but my wish is improve Sage.

edit flag offensive delete link more

answered 2013-03-19 09:42:16 -0500

ndomes gravatar image

I don't know the reason, but you are right and it is very funny, for example sqrt(17) gives a closed circle, sqrt(19) does not.

Using a numerical approximation seems to create closed circles in any case.

a = sqrt(2).n()
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


Asked: 2013-03-19 07:39:36 -0500

Seen: 133 times

Last updated: Mar 19 '13