interpolation

so i'm writing a program to do LaGrange interpolation. For those who aren't really familiar with the formulas for it, its like a series. I want to make this function into an array and for each value of the array have a certain formula plugged in, but I don't really know how to do it. The array is size n-1 (where n is inputted by the user as size). An example is

P(0)= (y-x1)/(x0-x1)
P(1)= (y-x0)/(x1-x0)
(where the user the xvalues are an entirely seperate array-that the user inputs- and y is input right before the array of P is declared)

hopefully this is straightforward..
any ideas?

Comments

  • : so i'm writing a program to do LaGrange interpolation. For those who
    : aren't really familiar with the formulas for it, its like a series.
    : I want to make this function into an array and for each value of the
    : array have a certain formula plugged in, but I don't really know how
    : to do it. The array is size n-1 (where n is inputted by the user as
    : size). An example is
    :
    : P(0)= (y-x1)/(x0-x1)
    : P(1)= (y-x0)/(x1-x0)
    : (where the user the xvalues are an entirely seperate array-that the
    : user inputs- and y is input right before the array of P is declared)
    :
    : hopefully this is straightforward..
    : any ideas?

    So you want to make an array of functions? In C this rather cumbersome to do, in C++ you can write a 'MyFunction' class:

    [code]
    struct MyFunction
    {
    double GetY(const double x);
    double GetDerivative(const double x);
    //etcetera
    };
    [/code]

    I hope this will help you, at least to formulate the question even more straightforward.

    See ya,
    bilderbikkel
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion