Satisfy the parabola when point (A, B) and the equation is given
Given a point (A, B) such that distance from each point on the curve M.y = N.x2 + O.x + P with (A, B) is equal to the distance between that point on the curve and x-axis. The task is to find the value of M, N O and P.
Note: The equation should be in simple form i.e. gcd( |M|, |N|, |O|, |P| ) = 1 and N should always be positive.
Input: A = 1, B = 1
Output: 2 1 -2 2
M = 2, N = 1, O = -2, P = 2
The equation of the curve will be
2y = x2 – 2x + 2
Input: A = -1, B = 1
Output: 2 1 2 2
Approach: From the property of the parabola, for every point on the curve the distance with the directrix and the focus will always be equal. Using this property, consider y = 0 as a directrix and (A, B) as the focus.
Since in the equation N is given to be always positive, the parabola will be facing upward and the equation of the parabola is (x – h)2 = 4p(y – k) where (h, k) is the co-ordinate of the vertex and p is the distance between focus and vertex or vertex and directrix.
Since the vertex is the mid point between the perpendicular distance form focus (A, B) and the directrix here (A, 0) is B. So the co-ordinate of the vertex is (A, B/2) and p is also B/2.
So, the equation will be (x – A)2 = 4 * B/2 * (y – B/2).
This equation can be solved to get the result:
Below is the implementation of the above approach:
2 1 -2 2
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.