interpolation - copy.pdf

Upload: vishnu-suresh

Post on 28-Feb-2018

212 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/25/2019 Interpolation - Copy.pdf

    1/9

    Interpolation and curve fitting

    In interpolation our aim is to find the curve which passes through our given data set. Equation

    of the curve gives us an idea as to how the parameters represented in the plane (or space) are

    related, and extension of that curve gives an idea of how the system might behave when some

    of the parameters are changed. Engineering is all about approximation and finding best solution

    as opposed to finding exact solution. Sometimes it might not be possible to obtain a curve

    which passes exactly through our given dataset. In such cases, we need to find the curve i.e.

    closest to these points. This is the domain of curve-fitting. Following fundamental theories of

    algebra might be useful in our study and application of interpolation principles.

    1. Values of n unknowns can be ascertained if there are minimum n variables.

    2. N+1 data points can be accommodated by a polynomial of degree N, which has exactly

    N+1 unknowns

    3. A polynomial of nth degree is represented by the equation

    4. A quadratic equation is represented by

    By various experiments (P3/P1) values and corresponding NLR values given in the

    table 1 is known.

    Table 1

    NLR P3/P1

    0 0.25

    30 0.625

    50 1.25

    65 1.94

    75 2.62

    85 3.5100 5.13

    Now if we know that NLR speed at any instant is 75 and P1 is 91kPa we can refer table1

    and realize that P3/P1 value is 2.62.

  • 7/25/2019 Interpolation - Copy.pdf

    2/9

    Therefore P3=2.62*91=238.42kPa.

    If we were to know the value of P3 when its value directlyfrom sensor is not available

    or erroneous Then we can predict a possible value of P3 given NLR is known if we can

    find a relation between P3 and NLR.As already stated an equation of degree 7 will give a

    curve which passes through these points. However, due to practical limitations we willuse a second degree equation using C coding. Our algorithm is explained below

    1. Obtaining the solution for a quadriatic equation given 3 points:

    A quadriatic equation is given by

    Which passes through (x1,y1),(x2,y2),(x3,y3).Our aim is to find a,b,c.

    Substituting these points, we have

    () ( ) ()

    Eqn (1)-(2) gives

    () ( ) () ()Eqn (1)-(3) gives

    () ( ) () ()

    From eqn 1

    () ()( )

    ()

    Substituting the value of a from (5) in eqn (4) we get,

    (3)22()(232)

    (22)(3)()(232) (6)

    ()()

    (22) (7)

  • 7/25/2019 Interpolation - Copy.pdf

    3/9

    Where b is known by (6)

    Where a and b are known from (6) and (7)

    Thus the equation of the curve

    Which passes through (x1,y1) , (x2,y2) , ( x3,y3) is known using eqn(6) ,(7) and (8).

    2.

    Finding the possible equations for all the combination of three data points.

    Equation of second degree requires three data points to be solved. There are seven data points.

    Therefore 7C3=35 possible combinations of three data points and Thereby that many equations

    are generated.

    3.

    Determining the accuracy of each equation.

    Suppose the datapoints given are (x1,y1),(x2,y2)(xn,yn).

    Where

    is the average error in the kth curve fitting equation ()is the equation of the kth curve is the number of datapoints

    (() ) is the difference between actual y value and predicted y value.i.e.f(x).Thus the summation gives the total error value for an equation

    4.

    Selecting the Best Curve

    The curve with the best value is chosen as winner

    (8)

    Average Error (() = )

  • 7/25/2019 Interpolation - Copy.pdf

    4/9

    Code

    The procedure stated above is coded as given.

    #include

    #include

    void main()

    {

    int i,j,k,l=0,N,M,m=0,L=0;

    float x[20],y[20],Y,a[100],b[100],c[100],e[100],E;

    for(i=0;i

  • 7/25/2019 Interpolation - Copy.pdf

    5/9

    for(k=j+1;k

  • 7/25/2019 Interpolation - Copy.pdf

    6/9

    for(i=0;i

  • 7/25/2019 Interpolation - Copy.pdf

    7/9

  • 7/25/2019 Interpolation - Copy.pdf

    8/9

  • 7/25/2019 Interpolation - Copy.pdf

    9/9

    Comparision between measured and calculated values

    0

    1

    2

    3

    4

    5

    6

    0 30 50 65 75 85 100

    P3/P1

    P3/P1(calc)