How to find a equation from approximate curve?

2.9k Views Asked by At

I want to know a way to find equation from a curve. enter image description here

for example, if I have 4 point (1, 3.5), (2, 4.3), (3, 7.2), (4, 8) then how to find a good approximation equation ?

What if I got above curve then how to get a equation like p(x)=9−10.05x+5.25x2−0.7x3 ? Might be above curve have like this p(x) = ...x^10000

Also what is the Best way to approximate a curve as soon as possible?

2

There are 2 best solutions below

3
On

One idea that comes to mind is to use matrices to solve for a polynomial that goes through each of those points. With 4 points, we demand a third degree polynomial of the form $$p(x)=a+bx+cx^2+dx^3$$ Taking those four points we have the system of equations $$ \left[\begin{array}{rrrr|r} a & b & c & d & 3.5 \\ a & 2b & 4c & 8d & 4.3 \\ a & 3b & 9c & 27d & 7.2 \\ a & 4b & 16c & 64d & 8 \\ \end{array}\right] $$ You can use a graphing calculator or any computer algebra software (or do it manually if you're so inclined) to obtain the rref: $$ \left[\begin{array}{rrrr|r} a & 0 & 0 & 0 & 9 \\ 0 & b & 0 & 0 & -10.05 \\ 0 & 0 & c & 0 & 5.25 \\ 0 & 0 & 0 & d & -0.7 \\ \end{array}\right] $$ Thus we have $$p(x)=9-10.05x+5.25x^2-0.7x^3$$ which fits all the required points. My apologies if this method is not quite as civilized an approach as you were hoping for, curious to see what else is out there.

8
On

It's best to have some idea of what the function will look like: \begin{align} y &= a \ln x + b \\ y &= ax + b \\ y &= ae^x + b \\ y &= \sum_{i=0}^n a_ix^i \\ y &= \dfrac{\sum_{i=0}^n a_ix^i}{\sum_{j=0}^m a_ix^i} \\ y &= \operatorname{spline}(x; \alpha_0, \alpha_1, \dots)\\ y &= \operatorname{bode}(x; \alpha_0, \alpha_1, \dots)\\ \end{align} The list of possibilities is essentially endless.

If the data is exact values derived from some complicated computations, then a high order polynomial or rational polynomial fit would be my first choice.

If the data is experimental data with errors attached, then linear would be my first choice, then quadratic. If neither of work well, I would plot the data as $\ln x$ vs $y$ or as $x$ vs $\ln y$ to see if I could transform the data into something that looked linear.

Warning. Fitting a nth degree polynomial to $n+1$ equally-spaced data points is a notoriously bad idea.