Mathc matrices/03j
Apparence
Fonctions matricielles ex : cos(A)
Installer et compiler ces fichiers dans votre répertoire de travail.
c00b.c |
|---|
/* ------------------------------------ */
/* Save as: c00b.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define RCA RC5
/* ------------------------------------ */
/* ------------------------------------ */
double f(
double x)
{
return(cosh(2*x));
}
char feq[] = "cosh(2*x)";
/* ------------------------------------ */
double g(
double x)
{
return(2*cosh(x)*cosh(x)-1);
}
char geq[] = "2*cosh(x)**2)-1";
/* ------------------------------------ */
/* ------------------------------------ */
void fun(void)
{
double **A = rEsymmetric_mR( i_mR(RCA,RCA),999,+1.E-4);
double **cosh2A = i_mR(RCA,RCA);
double **TwocoshA_P2_mns1 = i_mR(RCA,RCA);
double **EVector = i_mR(RCA,RCA);
double **EVectorT = i_mR(RCA,RCA);
double **EValue = i_mR(RCA,RCA);
double **cosh2A_EValue = i_mR(RCA,RCA);
double **TwocoshA_P2_mns1_EValue = i_mR(RCA,RCA);
double **T1 = i_mR(RCA,RCA);
clrscrn();
printf(" A:");
p_mR(A, S10,P4,C6);
stop();
clrscrn();
eigs_V_mR(A,EVector);
transpose_mR(EVector,EVectorT);
/* EValue = EVectorT A EVector */
mul_mR(EVectorT,A,T1);
mul_mR(T1,EVector,EValue);
printf(" cosh(2 A)");
f_eigs_mR(f,EValue,cosh2A_EValue);
/* cosh2A = EVector cosh2A_EValue EVectorT */
mul_mR(EVector,cosh2A_EValue,T1);
mul_mR(T1,EVectorT,cosh2A);
pE_mR(cosh2A, S10,P4,C6);
printf(" 2cosh(A)**2-1");
f_eigs_mR(g,EValue,TwocoshA_P2_mns1_EValue);
/* TwocoshA_P2_mns1 = EVector TwocoshA_P2_mns1_EValue EVectorT */
mul_mR(EVector,TwocoshA_P2_mns1_EValue,T1);
mul_mR(T1,EVectorT,TwocoshA_P2_mns1);
pE_mR(TwocoshA_P2_mns1, S10,P4,C6);
f_mR(A);
f_mR(cosh2A);
f_mR(TwocoshA_P2_mns1);
f_mR(EVector);
f_mR(EVectorT);
f_mR(EValue);
f_mR(TwocoshA_P2_mns1_EValue);
f_mR(cosh2A_EValue);
f_mR(T1);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun();
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Vérifions les égalités :
Nous savons que :
cosh(x+y) = cosh(x) cosh(y) + sinh(x) sinh(y)
posons x = y
cosh(x+x) = cosh(x) cosh(x) + sinh(x) sinh(x)
cosh(2x) = cosh(x)**2 + sinh(x)**2 cosh(x)**2-sinh(x)**2 = 1
sinh(x)**2 = cosh(x)**2-1
cosh(2x) = cosh(x)**2 + (cosh(x)**2-1)
cosh(2x) = 2*cosh(x)**2 - 1
Exemple de sortie écran :
A:
+0.0254 +0.0143 -0.0145 +0.0007 +0.0082
+0.0143 +0.0161 -0.0023 -0.0104 +0.0050
-0.0145 -0.0023 +0.0279 -0.0141 -0.0096
+0.0007 -0.0104 -0.0141 +0.0289 +0.0087
+0.0082 +0.0050 -0.0096 +0.0087 +0.0199
Press return to continue.
cosh(2 A)
+1.0023e+00 +1.3156e-03 -1.7893e-03 +3.3706e-04 +1.1817e-03
+1.3156e-03 +1.0012e+00 -4.1518e-04 -7.6214e-04 +4.5606e-04
-1.7893e-03 -4.1518e-04 +1.0026e+00 -1.7503e-03 -1.4305e-03
+3.3706e-04 -7.6214e-04 -1.7503e-03 +1.0024e+00 +1.0307e-03
+1.1817e-03 +4.5606e-04 -1.4305e-03 +1.0307e-03 +1.0013e+00
2cosh(A)**2-1
+1.0023e+00 +1.3156e-03 -1.7893e-03 +3.3706e-04 +1.1817e-03
+1.3156e-03 +1.0012e+00 -4.1518e-04 -7.6214e-04 +4.5606e-04
-1.7893e-03 -4.1518e-04 +1.0026e+00 -1.7503e-03 -1.4305e-03
+3.3706e-04 -7.6214e-04 -1.7503e-03 +1.0024e+00 +1.0307e-03
+1.1817e-03 +4.5606e-04 -1.4305e-03 +1.0307e-03 +1.0013e+00
Press return to continue
Press X return to stop