%martinez Jonathan-Lopez Edison

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

%MARTINEZ JONATHAN-LOPEZ EDISON

clear, clc, clf


syms x

f= x^3-13*x-12
r= vpa(solve(f)) %SOLUCION ANALITICA
fplot(char(f),[-5 5])%SOLUCION GRAFICA
hold on

% SOLUCION NUMERICA
n=5
xn(1)=4.5
xn(2)=5.5
xn(3)=5

for i=1:n
%d(i)=vpa(subs(f,x,xn(i)))
h1=vpa(xn(i+1)-xn(i))
h2=vpa(xn(i+2)-xn(i+1))
de1=vpa(subs(f,x,xn(i+1))-subs(f,x,xn(i)))/(xn(i+1)-xn(i)) %DELTA1
de2=vpa(subs(f,x,xn(i+2))-subs(f,x,xn(i+1)))/(xn(i+2)-xn(i+1)) %DELTA2
a=vpa(de2-de1)/(h2+h1) %COEFICIENTES
b=vpa(a*h2+de2)
c=vpa(subs(f,x,xn(i+2)))

rad=vpa(sqrt(b^2-4*a*c))

if b>0
b+sqrt(b^2-4*a*c)
xn(i+3)=(xn(i+2))+(-2*c)/(b+rad)
elseif b<0
b-sqrt(b^2-4*a*c)
xn(i+3)=(xn(i+2))+(-2*c)/(b-rad)
else
break
end

end

f =

x^3 - 13*x - 12

r =

4.0
-1.0
-3.0

1
n =

xn =

4.5000

xn =

4.5000 5.5000

xn =

4.5000 5.5000 5.0000

h1 =

1.0

h2 =

-0.5

de1 =

62.25

de2 =

69.75

a =

15.0

b =

62.25

c =

48.0

2
rad =

31.544611267219635845147467800233

ans =

93.794611267219635845147467800233

xn =

4.5000 5.5000 5.0000 3.9765

h1 =

-0.5

h2 =

-1.0235129577593453653605592990061

de1 =

69.75

de2 =

47.694884408311103009737078737402

a =

14.476487042240654634639440700994

b =

32.878012337742533336793877825301

c =

-0.81633221074058184428623488798032

rad =

3
33.589197459370014601023479579739

ans =

66.46720979711254793781735740504

xn =

4.5000 5.5000 5.0000 3.9765 4.0011

h1 =

-1.0235129577593453653605592990061

h2 =

0.024563456574524078490640022209845

de1 =

47.694884408311103009737078737402

de2 =

34.730979755066086085102928858243

a =

12.977537541055833347769521424198

b =

35.049752934900067037936987303909

c =

0.03678070226365887721382077600796

rad =

35.022505464627794695012191259139

ans =

4
70.072258399527861732949178563048

xn =

4.5000 5.5000 5.0000 3.9765 4.0011 4.0000

h1 =

0.024563456574524078490640022209845

h2 =

-0.0010497935446567296935427293647081

de1 =

34.730979755066086085102928858243

de2 =

35.012615553317552304912763810301

a =

11.977538246326355331206059418037

b =

35.000041610985679810347107479952

c =

0.00002468447423829873978140122397263

rad =

35.000024716188300745232730368106

ans =

70.000066327173980555579837848059

5
xn =

4.5000 5.5000 5.0000 3.9765 4.0011 4.0000 4.0000

h1 =

-0.0010497935446567296935427293647081

h2 =

-0.00000070527002460352150592370890080929

de1 =

35.012615553317552304912763810301

de2 =

35.000008463252729767078807196356

a =

12.001051204086198076481650787173

b =

34.999999999271051793084496369746

c =

0.000000000017408297026125423195201072390335

rad =

34.999999999259113629427875828452

ans =

69.999999998530165422512372198198

xn =

Columns 1 through 7

6
4.5000 5.5000 5.0000 3.9765 4.0011 4.0000 4.0000

Column 8

4.0000

Published with MATLAB® R2014a

You might also like