| 1 |
'\" t |
| 2 |
.\" Copyright 2002, Walter Harms <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: GPL-1.0-or-later |
| 6 |
.\" |
| 7 |
.TH sincos 3 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
sincos, sincosf, sincosl \- calculate sin and cos simultaneously |
| 10 |
.SH LIBRARY |
| 11 |
Math library |
| 12 |
.RI ( libm ,\~ \-lm ) |
| 13 |
.SH SYNOPSIS |
| 14 |
.nf |
| 15 |
.BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" |
| 16 |
.B #include <math.h> |
| 17 |
.P |
| 18 |
.BI "void sincos(double " x ", double *" sin ", double *" cos ); |
| 19 |
.BI "void sincosf(float " x ", float *" sin ", float *" cos ); |
| 20 |
.BI "void sincosl(long double " x ", long double *" sin ", long double *" cos ); |
| 21 |
.fi |
| 22 |
.SH DESCRIPTION |
| 23 |
Several applications need sine and cosine of the same angle |
| 24 |
.IR x . |
| 25 |
These functions compute both at the same time, and store the results in |
| 26 |
.I *sin |
| 27 |
and |
| 28 |
.IR *cos . |
| 29 |
Using this function can be more efficient than two separate calls to |
| 30 |
.BR sin (3) |
| 31 |
and |
| 32 |
.BR cos (3). |
| 33 |
.P |
| 34 |
If |
| 35 |
.I x |
| 36 |
is a NaN, |
| 37 |
a NaN is returned in |
| 38 |
.I *sin |
| 39 |
and |
| 40 |
.IR *cos . |
| 41 |
.P |
| 42 |
If |
| 43 |
.I x |
| 44 |
is positive infinity or negative infinity, |
| 45 |
a domain error occurs, and |
| 46 |
a NaN is returned in |
| 47 |
.I *sin |
| 48 |
and |
| 49 |
.IR *cos . |
| 50 |
.SH RETURN VALUE |
| 51 |
These functions return |
| 52 |
.IR void . |
| 53 |
.SH ERRORS |
| 54 |
See |
| 55 |
.BR math_error (7) |
| 56 |
for information on how to determine whether an error has occurred |
| 57 |
when calling these functions. |
| 58 |
.P |
| 59 |
The following errors can occur: |
| 60 |
.TP |
| 61 |
Domain error: \f[I]x\f[] is an infinity |
| 62 |
.I errno |
| 63 |
is set to |
| 64 |
.B EDOM |
| 65 |
(but see BUGS). |
| 66 |
An invalid floating-point exception |
| 67 |
.RB ( FE_INVALID ) |
| 68 |
is raised. |
| 69 |
.SH ATTRIBUTES |
| 70 |
For an explanation of the terms used in this section, see |
| 71 |
.BR attributes (7). |
| 72 |
.TS |
| 73 |
allbox; |
| 74 |
lbx lb lb |
| 75 |
l l l. |
| 76 |
Interface Attribute Value |
| 77 |
T{ |
| 78 |
.na |
| 79 |
.nh |
| 80 |
.BR sincos (), |
| 81 |
.BR sincosf (), |
| 82 |
.BR sincosl () |
| 83 |
T} Thread safety MT-Safe |
| 84 |
.TE |
| 85 |
.SH STANDARDS |
| 86 |
GNU. |
| 87 |
.SH HISTORY |
| 88 |
glibc 2.1. |
| 89 |
.SH NOTES |
| 90 |
To see the performance advantage of |
| 91 |
.BR sincos (), |
| 92 |
it may be necessary to disable |
| 93 |
.BR gcc (1) |
| 94 |
built-in optimizations, using flags such as: |
| 95 |
.P |
| 96 |
.in +4n |
| 97 |
.EX |
| 98 |
cc \-O \-lm \-fno\-builtin prog.c |
| 99 |
.EE |
| 100 |
.in |
| 101 |
.SH BUGS |
| 102 |
Before glibc 2.22, the glibc implementation did not set |
| 103 |
.\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=15467 |
| 104 |
.I errno |
| 105 |
to |
| 106 |
.B EDOM |
| 107 |
when a domain error occurred. |
| 108 |
.SH SEE ALSO |
| 109 |
.BR cos (3), |
| 110 |
.BR sin (3), |
| 111 |
.BR tan (3) |