1 /*  txivtrg.c    CCMATH mathematics library source code.
2  *
3  *  Copyright (C)  2000   Daniel A. Atkinson    All rights reserved.
4  *  This code may be redistributed under the terms of the GNU library
5  *  public license (LGPL). ( See the lgpl.license file for details.)
6  * ------------------------------------------------------------------------
7  */
8 /*
9     Test:  xatan  xasin  xacos
10 
11     Uses:  xtan  xsin  xcos  dubtox  prxpr
12 */
13 #define XMATH 1
14 #include "ccmath.h"
15 int decd=30;
main(void)16 void main(void)
17 { struct xpr z,f,c; int k;
18   printf("     Test of Inverse Trig Functions\n");
19   printf("\n Atan:\n");
20   for(k=0; k<3 ;++k){
21     switch(k){
22       case 0: z=dubtox(.5); break;
23       case 1: z=dubtox(1.); break;
24       case 2: z=dubtox(-2.); break;
25      }
26 
27 /* compute extended precision arctangent and tangent */
28     f=xatan(z); c=xtan(f);
29 
30     printf(" %8.4f   ",xtodub(z)); prxpr(f,decd);
31     printf(" check tan= "); prxpr(c,decd);
32    }
33   printf("\n Asin:\n");
34   for(k=0; k<3 ;++k){
35     switch(k){
36       case 0: z=dubtox(.5); break;
37       case 1: z=dubtox(.75); break;
38       case 2: z=dubtox(.25); break;
39      }
40 
41 /* compute extended precision arcsin and sine */
42     f=xasin(z); c=xsin(f);
43 
44     printf(" %8.4f   ",xtodub(z)); prxpr(f,decd);
45     printf(" check sin= "); prxpr(c,decd);
46    }
47   printf("\n Acos:\n");
48   for(k=0; k<3 ;++k){
49     switch(k){
50       case 0: z=dubtox(.5); break;
51       case 1: z=dubtox(.75); break;
52       case 2: z=dubtox(.25); break;
53      }
54 
55 /* compute extended precision arccos and cosine */
56     f=xacos(z); c=xcos(f);
57 
58     printf(" %8.4f   ",xtodub(z)); prxpr(f,decd);
59     printf(" check cos= "); prxpr(c,decd);
60    }
61 }
62 /*  Test output
63 
64      Test of Inverse Trig Functions
65 
66  Atan:
67    0.5000     4.636476090008061162142562314612e-1
68  check tan=   5.000000000000000000000000000000e-1
69    1.0000     7.853981633974483096156608458199e-1
70  check tan=   1.000000000000000000000000000000e+0
71   -2.0000    -1.107148717794090503017065460179e+0
72  check tan=  -2.000000000000000000000000000000e+0
73 
74  Asin:
75    0.5000     5.235987755982988730771072305466e-1
76  check sin=   5.000000000000000000000000000000e-1
77    0.7500     8.480620789814810080529443389984e-1
78  check sin=   7.500000000000000000000000000000e-1
79    0.2500     2.526802551420786534856574369937e-1
80  check sin=   2.500000000000000000000000000000e-1
81 
82  Acos:
83    0.5000     1.047197551196597746154214461093e+0
84  check cos=   5.000000000000000000000000000000e-1
85    0.7500     7.227342478134156111783773526413e-1
86  check cos=   7.500000000000000000000000000000e-1
87    0.2500     1.318116071652817965745664254646e+0
88  check cos=   2.500000000000000000000000000000e-1
89 */
90