Mathc complexes/c083b
Installer et compiler ces fichiers dans votre répertoire de travail.
c01b.c |
---|
/* ------------------------------------ */
/* Save as : c01b.c */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **A = i_mZ(r,r);
double **Inv = i_mZ(r,r);
double **B = r_mZ(i_mZ(r,C5),99.);
double **X = i_mZ(r,C5);
double **T = i_mZ(r,C5);
do
{
r_mZ(A,99.);
printf(".");
}while(!det_Z(A).r);
clrscrn();
printf(" \n");
printf(" Linear systems with common coefficient matrix.\n\n");
printf(" Ax1=b1 \n");
printf(" Ax2=b2 \n");
printf(" ... \n");
printf(" Axn=bn \n\n");
printf(" We can write these equalities in this maner. \n\n");
printf(" A|x1|x2|...|xn| = b1|b2|...|bn| \n\n");
printf(" or simply : \n\n");
printf(" AX = B \n\n");
printf(" where B = b1|b2|...|bn \n\n");
printf(" and X = x1|x2|...|xn \n\n");
getchar();
clrscrn();
printf(" We want to find X such as, \n\n");
printf(" AX = B \n\n");
printf(" If A is a square matrix and, \n\n");
printf(" If A has an inverse matrix, \n\n");
printf(" you can find X by this method\n\n");
printf(" X = inv(A) B \n\n\n");
printf(" To verify the result you can \n\n");
printf(" multiply the matrix A by X. \n\n");
printf(" You must refind B. \n\n");
getchar();
clrscrn();
printf(" A :\n");
p_mZ(A, S5,P0, S4,P0, C6);
printf(" b1 b2 ... bn");
p_mZ(B, S8,P0, S4,P0, C6);
getchar();
clrscrn();
printf(" inv(A) :");
inv_mZ(A,Inv);
pE_mZ(Inv, S1,P4, S1,P4, C3);
printf(" X = inv(A) * B :\n");
printf(" x1 x2 ... xn");
mul_mZ(Inv,B,X);
p_mZ(X, S6,P4, S5,P4, C4);
getchar();
clrscrn();
printf(" b1 b2 ... bn");
p_mZ(B, S8,P0, S4,P0, C6);
printf(" Ax1 Ax2 ... Axn");
mul_mZ(A,X,T);
p_mZ(T, S8,P0, S4,P0, C6);
f_mZ(T);
f_mZ(X);
f_mZ(B);
f_mZ(Inv);
f_mZ(A);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(rp_I(RC3)+RC1);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Nous résolvons un système d'équations, et nous vérifions les calculs. Exemple de sortie écran :
--------------------------------------
Linear systems with common coefficient matrix.
Ax1=b1
Ax2=b2
...
Axn=bn
We can write these equalities in this maner.
A|x1|x2|...|xn| = b1|b2|...|bn|
or simply :
AX = B
where B = b1|b2|...|bn
and X = x1|x2|...|xn
--------------------------------------
We want to find X such as,
AX = B
If A is a square matrix and,
If A has an inverse matrix,
you can find X by this method
X = inv(A) B
To verify the result you can
multiply the matrix A by X.
You must refind B.
--------------------------------------
A :
+2 -1i +8 -7i +4 +4i
+2 -5i -5 -5i -3 +2i
+6 -9i +4 -3i -5 +8i
b1 b2 ... bn
+8 +4i +6 +6i +8 +4i +2 -1i +6 -1i
-9 -3i -9 -3i -7 -5i +6 +6i +2 -5i
-7 -9i -3 +6i -9 -1i -3 +6i -3 -7i
--------------------------------------
inv(A) :
+1.3599e-01-1.8737e-01i -1.0924e-01-2.6287e-01i +8.7837e-02+2.1346e-01i
-8.0369e-02+3.9115e-02i -1.1129e-01+1.7666e-01i +5.4537e-02-9.6259e-02i
+1.1497e-01-2.0616e-01i -2.0510e-01-2.3886e-01i +8.2640e-02+1.2054e-01i
X = inv(A) * B :
x1 x2 ... xn
+3.3383-0.5462i +0.5904+2.2719i +0.7107-0.5777i -0.5379-2.8567i
-0.5159-1.0817i +1.2287-0.8876i +0.2759+0.1231i -1.4354+1.1668i
+3.3802-0.0119i +2.0849+2.3521i +1.3626+0.3406i -0.7449-3.0569i
+0.3265-2.4950i
-0.6198+1.1319i
-0.5250-1.7443i
-------------------------------------- Ax = B ?
b1 b2 ... bn
+8 +4i +6 +6i +8 +4i +2 -1i +6 -1i
-9 -3i -9 -3i -7 -5i +6 +6i +2 -5i
-7 -9i -3 +6i -9 -1i -3 +6i -3 -7i
Ax1 Ax2 ... Axn
+8 +4i +6 +6i +8 +4i +2 -1i +6 -1i
-9 -3i -9 -3i -7 -5i +6 +6i +2 -5i
-7 -9i -3 +6i -9 -1i -3 +6i -3 -7i
Press return to continue
Press X to stop