Vous êtes sur la page 1sur 14

 EJEMPLO 1

>> x=-5:0.1:0;

>> f=inline(' sin(x)-0.5*exp(x)')

f=

Inline function:

f(x) = sin(x)-0.5*exp(x)

>> plot(x,f(x)); grid minor

>> r(1)=-4;

>> syms x

>> r(2)=r(1)-f(r(1))/subs(diff(f(x)),R(1))

Undefined function 'R' for input arguments of type 'double'.

Did you mean:

>> r(2)=r(1)-f(r(1))/subs(diff(f(x)),r(1))

r=

-4.0000 -2.8720

>> r(3)=r(2)-f(r(2))/subs(diff(f(x)),r(2))

r=

-4.0000 -2.8720 -3.1690

>> e(1==inf
e(1==inf

Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.

>> e(1)=inf

e=

Inf

>> e(2)=abs(r(2)-r(1))

e=

Inf 1.1280

>> e(3)=abs(r(3)-r(2))

e=

Inf 1.1280 0.2970

>> r(4)=r(3)-f(r(3))/subs(diff(f(x)),r(3))

r=

-4.0000 -2.8720 -3.1690 -3.1627

>> e(4)=abs(r(4)-r(3))
e=

Inf 1.1280 0.2970 0.0062

>> r(5)=r(4)-f(r(4))/subs(diff(f(x)),r(4))

r=

-4.0000 -2.8720 -3.1690 -3.1627 -3.1627

>> e(5)=abs(r(5)-r(4))

e=

Inf 1.1280 0.2970 0.0062 0.0000

 EJEMPLO 2

>> clear

>> x=0:0.1:50;

>> clear all

>> x=0:0.1:50;

>> f=inline('-x+1.14-2*log10((0.0025/0.1)+9.35*x/3e4)')

f=

Inline function:

f(x) = -x+1.14-2*log10((0.0025/0.1)+9.35*x/3e4)
>> plot(x,f(x));grid minor

>> format long

>> r(1)=5

r=

>> syms x

>> r(2)=r(1)-f(r(1))/subs (diff(f(x)),r(1))

r=

5.000000000000000 4.298746274352372

>> e(1)=inf

e=

Inf

>> e(2)=abs(r(2)-r(1))

e=

Inf 0.701253725647628

>> r(3)=r(2)-f(r(2))/subs (diff(f(x)),r(2))


r=

5.000000000000000 4.298746274352372 4.298775547125420

>> e(3)=abs(r(3)-r(2))

e=

Inf 0.701253725647628 0.000029272773047

>> r(4)=r(3)-f(r(3))/subs (diff(f(x)),r(3))

r=

5.000000000000000 4.298746274352372 4.298775547125420 4.298775547125471

>> e(4)=abs(r(4)-r(3))

e=

Inf 0.701253725647628 0.000029272773047 0.000000000000052

>> f=(1/r(4))^2

f=

0.054114102559008
 METODO PUNTO FIJO

>> x=-2:0.1:2;

>> f=inline('x.^2-3*x+exp(x)-2')

f=

Inline function:

f(x) = x.^2-3*x+exp(x)-2

>> plot(x,f(x)); grid MINOR

>> g=inline('x')

g=

Inline function:

g(x) = x

>> hold on

>> plot(x,g(x),'r')

>> h=inline('(x.^2+exp(x)-2)/3')

h=

Inline function:

h(x) = (x.^2+exp(x)-2)/3

>> plot(x,h(x),'m')

>> 0
ans =

>> x(1)=1

x=

Columns 1 through 4

1.000000000000000 -1.900000000000000 -1.800000000000000 -1.700000000000000

Columns 5 through 8

-1.600000000000000 -1.500000000000000 -1.400000000000000 -1.300000000000000

Columns 9 through 12

-1.200000000000000 -1.100000000000000 -1.000000000000000 -0.900000000000000

Columns 13 through 16

-0.800000000000000 -0.700000000000000 -0.600000000000000 -0.500000000000000

Columns 17 through 20

-0.400000000000000 -0.300000000000000 -0.200000000000000 -0.100000000000000


Columns 21 through 24

0 0.100000000000000 0.200000000000000 0.300000000000000

Columns 25 through 28

0.400000000000000 0.500000000000000 0.600000000000000 0.700000000000000

Columns 29 through 32

0.800000000000000 0.900000000000000 1.000000000000000 1.100000000000000

Columns 33 through 36

1.200000000000000 1.300000000000000 1.400000000000000 1.500000000000000

Columns 37 through 40

1.600000000000000 1.700000000000000 1.800000000000000 1.900000000000000

Column 41

2.000000000000000

>> h(x(1))

ans =

0.572760609486349
>> x(2)=h(x(1))

x=

Columns 1 through 4

1.000000000000000 0.572760609486349 -1.800000000000000 -1.700000000000000

Columns 5 through 8

-1.600000000000000 -1.500000000000000 -1.400000000000000 -1.300000000000000

Columns 9 through 12

-1.200000000000000 -1.100000000000000 -1.000000000000000 -0.900000000000000

Columns 13 through 16

-0.800000000000000 -0.700000000000000 -0.600000000000000 -0.500000000000000

Columns 17 through 20

-0.400000000000000 -0.300000000000000 -0.200000000000000 -0.100000000000000

Columns 21 through 24

0 0.100000000000000 0.200000000000000 0.300000000000000


Columns 25 through 28

0.400000000000000 0.500000000000000 0.600000000000000 0.700000000000000

Columns 29 through 32

0.800000000000000 0.900000000000000 1.000000000000000 1.100000000000000

Columns 33 through 36

1.200000000000000 1.300000000000000 1.400000000000000 1.500000000000000

Columns 37 through 40

1.600000000000000 1.700000000000000 1.800000000000000 1.900000000000000

Column 41

2.000000000000000

>> h(x(2))

ans =

0.033736668721494

>> x(3)=h(x(x(2)));

Subscript indices must either be real positive integers or logicals.


>> x(3)=h(x(2));

>> h(x(3))

ans =

-0.321516544358344

>> x(4)=h(x(3));

>> h(x(4))

ans =

-0.390526159080027

>> e(1)=inf

e=

Inf

>> e(2)=abs(x(2)-x(1))

e=

Inf 0.427239390513651

>> e(3)=abs(x(3)-x(2))

e=
Inf 0.427239390513651 0.539023940764855

>> e(4)=abs(x(4)-x(3))

e=

Inf 0.427239390513651 0.539023940764855 0.355253213079838

>> x(5)=h(x(4));

>> h(x(5))

ans =

-0.390262863498443

>> e(5)=abs(x(5)-x(4))

e=

Columns 1 through 4

Inf 0.427239390513651 0.539023940764855 0.355253213079838

Column 5

0.069009614721683

>> h(x(6))
ans =

0.157710053382810

>> x(6)=h(x(5));

>> e(6)=abs(x(6)-x(5))

e=

Columns 1 through 4

Inf 0.427239390513651 0.539023940764855 0.355253213079838

Columns 5 through 6

0.069009614721683 0.000263295581585

>> h(x(6))

ans =

-0.390271991008394

>> e(7)=abs(x(7)-x(6))

e=

Columns 1 through 4
Inf 0.427239390513651 0.539023940764855 0.355253213079838

Columns 5 through 7

0.069009614721683 0.000263295581585 1.009737136501557

>> x(7)=h(x(6));

>> h(x(7))

ans =

-0.390271675625484

>> e(7)=abs(x(7)-x(6))

e=

Columns 1 through 4

Inf 0.427239390513651 0.539023940764855 0.355253213079838

Columns 5 through 7

0.069009614721683 0.000263295581585 0.000009127509952

>>

Vous aimerez peut-être aussi