Aller au contenu

Mathc complexes/a139

Un livre de Wikilivres.


Application


Installer et compiler ces fichiers dans votre répertoire de travail.


c00a.c
/* ------------------------------------ */
/*  Save as :   c00b.c                  */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
#define   RCA        RC4
/* ------------------------------------ */
double **sin_mZ(
double **A,
double **sinA
)
{	
double **A_n     = i_mZ(RCA,RCA);
double **sA      = i_mZ(RCA,RCA);
double **NewsinA = i_mZ(RCA,RCA);

int n = 10; 
int i;
int j;  
	
  for(i=1.,j=0.; i <= n; i+=2.,j++)
   {
     pow_mZ(i, A, A_n);         
    smul_mZ(pow((-1),j)/factorial(i), A_n, sA);      
     add_mZ(sinA,sA,NewsinA);    
       c_mZ(NewsinA,sinA);
   }
   
  f_mZ(A_n);
  f_mZ(sA);
  f_mZ(NewsinA);
   
  return (sinA);	
}
/* ------------------------------------ */
double **cos_mZ(
double **A,
double **cosA
)
{	
double **A_n     = i_mZ(RCA,RCA);
double **sA      = i_mZ(RCA,RCA);
double **NewcosA = i_mZ(RCA,RCA);

int n = 10; 
int i; 
int j; 
	
  for(i=0.,j=0.; i <= n; i+=2.,j++)
   {
     pow_mZ(i, A, A_n);         
    smul_mZ(pow((-1),j)/factorial(i), A_n, sA);      
     add_mZ(cosA,sA,NewcosA);    
       c_mZ(NewcosA,cosA);
   }
   
  f_mZ(A_n);
  f_mZ(sA);
  f_mZ(NewcosA);
   
  return (cosA);	
}
/* ------------------------------------ */
void fun(void)
{
double **A    = rE_mZ(i_mZ(RCA,RCA),999,+1.E-3); 
double **sinA =      i_mZ(RCA,RCA);   
double **cosA =      i_mZ(RCA,RCA);
double **sinA2 =     i_mZ(RCA,RCA);   
double **cosA2 =     i_mZ(RCA,RCA);
      
   clrscrn();   
   printf(" Copy/Past into the octave window.       \n");
   p_Octave_mZ(A, "A", P4, P4);
   stop();

   clrscrn();    
   sin_mZ(A, sinA);
   cos_mZ(A, cosA);   
   
   printf(" sinA :");
   p_mZ(sinA,S8,P4,S8,P4,C6);
   printf(" cosA :");
   p_mZ(cosA,S8,P4,S8,P4,C6);   
   stop();

   clrscrn(); 
   pow_mZ(2, sinA, sinA2);
   pow_mZ(2, cosA, cosA2); 
   
   printf(" sinA2 :");
   p_mZ(sinA2,S8,P4,S8,P4,C6);
   printf(" cosA2 :");
   p_mZ(cosA2,S8,P4,S8,P4,C6); 
      
   add_mZ(cosA2,sinA2,A);  
   printf(" I = cosA**2  + sinA**2 ");
   p_mZ(A,S8,P4,S8,P4,C6);     

   f_mZ(A);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
    fun();
    
} while(stop_w());

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */


            SinA =   + A - (1/3!) A**3 + (1/5!) A**5  - (1/7!) A**7 + ...
 
            CosA =   + I - (1/2!) A**2 + (1/4!) A**4  - (1/6!) A**6 + ...

Exemple de sortie écran :
 ------------------------------------
 Copy/Past into the octave window.       
 A=[
+0.0150+0.8620*i,+0.8090-0.1010*i,-0.5420-0.2690*i,+0.0410-0.4890*i;
+0.1570+0.5210*i,-0.1280-0.1570*i,+0.8910-0.8330*i,+0.1570+0.7060*i;
+0.0340-0.0660*i,+0.0980+0.7600*i,+0.0510-0.6280*i,-0.4550-0.3040*i;
+0.6270-0.4600*i,+0.4350-0.1430*i,+0.1750-0.0950*i,-0.1210+0.2200*i]

 Press return to continue. 


 ------------------------------------
 sinA :
 +0.1476 -0.9604i  -0.6905 +0.2243i  +0.5543 +0.2278i  -0.1865 +0.6193i 
 -0.3493 -0.3616i  +0.1917 +0.0573i  -0.6478 +0.8880i  -0.2179 -0.4674i 
 -0.0580 +0.0645i  -0.3040 -0.6386i  +0.0805 +0.5542i  +0.5175 +0.3225i 
 -0.7647 +0.5690i  -0.3197 +0.1995i  -0.2168 -0.0888i  +0.2525 -0.1706i 

 cosA :
 +1.4006 +0.0235i  -0.0104 +0.0264i  -0.2973 +0.5119i  -0.4805 -0.4713i 
 -0.0064 -0.1624i  +0.4228 -0.5492i  +0.3343 +0.3557i  +0.2438 +0.0540i 
 +0.3824 -0.1319i  -0.1537 +0.1587i  +0.8827 -0.2250i  +0.2690 -0.2170i 
 -0.2924 -0.4774i  -0.2014 +0.1328i  +0.1644 +0.2229i  +1.0765 +0.1221i 

 Press return to continue. 

 ------------------------------------
 sinA2 :
 -0.8349 -0.6694i  -0.1188 +0.0412i  +0.5626 -1.0494i  +1.0945 +1.0293i 
 -0.0321 +0.3329i  +1.2827 +0.4430i  -0.8249 -0.3138i  -0.4822 -0.0811i 
 -0.6910 +0.4191i  +0.1036 -0.4171i  +0.3329 +0.1396i  -0.2127 +0.5392i 
 +0.5397 +1.1297i  +0.2903 -0.2741i  -0.5618 -0.3847i  -0.0958 -0.6758i 

 cosA2 :
 +1.8349 +0.6694i  +0.1188 -0.0412i  -0.5626 +1.0494i  -1.0945 -1.0293i 
 +0.0321 -0.3329i  -0.2827 -0.4430i  +0.8249 +0.3138i  +0.4822 +0.0811i 
 +0.6910 -0.4191i  -0.1036 +0.4171i  +0.6671 -0.1396i  +0.2127 -0.5392i 
 -0.5397 -1.1297i  -0.2903 +0.2741i  +0.5618 +0.3847i  +1.0958 +0.6758i 

 I = cosA**2  + sinA**2 
 +1.0000 -0.0000i  -0.0000 -0.0000i  +0.0000 -0.0000i  +0.0000 +0.0000i 
 +0.0000 -0.0000i  +1.0000 +0.0000i  -0.0000 +0.0000i  -0.0000 -0.0000i 
 -0.0000 +0.0000i  +0.0000 -0.0000i  +1.0000 +0.0000i  -0.0000 +0.0000i 
 +0.0000 +0.0000i  -0.0000 -0.0000i  -0.0000 +0.0000i  +1.0000 -0.0000i 


 Press return to continue
 Press X      to stop