How to convert the given data to a quadratic polynomial form?

612 Views Asked by At

I have data such as the following:

$x0 = [25;25;25;25;25;25]$

$y0 = [500;750;250;250;2000;3000]$

$x1 = [45;45;45;45;45;45]$

$y1 = [2500;1750;650;550;8000;18000]$

$x2 = [60;60;60;60;60;60]$

$y2 = [4750;4300;965;1075;15500;32985]$

The above data are coordinates in the Cartesian coordinate system. If this is confusing, just take a couple of points then, such as:

$x0 = [25 25], y0 = [500 750], x1 = [45 45], y1 = [2500 1750], x2 = [60 60], y2 = [4750 4300]$

For linear data conversion to linear polynomial, I know that $x0, y0, x1, y1$ are given and are converted using the $y = mx+c$ form. I'm clueless as to how it can be done for the above given data to the quadratic form. How do I convert this data into the quadratic polynomial form?

1

There are 1 best solutions below

0
On BEST ANSWER

I've thought about this some more, and I think you must be wanting to pass a quadratic curve through three points. As long as the three points aren't in a straight line, you can do this with a curve of the form $$y=ax^2+bx+c\tag{1},$$ for some real numbers $a,b,c.$ The graph will be a parabola.

You just have to substitute each of the $3$ points into $(1).$ This will give you $3$ linear equations in the the $3$ unknowns $a,b,c,$ and you can solve them. The example you give has numbers too large for me to do it by hand, but I did it in python:

import numpy as np
y = np.array([500750,25001750,47504300])
x =np.array([2525,4545,6060])
A=np.array([
    [x[0]**2, x[0], 1],
    [x[1]**2, x[1], 1],
    [x[2]**2, x[2], 1],
])
(a,b,c) =np.linalg.inv(A)@y
print(a,b,c)

This prints out

0.770568711751 6681.28712871 -21282357.1429

so that the equation is

$$y=0.770568711751x^2+6681.28712871x-21282357.1429$$

If you substitute your $x$ values into this formula, it will give you the corresponding $y$ values.

Let me do a smaller example so you can see it better. Suppose the points are $$(1,2),(3,4),(5,7).$$ We would set up the following equations: $$\begin{align} a + b + c &= 2\\ 9a + 3b + c&=4\\ 25a + 5b + c&=7 \end{align}$$

and solve for $a,b,\text{ and }c,$ getting$$ a=\frac18,b=\frac48,c=\frac{11}{8}$$