Ask Your Question
1

how to plot a circle (without circle())

asked 2017-09-20 22:43:54 +0100

germac gravatar image

Hello, I know you can plot a circle with circle(x,y,radius), but how do you do it with plot()?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-09-21 18:36:45 +0100

slelievre gravatar image

There are several ways you can use plot or similar functions.

  • use plot with the circle as the graphics object you already discovered:

    sage: plot(circle((0, 0), 2))
    
  • express y as a function of x for two half-circles (this will miss part of the circle):

    sage: p = plot(sqrt(4 - x^2), (-3, 3))
    sage: q = plot(-sqrt(4 - x^2), (-3, 3))
    sage: (p + q).show(aspect_ratio=1)
    
  • use an implicit plot starting from an equation for the circle:

    sage: x, y = SR.var("x y")
    sage: implicit_plot(x^2 + y^2 - 4, (x, -3, 3), (y, -3, 3))
    
  • use a parametric plot for the circle; here is one (there are many others):

    sage: t = var('t')
    sage: parametric_plot((2*cos(t), 2*sin(t)), (t, 0, 2*pi))
    

In this case I would recommend the parametric plot rather than the functions or the implicit plot.

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

Stats

Asked: 2017-09-20 22:43:54 +0100

Seen: 2,002 times

Last updated: Sep 21 '17