Problem 17.9.
Employ inverse interpolation to determine the value of x that corresponds to f(x) = 0.93 for the following tabulated data:
Note that the values in the table were generated with the function f(x) = x2/(1+x2).
(a) Determine the correct value analytically.
(b) Use quadratic interpolation and the quadratic formula to determine the value numerically.
(c) Use cubic interpolation and bisection to determine the value numerically.
Solution:
(a) Using the function available, manipulate it to determine corresponding x value:
(b) A quadratic interpolating polynomial can be fit to the last three points: (3, 0.9), (4, 0.941176), and (5, 0.961538) using polyfit function:
>> format long
>> x = [3 4 5];
>> fx = [0.9 0.941176 0.961538];
>> a = polyfit(x,fx,2)
a =
-0.010407000000000 0.114024999999999 0.651588000000002
Thus, the best-fit parabola that passes through the last three points is f2(x) = -0.010407x2 + 0.114025x + 0.651588.
We must therefore find the root of
0.93 = -0.010407x2 + 0.114025x + 0.651588
or
0 = -0.010407x2 + 0.114025x - 0.278412
The quadratic formula can be used to calculate:
Thus, the second root, 3.67295, is a good estimate of the true value.
(c) A cubic interpolating polynomial can be fit to the last four points: (2, 0.8), (3, 0.9), (4, 0.941176), and (5, 0.961538) using polyfit function:
>> format long
>> x = [2 3 4 5];
>> fx = [0.8 0.9 0.941176 0.961538];
>> a = polyfit(x,fx,3)
a =
0.006335000000000 -0.086427000000002 0.411770000000007 0.271487999999994
Thus, the best-fit cubic that passes through the last four points is f3(x) = 0.006335x3 - 0.086427x2 + 0.41177x + 0.271488.
We must therefore find the root of
0.93 = 0.006335x3 - 0.086427x2 + 0.41177x + 0.271488
or
0 = 0.006335x3 - 0.086427x2 + 0.41177x - 0.658512
Bisection method (bisect.m) can be employed to find the root of this polynomial. Using initial guesses of xl = 3 and xu = 4 (that bracket the root), a value of 3.61884 is obtained.
>> fx = @(x) 0.006335*x^3 - 0.086427*x^2 + 0.41177*x - 0.658512;
>> [root,fx,ea,iter]=bisect(fx,3,4)
root =
3.618841171264648
fx =
1.082876788238707e-08
ea =
5.270606093347705e-05
iter =
19
No comments:
Post a Comment