UNIVERSIDAD NACIONAL
DE TRUJILLO
TEMA:
PRACTICA CALIFICADA
FINAL DE LA IIUNIDAD
2020
INTEGRANTES:
Rosales Ventura Wiston Alexander
Alfaro Aguilar Bruno Nicolás
Díaz 𝑴𝒐𝒔𝒄𝒐𝒍 𝑵𝒊𝒄𝒐𝒍𝒂𝒔 Alejandro
Victorio 𝑨𝒏𝒕𝒊𝒄𝒐𝒏𝒂 𝑨𝒎𝒆𝒓𝒊𝒄𝒐
Rodríguez Castillo Santiago Manuel
Polo Acosta Kevin Hugo
ING: METALÚRGICA
CURSO: MÉTODOS NUMÉRICOS
DOCENTE: GLORIA POÉMAPE ROJAS
CICLO: IV
PRACTICA METALURGICA
1) Resolver por Gauss:
Se tienen tres lingotes compuestos del siguiente modo:
El 1. ° de 20 g de oro, 30 g de plata y 40 g de cobre.
El 2. ° de 30 g de oro, 40 g de plata y 50 g de cobre.
El 3. ° de 40 g de oro, 50 g de plata y 90 g de cobre.
Se pide qué peso habrá de tomarse de cada uno de los lingotes anteriores para
formar un nuevo lingote de 34 g de oro, 46 de plata y 67 g de cobre.
Identificamos datos:
x es el % del primer lingote que usaremos para el nuevo lingote.
y es el % del segundo lingote que usaremos para el nuevo lingote.
z es el % del tercer lingote que usaremos para el nuevo lingote
Planteamos las ecuaciones:
Para el oro del nuevo lingote → 20 x+30 y+40 z=34
Para la plata del nuevo lingote → 30 x+40 y+50 z=46
Para el cobre del nuevo lingote → 40 x+50 y+90 z=67
Sistema de ecuaciones:
20𝑥 + 30𝑦 + 40𝑧 = 34
(30𝑥 + 40𝑦 + 50𝑧 = 46)
40𝑥 + 50𝑦 + 90𝑧 = 67
Matriz:
20 + 30 + 40 = 34
[30 + 40 + 50 = 46]
40 + 50 + 90 = 67
3
Si multiplicamos la primera por 3/2 y le restamos la segunda → F 2 = 2 F1−F2
𝑥 𝑦 𝑧
[20 + 30 + 40 = 34]
0 5 + 10 = 5
40 + 50 + 90 = 67
Si multiplicamos la primera por 2 y le restamos la tercera → F ' 3=2 F1−F3
𝑥 𝑦 𝑧
[20 + 30 + 40 = 34]
0 5 + 10 = 5
0 10 − 10 = 1
Si multiplicamos la segunda por 2 y le restamos la tercera → F ' 3=2 F2−F3
𝑥 𝑦 𝑧
[20 + 30 + 40 = 34]
0 5 + 10 = 5
0 0 30 = 9
Formando sistema ecuaciones:
20𝑥 + 30𝑦 + 40𝑧 = 34
( 0 + 5𝑦 + 10𝑧 = 5)
0 + 0 + 30𝑧 = 9
Fila 3:
9
z= 30 =0.3
Fila 2:
5 y+3=5
2
y= 5=0.4
Fila 1:
20 x+12+12=34
10
x= 20 =0.5
Tenemos:
Lingote N°1= 0.5 %
Lingote N°2= 0.4 %
Lingote N°3= 0.3 %
Deducimos el peso de lingote nuevo:
Primer lingote: Peso es 90g, pero utilizaremos el 50% de 90 g = 45 g
Segundo lingote: Peso es 120g, pero utilizaremos el 40% de 120 g = 48 g
Tercer lingote: Peso es de 180 g; pero utilizaremos 30% de 180G g , = 54g
PROGRAMA REALIZADO EN OCTAVE
%METODO DE GAUSS
A=[20 30 40;
30 40 50;
40 50 90];
b=[34 46 67]';
%permite obtener el tamaño de la matriz A
[n,m]=size(A);
C=[A,b];
% la matriz C, representa la forma de la matriz aumentada [Ab]
fprintf('\nLa Matriz C, que corresponte a la matriz aumentada [Ab] es = \n');
disp(C); % la funcion disp nos permite imprimir una variable en el espacio de trabajo
if n==m
for k=1:(n-1)%instruccion iterativa que permite repetir pasos un numero
%determinado de veces
fprintf('\n ETAPA %g=\n\n',k)
fprintf('\nLa matriz correspondiente a esta etapa antes del proceso:\n')
disp(C)
fprintf('\nLos Multiplicadores correpondientes a esta etapa son:\n')
for i=(k+1):n
m(i,k)=C(i,k)/C(k,k); %formula para hallar los multiplicadores
fprintf('\nm(%g,%g)=',i,k)
disp(m(i,k));
for j=k:(n+1)
C(i,j)= C(i,j) - m(i,k)*C(k,j); %formula de la nueva fila
end
end
fprintf('\nLa matriz correspondiente a esta etapa despues del proceso:\n')
disp(C)
end
for i=n:-1:1
suma=0;
for p=(i+1):n
suma = suma + C(i,p)*X(p);
end
X(i)=(C(i,n+1)-suma)/C(i,i);
%formula de la susticion regresiva y solucion de las variables
end
else %funcion asignada del if, en caso de que este sea falso
fprintf('\nERROR: La matriz NO es cuadrada\n');
end
fprintf('\n\n\nSOLUCIÓN:\n');
fprintf('\n\nLa matriz Ab final:\n');
disp(C)
fprintf('\n\nLa solucion de X1 hasta Xn es:\n');
%a continuacion de utiliza una instruccion for, para mostrar el usuario,
%los resultados de una manera mas ordena
for i=1:n
Xi=X(1,i);
fprintf('\nX%g=',i)
disp(Xi);
end
********************* FIN **********************
De ello calculamos el porcentaje en peso de cada uno de los lingotes para formar uno nuevo:
Lingote N°1= 0.5 %
Lingote N°2= 0.4 %
Lingote N°3= 0.3 %
Deducimos el peso de lingote nuevo:
Primer lingote: Peso es 90g, pero utilizaremos el 50% de 90 g = 45 g
Segundo lingote: Peso es 120g, pero utilizaremos el 40% de 120 g = 48 g
Tercer lingote: Peso es de 180 g ; pero utilizaremos 30% de 180G g , = 54%
PROGRAMA REALIZADO EN OCTAVE
%METODO DE GAUSS
A=[20 30 40;
30 40 50;
40 50 90];
b=[34 46 67]';
%permite obtener el tamaño de la matriz A
[n,m]=size(A);
C=[A,b];
% la matriz C, representa la forma de la matriz aumentada [Ab]
fprintf('\nLa Matriz C, que corresponte a la matriz aumentada [Ab] es = \n');
disp(C); % la funcion disp nos permite imprimir una variable en el espacio de trabajo
if n==m
for k=1:(n-1)%instruccion iterativa que permite repetir pasos un numero
%determinado de veces
fprintf('\n ETAPA %g=\n\n',k)
fprintf('\nLa matriz correspondiente a esta etapa antes del proceso:\n')
disp(C)
fprintf('\nLos Multiplicadores correpondientes a esta etapa son:\n')
for i=(k+1):n
m(i,k)=C(i,k)/C(k,k); %formula para hallar los multiplicadores
fprintf('\nm(%g,%g)=',i,k)
disp(m(i,k));
for j=k:(n+1)
C(i,j)= C(i,j) - m(i,k)*C(k,j); %formula de la nueva fila
end
end
fprintf('\nLa matriz correspondiente a esta etapa despues del proceso:\n')
disp(C)
end
for i=n:-1:1
suma=0;
for p=(i+1):n
suma = suma + C(i,p)*X(p);
end
X(i)=(C(i,n+1)-suma)/C(i,i);
%formula de la susticion regresiva y solucion de las variables
end
else %funcion asignada del if, en caso de que este sea falso
fprintf('\nERROR: La matriz NO es cuadrada\n');
end
fprintf('\n\n\nSOLUCIÓN:\n');
fprintf('\n\nLa matriz Ab final:\n');
disp(C)
fprintf('\n\nLa solucion de X1 hasta Xn es:\n');
%a continuacion de utiliza una instruccion for, para mostrar el usuario,
%los resultados de una manera mas ordena
for i=1:n
Xi=X(1,i);
fprintf('\nX%g=',i)
disp(Xi);
end
********************* FIN **********************
De ello calculamos el porcentaje en peso de cada uno de los lingotes para formar uno nuevo:
Lingote N°1= 0.5 %
Lingote N°2= 0.4 %
Lingote N°3= 0.3 %
Deducimos el peso de lingote nuevo:
Primer lingote: Peso es 90g, pero utilizaremos el 50% de 90 g = 45 g
Segundo lingote: Peso es 120g, pero utilizaremos el 40% de 120 g = 48 g
Tercer lingote: Peso es de 180 g ; pero utilizaremos 30% de 180G g , = 54%
2) En el estudio de la constante de velocidad k de una reacción química a diferentes
temperaturas se obtuvieron los datos:
𝑇(°𝐾) 293 300 320 340 360 380 400
−5 −5 −3
𝑘 8.53𝑥10 19.1𝑥10 1.56𝑥10 0.01 0.0522 0.2284 0.8631
Calcule el factor de frecuencia z y la energía de activación E, asumiendo que los
datos experimentales siguen la ley de Arrhenius:
𝐸
𝑘 = 𝑧𝑒 −1.98𝑇
Aplicando logaritmo neperiano:
−𝐸
ln(𝐾) = ln (𝑧𝑒 1.98𝑇 )
−𝐸
ln(𝐾) = ln 𝑧 + ln (𝑒 1.98𝑇 )
−𝐸 1
ln(𝐾) = ln 𝑧 + ( )
1.98 𝑇
Sea
𝑦 = ln 𝐾
1
𝑥=𝑇
−𝐸
𝑚=( )
1.98
𝑏 = ln(𝑧)
Por lo tanto, se tiene:
𝑦 = 𝑚𝑥 + 𝑏
Por mínimos cuadrados:
𝑛 ∑ 𝑥𝑦 − ∑ 𝑥 ∑ 𝑦 ∑𝑦 − 𝑚∑𝑥
𝒎= 2 2
, 𝒃=
𝑛 ∑ 𝑥 − (∑ 𝑥) 𝑛
Luego:
𝐸 = −1.98 𝒎
𝑧 = 𝑒𝒃
3) En el siguiente ejercicio Resolver usando Jacobi y encontrar una solución con 5
cifras signitivas:
Primero hacemos dominante a la matriz usando el método de Gauss, con el
siguiente programa en C++:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include<iostream>
using namespace std;
void allocMatrix(double ***matrix, int fil, int col);
void deallocMatrix(double **matrix, int fil );
void leerDatos( double **A, int fil, int col, double B[] );
void gaussEliminacion( double **A, int fil, int col, double v[] );
void intercambiarFilas( double **A, int col, int k, int max );
void imprimirMatriz( double **A, int fil, int col, double v[] );
void imprimirSolucion( double v[], int fil );
int main()
{
cout << "\n ";
cout << "\t\t\t\t\t UNIVERSIDAD NACIONAL DE TRUJILLO \n";
cout << "\t\t\t\t\t\tINGENIERIA METALURGICA \n";
cout << "\t\t\t METODO DE GAUSS \n";
cout << "\n ";
int fil, col;
printf( "\n\tNumero de variables: " );
scanf( "%d", &fil );
col = fil;
double** A = NULL;
allocMatrix(&A, fil, col);
double B[fil];
leerDatos( A, fil, col, B );
imprimirMatriz( A, fil, col, B );
gaussEliminacion( A, fil, col, B );
deallocMatrix( A, fil );
return 0;
}
void allocMatrix(double ***matrix, int fil, int col )
{
*matrix = (double **)malloc(sizeof(double *) * fil);
for( int i = 0; i < col; i++){
*(*matrix + i) = (double *)malloc(sizeof(double) * col);
}
}
void deallocMatrix(double **matrix, int fil )
{
int i = 0;
for(i = 0; i < fil; i++){
free(matrix[i]);
}
free(matrix);
}
void leerDatos( double **A, int fil, int col, double B[] )
{
printf( "\n\tIntroduzca coeficientes de la ecuacion:\n" );
for( int i = 0; i < fil; i++ ){
printf( "\n\tFila %d:\n", i + 1 );
for( int j = 0; j < col; j++ ) {
printf( "\tColumna %d: ", j + 1 );
scanf( "%lf", &A[i][j] );
}
}
printf( "\n\tIntroduzca igualdad de la ecuacion:\n" );
for( int i = 0; i < fil; i++ ){
printf( "\tFila %d: ", i + 1 );
scanf( "%lf", &B[i] );
}
}
void gaussEliminacion( double **A, int fil, int col, double B[] )
{
int max;
int N = fil;
double factor, temp;
for( int k = 0; k < N; k++ ){
max = k;
for( int i = k + 1; i < N; i++ )
if( abs( A[i][k] ) > abs( A[max][k] ) )
max = i;
intercambiarFilas( A, col, k, max );
temp = B[k];
B[k] = B[max];
B[max] = temp;
for( int i = k + 1; i < N; i++ ) {
factor = A[i][k] / A[k][k];
B[i] -= factor * B[k];
for( int j = k; j < N; j++ )
A[i][j] -= factor * A[k][j];
}
}
imprimirMatriz( A, fil, col, B );
double solucion[fil];
double suma;
for( int i = 0; i < fil; i++ )
solucion[i] = 0.00;
for( int i = N - 1; i >= 0; i-- ){
suma = 0.0;
for( int j = i + 1; j < N; j++ )
suma += A[i][j] * solucion[j];
solucion[i] = (B[i] - suma) / A[i][i];
}
imprimirSolucion( solucion, fil );
void intercambiarFilas( double **M, int col, int k, int max )
{
double temp[col];
for( int i = k; i < col; i++ ) {
temp[i] = M[k][i];
M[k][i] = M[max][i];
M[max][i] = temp[i];
}
}
void imprimirMatriz( double **M, int fil, int col, double v[] )
{
printf( "\n\tMatriz:\n" );
for( int i = 0; i < fil; i++ ){
for( int j = 0; j < col; j++ ){
printf( "\t%.3lf ", M[i][j] );
}
printf( "\t| %.3lf\n", v[i] );
}
printf( "\n\t" );
}
void imprimirSolucion( double v[], int fil )
{
printf( "\n\tSolucion: " );
for( int i = 0; i < fil; i++ )
printf( "\n\tX%d: %.3lf", i + 1, v[i] );
printf( "\n" );
}
MATRIZ DOMINANTE
Una vez obtenido la matriz dominante, la ingresamos en el programa de Jacobi
realizado en C++ con un tolerancia (error de parada) de 0.001:
#include <stdio.h>
#include <stdlib.h>
int dim;
float norma(float vector1[],float vector2[]);
float suma_jacobi(float Matriz[], float vector[], int componente);
int main(){
int i,j,iteraciones=0;
float error,epsilon;
printf("\n METODO DE JACOBI DE RESOLUCION DE SISTEMAS Ax=b
\n");
printf("Dimension de la matriz A: ");
scanf("%d",&dim);
float A[dim][dim],b[dim],x[dim],x_prev[dim],aux[dim];
printf("\n Elementos de la matriz A: \n");
for(i=0;i<dim;i++) for(j=0;j<dim;j++){
printf("A(%d,%d)=",i,j); scanf("%f",&A[i][j]);
}
printf("\n Elementos del vector b: \n");
for(i=0;i<dim;i++){
printf("b(%d)=",i); scanf("%f",&b[i]);
}
printf("\n Error de parada: \n");
printf("E=",i); scanf("%f",&epsilon);
error=epsilon+1;
//cominezo algoritmo de Jacobi
//Error se mide como la norma del vector diferenceia entre la iteracion i e i+1
printf("\n Valor inicail de la iteracion: \n");
for(i=0;i<dim;i++){
printf("x0(%d)=",i); scanf("%f",&x_prev[i]);
}
while (error>epsilon){
for(i=0;i<dim;i++){
for(j=0;j<dim;j++) aux[j]=A[i][j];
x[i]=(1/A[i][i])*(b[i]-suma_jacobi(aux,x_prev,i));
}
error=norma(x,x_prev);
printf("\n\n Iteracion %d: \n",iteraciones);
for(i=0;i<dim;i++){
x_prev[i]=x[i];
printf("X(%d)=%f \n",i,x[i]);
}
iteraciones++;
if (iteraciones==10) error=epsilon-1;
}
printf("Solucion del sistema\n");
printf("Numero de iteraciones: %d \n", iteraciones);
for(i=0;i<dim;i++){
printf("x(%d)=%f\n",i,x[i]);
}
return 1;
}
float norma(float vector1[],float vector2[]){
float aux=0;
int i;
for(i=0;i<dim;i++){
aux=aux+(vector1[i]-vector2[i])*(vector1[i]-vector2[i]);
}
return aux;
}
float suma_jacobi(float Matriz[], float vector[], int componente)
{
float aux=0;
int i;
for(i=0;i<dim;i++){
if (componente!=i){
aux=aux+Matriz[i]*vector[i];
}
}
return aux;
}
4) Resolver para una tol=0.001.
Para la obtención del butadieno a partir del etanol en fase vapor, se propone el siguiente
mecanismo de reacción.
Calcule las composiciones en el equilibrio a 400°C y 1 atm, si las constantes de
equilibrio son 5.97, 0.27 y 2.8, para las reacciones (1), (2) y (3), respectivamente.
Base de cálculo: 1 mol de etanol.
Si
Entonces, en el equilibrio se tendrá
De acuerdo con la ley de acción de masas, se tiene
donde ∆𝑛𝑖 = número de productos de moles de los reactantes (en la reacción i)
Considerar:
∆𝑛1 = 2 − 1 = 1
∆𝑛2 = 2 − 1 = 1
∆𝑛3 = 2 − 2 = 0
𝑃 = 1 𝑎𝑡𝑚
SOLUCIÓN:
(𝑥 + 𝑧)(𝑥 − 𝑧) = 5.47(1 − 𝑥 − 𝑦)(1 + 𝑥 + 𝑦) … … … … … … … 𝐹1
(𝑦 + 𝑧)(𝑦) = 0.27(1 − 𝑥 − 𝑦)(1 + 𝑥 + 𝑦) … … … … … … … … … 𝐹2
(𝑥 + 𝑧)(𝑧) = 2.8(𝑥 − 𝑧)(𝑦 − 𝑧) … … … … … … … … … … … … … … . 𝐹3
Encontramos las derivadas:
𝑑𝐹1
= 13.94𝑥 + 11.94𝑦
𝑑(𝑥)
𝑑𝐹2
= 2.54𝑦 + 2 + 0.54𝑥
𝑑(𝑦)
𝑑𝐹3
= 3.8𝑥 − 3.62 + 2.8𝑦
𝑑(𝑧)
-------------------I
---------------------------II
----------------------------- III
Considerando: x1= X, x2=Y, x3=Z
Dividiendo I entre II se obtiene:
5.97
𝑍 = √𝑋 2 − (1 − 𝑋 − 𝑌)
0.27
Simplificando las ecuaciones I. II Y III.
6.97𝑋 2 − 𝑍 2 + 11.94𝑋𝑌 + 5.97𝑌 2 − 5.97 = 0
1.27𝑌 2 + 0.27𝑋 2 + 𝑌𝑍 + 0.54𝑋𝑌 − 0.27 = 0
3.8𝑋𝑍 − 1.8𝑍 2 − 2.8𝑋𝑌 + 2.8𝑌𝑍 = 0
Remplazando el valor de Z.
2
5.97
6.97𝑋 2 − (√𝑋 2 − (1 − 𝑋 − 𝑌) ) + 11.94𝑋𝑌 + 5.97𝑌 2 − 5.97 = 0 − − − − − − − 𝐴
0.27
5.97
1.27𝑌 2 + 0.27𝑋 2 + 𝑌 (√𝑋 2 − (1 − 𝑋 − 𝑌) ) + 0.54𝑋𝑌 − 0.27 = 0 − − − − − − − 𝐵
0.27
2
5.97 5.97 5.97
3.8𝑋√𝑋 2 − (1 − 𝑋 − 𝑌) − 1.8√𝑋 2 − (1 − 𝑋 − 𝑌) − 2.8𝑋𝑌 + 2.8𝑌√𝑋 2 − (1 − 𝑋 − 𝑌)
0.27 0.27 0.27
= 0. − − −𝐶
Sumando A+B
5.97
5.97𝑋 2 + (1 − 𝑋 − 𝑌) + 11.94𝑋𝑌 + 5.97𝑌 2 − 5.97 = 0 (A)
0.27
5.97
1.27𝑌 2 + 0.27𝑋 2 + 𝑌 (√𝑋 2 − (1 − 𝑋 − 𝑌) ) + 0.54𝑋𝑌 − 0.27 = 0 (B)
0.27
Se obtiene:
Línea de color celeste la ecuación D:
5.97 5.97
6.24𝑋 2 + 7.24 ∗ 𝑌 2 + (1 − 𝑋 − 𝑌) 0.27 + 𝑌 (√𝑋 2 − (1 − 𝑋 − 𝑌) 0.27) + 12.48𝑋𝑌 − 6.24 = 0 (D)
Línea de color morado la ecuación C:
5.97 5.97 5.97
3.8𝑋√𝑋 2 − (1 − 𝑋 − 𝑌) − 1.8 (𝑋 2 − (1 − 𝑋 − 𝑌) ) − 2.8𝑋𝑌 + 2.8𝑌√𝑋 2 − (1 − 𝑋 − 𝑌) =0 (C)
0.27 0.27 0.27