Está en la página 1de 7

Unidad 2.

RESOLUCION DE SISTEMAS DE ECUACIONES ALGEBRAICAS


PRACTICA 27/09/2019
Ejemplo función gauss_ecuacion
x1 + x2 + x3 = 4
2x1 + x2 + 3x3 = 7
3x1 + x2 + 6x3 = 2
>> A=[1 1 1; 2 1 3; 3 1 6]
A=
1 1 1
2 1 3
3 1 6
>> b=[4;7;2]
b=
4
7
2
>> gauss_ecuacion (A,b)
ans =

19
-7
-8
>> C=ans
C=
19
-7
-8
Comprobacion si x,y,z son correctas, al multiplicar la Matriz A con el resultado C, es
como si sustituyéramos las x,y,z en la matriz A.
>> A*C
ans =

4
7
2
Ejercicio con el comando solve 4.a
>> syms x y z;
>> eq1= x+y==5 ;
>> eq2= x-y==-1 ;
>> eq3= exp(z*x)==7.389 ;
>> [x1 y1 z1]=solve(eq1,eq2,eq3)
x1 =
2
y1 =
3
z1 =
log(7389/1000)/2
>> z2= double(z1)
z2 =
1.0000
RESULTADO FINAL (X1=2 ,Y1=3 ,Z2=1)
PRACTICA 04/10/2019
4.b METODO DE NEWTON-RAPHSON
x=[0.5; 2.2]
>> Newton_Raphson_UD2
Solución
0.6252
2.1794

x=[-4.6; -3.8]
>> Newton_Raphson_UD2
Solución
-4.8642
-3.9659

x=[-1.8; 3.1]
>> Newton_Raphson_UD2
Solución
-1.8706
3.1211

x=[2.1; -1.3]
>> Newton_Raphson_UD2
Solución
2.1095
-1.3345
4.c MEDIANTE LA FUNCION fsolve
F=@(x) [x(1)^2-x(2)^2+2*x(2);2*x(1)+x(2)^2-6];
>> fsolve(F,[0.5,2.2])

Equation solved.

fsolve completed because the vector of function values is near zero


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

<stopping criteria details>

ans =

0.6252 2.1794

>> %Comprobacion que esta bien el resultado


>> F(ans)

ans =

1.0e-09 *

0.4000
0.0535

>> fsolve(F,[-4.6,-3.8])
ans =
-4.8642 -3.9659

>> F(ans)

ans =

1.0e-09 *

0.2847
0.1131

>> fsolve(F,[-1.8,-3.1])
ans =

-4.8642 -3.9659

>> fsolve(F,[2.1,-1.3])
ans =

2.1095 -1.3345

>> fsolve(F,[-1.8,3.1])
ans =

-1.8705 3.1211
Ejercicio (pag 10)
Resolver el sistema de ecuaciones no lineales:

sin(xy) + exp(−xz) − 0.9 = 0

z (x2+ y2)0.5− 6.7 = 0

tan (y/x) + cos (z) + 3.2 = 0

Considerando como aproximación inicialx0=1, y0=2 yz0=2.

>> F=@(x) [sin(x(1)*x(2))+exp(-x(1)*x(3))-0.9, x(3)*(x(1)^2+x(2)^2)^0.5 - 6.7,


tan(x(2)/x(1)) + cos(x(3)) + 3.2];
>> x0 =[1 2 2]; %valor inicial
>> [x,fval] = fsolve(F,x0)
Equation solved.

fsolve completed because the vector of function values is near zero


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

<stopping criteria details>

x=
1.0325 2.0578 2.9101
fval =

1.0e-08 *
-0.0841 -0.0192 -0.7263
>> fprintf('La solución es x=%1.3f, y=%1.3f, z=%1.3f\n',x(1),x(2),x(3));
La solución es x=1.033, y=2.058, z=2.910

También podría gustarte