You are on page 1of 8

Ejercicios de Clculo de races

04-mayo-2017 villalba saul-acua sebastian

1). Usando Fzero (Matlab)

Encontrar las races de los siguientes ejercicios, Resolver mostrando los


resultados parciales de las iteraciones y comentar los resultados.
a). 2 x+2 = 0
f=inline('2*x+2')

f=

Inline function:
f(x) = 2*x+2

>> f

f=

Inline function:
f(x) = 2*x+2

>> fzero(f,0)

ans =

-1
Rta:la raz se encuentra en -1

b). 2 x2+2 = 0

f2 =

Inline function:
f2(x) = 2*x^2+2
Mtodos numricos Ing. Qumica e Ing. en Alimentos 2011
Ejercicios de Clculo de races
04-mayo-2017 villalba saul-acua sebastian

>> f2=inline('2.*x^2+2')

f2 =

Inline function:
f2(x) = 2.*x^2+2

>> ezplot('f2')
>> ezplot(f2)
>> fzero(f2,2)
Exiting fzero: aborting search for an interval containing a sign change
because NaN or Inf function value encountered during search.
(Function value at -1.21354e+154 is Inf.)
Check function or try again with a different starting value.

ans =

NaN

Rta: no tiene races en x=0


c). x3 + x2 = 0
f3=inline('x^3+x^2')

f3 =

Inline function:
f3(x) = x^3+x^2

>> fzero(f3,0)

ans =

Mtodos numricos Ing. Qumica e Ing. en Alimentos 2011


Ejercicios de Clculo de races
04-mayo-2017 villalba saul-acua sebastian

Rta: la funcin tiene raz en x=0

>> ezplot(f3)

2). Resolver los mismos ejercicios del problema 1 utilizando roots


(Matlab)

a). 2 x+2 = 0
roots([2,2])

ans =

-1
b). 2 x2+2 = 0
roots([2,0,2])

ans =

0.0000 + 1.0000i
0.0000 - 1.0000i
c). x3 + x2 = 0
roots([1,1,0,0])

ans =

0
0
-1

Explicar si hay diferencia ente los resultados con el problema 1.


A diferencia del problema 1 esta funcin permite obtener races prximas al
punto y calcula races reales, complejas y multiples.

Mtodos numricos Ing. Qumica e Ing. en Alimentos 2011


Ejercicios de Clculo de races
04-mayo-2017 villalba saul-acua sebastian

Root esta limitada solo a funciones polinmicas.



3). Determine los ceros de la funcin () = ms cercana a 1.
f=inline('exp(-x^2)-cos(x)')

f=

Inline function:
f(x) = exp(-x^2)-cos(x)

>> ezplot(f),grid
>> x01=fzero(f,0)

x01 =

>> x02=fzero(f,1)

x02 =

1.4474

>> x03=fzero(f,2)

x03 =

1.4474

>> x04=fzero(f,3)

x04 =

1.4474

>> x05=fzero(f,4)

x05 =

4.7124

Mtodos numricos Ing. Qumica e Ing. en Alimentos 2011


Ejercicios de Clculo de races
04-mayo-2017 villalba saul-acua sebastian

4). Resuelva los siguientes sistemas de ecuaciones utilizando Fsolve (Matlab)

2 3 = 16
a) {
2 = 1
2 + 4 2 = 16
b) {
2 = 4
5 + = 3
c) {
+ + tan sin = 0

Considerando en los tres casos [x0 y0] = [1 0.5]

f=inline('[x(1)*x(2)-x(2)-2*x(1)^3+16;x(1)-x(2)^2+1]')

f=

Inline function:
f(x) = [x(1)*x(2)-x(2)-2*x(1)^3+16;x(1)-x(2)^2+1]

x0 =

1.0000 0.5000

>> fsolve(f,x0)

Equation solved.

fsolve completed because the vector of function values is near zero


as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.

Mtodos numricos Ing. Qumica e Ing. en Alimentos 2011


Ejercicios de Clculo de races
04-mayo-2017 villalba saul-acua sebastian

<stopping criteria details>

ans =

2.0757 1.7538

b)
f=inline('[x(1)^2+4*x(2)^2-16;x(1)*x(2)^2-4]')

f=

Inline function:
f(x) = [x(1)^2+4*x(2)^2-16;x(1)*x(2)^2-4]

>> x0

x0 =

1.0000 0.5000

Mtodos numricos Ing. Qumica e Ing. en Alimentos 2011


Ejercicios de Clculo de races
04-mayo-2017 villalba saul-acua sebastian

>> fsolve(f,x0)

Equation solved.

fsolve completed because the vector of function values is near zero


as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.

<stopping criteria details>

ans =

1.0784 1.9259
>> ezplot('x^2+4*y^2-16')
>> hold on
>> ezplot('x*y^2-4'), grid
>>

c)
>> f=inline('[exp(x(2))-x(1)^5+x(2)-3;x(1)+x(2)+tan(x(1))-sin(x(2))]')

f=

Inline function:
f(x) = [exp(x(2))-x(1)^5+x(2)-3;x(1)+x(2)+tan(x(1))-sin(x(2))]

>> x0

x0 =

Mtodos numricos Ing. Qumica e Ing. en Alimentos 2011


Ejercicios de Clculo de races
04-mayo-2017 villalba saul-acua sebastian

1.0000 0.5000

>> fsolve(f,x0)

Equation solved.

fsolve completed because the vector of function values is near zero


as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.

<stopping criteria details>

ans =

-0.0401 0.7921

>> ezplot('exp(y)-x^5+y-3')
>> hold on
>> ezplot('x+y+tan(x)-sin(x)')
>> grid
>>

Mtodos numricos Ing. Qumica e Ing. en Alimentos 2011

You might also like