Solving Equation by Fixed Point Iteration Method (FPI)
Equation: e^(-x)+ x^3-x-2=0
(2)g(x)= -ln(-x^3+x+2)
- First root: -0.48756103475
- Number of steps: 15
- x_0= -0.5
- S = abs(-(1-3(r^2))/(-r^3+r+2)) = 0.17616267
- Approximation rate: 0.176162171045838 Match with convergence rate above. However, it matches for up to 6 decimal places and only happen once.
FPI Code:
g = @(x) -log(- x^3 + x + 2);
numSteps = 15;
x = zeros(numSteps,1);
x(1) = -0.5;
for i=1:numSteps
x(i+1) = g(x(i));
end
r = x
Convergence Rate Code:
g = @(x) -log(- x^3 + x + 2);
numSteps = 15;
x = zeros(numSteps,1);
x(1) = -0.5;
for i=1:numSteps
x(i+1) = g(x(i));
end
r = x(numSteps + 1); %best guess at root
e = abs(x-r); % array of errors
ratios = zeros(numSteps + 1,1);
for i=1:numSteps
ratios(i) = e(i+1)/e(i);
end
ratios(numSteps+1) = 0;
ratios
Matlab Session:
>> format long
>> FPI_P2
root =
-0.500000000000000
-0.485507815781701
-0.487926450041332
-0.487496780131671
-0.487572357666484
-0.487559040194681
-0.487561386126457
-0.487560972857440
-0.487561045659910
-0.487561032834829
-0.487561035094129
-0.487561034696125
-0.487561034766238
-0.487561034753887
-0.487561034756063
-0.487561034755679
>> fpi_error
ratios =
0.165063486684809
0.177971901820501
0.175840000490639
0.176219392449621
0.176152672450803
0.176164468417342
0.176162171045838
0.176163818967924
0.176156465201077
0.176197828573612
0.175963200069280
0.177297309389453
0.169757954282590
0.213874264478167
0
0
Second root: -4.451620296
- Number of steps: 40
- x_0= -4.45
- S = abs(-(1-3(r^2))/(-r^3+r+2)) = 0.68151607
- Approximation rate: 0.681515541009002 Match with convergence rate above. However, it matches for up to 5 decimal places and happens a couple of times.
FPI Code:
g = @(x) -log(- x^3 + x + 2);
numSteps = 15;
x = zeros(numSteps,1);
x(1) = -0.5;
for i=1:numSteps
x(i+1) = g(x(i));
end
r = x
Convergence Rate Code:
g = @(x) -log(- x^3 + x + 2);
numSteps = 15;
x = zeros(numSteps,1);
x(1) = -0.5;
for i=1:numSteps
x(i+1) = g(x(i));
end
r = x(numSteps + 1); %best guess at root
e = abs(x-r); % array of errors
ratios = zeros(numSteps + 1,1);
for i=1:numSteps
ratios(i) = e(i+1)/e(i);
end
ratios(numSteps+1) = 0;
ratios
Matlab Session:
>> format long
>> FPI_P2
r =
-4.450000000000000
-4.450515837674487
-4.450867496924248
-4.451107208342674
-4.451270598750689
-4.451381962728406
-4.451457864080729
-4.451509594400246
-4.451544850525814
-4.451568878644365
-4.451585254426693
-4.451596414893949
-4.451604020982121
-4.451609204676858
-4.451612737459011
-4.451615145111884
-4.451616785968364
-4.451617904239521
-4.451618666359797
-4.451619185757252
-4.451619539735076
-4.451619780976705
-4.451619945386776
-4.451620057434893
-4.451620133797492
-4.451620185839833
-4.451620221307526
-4.451620245479329
-4.451620261952803
-4.451620273179739
-4.451620280831078
-4.451620286045587
-4.451620289599360
-4.451620292021312
-4.451620293671912
-4.451620294796823
-4.451620295563467
-4.451620296085948
-4.451620296442027
-4.451620296684700
-4.451620296850086
>> fpi_error
ratios =
0.681640018950950
0.681600499565625
0.681573536077006
0.681555120306377
0.681542513645649
0.681533840860771
0.681527811649525
0.681523528889349
0.681520355261449
0.681517818485699
0.681515541009002
0.681513183925514
0.681510396343762
0.681506763332523
0.681501744151592
0.681494591611086
0.681484240733670
0.681469150291914
0.681447072413142
0.681414717841083
0.681367262133698
0.681297625967863
0.681195407146443
0.681045308385230
0.680824818921794
0.680500746829058
0.680024038085926
0.679321965208885
0.678286225840684
0.676754279600852
0.674479867818450
0.671084007739061
0.665971057838265
0.658174162490739
0.646051232063440
0.626621431466552
0.593911793699313
0.534012597301309
0.405298693609964
0
0
(3)g(x)= √(3&〖-e〗^(-x)+x+2)
- Third root: -1.80657027
- Number of steps: 55
- x_0= -2
- S = abs((1+e^(-x))/(3(e^(-x)+x+2)^(2/3))) = 0.72407947
- Approximation rate: 0.724079440171620 Match with convergence rate above. However, it matches for up to 7 decimal places and only happen once.
FPI Code:
g = @(x) nthroot(x+2-exp(-x),3);
numSteps = 55;
x = zeros(numSteps,1);
x(1) = -2;
for i=1:numSteps
x(i+1) = g(x(i));
end
r = x
Convergence Rate Code:
g = @(x) nthroot(x+2-exp(-x),3);
numSteps = 15;
x = zeros(numSteps,1);
x(1) = -0.5;
for i=1:numSteps
x(i+1) = g(x(i));
end
r = x(numSteps + 1); %best guess at root
e = abs(x-r); % array of errors
ratios = zeros(numSteps + 1,1);
for i=1:numSteps
ratios(i) = e(i+1)/e(i);
end
ratios(numSteps+1) = 0;
ratios
Matlab Session:
>> format long
>> FPI_P2
r =
-2.000000000000000
-1.947734041054676
-1.909327443839455
-1.881244454642133
-1.860775674961654
-1.845887833520614
-1.835074295841679
-1.827227423000708
-1.821536970924202
-1.817412161733315
-1.814423162445708
-1.812257691450433
-1.810689095220473
-1.809552982074631
-1.808730176289082
-1.808134310875333
-1.807702810594613
-1.807390345829074
-1.807164083796965
-1.807000245446301
-1.806881609971286
-1.806795706630932
-1.806733504827357
-1.806688465275962
-1.806655852798046
-1.806632238634203
-1.806615140030535
-1.806602759244666
-1.806593794551870
-1.806587303391407
-1.806582603269892
-1.806579200005515
-1.806576735770135
-1.806574951467092
-1.806573659489471
-1.806572723994780
-1.806572046622163
-1.806571556150495
-1.806571201009998
-1.806570943860037
-1.806570757663020
-1.806570622841577
-1.806570525220136
-1.806570454534453
-1.806570403352400
-1.806570366292526
-1.806570339458232
-1.806570320028070
-1.806570305959089
-1.806570295772028
-1.806570288395786
-1.806570283054801
-1.806570279187504
-1.806570276387273
-1.806570274359683
-1.806570272891547
>> fpi_error
ratios =
0.729793554865435
0.727928789979321
0.726705309826425
0.725892146380041
0.725343953324356
0.724969262947089
0.724709987263902
0.724528696047858
0.724400854357602
0.724310096586489
0.724245326469991
0.724198911383240
0.724165536866324
0.724141465009127
0.724124044423006
0.724111380162923
0.724102107423232
0.724095233783219
0.724090027365721
0.724085935942462
0.724082526803060
0.724079440171620
0.724076350802992
0.724072933482670
0.724068828664892
0.724063604572003
0.724056711706485
0.724047424982366
0.724034767347444
0.724017406776880
0.723993515712993
0.723960578024288
0.723915122495205
0.723852354567014
0.723765645506867
0.723645822787801
0.723480181829357
0.723251103629130
0.722934113925429
0.722495139807702
0.721886600108629
0.721041769035122
0.719866531306552
0.718227075687898
0.715931075395360
0.712697932682268
0.708109817757045
0.701526959444763
0.691931717342620
0.677618592545310
0.655514539615575
0.619482352538149
0.555233482074148
0.419980372665284
0
0
- Fourth root 1.481974814587466
- Number of steps: 25
- x_0=1.5
- S = abs((1+e^(-x))/(3(e^(-x)+x+2)^(2/3))) = 0.1862552
- Approximation rate: 0.186255194701434, match with convergence rate above. However, it matches for up to 6 decimal places and only happen once.
FPI Code:
g = @(x) nthroot(x+2-exp(-x),3);
numSteps = 25;
x = zeros(numSteps,1);
x(1) = 1.5;
for i=1:numSteps
x(i+1) = g(x(i));
end
r = x
Convergence Rate Code:
g = @(x) nthroot(x+2-exp(-x),3);
numSteps = 25;
x = zeros(numSteps,1);
x(1) = 1.5;
for i=1:numSteps
x(i+1) = g(x(i));
end
r = x(numSteps + 1); %best guess at root
e = abs(x-r); % array of errors
ratios = zeros(numSteps + 1,1);
for i=1:numSteps
ratios(i) = e(i+1)/e(i);
end
ratios(numSteps+1) = 0;
ratios
Matlab Session:
>> format long
>> FPI_P2
r =
1.500000000000000
1.485318979020808
1.482597228565602
1.482090726683878
1.481996403272099
1.481978835573305
1.481975563516332
1.481974954079339
1.481974840568552
1.481974819426578
1.481974815488775
1.481974814755339
1.481974814618733
1.481974814593289
1.481974814588550
1.481974814587667
1.481974814587503
1.481974814587472
1.481974814587467
1.481974814587466
1.481974814587466
1.481974814587466
1.481974814587466
1.481974814587466
1.481974814587466
1.481974814587466
>> fpi_error
ratios =
0.185527325062480
0.186119429993050
0.186229905631342
0.186250488965471
0.186254322950300
0.186255037025190
0.186255170055531
0.186255194075115
0.186255194701434
0.186255174955528
0.186255062035339
0.186254604614866
0.186251464687711
0.186220307316887
0.186117936117936
0.185918591859186
0.183431952662722
0.161290322580645
0.200000000000000
0
NaN
NaN
NaN
NaN
NaN
0
Conclusion:
- I found 4 roots of the given equation by the following: {-0.48756103475, -4.451620296, -1.80657027, 1.481974814587466}
- I derive the original equation into 3 different form of x = g(x). However, I only use 2 of them since I tried to work with the other one but it doesn’t work (not working MATLAB session is not included)
(1) x= e^(-x)+x^3-2 - Not used, derive from isolating x
(2) x=-ln(-x^3+x+2) - Used, derive from isolation x^3 and solve for x
(3) x= ∛(-e^(-x)+x+2 ) - Used, derive from isolation x^3 and solve for x
- First root took the least steps (15 steps) while third root took the most steps (55 steps).
- I am satisfied about the comparison between convergence rate calculated by using g prime verse generated by MATLAB’s code.
- Final conclusion: the closer your initial x to the actual root, the higher chance your “guess” root will match the actual root of given equation.