Polynomial Curve Fitting to Approximate a Function

In this tutorial, we will see the application of the polynomial curve fitting method to approximate a function. Let us consider the following differential equation.

t = m ∂f/∂x

When, x is at zero and m is 0.00024. The experimental data is given for the function f at four different points of x.

x     |    0     |           1      |            2  |        3
----------------------------------------------
     |   0      |   55.56     |   88.89   |    100

Plotting the values of f with respect to x gives following graph:
Function f is plotted against four given points














Our goal is to find the value of t by fitting the given experimental data through a polynomial. The most general nth degree polynomial is,

Pₙ (x) = aₒ + a₁ x + a₂ x² + a₃ x³ + ... .... ... + aₙ xⁿ

Where, aₒa₁, a₂, a₃, ... ... aₙ are constant coefficients of the polynomial equation. As it is mentioned in the experimental data where the function values are known for four respective points, so a third degree polynomial would fit the data. The third degree polynomial is,

f (x) = aₒ + a₁ x + a₂ x² + a₃ x³

Where, the coefficients are to be determined. According to the experimental data, we have,

f (0) = aₒ + a₁ (0) + a₂ (0)² + a₃ (0)³

⇒ aₒ = 0

Then,

f (1) = aₒ + a₁ (1) + a₂ (1)² + a₃ (1)³

⇒ a₁ + a₂ + a₃ = 55.56 .....................................................(1)

Then,

f (2) = aₒ + a₁ (2) + a₂ (2)² + a₃ (2)³

⇒ 2a₁ + 4a₂ + 8a₃ = 88.89 .............................................(2)

Then,

f (3) = aₒ + a₁ (3) + a₂ (3)² + a₃ (3)³

⇒ 3a₁ + 9a₂ + 27a₃ = 100 ...............................................(3)

Now, from equation (1):

a₁ = 55.56 - a₂ - a₃

Substituting a₁ into equation (2):

a₂ + 3a₃ = -11.115 ..............................................................(4)

Again, substituting a₁ into equation (3):

a₂ + 4a₃ = -11.113 ..............................................................(5)

Subtracting equation (5) from (4), we have,

a₃ = 0.002

Now, substituting a₃ in equation (4), we get,

a₂ = - 11.121

And finally we get, a₁ = 66.679

So, our polynomial function is,

f (x) = 66.679 - 11.121 x² + 0.002 x³

A plot is obtained to visualize the approximated function’s shape for the corresponding values of x where function values are determined for x, which is started from 0 with an interval 0.005 between points until 3. Following figure shows a smooth graph compared to the aforementioned one.

Plot of the approximated polynomial for different values of x















Now, we can determine the value of  ∂f/∂x:

∂f/∂x = 66.679  - 22.242 x + 0.006 

At x = 0, we get,

∂f/∂x = 66.679

Now, to evaluate t, according to the given equation:

t = m ∂f/∂x

t = 0.00024 × 66.679 = 0.016



#CurveFitting #Matlab #PolynomialFunction #Blog #Blogger

No comments:

Post a Comment