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/a0nh

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: c00a.c */ /* ------------------------------------ */ #include "v_a.h" /* ------------------------------------ */ #define RCA RC5 /* ------------------------------------ */ /* ------------------------------------ */ double f( double x) { return(sinh(x)*sinh(x)); } char feq[] = "sinh(x)*sinh(x)"; /* ------------------------------------ */ double g( double x) { return(cosh(x)*cosh(x)); } char geq[] = "cosh(x)*cosh(x)"; /* ------------------------------------ */ /* ------------------------------------ */ void fun(void) { double **A = rEsymmetric_mR( i_mR(RCA,RCA),999,+1.E-4); double **sinhA_P2 = i_mR(RCA,RCA); double **coshA_P2 = i_mR(RCA,RCA); double **EVector = i_mR(RCA,RCA); double **EVectorT = i_mR(RCA,RCA); double **EValue = i_mR(RCA,RCA); double **sinhA_P2_EValue = i_mR(RCA,RCA); double **coshA_P2_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(" sinh(A)**2"); f_eigs_mR(f,EValue,sinhA_P2_EValue); /* sinhA_P2 = EVector sinhA_P2_EValue EVectorT */ mul_mR(EVector,sinhA_P2_EValue,T1); mul_mR(T1,EVectorT,sinhA_P2); pE_mR(sinhA_P2, S10,P4,C6); printf(" cosh(A)**2"); f_eigs_mR(g,EValue,coshA_P2_EValue); /* coshA_P2 = EVector coshA_P2_EValue EVectorT */ mul_mR(EVector,coshA_P2_EValue,T1); mul_mR(T1,EVectorT,coshA_P2); pE_mR(coshA_P2, S10,P4,C6); printf(" Ide = cosh(A)**2 - sinh(A)**2"); sub_mR(coshA_P2,sinhA_P2,T1); p_mR(T1, S10,P4,C6); f_mR(A); f_mR(sinhA_P2); f_mR(coshA_P2); f_mR(EVector); f_mR(EVectorT); f_mR(EValue); f_mR(coshA_P2_EValue); f_mR(sinhA_P2_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: a) ******************* sinh(x) = (e**x - e**(-x)) / 2 cosh(x) = (e**x + e**(-x)) / 2 2 sinh(x) = e**x - e**(-x) 2 cosh(x) = e**x + e**(-x) 2 sinh(x) = e**x - e**(-x) + 2 cosh(x) = e**x + e**(-x) ---------------------------- 2 sinh(x) + 2 cosh(x) = e**x - e**(-x) + e**x + e**(-x) 2 sinh(x) + 2 cosh(x) = e**x + e**x 2 sinh(x) + 2 cosh(x) = 2 e**x sinh(x) + cosh(x) = e**x e**x = sinh(x) + cosh(x) b) ******************* sinh(x) = (e**x - e**(-x)) / 2 cosh(x) = (e**x + e**(-x)) / 2 2 sinh(x) = e**x - e**(-x) 2 cosh(x) = e**x + e**(-x) 2 sinh(x) = e**x - e**(-x) - 2 cosh(x) = e**x + e**(-x) ---------------------------- 2 sinh(x) - 2 cosh(x) = e**x - e**(-x) - (e**x + e**(-x)) 2 sinh(x) - 2 cosh(x) = e**x - e**(-x) - e**x - e**(-x) 2 sinh(x) - 2 cosh(x) = - e**(-x) - e**(-x) 2 sinh(x) - 2 cosh(x) = - 2 e**(-x) sinh(x) - cosh(x) = - e**(-x) - e**(-x) = sinh(x) - cosh(x) e**(-x) = cosh(x) - sinh(x) c) ******************* e**x = sinh(x) + cosh(x) a) e**(-x) = cosh(x) - sinh(x) b) e**x = cosh(x) + sinh(x) * e**(-x) = cosh(x) - sinh(x) ----------------------------- e**x e**(-x) = (cosh(x) + sinh(x)) (cosh(x) - sinh(x)) (a+b)(a-b) = a**2-b**2 e**(x-x) = cosh(x)**2 - sinh(x)**2 e**(0) = cosh(x)**2 - sinh(x)**2 1 = cosh(x)**2 - sinh(x)**2 Screen output example: A: +0.0300 +0.0058 +0.0155 +0.0039 +0.0210 +0.0058 +0.0218 +0.0037 +0.0102 +0.0102 +0.0155 +0.0037 +0.0249 -0.0028 +0.0103 +0.0039 +0.0102 -0.0028 +0.0076 +0.0065 +0.0210 +0.0102 +0.0103 +0.0065 +0.0176 Press return to continue. sinh(A)**2 +1.6338e-03 +6.1375e-04 +1.0786e-03 +2.9843e-04 +1.2458e-03 +6.1375e-04 +7.3024e-04 +3.3764e-04 +3.7717e-04 +6.2842e-04 +1.0786e-03 +3.3764e-04 +9.8826e-04 +7.2425e-05 +7.8267e-04 +2.9843e-04 +3.7717e-04 +7.2425e-05 +2.2587e-04 +3.1965e-04 +1.2458e-03 +6.2842e-04 +7.8267e-04 +3.1965e-04 +1.0037e-03 cosh(A)**2 +1.0016e+00 +6.1375e-04 +1.0786e-03 +2.9843e-04 +1.2458e-03 +6.1375e-04 +1.0007e+00 +3.3764e-04 +3.7717e-04 +6.2842e-04 +1.0786e-03 +3.3764e-04 +1.0010e+00 +7.2425e-05 +7.8267e-04 +2.9843e-04 +3.7717e-04 +7.2425e-05 +1.0002e+00 +3.1965e-04 +1.2458e-03 +6.2842e-04 +7.8267e-04 +3.1965e-04 +1.0010e+00 Ide = cosh(A)**2 - sinh(A)**2 +1.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 +1.0000 +0.0000 +0.0000 -0.0000 -0.0000 -0.0000 +1.0000 -0.0000 -0.0000 -0.0000 +0.0000 -0.0000 +1.0000 +0.0000 -0.0000 -0.0000 -0.0000 -0.0000 +1.0000 Press return to continue Press X return to stop