Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
Python Program for Finding the vertex, focus and directrix of a parabola
In this article, we will learn how to find the vertex, focus, and directrix of a parabola given its equation in standard form y = ax² + bx + c.
Problem Statement
Given a parabola equation in the standard form y = ax² + bx + c, we need to find:
- Vertex: The point where the parabola changes direction
- Focus: A fixed point inside the parabola
- Directrix: A fixed line outside the parabola
Mathematical Formulas
For a parabola y = ax² + bx + c:
- Vertex: (-b/(2a), (4ac - b²)/(4a))
- Focus: (-b/(2a), (4ac - b² + 1)/(4a))
- Directrix: y = (4ac - b² - 1)/(4a)
Python Implementation
def find_parabola_properties(a, b, c):
"""
Find vertex, focus, and directrix of parabola y = ax^2 + bx + c
"""
# Calculate vertex coordinates
vertex_x = -b / (2 * a)
vertex_y = (4 * a * c - b * b) / (4 * a)
# Calculate focus coordinates
focus_x = vertex_x
focus_y = (4 * a * c - b * b + 1) / (4 * a)
# Calculate directrix equation
directrix_y = (4 * a * c - b * b - 1) / (4 * a)
print(f"Parabola: y = {a}x² + {b}x + {c}")
print(f"Vertex: ({vertex_x:.3f}, {vertex_y:.3f})")
print(f"Focus: ({focus_x:.3f}, {focus_y:.3f})")
print(f"Directrix: y = {directrix_y:.3f}")
# Example usage
a = 1
b = -2
c = 3
find_parabola_properties(a, b, c)
The output of the above code is ?
Parabola: y = 1x² + -2x + 3 Vertex: (1.000, 2.000) Focus: (1.000, 2.250) Directrix: y = 1.750
Multiple Examples
# Test with different parabolas
test_cases = [
(1, 0, 0), # y = x²
(2, 4, 1), # y = 2x² + 4x + 1
(-1, 2, 3) # y = -x² + 2x + 3 (opens downward)
]
for i, (a, b, c) in enumerate(test_cases, 1):
print(f"\nExample {i}:")
find_parabola_properties(a, b, c)
The output shows properties of different parabolas ?
Example 1: Parabola: y = 1x² + 0x + 0 Vertex: (0.000, 0.000) Focus: (0.000, 0.250) Directrix: y = -0.250 Example 2: Parabola: y = 2x² + 4x + 1 Vertex: (-1.000, -1.000) Focus: (-1.000, -0.875) Directrix: y = -1.125 Example 3: Parabola: y = -1x² + 2x + 3 Vertex: (1.000, 4.000) Focus: (1.000, 3.750) Directrix: y = 4.250
Key Properties
| Component | Formula | Description |
|---|---|---|
| Vertex X | -b/(2a) | Axis of symmetry |
| Vertex Y | (4ac - b²)/(4a) | Minimum/maximum value |
| Focus | Same x, y + 1/(4a) | Inside the parabola |
| Directrix | y = vertex_y - 1/(4a) | Outside the parabola |
Conclusion
The vertex, focus, and directrix are fundamental properties of any parabola. Using the standard form coefficients a, b, and c, we can calculate these properties with simple mathematical formulas. The vertex represents the turning point, while the focus and directrix help define the parabola's geometric shape.
Advertisements
