1sincos(3) Library Functions Manual sincos(3)
2
3
4
6 sincos, sincosf, sincosl - calculate sin and cos simultaneously
7
9 Math library (libm, -lm)
10
12 #define _GNU_SOURCE /* See feature_test_macros(7) */
13 #include <math.h>
14
15 void sincos(double x, double *sin, double *cos);
16 void sincosf(float x, float *sin, float *cos);
17 void sincosl(long double x, long double *sin, long double *cos);
18
20 Several applications need sine and cosine of the same angle x. These
21 functions compute both at the same time, and store the results in *sin
22 and *cos. Using this function can be more efficient than two separate
23 calls to sin(3) and cos(3).
24
25 If x is a NaN, a NaN is returned in *sin and *cos.
26
27 If x is positive infinity or negative infinity, a domain error occurs,
28 and a NaN is returned in *sin and *cos.
29
31 These functions return void.
32
34 See math_error(7) for information on how to determine whether an error
35 has occurred when calling these functions.
36
37 The following errors can occur:
38
39 Domain error: x is an infinity
40 errno is set to EDOM (but see BUGS). An invalid floating-point
41 exception (FE_INVALID) is raised.
42
44 For an explanation of the terms used in this section, see at‐
45 tributes(7).
46
47 ┌────────────────────────────────────────────┬───────────────┬─────────┐
48 │Interface │ Attribute │ Value │
49 ├────────────────────────────────────────────┼───────────────┼─────────┤
50 │sincos(), sincosf(), sincosl() │ Thread safety │ MT-Safe │
51 └────────────────────────────────────────────┴───────────────┴─────────┘
52
54 GNU.
55
57 glibc 2.1.
58
60 To see the performance advantage of sincos(), it may be necessary to
61 disable gcc(1) built-in optimizations, using flags such as:
62
63 cc -O -lm -fno-builtin prog.c
64
66 Before glibc 2.22, the glibc implementation did not set errno to EDOM
67 when a domain error occurred.
68
70 cos(3), sin(3), tan(3)
71
72
73
74Linux man-pages 6.04 2023-03-30 sincos(3)