---
name: "cospi"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/cospi"
---

# cospi(3)

half–cycle cosine functions

## NAME

**cospi**, **cospif**, **cospil** – half–cycle cosine functions

## LIBRARY

Math Library (libm, -lm)

## SYNOPSIS

**#include \<math.h\>**

*double*\

**cospi**(*double x*);

*float*\

**cospif**(*float x*);

*long* *double*\

**cospil**(*long double x*);

## DESCRIPTION

The **cospi**(), **cospif**(), and **cospil**() functions compute the cosine of *π × x*. and measure angles in half-cycles.

## RETURN VALUES

The **cospi**(), **cospif**(), and **cospil**() functions returns **cos**(*π × x*). If x  2^(p - 1) where p is the floating–point precision of *x*, then the returned value is 1 and it has no significance.

## SPECIAL VALUES

- **cospi**(*0*)

  returns 1.

- **cospi**(*n/2*)

  returns 0 for positive integers *n*.

- **cospi**(*n*)

  returns 1 for even integers *n*.

- **cospi**(*n*)

  returns -1 for odd integers *n*.

- **cospi**(*∞*)

  return an  and raises an FE\_INVALID exception.

- **cospi**()

  return an  and raises an FE\_INVALID exception.

## SEE ALSO

[cos(3)](/cos/3.md), [fenv(3)](/fenv/3.md), [math(3)](/math/3.md), [sin(3)](/sin/3.md), [sinpi(3)](/sinpi/3.md), [tan(3)](/tan/3.md), [tanpi(3)](/tanpi/3.md)

## AUTHORS

The half–cycle trignometric functions were written by Steven G. Kargl ⟨*kargl@FreeBSD.org*⟩.

## STANDARDS

These functions conform to IEEE Std 754-2008, to ISO/IEC TS 18661-4, "Information technology — Programming languages, their environments, and system software interfaces — Floating–point extensions for C" — Part 4: Supplementary functions, and to ISO/IEC 9899:2024 (“ISO C23”).
