Linear Algebra and the C Language/a0k0
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define RA R3
#define CA C3
#define Cb C1
/* ------------------------------------ */
int main(void)
{
double ab[RA*(CA+Cb)]={
+0.4790, -0.1540, -0.5010, -0.1760,
+0.9920, -0.7630, -0.5910, -0.3620,
-0.8430, +0.7080, +0.0880, -0.0470
};
double **Ab = ca_A_mR(ab, i_Abr_Ac_bc_mR(RA,CA,Cb));
double **A = c_Ab_A_mR(Ab, i_mR(RA,CA));
double **b = c_Ab_b_mR(Ab, i_mR(RA,Cb));
clrscrn();
printf(" You have this nonlinear system of equations :\n\n");
printf(" (x, y, z [0..2pi])\n");
printf("\n");
printf(" a sin(x) + b cos(y) + c sin(z) = d\n");
printf(" e sin(x) + f cos(y) + g sin(z) = h\n");
printf(" i sin(x) + j cos(y) + k sin(z) = l\n\n\n");
printf(" We write X = sin(x) Y = cos(y) Z = sin(z)\n\n");
printf(" a X + b Y + c Z = d\n");
printf(" e X + f Y + g Z = h\n");
printf(" i X + j Y + k Z = l\n\n");
printf(" Ab :\n");
printf(" a b c d\n");
printf(" e f g h\n");
printf(" i j k l\n\n\n");
stop();
clrscrn();
printf(" With A:");
p_mR(A, S8,P4,C7);
printf(" And b:");
p_mR(b, S8,P4,C7);
printf(" Ab:");
p_mR(Ab, S8,P4,C7);
stop();
clrscrn();
printf(" Copy/Paste into the octave window.\n\n");
p_Octave_mR(Ab,"Ab",P4);
printf("\n rref(Ab,.00000000001)\n\n");
printf(" gj_TP_mR(Ab):");
p_mR(gj_TP_mR(Ab), S10,P4,C7);
printf(" Then X = sin(x) = 1; Y = cos(y) = 1; Z = sin(z) = 1\n\n");
stop();
f_mR(Ab);
f_mR(b);
f_mR(A);
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Screen output example:
You have this nonlinear system of equations :
(x, y, z [0..2pi])
a sin(x) + b cos(y) + c sin(z) = d
e sin(x) + f cos(y) + g sin(z) = h
i sin(x) + j cos(y) + k sin(z) = l
We write X = sin(x) Y = cos(y) Z = sin(z)
a X + b Y + c Z = d
e X + f Y + g Z = h
i X + j Y + k Z = l
Ab :
a b c d
e f g h
i j k l
Press return to continue.
With A:
+0.4790 -0.1540 -0.5010
+0.9920 -0.7630 -0.5910
-0.8430 +0.7080 +0.0880
And b:
-0.1760
-0.3620
-0.0470
Ab:
+0.4790 -0.1540 -0.5010 -0.1760
+0.9920 -0.7630 -0.5910 -0.3620
-0.8430 +0.7080 +0.0880 -0.0470
Press return to continue.
Copy/Paste into the octave window.
Ab=[
+0.4790,-0.1540,-0.5010,-0.1760;
+0.9920,-0.7630,-0.5910,-0.3620;
-0.8430,+0.7080,+0.0880,-0.0470]
rref(Ab,.00000000001)
gj_TP_mR(Ab):
+1.0000 +0.0000 +0.0000 +1.0000
+0.0000 +1.0000 +0.0000 +1.0000
+0.0000 +0.0000 +1.0000 +1.0000
Then X = sin(x) = 1; Y = cos(y) = 1; Z = sin(z) = 1
Press return to continue.