Find the vertex, focus, and directrix of a parabola in python

Share on facebook
Share on twitter
Share on linkedin
Share on twitter
Share on tumblr

In this python program, we will have a look at how to find the vertex, focus and directrix of a parabola in the Python programming language.

Python Program To Find the vertex, focus, and directrix of a parabola

 
def parabola(x, y, z):
    print ("Vertex: (" , (-y / (2 * x)) , ", "
        ,(((4 * x * z) - (y * y)) / (4 * x)) , ")" )
          
    print ("Focus: (" , (-y / (2 * x)) , ", "
        , (((4 * x * z) - (y * y) + 1) / (4 * x)) , ")" )
      
    print ("Directrix: y="
            , (int)(z - ((y * y) + 1) * 4 * x )) 
x = 6
y = 4
z = 3

parabola(x, y, z) 

Output:

Vertex: ( -0.3333333333333333 ,  2.3333333333333335 )
Focus: ( -0.3333333333333333 ,  2.375 )
Directrix: y= -405

Leave a Comment

Your email address will not be published. Required fields are marked *