Write a program that implements the Lagrange interpolationscheme directly. Test
ID: 3613699 • Letter: W
Question
Write a program that implements the Lagrange interpolationscheme directly. Test it by evaluating f(0.3) and f(0.5) from thegiven data taken from the error function with f(0)=0,f(0.4)=0.428392,f(0.8)=0.742101, f(1.2)=0.910314, and f(1.6)=0.970348. Examine theaccuracy of the interpolation by comparing the results obtainedfrom the interpolation with the exact values f(0.3)=0.328627and f(0.5)=0.520500 please use the fortran 77/90 to write this program and I willrate as lifesaver! Write a program that implements the Lagrange interpolationscheme directly. Test it by evaluating f(0.3) and f(0.5) from thegiven data taken from the error function with f(0)=0,f(0.4)=0.428392,
f(0.8)=0.742101, f(1.2)=0.910314, and f(1.6)=0.970348. Examine theaccuracy of the interpolation by comparing the results obtainedfrom the interpolation with the exact values f(0.3)=0.328627and f(0.5)=0.520500 please use the fortran 77/90 to write this program and I willrate as lifesaver!
Explanation / Answer
please rate, thanks.. // Program for Exercise 2.2. An direct implementation of theLagrange // interpolation scheme on the data given. import java.lang.*; public class Ex2_2 { public static void main(String argv[]) { double xi[] = {0, 0.4, 0.8, 1.2, 1.6}; double fi[] = {0, 0.428392, 0.742101, 0.910314,0.970348}; double x = 0.3; double f = lagrange(x, xi, fi); double df = Math.abs(f-0.328627); System.out.println("f(0.3) = " + f + "+-" +df); x = 0.5; f = lagrange(x, xi, fi); df = Math.abs(f-0.520500); System.out.println("f(0.5) = " + f + "+-" +df); } // Method to carry out the Lagrange interpolation directly. public static double lagrange(double x, double xi[], double fi[]) { int n = xi.length-1; double p[] = new double[n+1]; double f = 0; for (int j=0; jRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.