Question: PLEASE CODE IN C Example Output: Lagrange interpolation MENU 1. Function A 2. Function B 3. Quit Enter your choice: 1 WHEN n=5 K Xk
PLEASE CODE IN C


Example Output: Lagrange interpolation MENU 1. Function A 2. Function B 3. Quit Enter your choice: 1 WHEN n=5 K Xk P TRUE VALUE ABSOLUTE ERROR 0 -1.0000000 1.4142140 1.414213562 4.38E-07 1 -0.9500000 1.3802810 1.379311422 9.70E-04 2 -0.9000000 1.3468090 1.345362405 1.45E-03 3 -0.8500000 1.3139990 1.312440475 1.56E-03 4 -0.8000000 1.2820420 1.280624847 1.42E-03 5 -0.7500000 1.2511190 1.25 1.12E-03 6 -0.7000000 1.2213990 1.220655562 7.43E-04 7 -0.6500000 1.1930400 1.192686044 3.54E-04 8 -0.6000000 1.1661900 1.166190379 3.79E-07 9 -0.5500000 1.1409860 1.141271221 2.85E-04 10 -0.5000000 1.1175530 1.118033989 4.81E-04 11 -0.4500000 1.0960050 1.09658561 5.81E-04 12 -0.4000000 1.0764470 1.077032961 5.86E-04 13 -0.3500000 1.0589710 1.059481005 5.10E-04 14 -0.3000000 1.0436600 1.044030651 3.71E-04 15 -0.2500000 1.0305840 1.030776406 1.92E-04 16 -0.2000000 1.0198040 1.019803903 9.73E-08
17 -0.1500000 1.0113680 1.011187421 1.81E-04 18 -0.1000000 1.0053150 1.004987562 3.27E-04 19 -0.0500000 1.0016730 1.00124922 4.24E-04 20 0.0000000 1.0004570 1 4.57E-04 21 0.0500000 1.0016730 1.00124922 4.24E-04 22 0.1000000 1.0053150 1.004987562 3.27E-04 23 0.1500000 1.0113680 1.011187421 1.81E-04 24 0.2000000 1.0198040 1.019803903 9.73E-08 25 0.2500000 1.0305840 1.030776406 1.92E-04 26 0.3000000 1.0436600 1.044030651 3.71E-04 27 0.3500000 1.0589710 1.059481005 5.10E-04 28 0.4000000 1.0764470 1.077032961 5.86E-04 29 0.4500000 1.0960050 1.09658561 5.81E-04 30 0.5000000 1.1175530 1.118033989 4.81E-04 31 0.5500000 1.1409860 1.141271221 2.85E-04 32 0.6000000 1.1661900 1.166190379 3.79E-07 33 0.6500000 1.1930400 1.192686044 3.54E-04 34 0.7000000 1.2213990 1.220655562 7.43E-04 35 0.7500000 1.2511190 1.25 1.12E-03 36 0.8000000 1.2820420 1.280624847 1.42E-03 37 0.8500000 1.3139990 1.312440475 1.56E-03 38 0.9000000 1.3468090 1.345362405 1.45E-03 39 0.9500000 1.3802810 1.379311422 9.70E-04 40 1.0000000 1.4142140 1.414213562 4.38E-07 WHEN n=10 display 41 column table WHEN n=15 display 41 column table MENU 1. Function A 2. Function B 3. Quit Enter your choice: 2 WHEN n=5 display 41 column table WHEN n=10 display 41 column table WHEN n=15 display 41 column table MENU 1. Function A 2. Function B 3. Quit Enter your choice: 3 Exit
Give like to anyone help me for this code. Thank you!
STATEMENT OF THE PROBLEM: Discussion Lagrange interpolation is usually used to find an unknown value of a function at a random value of the independent variable. For example, if a function is defined as y = f(x), where y is the dependent variable and x is the independent variable, and we are given a set of points of this function at Xi, i = 1,2,3,..., n. and we need to find the value of f(x;), where x; is not one of the values xi, then we can use Lagrange Interpolation to find y; = f(x;). Lagrange Interpolation Polynomials Pseudocode Start the program Read the number of points (n) Enter (x,y) of all points (n) Read x, i.e. Xp Calculate the value of the function at Xp, i.e. Yp = f(xp) Using Lagrange interpolation to find yp: Initialize yp = 0 For i = 1 ton Set p = 1 For j = 1 to n If i #j, then Calculate p = p xp-x) *1-*/ End if Next j Calculate yp = Yp + p X Yi Next i Display the value of yp Stop Lagrange Interpolation Problem Description: Use Lagrange interpolation to interpolate the following functions: (a) f(x) = V1 + x2 (b) f(x) 1 1+25x2 using a set of n+1 regularly spaced nodes computed by the following equation: 2(k-1) Xx = -1 + ik = 1,2,3,......., n + 1 n Test your generated polynomial with different orders, n= 5, 10, 20 and compute the interpolation polynomial P.(x) at 41 regularly spaced points. For each value of xx the Lagrange polynomial approximation is output together with the exact /true value from the math library, also output the absolute error. STATEMENT OF THE PROBLEM: Discussion Lagrange interpolation is usually used to find an unknown value of a function at a random value of the independent variable. For example, if a function is defined as y = f(x), where y is the dependent variable and x is the independent variable, and we are given a set of points of this function at Xi, i = 1,2,3,..., n. and we need to find the value of f(x;), where x; is not one of the values xi, then we can use Lagrange Interpolation to find y; = f(x;). Lagrange Interpolation Polynomials Pseudocode Start the program Read the number of points (n) Enter (x,y) of all points (n) Read x, i.e. Xp Calculate the value of the function at Xp, i.e. Yp = f(xp) Using Lagrange interpolation to find yp: Initialize yp = 0 For i = 1 ton Set p = 1 For j = 1 to n If i #j, then Calculate p = p xp-x) *1-*/ End if Next j Calculate yp = Yp + p X Yi Next i Display the value of yp Stop Lagrange Interpolation Problem Description: Use Lagrange interpolation to interpolate the following functions: (a) f(x) = V1 + x2 (b) f(x) 1 1+25x2 using a set of n+1 regularly spaced nodes computed by the following equation: 2(k-1) Xx = -1 + ik = 1,2,3,......., n + 1 n Test your generated polynomial with different orders, n= 5, 10, 20 and compute the interpolation polynomial P.(x) at 41 regularly spaced points. For each value of xx the Lagrange polynomial approximation is output together with the exact /true value from the math library, also output the absolute error
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
