Professional Documents
Culture Documents
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%
%% main routine %%
%% %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end
%% Repeat the algorithm on the new interval
end
end
Result
>> newtonsimple
Iteration 1: x=10.83513513513513600000, err=-10.77275753513513700000
Iteration 2: x=7.33879377574983940000, err=-7.27641617574983980000
Iteration 3: x=5.00793477984931100000, err=-4.94555717984931140000
Iteration 4: x=3.45146490648721600000, err=-3.38908730648721600000
Iteration 5: x=2.40400695923320210000, err=-2.34162935923320200000
Iteration 6: x=1.67660874589255270000, err=-1.61423114589255270000
Iteration 7: x=1.10533828992829090000, err=-1.04296068992829080000
Iteration 8: x=0.32940872028529722000, err=-0.26703112028529724000
Iteration 9: x=3.11149659193232740000, err=-3.04911899193232740000
Iteration 10: x=2.17192159622983730000, err=-2.10954399622983720000
Iteration 11: x=1.50631040051809780000, err=-1.44393280051809780000
Iteration 12: x=0.93998512138526191000, err=-0.87760752138526188000
Iteration 13: x=-0.28865923806673521000, err=0.35103683806673519000
Iteration 14: x=-1.36763098822032720000, err=1.43000858822032730000
Iteration 15: x=-0.95686610424185692000, err=1.01924370424185700000
Iteration 16: x=-0.78699363803054223000, err=0.84937123803054226000
Iteration 17: x=-0.75587808748570084000, err=0.81825568748570088000
Iteration 18: x=-0.75487867975500456000, err=0.81725627975500459000
Iteration 19: x=-0.75487766624773434000, err=0.81725526624773437000
Iteration 20: x=-0.75487766624669272000, err=0.81725526624669276000
Iteration 21: x=-0.75487766624669272000, err=0.81725526624669276000
>> ....
Scaled Partial Pivoting
Code
% Gaussian elimination with scaled partial pivoting.
clear;
format short;
n = 7;
A = [ 13, 72, 57, 94, 90, 92, 35;
40, 93, 90, 99, 1, 95, 66;
48, 91, 71, 48, 93, 32, 67;
7, 93, 29, 2, 24, 24, 7;
41, 84, 44, 40, 82, 27, 49;
3, 72, 6, 33, 97, 34, 4;
43, 82, 66, 43, 83, 29, 61 ];
b = [ 453; 484; 450; 186; 367; 249; 407 ];
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
>> ....
Newtons Divided Difference
Write the newtons divided difference method in Matlab as follows:
function TDD = divdiff(X, Y)
%
% TDD = divdiff(X, Y)
%
% DIVDIFF
% Newton's Method for Divided Differences.
%
% The following formula is solved:
% Pn(x) = f(x0) + f[x0,x1](x-x0) + f[x0,x1,x2](x-x0)(x-x1) + ...
% + f[x0,x1,..,xn](x-x0)(x-x1)..(x-x[n-1])
% where f[x0,x1] = (f(x1-f(x0))/(x1-x0)
% f[x0,x1,..,xn] = (f[x1,..,xn]-f[x0,..,x_[n-1]])/(xn-x0)
%
% NOTE: f^(n+1)(csi)/(n+1)! aprox. = f[x0,x1,..,xn,x_[n+1]]
%
% Input::
% X = [ x0 x1 .. xn ] - object vector
% Y = [ y0 y1 .. yn ] - image vector
%
% Output:
% TDD - table of divided differences
%
% Example:
% TDD = divdiff( [ 1.35 1.37 1.40 1.45 ], [ .1303 .1367 .1461 .1614 ])
%
%
%
if nargin ~= 2
error('divdiff: invalid input parameters');
end
end
Step 2: Call the function using the appropriate data points
TDD = divdiff( [ 1.35 1.40 1.45 1.50 1.55 1.57 1.62 1.67 1.72 ], [ .1303 .
1367 .1461 .1614 .1686 .1692 .1699 .1932 .2122])
Result
>>mc3
>>TDD =
1.0e+05 *
Hermite Polynomial