Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Linear Algebra and the C Language/a0nj

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

__NOTOC__ Install and compile this file in your working directory. /* ------------------------------------ */ /* Save as: c00c.c */ /* ------------------------------------ */ #include "v_a.h" /* ------------------------------------ */ #define RCA RC5 /* ------------------------------------ */ /* ------------------------------------ */ double f( double x) { return(sinh(2*x)); } char feq[] = "sinh(2*x)"; /* ------------------------------------ */ double g( double x) { return(2*sinh(x)*cosh(x)); } char geq[] = "2*sinh(x)*cosh(x)"; /* ------------------------------------ */ /* ------------------------------------ */ void fun(void) { double **A = rEsymmetric_mR( i_mR(RCA,RCA),999,+1.E-4); double **sinh2A = i_mR(RCA,RCA); double **TwosinhcoshA = i_mR(RCA,RCA); double **EVector = i_mR(RCA,RCA); double **EVectorT = i_mR(RCA,RCA); double **EValue = i_mR(RCA,RCA); double **sinh2A_EValue = i_mR(RCA,RCA); double **TwosinhcoshA_EValue = i_mR(RCA,RCA); double **T1 = i_mR(RCA,RCA); clrscrn(); printf(" A:"); p_mR(A, S10,P4,C6); eigs_V_mR(A,EVector); transpose_mR(EVector,EVectorT); /* EValue = EVectorT A EVector */ mul_mR(EVectorT,A,T1); mul_mR(T1,EVector,EValue); printf(" sinh(2A)"); f_eigs_mR(f,EValue,sinh2A_EValue); /* sinh2A = EVector sinh2A_EValue EVectorT */ mul_mR(EVector,sinh2A_EValue,T1); mul_mR(T1,EVectorT,sinh2A); p_mR(sinh2A, S10,P4,C6); printf(" 2 sinh(A) cosh(A)"); f_eigs_mR(g,EValue,TwosinhcoshA_EValue); /* TwosinhcoshA = EVector TwosinhcoshA_EValue EVectorT */ mul_mR(EVector,TwosinhcoshA_EValue,T1); mul_mR(T1,EVectorT,TwosinhcoshA); p_mR(TwosinhcoshA, S10,P4,C6); f_mR(A); f_mR(sinh2A); f_mR(TwosinhcoshA); f_mR(EVector); f_mR(EVectorT); f_mR(EValue); f_mR(TwosinhcoshA_EValue); f_mR(sinh2A_EValue); f_mR(T1); } /* ------------------------------------ */ int main(void) { time_t t; srand(time(&t)); do { fun(); } while(stop_w()); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ Let's check the equations: We know that: sinh(x+y) = cosh(x) sinh(y) + sinh(x) cosh(y) let x = y sinh(x+x) = cosh(x) sinh(x) + sinh(x) cosh(x) sinh(2x) = 2 cosh(x) sinh(x) Screen output example: A: +0.0143 -0.0094 +0.0092 +0.0015 -0.0009 -0.0094 +0.0170 -0.0063 -0.0141 +0.0029 +0.0092 -0.0063 +0.0090 -0.0000 +0.0025 +0.0015 -0.0141 -0.0000 +0.0282 +0.0030 -0.0009 +0.0029 +0.0025 +0.0030 +0.0124 sinh(2A) +0.0287 -0.0188 +0.0184 +0.0031 -0.0019 -0.0188 +0.0341 -0.0125 -0.0282 +0.0057 +0.0184 -0.0125 +0.0181 -0.0000 +0.0050 +0.0031 -0.0282 -0.0000 +0.0564 +0.0061 -0.0019 +0.0057 +0.0050 +0.0061 +0.0248 2 sinh(A) cosh(A) +0.0287 -0.0188 +0.0184 +0.0031 -0.0019 -0.0188 +0.0341 -0.0125 -0.0282 +0.0057 +0.0184 -0.0125 +0.0181 -0.0000 +0.0050 +0.0031 -0.0282 -0.0000 +0.0564 +0.0061 -0.0019 +0.0057 +0.0050 +0.0061 +0.0248 Press return to continue Press X return to stop