Вы находитесь на странице: 1из 3

clc

syms x;
fprintf('METODO NEWTON-RAPHSON\n');
fprintf('PROBLEMA MINA(ESCALARE)n');
y =input('ingrese la función en términos de x: ' );
f = inline(y);
z = diff(y);
d = inline (z)
xi = input('ingrese el valor inicial de la raíz: ');
n = input('ingrese el número de la iteracion: ');
x1 = xi-f(xi)/d(xi);
ea = (x1-xi) / x1;
for i = 1: n;
xi = x1;
x1 = xi-f(xi)/d(xi)
ea = (x1-xi)/x1;
c=80-x1*180/pi;
b=x1*180/pi;
XL=4/sin(b)+5/sin(80-b);

end
if(c<0)
s=(b+100-(c))/3;
b=s+c;
c=80-b;
end
fprintf ('iteration es =% 0.10g, raíz es =% 0.10g y ea =% 0.10g \ n', i,
x1, ea)
fprintf ('el angulo es=% 0.10g\ n',c)
fprintf ('La longitud maxima es=% 0.10g\ n',XL)

METODO NEWTON-RAPHSON

PROBLEMA MINA(ESCALARE)ningrese la función en términos de x: -


4*(cos(x)/(sin(x))^2)+5*(cos(80-x)/(sin(80-x))^2)

d=

Inline function:
d(x) = 4.0./sin(x)-cos(x-8.0e1).^2.*1.0./sin(x-8.0e1).^3.*1.0e1-5.0./sin(x-
8.0e1)+cos(x).^2.*1.0./sin(x).^3.*8.0

ingrese el valor inicial de la raíz: 0.01

ingrese el número de la iteracion: 30

x1 = 0.0225

x1 = 0.0338

x1 = 0.0506

x1 = 0.0759

x1 = 0.1139

x1 =0.1711

x1 = 0.2574

x1 =0.3911

x1=0.6200

x1=1.5748

x1 =1.6320

x1 =1.7171

x1 = 1.8422

x1 = 2.0170

x1 =2.2189

x1=2.3319

x1 =2.3392

x1 = 2.3392

x1 =2.3392

x1 = 2.3392

x1 = 2.3392

x1 = 2.3392

x1 =2.3392
x1 = 2.3392

x1 = 2.3392

x1 =2.3392

x1 = 2.3392

x1 =2.3392

x1 =2.3392

x1 =2.3392

Warning: Control Character '\ ' is not valid. See 'doc sprintf' for control characters valid in the
format string.

> In INTERIOR_MINA2 (line 27)

iteration es = 30, raíz es = 2.3392 y ea = 0 Warning: Control Character '\ ' is not valid. See 'doc
sprintf' for control characters valid in the format string.

> In INTERIOR_MINA2 (line 28)

el angulo es= 38.0092667Warning: Control Character '\ ' is not valid. See 'doc sprintf' for control
characters valid in the format string.

> In INTERIOR_MINA2 (line 29)

La longitud maxima es= 13.18013418>>

Вам также может понравиться