0% found this document useful (0 votes)
7 views47 pages

Tarea 2

Uploaded by

rj0826457
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views47 pages

Tarea 2

Uploaded by

rj0826457
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

4

a) x3 − 2x2 − 5 = 0, [1,4
Comandos de grafica.

% Demo: Ecuacion no lineal


clc
disp('Demo: Solucion de una ecuacion no lineal')
disp('========================================')
x = 1:0.1:4;
y = x .^ 3 - 2 * x .^ 2 - 5;
plot(x,y)
Grafico.

b) x3 + 3x2 − 1 = 0, [−3,−2]
Comandos de grafica.
% Demo: Ecuacion no lineal
clc
disp('Demo: Solucion de una ecuacion no lineal')
disp('========================================')
x = -3:0.1:-2;
y = x.^3+3*x.^2-1;
plot(x,y)
Grafica.

c) x − 0.8 − 0.2sinx = 0, [0,π/2]


Comandos de grafica.
% Demo: Ecuacion no lineal
clc
disp('Demo: Solucion de una ecuacion no lineal')
disp('========================================')
x = 0:0.1:pi/2;
y = x - 0.8 -0.2*sin(x);
plot(x,y)

Grafica.
2. By hand. Use Newton’s method to find solutions accurate to within 10−4 for the
following problems
a) ex + 2−x + 2cosx − 6 = 0, [1,2]
Comandos de grafica.

% Demo: Ecuacion no lineal


clc
disp('Demo: Solucion de una ecuacion no lineal')
disp('========================================')
x = 1:0.1:2;
y = exp(x)+ 2.^(-x)+2.*cos(x)-6;
plot(x,y)
Grafica.

b) 2xcos2x − (x − 2)2 = 0, [1.3,2]


Comandos de grafica.
% Demo: Ecuacion no lineal
clc
disp('Demo: Solucion de una ecuacion no lineal')
disp('========================================')
x = 1.3:0.1:2;
y = 2.*x.*cos(2*x)-(x-2).^2;
plot(x,y)

Grafica.

3. M-File. Find the zeros of the function

f(x) = −25182x − 90x2 + 44x3 − 8x4 + 0.7x5


Use Newton’s method to find zeros of the function.

% DEMO: Método de Newton


% Input:
% Fun : Función defina la ecuación
% Funder : derivada de la función ecuación
% x0 : estimación inicial de la solución
% em : error máximo permitido
% imax : número máximo de iteraciones permitidas
% Output:
% ms : solución aproximada
clc
disp ('Demo: Método de Newton')
disp ('======================')
% Input:
x0 = 12.9
er = 10^(-3)
imax = 10
Fun = @(x) -25182*x - 90*x.^2 + 44*x.^3 -8*x.^4 + 0.7*x^5
FunDer = @(x) -25182 - 180*x + 132*x.^3 -32*x.^3 + 3.5*x^4
% print
disp(' iter sol er ')
disp('=====================================')
% main
for i = 1:imax
x = x0 - (Fun(x0))/FunDer(x0);
e = abs((x - x0)/x0);
fprintf('% 3i %11.6f %11.6f\n', i, x, e)
if e < er
xs = x0;
break
end
x0 = x;
end
fprintf('\n\n raiz -----> %11.6f\n', xs)

RESUSLTADOS DE COMANDOS
Demo: Método de Newton
======================
x0 = 12.900
er = 1.0000e-03
imax = 10
Fun =

@(x) -25182 * x - 90 * x .^ 2 + 44 * x .^ 3 - 8 * x .^ 4 + 0.7 * x ^ 5

FunDer =

@(x) -25182 - 180 * x + 132 * x .^ 3 - 32 * x .^ 3 + 3.5 * x ^ 4


iter sol er
=====================================
1 13.663311 0.059171
2 14.218866 0.040660
3 14.640745 0.029670
4 14.968794 0.022407
5 15.227712 0.017297
6 15.434133 0.013556
7 15.599881 0.010739
8 15.733667 0.008576
9 15.842079 0.006890
10 15.930192 0.005562

raiz -----> 16.245312


4. By hand. Determine the root of f(x) = x − 2e−x by:

a) Using the bisection method. Start with a = 0 and b = 1, and carry out the
first three iterations.
b) Using the secant method. Start with the two points, x1 = 0 and x2 = 1, and
carry out the first three iterations.
c) Using Newton’s method. Star at x1 = 1 and carry out the first three
iterations.
5. By hand. The lateral surface area, S, of a cone is given by: where
r is the radius of the base and h is the height. Determine the radius of a cone
that has a surface area of 1800 m2 and a height of 25 m. Solve by using
Newton’s method with

as the iteration function with with a tolerance of ε = 10−5.


6. M-File. The speed v of a falling parachutist is given by

where g = 9.8m/s2. For a skydiver with drag coefficient c = 15kg/s, find the
mass m so that the speed is v = 35 m/s in t = 9 s. Use Newton’s method to
determine the mass m with a tolerance of ε = 10−5.
% DEMO: Método de Newton
% Input:
% Fun : Función defina la ecuación
% Funder : derivada de la función ecuación
% m0 : estimación inicial de la solución
% em : error máximo permitido
% imax : número máximo de iteraciones permitidas
% Output:
% ms : solución aproximada
clc
disp ('Demo: Método de Newton')
disp ('======================')
% Input:
m0 = 15
er = 10^(-5)
imax = 15
Fun = @(m) ((9.8.*m.*(1.-exp(-135./m)))-525)
FunDer = @(m) ((49*(1.-exp(-135./m)))/5)-((1323.*exp(-135./m))/m)
% print
disp(' iter sol er ')
disp('=====================================')
% main
for i = 1:imax
m = m0 - (Fun(m0))/FunDer(m0);
e = abs((m - m0)/m0);
fprintf('% 3i %11.6f %11.6f\n', i, m, e)
if e < er
ms = m0;
break
end
m0 = m;
end
fprintf('\n\n raiz -----> %11.6f\n', ms)

RESUSLTADOS DE COMANDOS
Demo: Método de Newton
======================
m0 = 15
er = 1.0000e-05
imax = 15
Fun =

@(m) ((9.8 .* m .* (1. - exp (-135 ./ m))) - 525)

FunDer =
@(m) ((49 * (1. - exp (-135 ./ m))) / 5) - ((1323 .* exp (-135 ./ m)) / m)

iter sol er
=====================================
1 53.620942 2.574729
2 59.588829 0.111298
3 59.840615 0.004225
4 59.841045 0.000007

raiz -----> 59.840615

Comandos de grafica.
% Demo: Ecuacion no lineal

clc
disp('Demo: Solucion de una ecuacion no lineal')

disp('========================================')

x = 10:0.1:15;

y = ((9.8.*x.*(1.-exp(-135./x)))-525);

plot(x,y)

Grafica.

7. M-File. Use the Newton-Raphson method to determine a real root of the


equation

0.5x3 − 4x2 + 5.5x − 1 = 0

with an initial condition of (a) 4.52 and (b) 4.54.


A)
% DEMO: Método de Newton
% Input:
% Fun : Función defina la ecuación
% Funder : derivada de la función ecuación
% x0 : estimación inicial de la solución
% er : error máximo permitido
% imax : número máximo de iteraciones permitidas
% Output:
% xs : solución aproximada
clc
disp ('Demo: Método de Newton')
disp ('======================')
% Input:
x0 = 4.52
er = 10^(-4)
imax = 10
Fun = @(x) 0.5*x.^3 - 4*x.^2 - 5.5*x - 1
FunDer = @(x) 1.5*x.^2 - 8*x - 5.5
% print
disp(' iter sol er ')
disp('=====================================')
% main
for i = 1:imax
x = x0 - Fun(x0)/FunDer(x0);
e = abs((x - x0)/x0);
fprintf('% 3i %11.6f %11.6f\n', i, x, e)
if e < er
xs = x0;
break
end
x0 = x;
end
fprintf('\n\n raiz -----> %11.6f\n', xs)

RESUSLTADOS DE COMANDOS
%Demo: Método de Newton
======================
x0 = 4.5200
er = 1.0000e-04
imax = 10
Fun =

@(x) 0.5 * x .^ 3 - 4 * x .^ 2 - 5.5 * x - 1

FunDer =

@(x) 1.5 * x .^ 2 - 8 * x - 5.5

iter sol er
=====================================
1 -1.055328 1.233480
2 -1.003686 0.048934
3 -1.000019 0.003654
4 -1.000000 0.000019
raiz -----> -1.000019

Comandos de grafica.

% Demo: Ecuacion no lineal


clc
disp('Demo: Solucion de una ecuacion no lineal')
disp('========================================')
x = 4:0.1:5;
y = 0.5*x.^3 - 4*x.^2 - 5.5*x - 1;
plot(x,y)
Grafica.

7.B)
% DEMO: Método de Newton
% Input:
% Fun : Función defina la ecuación
% Funder : derivada de la función ecuación
% x0 : estimación inicial de la solución
% er : error máximo permitido
% imax : número máximo de iteraciones permitidas
% Output:
% xs : solución aproximada
clc
disp ('Demo: Método de Newton')
disp ('======================')
% Input:
x0 = 4.54
er = 10^(-4)
imax = 10
Fun = @(x) 0.5*x.^3 - 4*x.^2 - 5.5*x - 1
FunDer = @(x) 1.5*x.^2 - 8*x - 5.5
% print
disp(' iter sol er ')
disp('=====================================')
% main
for i = 1:imax
x = x0 - Fun(x0)/FunDer(x0);
e = abs((x - x0)/x0);
fprintf('% 3i %11.6f %11.6f\n', i, x, e)
if e < er
xs = x0;
break
end
x0 = x;
end
fprintf('\n\n raiz -----> %11.6f\n', xs)

RESUSLTADOS DE COMANDOS
Demo: Método de Newton
======================
x0 = 4.5400
er = 1.0000e-04
imax = 10
Fun =
@(x) 0.5 * x .^ 3 - 4 * x .^ 2 - 5.5 * x - 1

FunDer =

@(x) 1.5 * x .^ 2 - 8 * x - 5.5

iter sol er
=====================================
1 -1.112603 1.245067
2 -1.013535 0.089041
3 -1.000243 0.013114
4 -1.000000 0.000243
5 -1.000000 0.000000

raiz -----> -1.000000


8. M-File. Solve the equation

using the method of (a) Newton-Raphson and (b) Secant.

(a) Newton-Raphson
% DEMO: Método de Newton
% Input:
% Fun : Función defina la ecuación
% Funder : derivada de la función ecuación
% x0 : estimación inicial de la solución
% em : error máximo permitido
% imax : número máximo de iteraciones permitidas
% Output:
% ms : solución aproximada
clc
disp ('Demo: Método de Newton')
disp ('======================')
% Input:
x0 = 2
er = 10^(-5)
imax = 15
Fun = @(x) 2.*sin(sqrt(x))-x
FunDer = @(x) (cos(sqrt(x))/sqrt(x))-1
% print
disp(' iter sol er ')
disp('=====================================')
% main
for i = 1:imax
x = x0 - (Fun(x0))/FunDer(x0);
e = abs((x - x0)/x0);
fprintf('% 3i %11.6f %11.6f\n', i, x, e)
if e < er
xs = x0;
break
end
x0 = x;
end
fprintf('\n\n raiz -----> %11.6f\n', xs)

RESUSLTADOS DE COMANDOS
Demo: Método de Newton
======================
x0 = 2
er = 1.0000e-05
imax = 15
Fun =

@(x) 2 .* sin (sqrt (x)) - x

FunDer =

@(x) (cos (sqrt (x)) / sqrt (x)) - 1

iter sol er
=====================================
1 1.972499 0.013750
2 1.972381 0.000060
3 1.972381 0.000000

raiz -----> 1.972381

(b) Secant.
% DEMO: Método de Secante
% Input:
% Fun : Función defina la ecuación
% xa, xb : estimación inicial de la solución
% er : error máximo permitido
% imax : número máximo de iteraciones permitidas
% Output:
% xs : solución aproximada
clc
disp ('Demo: Método de Secante')
disp ('======================')
% Input:
xa = -2
xb = 2
er = 10^(-5)
imax = 10
Fun = @(x) 2.*sin(sqrt(x))-x
% print
disp(' iter sol er ')
disp('=====================================')
% main
for i = 1:imax
x = xb - (Fun(xb)*(xb - xa)/(Fun(xb) - Fun(xa)));
e = abs((x - xb)/xb);
fprintf('% 3i %11.6f %11.6f\n', i, x, e)
if e < er
xs = x;
break
end
xa = xb;
xb = x ;
end
fprintf('\n\n raiz -----> %11.6f\n', xs)

RESUSLTADOS DE COMANDOS
Demo: Método de Secante
======================
xa = -2
xb = 2
er = 1.0000e-05
imax = 10
Fun =
@(x) 2 .* sin (sqrt (x)) - x

iter sol er
=====================================
1 1.989613 0.011204
2 1.972456 0.013157
3 1.972381 0.000057
4 1.972381 0.000000

raiz -----> 1.972381

Comandos de grafica.
% Demo: Ecuacion no lineal
clc
disp('Demo: Solucion de una ecuacion no lineal')
disp('========================================')
x = -2:0.1:2;
y = 2.*sin(sqrt(x))-x;
plot(x,y)

Grafica.

9. M-File. Find the roots of the system of nonlinear equations

y = −x2 + x + 0.75, y + 5xy = x2

using the Newton-Raphson method. Use the initial values of (a) x = 1.2 and y
= 1.2

% DEMO: Método de Newton


% Input:
% Fun : Función defina la ecuación
% Funder : derivada de la función ecuación
% x0 : estimación inicial de la solución
% em : error máximo permitido
% imax : número máximo de iteraciones permitidas
% Output:
% ms : solución aproximada
clc
disp ('Demo: Método de Newton')
disp ('======================')
% Input:
x0 = 1.2
er = 10^(-4)
imax = 15
Fun = @(x) 5.*x.^3-4.*x.^2-3.75*x;
FunDer = @(x) 15.*x.^2-8.*x-3.75;
% print
disp(' iter sol er ')
disp('=====================================')
% main
for i = 1:imax
x = x0 - (Fun(x0))/FunDer(x0);
e = abs((x - x0)/x0);
fprintf('% 3i %11.6f %11.6f\n', i, x, e)
if e < er
xs = x0;
break
end
x0 = x;
end
fprintf('\n\n raiz -----> %11.6f\n', xs)

RESUSLTADOS DE COMANDOS

䛅 Demo: Método de Newton

======================
x0 = 1.2000
er = 1.0000e-04
imax = 15
iter sol er
=====================================
1 1.396364 0.163636
2 1.356041 0.028877
3 1.353945 0.001546
4 1.353939 0.000004
raiz -----> 1.353945
Comandos de grafica.

% Demo: Ecuacion no lineal


clc
disp('Demo: Solucion de una ecuacion no lineal')
disp('========================================')
x = 0:0.1:1.2;
y = 5.*x.^3-4.*x.^2-3.75*x;
plot(x,y)

Grafica.
10. M-File. The equation

0.0074x4 − 0.284x3 + 3.355x2 − 12.183x + 5 = 0

has a root between 15 and 20. Apply the Newton-Raphson method to find the
root with a tolerance of 10−5 and initial condition of x0 = 16.15.

% DEMO: Método de Newton


% Input:
% Fun : Función defina la ecuación
% Funder : derivada de la función ecuación
% x0 : estimación inicial de la solución
% er : error máximo permitido
% imax : número máximo de iteraciones permitidas
% Output:
% xs : solución aproximada
clc
disp ('Demo: Método de Newton')
disp ('======================')
% Input:
x0 = 16.15
er = 10^(-5)
imax = 15
Fun = @(x) 0.0074*x^4-0.284*x^3+3.355*x^2-12.183*x+5
FunDer = @(x) 0.0296*x^3-0.852*x^2+6.71*x-12.183
% print
disp(' iter sol er ')
disp('=====================================')
% main
for i = 1:imax
x = x0 - (Fun(x0))/FunDer(x0);
e = abs((x - x0)/x0);
fprintf('% 3i %11.6f %11.6f\n', i, x, e)
if e < er
xs = x0;
break
end
x0 = x;
end
fprintf('\n\n raiz -----> %11.6f\n', xs)

RESUSLTADOS DE COMANDOS
Demo: Método de Newton
======================
x0 = 16.150
er = 1.0000e-05
imax = 15
Fun =

@(x) 0.0074 * x ^ 4 - 0.284 * x ^ 3 + 3.355 * x ^ 2 - 12.183 * x + 5

FunDer =

@(x) 0.0296 * x ^ 3 - 0.852 * x ^ 2 + 6.71 * x - 12.183

iter sol er
=====================================
1 9.077102 0.437950
2 -4.021010 1.442984
3 -1.676451 0.583077
4 -0.280396 0.832744
5 0.334244 2.192042
6 0.463023 0.385286
7 0.468470 0.011764
8 0.468480 0.000020
9 0.468480 0.000000

raiz -----> 0.468480

Comandos de grafica.

% Demo: Ecuacion no lineal


clc
disp('Demo: Solucion de una ecuacion no lineal')
disp('========================================')
x = 16.150:0.5:17;
y = 0.0074*x.^4-0.284*x.^3+3.355*x.^2-12.183*x+5;
plot(x,y)
Grafica.

11. M-File. Suppose the reader is designing a spherical water storage tank for a
small town in a developing city. The volume of the liquid that it can contain
is calculated with

where V volume (pie3), h depth of water in the tank


(pie), and R tank radio (pies). If R = 3 m, at what depth the tank should be filled
to contain 30 m3?. Use the Newton-Raphson
method to determine the answer.
% DEMO: Método de Newton

% Input:

% Fun : Función defina la ecuación

% Funder : derivada de la función ecuación

% h0 : estimación inicial de la solución

% er : error máximo permitido

% imax : número máximo de iteraciones permitidas

% Output:

% xs : solución aproximada

clc

disp ('Demo: Método de Newton')

disp ('======================')

% Input:

h0 = 3

er = 10^(-4)

imax = 10

Fun = @(h) (pi*3*h.^(2)).-((pi./3).*h^(3)).-30

FunDer = @(h) (2*pi*3*h).-(pi*h.^(2))


% print

disp(' iter sol er ')

disp('=====================================')

% main

for i = 1:imax

h = h0 - Fun(h0)/FunDer(h0);

e = abs((h - h0)/h0);

fprintf('% 3i %11.6f %11.6f\n', i, h, e)

if e < er

xs = h0;

break

end

h0 = h;

end

fprintf('\n\n raiz -----> %11.6f\n', xs)

RESUSLTADOS DE COMANDOS
Demo: Método de Newton
======================
h0 = 3
er = 1.0000e-04
imax = 10
Fun =

@(h) (pi * 3 * h .^ (2)) - ((pi ./ 3) .* h ^ (3)) - 30

FunDer =

@(h) (2 * pi * 3 * h) - (pi * h .^ (2))

iter sol er
=====================================
1 2.061033 0.312989
2 2.027042 0.016492
3 2.026906 0.000067

raiz -----> 2.027042


>>
Comandos de grafica.
% Demo: Ecuacion no lineal
clc
disp('Demo: Solucion de una ecuacion no lineal')
disp('========================================')
x = -3:0.1:3;
y = (pi*3*x.^(2))-((pi/3)*x.^(3))-30;
plot(x,y)
Grafica

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy