Skip to content

Cos ​

The cosine of x, in radians.

✓ checked against that system · ! checked, with disagreements (hover a chip)WikipediaSine and cosineMathWorldCosineWikidataQ13647261DLMF4.14.E2FungrimCos✓Fungrim entryWolfram LanguageCos!
Cos(x)the cosine of x, in radians.
SageMathcos(x)!SymPycos(x)mpmathcos(x)Oscarcos(x)Juliaenumeratio_ball(cos, x)Rustcos(x)
Typed signatures
TypePackageApplies
(complex | quantity) -> numberanalyticreplaces compute-enginealways
(complex | quantity) -> numbercompute-enginealways

Domain: Elementary functions

Details
  • Even function: cos⁡(−x)=cos⁡(x)\cos(-x) = \cos(x).
  • Period 2π2\pi.
  • Reciprocal of Sec: cos⁡(x)=1sec⁡(x)\cos(x) = \frac{1}{\sec(x)}.
  • Co-function with Sin: cos⁡(x)=sin⁡(π/2−x)\cos(x) = \sin(\pi/2 - x).

Examples

7 more kept as data, checked against the oracles
Basic #
live ↗
Incos⁡(0)\cos(0)Out11
live ↗
Incos⁡(π6)\cos(\frac{π}{6})Out32\frac{\sqrt{3}}{2}
live ↗
Incos⁡(π4)\cos(\frac{π}{4})Out22\frac{\sqrt{2}}{2}
live ↗
Incos⁡(π3)\cos(\frac{π}{3})Out12\frac{1}{2}
live ↗
Incos⁡(π2)\cos(\frac{π}{2})Out00
live ↗
Incos⁡(π)\cos(π)Out−1-1

cos⁡30∘\cos 30^\circ, exactly

live ↗
Incos⁡(30∘)\cos(30^{∘})Out32\frac{\sqrt{3}}{2}

A machine-precision argument evaluates numerically

live ↗
Incos⁡(1.2)\cos(1.2)Out0.362 357 754 476 673 577 6380.362\,357\,754\,476\,673\,577\,638
live ↗
InSeries⁡(cos⁡(x),x,0,10)\operatorname{Series}(\cos(x), x, 0, 10)Out1−x22+x424−x6720+x840 320−x103 628 800+O(x12)1-\frac{x^2}{2}+\frac{x^4}{24}-\frac{x^6}{720}+\frac{x^8}{40\,320}-\frac{x^{10}}{3\,628\,800}+O\left(x^{12}\right)
Scope #

N(...) of an exact argument gives an arbitrary-precision value

live ↗
InN(cos⁡(65))N(\cos(\frac{6}{5}))Out0.362 357 754 476 673 577 6380.362\,357\,754\,476\,673\,577\,638

Evaluates at a complex argument

live ↗
Incos⁡(2.5+i)\cos(2.5+i)Out−1.236 229 198 856 342−0.703 325 178 113 534 7i-1.236\,229\,198\,856\,342-0.703\,325\,178\,113\,534\,7i

Threads element-wise over a matrix

live ↗
Incos⁡([[5π6,0],[3π2,−π/2]])\cos(\bigl\lbrack\bigl\lbrack\frac{5π}{6}, 0\bigr\rbrack, \bigl\lbrack\frac{3π}{2}, -π/2\bigr\rbrack\bigr\rbrack)Out[[−31/22,1],[0,0]]\bigl\lbrack\bigl\lbrack-\frac{3^{1/2}}{2}, 1\bigr\rbrack, \bigl\lbrack0, 0\bigr\rbrack\bigr\rbrack

cos⁡(π/12)=6+24\cos(\pi/12) = \frac{\sqrt6 + \sqrt2}{4}

live ↗
Incos⁡(π12)\cos(\frac{π}{12})Out24+64\frac{\sqrt{2}}{4}+\frac{\sqrt{6}}{4}

cos⁡(π/8)=2+22\cos(\pi/8) = \frac{\sqrt{2+\sqrt2}}{2}

live ↗
Incos⁡(π8)\cos(\frac{π}{8})Out2+22\frac{\sqrt{2+\sqrt{2}}}{2}

cos⁡(π/10)=10+254\cos(\pi/10) = \frac{\sqrt{10+2\sqrt5}}{4}

live ↗
Incos⁡(π10)\cos(\frac{π}{10})Out1425+5\frac{1}{4}\sqrt{2}\sqrt{5+\sqrt{5}}

cos⁡(2π/5)=5−14\cos(2\pi/5) = \frac{\sqrt5 - 1}{4}

live ↗
Incos⁡(2π5)\cos(\frac{2π}{5})Out54−14\frac{\sqrt{5}}{4}-\frac{1}{4}

cos⁡(3π/5)=1−54\cos(3\pi/5) = \frac{1 - \sqrt5}{4}

live ↗
Incos⁡(3π5)\cos(\frac{3π}{5})Out14−54\frac{1}{4}-\frac{\sqrt{5}}{4}

Reduced into the first quadrant by symmetry

live ↗
Incos⁡(11π6)\cos(\frac{11π}{6})Out32\frac{\sqrt{3}}{2}

Interval arithmetic: the image of [π/3,π/2][\pi/3, \pi/2] is [0,12][0, \tfrac12]

live ↗
Incos⁡(Interval(π3,π2))\cos(\mathrm{Interval}(\frac{π}{3}, \frac{π}{2}))OutInterval(0,12)\mathrm{Interval}(0, \frac{1}{2})

Uncertainty propagation: cos⁡(2±0.01)≈−0.4161±0.0091\cos(2 \pm 0.01) \approx -0.4161 \pm 0.0091

live ↗
Incos⁡(Around(2,0.01))\cos(\mathrm{Around}(2, 0.01))OutAround(−0.416 146 836 547 142 4,0.009 092 974 268 256 816)\mathrm{Around}(-0.416\,146\,836\,547\,142\,4, 0.009\,092\,974\,268\,256\,816)

cos⁡(∞)\cos(\infty) is a type error at boxing, as for Sin; Wolfram gives the oscillation range [−1,1][-1, 1]

live ↗

An imaginary argument rewrites to Cosh: cos⁡(ix)=cosh⁡x\cos(ix) = \cosh x

live ↗
Incos⁡(ix)\cos(i x)Outcosh⁡(x)\cosh(x)

Evenness drops the sign of a symbolic argument: cos⁡(−x)=cos⁡x\cos(-x) = \cos x

live ↗
Incos⁡(−x)\cos(-x)Outcos⁡(x)\cos(x)

cos⁡(arccos⁡x)=x\cos(\arccos x) = x for every xx

live ↗
Incos⁡(arccos⁡(x))\cos(\arccos(x))Outxx

cos⁡(arccos⁡(2))=2\cos(\arccos(2)) = 2, even past [−1,1][-1, 1]

live ↗
Incos⁡(arccos⁡(2))\cos(\arccos(2))Out22

cos⁡(arcsin⁡x)=1−x2\cos(\arcsin x) = \sqrt{1 - x^2}

live ↗
Incos⁡(arcsin⁡(x))\cos(\arcsin(x))Out1−x2\sqrt{1-x^2}

cos⁡(arctan⁡x)=11+x2\cos(\arctan x) = \frac{1}{\sqrt{1 + x^2}}

live ↗
Incos⁡(arctan⁡(x))\cos(\arctan(x))Out1x2+1\sqrt{\frac{1}{x^2+1}}

Derivative: −sin⁡x-\sin x

live ↗
Indcos⁡(x)dx\frac{\mathrm{d}\cos(x)}{\mathrm{d}x}Out−sin⁡(x)-\sin(x)

Antiderivative

live ↗
In∫ ⁣cos⁡(x) dx\int\!\cos(x)\, \mathrm{d}xOutsin⁡(x)\sin(x)

Taylor series about 0 -- only even powers appear

live ↗
InSeries⁡(cos⁡(x),x,0,6)\operatorname{Series}(\cos(x), x, 0, 6)Out1−x22+x424−x6720+O(x8)1-\frac{x^2}{2}+\frac{x^4}{24}-\frac{x^6}{720}+O\left(x^8\right)

To 30 significant digits, every one correctly rounded

live ↗
InN(cos⁡(1),30)N(\cos(1), 30)Out0.540 302 305 868 139 717 400 936 607 4430.540\,302\,305\,868\,139\,717\,400\,936\,607\,443

1010010^{100} has 101 digits; the exact argument is still reduced modulo 2π2\pi before Cos sees it, not rounded to working precision first

live ↗
InN(cos⁡(10100))N(\cos(10^{100}))Out−0.928 081 905 074 655 343 456-0.928\,081\,905\,074\,655\,343\,456

Known value · Wolfram 15.0.0 Cos

Fifty digits of a rational argument

live ↗
InN(cos⁡(65),50)N(\cos(\frac{6}{5}), 50)Out0.362 357 754 476 673 577 638 373 355 623 076 020 339 947 785 576 650.362\,357\,754\,476\,673\,577\,638\,373\,355\,623\,076\,020\,339\,947\,785\,576\,65

Defined everywhere

live ↗
InFunctionDomain(cos⁡(x),x)\mathrm{FunctionDomain}(\cos(x), x)OutTrue\mathrm{True}

The range is [−1,1][-1, 1]

live ↗
InFunctionRange(cos⁡(x),x,y)\mathrm{FunctionRange}(\cos(x), x, y)Out−1≤y≤1-1≤y≤1

The period is 2π2\pi

live ↗
InFunctionPeriod(cos⁡(x),x)\mathrm{FunctionPeriod}(\cos(x), x)Out2π2π

Analytic on the whole line

live ↗
InFunctionAnalytic(cos⁡(x),x)\mathrm{FunctionAnalytic}(\cos(x), x)OutTrue\mathrm{True}

Not injective, since it repeats

live ↗
InFunctionInjective(cos⁡(x),x)\mathrm{FunctionInjective}(\cos(x), x)OutFalse\mathrm{False}

Not surjective onto the reals

live ↗
InFunctionSurjective(cos⁡(x),x)\mathrm{FunctionSurjective}(\cos(x), x)OutFalse\mathrm{False}

No singularities

live ↗
InFunctionSingularities(cos⁡(x),x)\mathrm{FunctionSingularities}(\cos(x), x)OutFalse\mathrm{False}

No discontinuities

live ↗
InFunctionDiscontinuities(cos⁡(x),x)\mathrm{FunctionDiscontinuities}(\cos(x), x)OutFalse\mathrm{False}

A matrix function with exact entries

live ↗
InMatrixFunction(_1⁡↦cos⁡(_1⁡),[[5π6,0],[3π2,−π2]])\mathrm{MatrixFunction}(\operatorname{\_1}↦\cos(\operatorname{\_1}), \bigl\lbrack\bigl\lbrack\frac{5π}{6}, 0\bigr\rbrack, \bigl\lbrack\frac{3π}{2}, -\frac{π}{2}\bigr\rbrack\bigr\rbrack)Out[[−31/22,0],[−9316,0]]\bigl\lbrack\bigl\lbrack-\frac{3^{1/2}}{2}, 0\bigr\rbrack, \bigl\lbrack-\frac{9\sqrt{3}}{16}, 0\bigr\rbrack\bigr\rbrack
live ↗
InAssuming(m∈Z,Refine(cos⁡(π(12+m))))\mathrm{Assuming}(m∈ℤ, \mathrm{Refine}(\cos(π(\frac{1}{2}+m))))Outcos⁡(π(m+12))\cos(π(m+\frac{1}{2}))
live ↗
InAssuming(m∈Z,FullSimplify(Refine(cos⁡(πm))))\mathrm{Assuming}(m∈ℤ, \mathrm{FullSimplify}(\mathrm{Refine}(\cos(πm))))Out(−1)m(-1)^{m}
Applications #

Threads element-wise over a list

live ↗
Incos⁡([0,π2,π])\cos(\bigl\lbrack0, \frac{π}{2}, π\bigr\rbrack)Out[1,0,−1]\bigl\lbrack1, 0, -1\bigr\rbrack
Properties #

Even function: cos⁡(−x)=cos⁡(x)\cos(-x) = \cos(x)

live ↗
Incos⁡(−π3)=cos⁡(π3)\cos(-\frac{π}{3})=\cos(\frac{π}{3})OutTrue\mathrm{True}

Co-function identity: cos⁡x=sin⁡(π/2−x)\cos x = \sin(\pi/2 - x)

live ↗
Incos⁡(π6)=sin⁡(π2−π6)\cos(\frac{π}{6})=\sin(\frac{π}{2}-\frac{π}{6})OutTrue\mathrm{True}

Double-angle formula: cos⁡2x=cos⁡2x−sin⁡2x\cos 2x = \cos^2 x - \sin^2 x

live ↗
InTrigExpand(cos⁡(2x))\mathrm{TrigExpand}(\cos(2x))Outcos⁡(x)2−sin⁡(x)2\cos(x)^2-\sin(x)^2

Angle-addition formula

live ↗
InTrigExpand(cos⁡(x+y))\mathrm{TrigExpand}(\cos(x+y))Outcos⁡(x)cos⁡(y)−sin⁡(x)sin⁡(y)\cos(x)\cos(y)-\sin(x)\sin(y)

Power reduction: cos⁡2x=1+cos⁡2x2\cos^2 x = \frac{1 + \cos 2x}{2}

live ↗
InTrigReduce(cos⁡(x)2)\mathrm{TrigReduce}(\cos(x)^2)Outcos⁡(2x)2+12\frac{\cos(2x)}{2}+\frac{1}{2}

Euler's formula: cos⁡x=eix+e−ix2\cos x = \frac{e^{ix} + e^{-ix}}{2}

live ↗
InTrigToExp(cos⁡(x))\mathrm{TrigToExp}(\cos(x))Out12(eix+e−ix)\frac{1}{2}(e^{i x}+e^{-i x})

cos⁡(3π/10)\cos(3\pi/10) in nested-radical form

live ↗
Incos⁡(3π10)\cos(\frac{3π}{10})Out1425−5\frac{1}{4}\sqrt{2}\sqrt{5-\sqrt{5}}

Known value · Wolfram MathematicalFunctionData, Cos

live ↗
In∫0π2 ⁣cos⁡(t)2 dt\int_{0}^{\frac{π}{2}}\!\cos(t)^2\, \mathrm{d}tOutπ4\frac{π}{4}

Known value · Wolfram MathematicalFunctionData, Cos, Wallis' cosine formula

live ↗
In∏k=12(54−cos⁡(14π(2k−1)))\prod_{k=1}^2(\frac{5}{4}-\cos(\frac{1}{4}π(2k-1)))Out116(5−22)(5+22)\frac{1}{16}(5-2\sqrt{2})(5+2\sqrt{2})

Known value · Wolfram MathematicalFunctionData, Cos, Cotes circle property

live ↗
In∫0π2 ⁣cos⁡(t)3 dt\int_{0}^{\frac{π}{2}}\!\cos(t)^3\, \mathrm{d}tOut23\frac{2}{3}

Known value · Wolfram MathematicalFunctionData, Cos, Wallis' cosine formula

live ↗
InN((isin⁡(1/2)+cos⁡(1/2))2)N((i\sin(1/2)+\cos(1/2))^2)Out0.540 302 305 868 139 717 401+0.841 470 984 807 896 506 652i0.540\,302\,305\,868\,139\,717\,401+0.841\,470\,984\,807\,896\,506\,652i

Known value · Wolfram MathematicalFunctionData, Cos, de Moivre's formula

live ↗
In∏k=13(54−cos⁡(16π(2k−1)))\prod_{k=1}^3(\frac{5}{4}-\cos(\frac{1}{6}π(2k-1)))Out164×5(5−23)(5+23)\frac{1}{64}×5(5-2\sqrt{3})(5+2\sqrt{3})

Known value · Wolfram MathematicalFunctionData, Cos, Cotes circle property

live ↗
InN((isin⁡(1/2)+cos⁡(1/2))2)N((i\sin(1/2)+\cos(1/2))^2)Out0.540 302 305 868 139 717 401+0.841 470 984 807 896 506 652i0.540\,302\,305\,868\,139\,717\,401+0.841\,470\,984\,807\,896\,506\,652i

Known value · Wolfram MathematicalFunctionData, Cos, de Moivre's formula

live ↗
InN((cos⁡(1/2)−isin⁡(1/2))2)N((\cos(1/2)-i\sin(1/2))^2)Out0.540 302 305 868 139 717 401−0.841 470 984 807 896 506 652i0.540\,302\,305\,868\,139\,717\,401-0.841\,470\,984\,807\,896\,506\,652i

Known value · Wolfram MathematicalFunctionData, Cos, de Moivre's formula

live ↗
InN(∫−π2π2 ⁣e(−(1/2)i)tcos⁡(t) dt)N(\int_{-\frac{π}{2}}^{\frac{π}{2}}\!e^{(-(1/2)i)t}\sqrt{\cos(t)}\, \mathrm{d}t)Out2.221441469079182±9.992016286406154e−142.221441469079182±9.992016286406154e-14

Known value · Wolfram MathematicalFunctionData, Cos, Cauchy's cosine integral formula

live ↗
InN(∫012 ⁣cos⁡(t/2)cos⁡(t)−cos⁡(1/2) dt)N(\int_{0}^{\frac{1}{2}}\!\frac{\cos(t/2)}{\sqrt{\cos(t)-\cos(1/2)}}\, \mathrm{d}t)Out2.2214414411509225±0.00070248146427238112.2214414411509225±0.0007024814642723811

Known value · Wolfram MathematicalFunctionData, Cos, Mehler-Dirichlet integral

live ↗
InN(−2cos⁡(1)cos⁡(1/2)2+2cos⁡(1/2)2+cos⁡(1)2)N(-2\cos(1)\cos(1/2)^2+2\cos(1/2)^2+\cos(1)^2)Out0.999 999 999 999 999 999 999 255 914 766 779 997 522 60.999\,999\,999\,999\,999\,999\,999\,255\,914\,766\,779\,997\,522\,6

Known value · Wolfram MathematicalFunctionData, Cos, FunctionalEquations

live ↗
InN(cos⁡(1/2+π/2)2)N(\cos(1/2+π/2)^2)Out0.229 848 847 065 930 141 2990.229\,848\,847\,065\,930\,141\,299

Known value · Wolfram MathematicalFunctionData, Cos, FunctionalEquations

live ↗
InN((isin⁡(12)+cos⁡(12))3)N((i\sin(\frac{1}{2})+\cos(\frac{1}{2}))^3)Out0.070 737 201 667 702 910 088 5+0.997 494 986 604 054 430 941i0.070\,737\,201\,667\,702\,910\,088\,5+0.997\,494\,986\,604\,054\,430\,941i

Known value · Wolfram MathematicalFunctionData, Cos, de Moivre's formula

Possible issues #

As with Sin, a non-special numeric argument stays symbolic unless it's already a float

live ↗
Incos⁡(2)\cos(2)Outcos⁡(2)\cos(2)

π/24\pi/24 is past the automatic special-angle table (as in Wolfram), so this stays symbolic

live ↗
Incos⁡(π24)\cos(\frac{π}{24})Outcos⁡(π24)\cos(\frac{π}{24})

Cos(ComplexInfinity) is Indeterminate, for the same unbounded growth off the real axis as Sin

live ↗

Known value · DLMF 4.28.9

Neat examples #
About
Examples75
Checked againstWolfram Language 66 agree9 differSageMath 57 agree1 differ3 errorSymPy 54 agree3 differmpmath 37 agree2 differOscar 16 agreeJulia 39 agree1 errorRust 24 agree10 differ1 error
CrosswalkWikipediaMathWorldWikidataDLMFFungrimFungrim entry ×59Wolfram LanguageSageMathSymPympmathOscarJuliaRust

Implementation

mappedoscarpackages/oracle/src/mappings.ts
mappedwolframpackages/oracle/src/mappings.ts
mappedsympypackages/oracle/src/mappings.ts
mappedmpmathpackages/oracle/src/mappings.ts
mappedsagepackages/oracle/src/mappings.ts
mappedrustpackages/oracle/src/mappings.ts
mappedjuliapackages/oracle/src/mappings.ts

See also: Sin, Tan, Sec, Arccos