Linear Algebra and the C Language/a066
The coefficients of the equation of a parabola.
Presentation :
A homogeneous linear system with as many equations
as unknowns has a nontrivial solution if and only
if the determinant of the matrix is zero.
Let us calculate the equation of the parabola passing through points P, Q R:
c1 y + c2 x^2 + c3 x + c4 = 0
This same equation with the points P(x1,y1) Q(x2,y2) and R(x3,y3):
c1 y1 + c2x1^2 + c3x1 + c4 = 0
c1 y2 + c2x2^2 + c3x2 + c4 = 0
c1 y3 + c2x3^2 + c3x3 + c4 = 0
The system of four equations:
c1 y + c2 x^2 + c3 x + c4 = 0
c1 y1 + c2x1^2 + c3x1 + c4 = 0
c1 y2 + c2x2^2 + c3x2 + c4 = 0
c1 y3 + c2x3^2 + c3x3 + c4 = 0
The determinant of the system:
|y x^2 x 1|
|y1 x1^2 x1 1| = 0
|y2 x2^2 x2 1|
|y3 x3^2 x3 1|
The determinant in C language:
|1 1 1 1|
|y1 x1^2 x1 1| = 0
|y2 x2^2 x2 1|
|y3 x3^2 x3 1|
To calculate the coefficients of the equation of the parabola,
we use the cofactor expansion along the first row.
cof(R1,C1) y + cof(R1,C2) x^2 + cof(R1,C3) x + cof(R1,C4) = 0
This equation gives us the equation of the parobola
that passes through the three points P, Q and R.
Application
Delete this file at the end of the session.