Create a class that can handle Quadratic functions.
Notes and Code
Outcome
Specifications
Use the general equation:
$$ y = a x^2 + b x + c \tag{1}$$
Required methods:
Return the value of y for a given x (f(x)).
Return the x coordinate of the vertex.
Return the y coordinate of the vertex.
Return both the x and y coordinates of the vertex.
Return the y-intercept
Find the zeros of the function (the x-intercepts: values of x where y = 0)
Print out the equation like: y = x² + 2x - 8
Draw the curve.
Find the slope of the line at a given x value.
Test
Test your class using the equation:
$$ y = x^2 + 2x - 8 $$
Test
Test your class using the equation:
$$ y = x^2 + 2x - 8 $$
Output
Your program's output should look something like this:
Show Notes ▼
For the equation: y = x² + 2x - 8
(1) If x = 3 then y = 7
(2) The x-coordinate of the vertex is -1.0
(3) The y-coordinate of the vertex is -9.0
(4) The (x, y) coordinates of the vertex are (-1.0, -9.0)
(5) The y-intercept is at y = -8
(6) The x intercepts (zeros) of the function are: [2.0, -4.0]
(7) The human readable form of the equation is: y = x² + 2x - 8
(8) Drawing graph (see below) ...
(9) The slope of the line at x = -1.0: dy/dx = 0.0
(9) The slope of the line at x = 3: dy/dx = 8
Area (by Integration)
Add a method to find the area bounded by the curve and the x axis between two x values.
Use the method to find the area bounded by x = 0 and x = 2 .
The area under the curve between 0 and 2
is -9.333