Ask Your Question
1

Plot circle or ellipse with equation?

asked 2013-07-02 07:24:51 -0500

bxdin gravatar image

Given the standard equation of a circle:

x^2 + y^2 + 7x - 2y + 6 = 0 --Simplified-to--> (x+7/2)^2 + (y-1)^2 = 29/4

Standard formula of a circle: (x + (-h))^2 + (y + (-k))^2 = r^2 The center is represented by (h, k); radius by sqrt(r^2).

So my first question is, is there are way I could insert either of the 1st 2 equations and have Sage 5.9 generate the circle?

My second question similarly deals with an ellipse that has the simplified equation:

((x+2)^2)/9 + ((y-1)^2)/25 = 1

Its major axis is: (-2,-4) (-2,6) Minor axis is: (-5,1) (1,1)

Standard form of an ellipse is: ((x - (-h))^2)/b^2 + ((y + (-k))^2)/a^2

Center is determined by analyzing the differences between the x2/x1, y2/y1 coordinates of the major or minor axis (i.e. midpoint formula).

Could I generate an ellipse baed on the simplified equation?

In case anyone's interested, the following thread has an unanswered question: http://ask.sagemath.org/question/2764...

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
4

answered 2013-07-02 09:21:41 -0500

niles gravatar image

You can use implicit_plot, either by giving a function of two variables (implicit_plot will plot the level set where the function is equal to 0):

sage: var('x,y')
sage: e(x,y) = ((x+2)^2)/9 + ((y-1)^2)/25
sage: implicit_plot(e - 1, (x,-5,1), (y,-4,6))

or by giving an equation in two variables (note the == sign):

sage: var('x,y')
sage: implicit_plot(((x+2)^2)/9 + ((y-1)^2)/25 == 1, (x,-5,1), (y,-4,6))
edit flag offensive delete link more

Comments

Thanks! As an added bonus I went ahead and plotted the y-axis/x-axis lines. Yax = x Xax = y p2 = implicit_plot(Yax, (x,-10,10), (y,-10,10)) p3 = implicit_plot(Xax, (x,-10,10), (y,-10,10)) p4 = point((-2, 1)) #center of circle

bxdin gravatar imagebxdin ( 2013-07-03 03:40:16 -0500 )edit

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2013-07-02 07:24:51 -0500

Seen: 714 times

Last updated: Jul 02 '13