Ema 523641
Ema 523641
Ema 523641
Spring 2003.
UCI.
Student Name: Nasser Abbasi
Assignment #1.
Problems
Solutions
REPEAT
Set x2= x1 – f(x1)*(x0-x1)/( f(x0) – f(x1) )
IF f(x2) of opposite sign to f(x0)
Set x1=x2
ELSE
Set x0=x2
END IF
UNTIL | f(x2) | < tolerance
ans =
[ .579326592861950261
846454370632]
[ 1.07726983544428433169938136893-
.860621514282949848638960605085*i]
[
1.07726983544428433169938136893+.8606215142829498486389
60605085*i]
[ 5.55614379120166361430046836883-
2.33378449456931739881421919764*i]
[
5.55614379120166361430046836883+2.333784494569317398814
21919764*i]
.170179993753835176860864670115239502017737590738214599
312052
N X0 X1 F(x0) F(x1) X2
0 0.5 0.4 1.0355040 0.827244 0.002782
1 0.4 0.002782 0.8272444 - 0.218237
0.9805797
2 0.002782 0.218237 0.2184109 - 0.178990
0.9805801
3 0.218237 0.178989 0.2184127 0.0420032 0.169644
ezplot('x^2-y-5*x*y');
hold on;
ezplot('y+x^2-x-0.5')
h=findobj(gca,'type','line');
set(h(1),'LineStyle','--')
Zoom in:
let me also find the exact solutions using matlab to
make sure my worked out answers are correct:
>> SOL=solve('x^2-y-5*x*y','y+x^2-x-0.5')
SOL =
x: [3x1 sym]
y: [3x1 sym]
>> SOL.x
ans =
[ -.45518959344844446505992693519646]
[ -.17812819955522914530391522665854]
[ 1.2333177930036736103638421618550]
>> SOL.y
ans =
[ -.16238715943220462132849109792298]
[ .29014214496798331801721391559981]
[ .21224501446422130331127718232317]
Now, using fixed point iteration to solve
X y x=G(x,y) Y=F(x,y)
1 1 1.5 -4
1.5 -4 -2.25 32.25
-2.25 32.25 36.8125 367.875
X y y=G(x,y) X=F(y,x)
1 1 0.5 0
0 0.5 0.5 -0.2
-.2 .5 .34 -.216
-.216 .34 .330656 -.1533
-.1533 .330656 .3702 -.1765
-.1765 .3702 .29235 -.1688
-.1688 .29235 .30271 -.17151
-.17151 .30271 .299 -.1705