Question

In: Computer Science

Make a program for LAGRANGE INTERPOLATION METHOD using C++ program and can be evaluated both polynomial...

Make a program for LAGRANGE INTERPOLATION METHOD using C++ program and can be evaluated both polynomial and Transcendental Functions.

Solutions

Expert Solution

In this C++ program, x and y are two array for storing x data and y data respectively. xp is interpolation point given by user and output of Lagrange interpolation method is obtained in yp.

#include<iostream>
#include<conio.h>

using namespace std;

int main()
{
         float x[100], y[100], xp, yp=0, p;
         int i,j,n;

         /* Input Section */
         cout<<"Enter number of data: ";
         cin>>n;
         cout<<"Enter data:"<< endl;
         for(i=1;i<=n;i++)
         {
                  cout<<"x["<< i<<"] = ";
                  cin>>x[i];
                  cout<<"y["<< i<<"] = ";
                  cin>>y[i];
         }
         cout<<"Enter interpolation point: ";
         cin>>xp;

         /* Implementing Lagrange Interpolation */
         for(i=1;i<=n;i++)
         {
                  p=1;
                  for(j=1;j<=n;j++)
                  {
                           if(i!=j)
                           {
                                p = p* (xp - x[j])/(x[i] - x[j]);
                           }
                  }
                  yp = yp + p * y[i];
         }
         cout<< endl<<"Interpolated value at "<< xp<< " is "<< yp;

         return 0;
}

Related Solutions

Find the lagrange polynomials that approximate f(x) = x3 a ) Find the linear interpolation polynomial...
Find the lagrange polynomials that approximate f(x) = x3 a ) Find the linear interpolation polynomial P1(x) using the nodes x0= -1 and x1 = 0 b) Find the quadratic interpolation polynomial P2(x) using the nodes x0= -1 and x1 = 0 and x2 = 1 c) Find the cubic interpolation polynomial P3(x) using the nodes x0= -1 and x1 = 0 and x2 = 1 and x3=2 d) Find the linear interpolation polynomial P1(x) using the nodes x0= 1...
Language: Java Design and implement a program that implements an Interpolation Search method. Interpolation search is...
Language: Java Design and implement a program that implements an Interpolation Search method. Interpolation search is similar to binary search, except it tries to begin the search nearer to the location of the item. Instead of the using the middle value of the sorted array, interpolation search estimates the location of the target with respect to the first & last values in the array. The implementation is the same as binary search except that you should calculate the mid value...
Using the bisection method:     Make a program to use this method using the following three...
Using the bisection method:     Make a program to use this method using the following three functions and use it to find the root of this function f (x) = x * x * x-8. a) A function so that the user between xlower and xupper that meets the value of the function has a different sign and if he does not ask for new values. b) A function to find the root and call it bisection and perform a...
find Lagrange polynomials that approximate f(x)=x^3, a) find the linear interpolation p1(x) using the nodes X0=-1...
find Lagrange polynomials that approximate f(x)=x^3, a) find the linear interpolation p1(x) using the nodes X0=-1 and X1=0 b) find the quadratic interpolation polynomial p2(x) using the nodes x0=-1,x1=0, x2=1 c) find the cubic interpolation polynomials p3(x) using the nodes x0=-1, x1=0 , x2=1 and x3=2. d) find the linear interpolation polynomial p1(x) using the nodes x0=1 and x1=2 e) find the quadratic interpolation polynomial p2(x) using the nodes x0=0 ,x1=1 and x2=2
The following two investment alternatives are being evaluated using the​ B/C ratio method. The alternatives have...
The following two investment alternatives are being evaluated using the​ B/C ratio method. The alternatives have a​ 5-year service life and the MARR is 18​% per year. Alternative A Alternative B Capital investment ​$10,900    ​$16,000    Annual revenues 4,000   7,500   Annual costs 250   900   Market value at EOY 5 5,000   9,200   Click the icon to view the interest and annuity table for discrete compounding when i equals=18​%per year. Calculate the modified​ B/C ratio of Alternative A A. 1.32 B.1.35 C.1.26 D.0.90...
Can you solve this C program by using Function? Q1. Write a C program to ring...
Can you solve this C program by using Function? Q1. Write a C program to ring the computer bell at any number of times you specify. Use the system clock as a delay, you need to include the time header file.
Using C++ 1) Write a program that repeatedly evaluates a n-th order polynomial p(x) = a0...
Using C++ 1) Write a program that repeatedly evaluates a n-th order polynomial p(x) = a0 + a1*x + a2*x^2 + ... + an*x^n where n <= 10 The program inputs n, ai, and x from the keyboard and then prints out the corresponding value of p to the screen. The program continues to input new values of n, ai, x and evaluates p until a negative value for n is input, at which point the program stops.
****C++, put both of them in to one main method, make sure to start with main...
****C++, put both of them in to one main method, make sure to start with main class, if I get a screenshot of the output as well. thank you (1) A palindrome is a string that reads the same forwards as backwards. Using only a fixed number of stacks and queues, the stack and queue ADT functions, and a fixed number of int and char variables, write an algorithm to determine if a string is a palindrome. Assume that the...
****C++, put both of them in to one main method, make sure to start with main...
****C++, put both of them in to one main method, make sure to start with main class, if I get a screenshot of the output as well. thank you (3) Use singly linked lists to implement integers of unlimited size. Each node of the list should store one digit of the integer. You should implement addition, subtraction, multiplication, and exponentiation operations. Limit exponents to be positive integers. What is the asymptotic running time for each of your operations, expressed in...
C++ program to accept characters as a polynomial and then output whether they're valid or not....
C++ program to accept characters as a polynomial and then output whether they're valid or not. Types of polynomials that don't work: n^5n, n^9.7, 8n, n^7-7*n
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT