Elementary functions¶
Every elementary function other than \(\exp\) and \(\log\) is a conservative definition (the kernel's Theorem M-5): on finite arguments, an explicit formula in \(\exp\), \(\log\), and \(\sqrt{}\); at infinity, the ray-limit principle (Definition E-4); at the exceptional points specified below, an explicit value. Nothing here is an axiom.
Every number in the tables of this page is produced by
tests/scalar_tests/reference/elementary_reference.py (mpmath at 60 digits, and twice
as many digits as the radius at infinity), which computes each function
from the formula below and never from mpmath's own inverse functions;
its output is kept in tests/scalar_tests/reference/elementary_reference.txt.
Definitions¶
Definition F-1 (formulas on finite arguments).
| Function | Formula |
|---|---|
| \(\sin z\), \(\cos z\) | \(\dfrac{e^{iz} - e^{-iz}}{2i}\), \(\quad \dfrac{e^{iz} + e^{-iz}}{2}\) |
| \(\tan z\), \(\cot z\), \(\sec z\), \(\csc z\) | \(\sin z / \cos z\), \(\cos z / \sin z\), \(1 / \cos z\), \(1 / \sin z\) |
| \(\sinh z\), \(\cosh z\) | \(\dfrac{e^{z} - e^{-z}}{2}\), \(\quad \dfrac{e^{z} + e^{-z}}{2}\) |
| \(\tanh z\), \(\coth z\), \(\operatorname{sech} z\), \(\operatorname{csch} z\) | \(\sinh z / \cosh z\), \(\cosh z / \sinh z\), \(1/\cosh z\), \(1/\sinh z\) |
| \(\arcsin z\) | \(-i \log\!\big(iz + \sqrt{1 - z^2}\big)\) |
| \(\arccos z\) | \(\pi/2 - \arcsin z\) |
| \(\arctan z\) | \(\tfrac{i}{2}\big(\log(1 - iz) - \log(1 + iz)\big)\) |
| \(\operatorname{arccot} z\) | \(\arctan(1/z)\); exception \(\operatorname{arccot} 0 = \pi/2\) |
| \(\operatorname{arcsec} z\), \(\operatorname{arccsc} z\) | \(\arccos(1/z)\), \(\arcsin(1/z)\) |
| \(\operatorname{arcsinh} z\) | \(\log\!\big(z + \sqrt{z^2 + 1}\big)\) |
| \(\operatorname{arccosh} z\) | \(\log\!\big(z + \sqrt{z + 1}\,\sqrt{z - 1}\big)\) |
| \(\operatorname{arctanh} z\) | \(\tfrac12\big(\log(1 + z) - \log(1 - z)\big)\) |
| \(\operatorname{arccoth} z\) | \(\operatorname{arctanh}(1/z)\); exception \(\operatorname{arccoth} 0 = i\pi/2\) |
| \(\operatorname{arcsech} z\), \(\operatorname{arccsch} z\) | \(\operatorname{arccosh}(1/z)\), \(\operatorname{arcsinh}(1/z)\) |
These are the definitions of Abramowitz and Stegun and of the DLMF (§§4.23, 4.37), in the form Corless, Jeffrey, Watt, and Davenport [2000] recommend for computer algebra. The arithmetic is \(\hat S\)'s, so a formula evaluated where a denominator vanishes or an argument is infinite takes the carrier's values: at \(z = 0\), \(1/z = C_\infty\), and \(\operatorname{arcsec} 0 = \arccos(C_\infty)\) is read from the table at infinity below. The two exceptions explicitly assign values where that reading gives \(I\).
Branch cuts and their closure¶
Proposition F-1 (cuts and closure). Each inverse function is analytic off the cuts below, and on each cut its value equals its limit from the side listed. For \(\log\), \(\sqrt{}\), and the functions defined directly from them, this is counterclockwise continuity: the side reached by turning counterclockwise around the cut's branch point [Corless, Davenport, Jeffrey and Watt 2000]. The functions defined through \(1/z\) (arccot, arcsec, arccsc, arccoth, arcsech, arccsch) inherit their closure from the function they compose with, and \(z \mapsto 1/z\) exchanges the upper and lower half-planes, so, for instance, \(\operatorname{arcsech}\) is continuous from below on all of \((-\infty, 0)\) because \(\operatorname{arccosh}\) is continuous from above on \((-\infty, 1)\).
| Function | Cut | Point | Value | Agrees with |
|---|---|---|---|---|
| \(\log\) | \((-\infty, 0]\) | \(-2\) | \(\ln 2 + i\pi\) | above |
| \(\sqrt{}\) | \((-\infty, 0)\) | \(-2\) | \(i\sqrt 2\) | above |
| \(\arcsin\) | \((1, \infty)\) | \(2\) | \(\pi/2 - i \ln(2 + \sqrt 3)\) | below |
| \((-\infty, -1)\) | \(-2\) | \(-\pi/2 + i \ln(2 + \sqrt 3)\) | above | |
| \(\arccos\) | \((1, \infty)\) | \(2\) | \(i \ln(2 + \sqrt 3)\) | below |
| \((-\infty, -1)\) | \(-2\) | \(\pi - i \ln(2 + \sqrt 3)\) | above | |
| \(\arctan\) | \((i, i\infty)\) | \(2i\) | \(\pi/2 + \tfrac{i}{2}\ln 3\) | right |
| \((-i\infty, -i)\) | \(-2i\) | \(-\pi/2 - \tfrac{i}{2}\ln 3\) | left | |
| \(\operatorname{arccot}\) | \((0, i)\) | \(i/2\) | \(-\pi/2 - \tfrac{i}{2}\ln 3\) | left |
| \((-i, 0)\) | \(-i/2\) | \(\pi/2 + \tfrac{i}{2}\ln 3\) | right | |
| \(\operatorname{arcsec}\) | \((0, 1)\) | \(1/2\) | \(i \ln(2 + \sqrt 3)\) | above |
| \((-1, 0)\) | \(-1/2\) | \(\pi - i \ln(2 + \sqrt 3)\) | below | |
| \(\operatorname{arccsc}\) | \((0, 1)\) | \(1/2\) | \(\pi/2 - i \ln(2 + \sqrt 3)\) | above |
| \((-1, 0)\) | \(-1/2\) | \(-\pi/2 + i \ln(2 + \sqrt 3)\) | below | |
| \(\operatorname{arcsinh}\) | \((i, i\infty)\) | \(2i\) | \(\ln(2 + \sqrt 3) + i\pi/2\) | right |
| \((-i\infty, -i)\) | \(-2i\) | \(-\ln(2 + \sqrt 3) - i\pi/2\) | left | |
| \(\operatorname{arccosh}\) | \((-\infty, 1)\) | \(1/2\) | \(i\pi/3\) | above |
| \(-1/2\) | \(2i\pi/3\) | above | ||
| \(-2\) | \(\ln(2 + \sqrt 3) + i\pi\) | above | ||
| \(\operatorname{arctanh}\) | \((1, \infty)\) | \(2\) | \(\tfrac12 \ln 3 - i\pi/2\) | below |
| \((-\infty, -1)\) | \(-2\) | \(-\tfrac12 \ln 3 + i\pi/2\) | above | |
| \(\operatorname{arccoth}\) | \((0, 1)\) | \(1/2\) | \(\tfrac12 \ln 3 - i\pi/2\) | above |
| \((-1, 0)\) | \(-1/2\) | \(-\tfrac12 \ln 3 + i\pi/2\) | below | |
| \(\operatorname{arcsech}\) | \((1, \infty)\) | \(2\) | \(i\pi/3\) | below |
| \((-\infty, 0)\) | \(-1/2\) | \(\ln(2 + \sqrt 3) + i\pi\) | below | |
| \(-2\) | \(2i\pi/3\) | below | ||
| \(\operatorname{arccsch}\) | \((0, i)\) | \(i/2\) | \(-\ln(2 + \sqrt 3) - i\pi/2\) | left |
| \((-i, 0)\) | \(-i/2\) | \(\ln(2 + \sqrt 3) + i\pi/2\) | right |
Proof. In each formula, the value on a cut is determined by the closure of the inner \(\log\) or \(\sqrt{}\), whose argument crosses the negative real axis exactly as \(z\) crosses the outer cut, and which takes the value from above there (Definitions E-3 and W-4). Along one piece of a cut, the value is continuous with the same side throughout (the inner argument stays on the same side), so one point per piece decides; the reference script evaluates each function at the listed point and at that point displaced by \(\pm 10^{-30}\) across the cut, and reports which side it agrees with. The listed closed forms are those of the numeric values (\(1.31695789692482 = \ln(2 + \sqrt 3)\), \(0.549306144334055 = \tfrac12\ln 3\), \(1.0471975511966 = \pi/3\), \(2.0943951023932 = 2\pi/3\)). \(\square\)
Values at infinity¶
Proposition F-2 (values at infinity). By the ray-limit principle (Definition E-4), with \(\theta\) the direction, the values are:
| Function | \(\theta = 1\) | \(\theta = -1\) | \(\theta = i\) | \(\theta = -i\) | quadrant I | II | III | IV | \(C_\infty\) |
|---|---|---|---|---|---|---|---|---|---|
| \(\exp\) | \(\infty\) | \(0\) | \(I\) | \(I\) | \(C_\infty\) | \(0\) | \(0\) | \(C_\infty\) | \(I\) |
| \(\log\) | \(\infty\) | \(\infty\) | \(\infty\) | \(\infty\) | \(\infty\) | \(\infty\) | \(\infty\) | \(\infty\) | \(\infty\) |
| \(\sqrt{}\) | \(\infty\) | \(D(i)\) | \(D(e^{i\pi/4})\) | \(D(e^{-i\pi/4})\) | \(D(e^{i\phi/2})\) | \(D(e^{i\phi/2})\) | \(D(e^{i\phi/2})\) | \(D(e^{i\phi/2})\) | \(C_\infty\) |
| \(\sin\) | \(I\) | \(I\) | \(D(i)\) | \(D(-i)\) | \(C_\infty\) | \(C_\infty\) | \(C_\infty\) | \(C_\infty\) | \(I\) |
| \(\cos\) | \(I\) | \(I\) | \(\infty\) | \(\infty\) | \(C_\infty\) | \(C_\infty\) | \(C_\infty\) | \(C_\infty\) | \(I\) |
| \(\tan\) | \(I\) | \(I\) | \(i\) | \(-i\) | \(i\) | \(i\) | \(-i\) | \(-i\) | \(I\) |
| \(\cot\) | \(I\) | \(I\) | \(-i\) | \(i\) | \(-i\) | \(-i\) | \(i\) | \(i\) | \(I\) |
| \(\sec\), \(\csc\) | \(I\) | \(I\) | \(0\) | \(0\) | \(0\) | \(0\) | \(0\) | \(0\) | \(I\) |
| \(\sinh\) | \(\infty\) | \(-\infty\) | \(I\) | \(I\) | \(C_\infty\) | \(C_\infty\) | \(C_\infty\) | \(C_\infty\) | \(I\) |
| \(\cosh\) | \(\infty\) | \(\infty\) | \(I\) | \(I\) | \(C_\infty\) | \(C_\infty\) | \(C_\infty\) | \(C_\infty\) | \(I\) |
| \(\tanh\), \(\coth\) | \(1\) | \(-1\) | \(I\) | \(I\) | \(1\) | \(-1\) | \(-1\) | \(1\) | \(I\) |
| \(\operatorname{sech}\), \(\operatorname{csch}\) | \(0\) | \(0\) | \(I\) | \(I\) | \(0\) | \(0\) | \(0\) | \(0\) | \(I\) |
| \(\arcsin\) | \(D(-i)\) | \(D(i)\) | \(D(i)\) | \(D(-i)\) | \(D(i)\) | \(D(i)\) | \(D(-i)\) | \(D(-i)\) | \(C_\infty\) |
| \(\arccos\) | \(D(i)\) | \(D(-i)\) | \(D(-i)\) | \(D(i)\) | \(D(-i)\) | \(D(-i)\) | \(D(i)\) | \(D(i)\) | \(C_\infty\) |
| \(\arctan\) | \(\pi/2\) | \(-\pi/2\) | \(\pi/2\) | \(-\pi/2\) | \(\pi/2\) | \(-\pi/2\) | \(-\pi/2\) | \(\pi/2\) | \(I\) |
| \(\operatorname{arccot}\), \(\operatorname{arccsc}\), \(\operatorname{arccoth}\), \(\operatorname{arccsch}\) | \(0\) | \(0\) | \(0\) | \(0\) | \(0\) | \(0\) | \(0\) | \(0\) | \(0\) |
| \(\operatorname{arcsec}\) | \(\pi/2\) | \(\pi/2\) | \(\pi/2\) | \(\pi/2\) | \(\pi/2\) | \(\pi/2\) | \(\pi/2\) | \(\pi/2\) | \(\pi/2\) |
| \(\operatorname{arcsinh}\) | \(\infty\) | \(-\infty\) | \(\infty\) | \(-\infty\) | \(\infty\) | \(-\infty\) | \(-\infty\) | \(\infty\) | \(C_\infty\) |
| \(\operatorname{arccosh}\) | \(\infty\) | \(\infty\) | \(\infty\) | \(\infty\) | \(\infty\) | \(\infty\) | \(\infty\) | \(\infty\) | \(\infty\) |
| \(\operatorname{arctanh}\) | \(-i\pi/2\) | \(i\pi/2\) | \(i\pi/2\) | \(-i\pi/2\) | \(i\pi/2\) | \(i\pi/2\) | \(-i\pi/2\) | \(-i\pi/2\) | \(I\) |
| \(\operatorname{arcsech}\) | \(i\pi/2\) | \(i\pi/2\) | \(-i\pi/2\) | \(i\pi/2\) | \(-i\pi/2\) | \(-i\pi/2\) | \(i\pi/2\) | \(i\pi/2\) | \(I\) |
Here \(\infty = D(1)\) and \(-\infty = D(-1)\); "quadrant I" means every direction strictly inside it (the script samples \(e^{i\pi/4}\), and the asymptotics below show the value is the same throughout), and for \(\sqrt{}\) the direction is \(e^{i\phi/2}\) with \(\theta = e^{i\phi}\).
Proof. Each entry follows from the dominant term of the formula as \(r \to \infty\): for instance \(\tan(r\theta) \to i\) in the open upper half-plane because \(e^{-ir\theta}\) dominates both numerator and denominator; \(\arctan(r\theta) \to \pm\pi/2\) because \(\log(1 - ir\theta) - \log(1 + ir\theta) \to \log(-i\theta) - \log(i\theta)\), whose value \(\mp i\pi\) depends on the half-plane through the closure of \(\log\); \(\arcsin(r\theta) \sim \mp i \log(2r)\), with the sign fixed by which of \(iz \pm \sqrt{1 - z^2}\) survives. The reference script confirms every entry numerically, classifying the values at the radii \(10^{30 \cdot 2^k}\), \(k \le 4\). \(\square\)
The carrier contains no intervals. An oscillatory expression such as \(\sin(\infty)\) therefore has value \(I\) under the ray-limit rule, rather than a set of accumulation values. The behavior checklist records these choices.
Special values¶
Proposition F-3 (selected exact values). \(\sin(\pi/6) = \cos(\pi/3) = 1/2\), \(\tan(\pi/4) = 1\), \(\arcsin(\pm 1) = \pm\pi/2\), \(\arccos(1) = 0\), \(\arccos(-1) = \pi\), \(\arctan(1) = \pi/4\), \(\arctan(\pm i) = D(\pm i)\), \(\operatorname{arcsinh}(\pm i) = \pm i\pi/2\), \(\operatorname{arccosh}(1) = 0\), \(\operatorname{arccosh}(-1) = i\pi\), \(\operatorname{arccosh}(0) = i\pi/2\), \(\operatorname{arctanh}(\pm 1) = \pm\infty\), \(\operatorname{arcsech}(0) = \infty\), \(\operatorname{arcsec}(0) = \operatorname{arccsc}(0) = \operatorname{arccsch}(0) = C_\infty\).
Proof. From the formulas, with \(\log(0) = -\infty\) and the carrier's arithmetic; the reference script confirms the finite ones. \(\square\)
Special values are lemmas of the library; conversion never evaluates them (they are not literal operations).
Identities and their domains¶
Theorem F-4.
- For every finite \(z\): \(\sin^2 z + \cos^2 z = 1\), \(\cosh^2 z - \sinh^2 z = 1\), \(\sin(\arcsin z) = z\), \(\cos(\arccos z) = z\), \(\tan(\arctan z) = z\) for \(z \ne \pm i\). For finite \(z\), also \(\sinh(\operatorname{arcsinh}z)=z\) and \(\cosh(\operatorname{arccosh}z)=z\); and \(\tanh(\operatorname{arctanh}z)=z\) for \(z\ne\pm1\).
- \(\arcsin(\sin z) = z\) exactly when \(z\) lies in the range of \(\arcsin\): \(-\pi/2 < \mathrm{Re}\,z < \pi/2\), or \(\mathrm{Re}\,z = -\pi/2\) and \(\mathrm{Im}\,z \ge 0\), or \(\mathrm{Re}\,z = \pi/2\) and \(\mathrm{Im}\,z \le 0\).
- \(\arctan(\tan z) = z\) exactly when \(z\) lies in the range of \(\arctan\): \(-\pi/2 < \mathrm{Re}\,z < \pi/2\), or \(\mathrm{Re}\,z = \pi/2\) and \(\mathrm{Im}\,z > 0\), or \(\mathrm{Re}\,z = -\pi/2\) and \(\mathrm{Im}\,z < 0\).
Proof. (1) from the formulas and G7 by direct computation (for the inverse functions, exponentiating the logarithm). (2), (3): each inverse function is injective with the stated range (its values on the cuts give the boundary rays, by the closure of Proposition F-1), and the forward function is injective on that range, so the composite is the identity exactly there. \(\square\)
The reference script checks (2) and (3) at a point of each boundary ray, where the identity holds, and of the opposite ray, where it fails. On a boundary ray the inner value (\(\sin z\), \(\tan z\)) lies exactly on the inverse function's cut, so the script removes the rounding-level component that the inexact \(\pi/2\) introduces before applying the inverse; without that, the side of the cut would be decided by rounding.
Guards¶
Definition F-5 (the guard language). Guards of the profile are conjunctions and disjunctions of atoms of these forms, each a proposition of the profile: \(\mathrm{finite}(t)\); \(t \ne 0\); \(\mathrm{real}(t)\); \(\mathrm{integer}(t)\); \(s < t\) and \(s \le t\); \(\mathrm{re}(t) \bowtie c\) and \(\mathrm{im}(t) \bowtie c\) for a rational or \(\pi\)-multiple constant \(c\) and \(\bowtie \in \{<, \le, =\}\); the off-cut atoms \(\mathrm{offcut}_f(t)\), true when \(t\) is not on the cut of \(f\) (Proposition F-1); and \(K(t) = 0\), the unwinding number of Theorem E-2.
The generic guards, those that generic mode accepts, are the subset of finiteness and nonzero atoms (Definition X-6). Identities such as Theorem E-2(2), W-5(2), and F-4(2) need the other atoms, so in generic mode their guards are shown and not silently accepted; in strict mode every atom needs evidence. The numeric semantics decides each atom at an exact point when its sign is separated from the boundary (numeric semantics).
Real-domain laws¶
Theorem F-6 (on the reals). For real \(x\): \(\sin x\), \(\cos x\), \(\exp x\), \(\arctan x\), \(\sinh x\), \(\cosh x\), \(\tanh x\) are real; \(\lvert\sin x\rvert \le 1\), \(\lvert\cos x\rvert \le 1\); \(\exp x > 0\); \(-\pi/2 < \arctan x < \pi/2\); for \(\lvert x\rvert \le 1\), \(\arcsin x\) is real in \([-\pi/2, \pi/2]\); for \(x > 0\), \(\log x\) is real; \(\exp\), \(\log\) (on positives), \(\arctan\), \(\sinh\), \(\tanh\), and \(\arcsin\) (on \([-1, 1]\)) are strictly increasing.
Proof. From the formulas, the real-valued theory of the exponential, and Theorem E-2(5). \(\square\)
These, and the polynomial bounds of the form \(x - x^3/6 \le \sin x \le x\) for \(x \ge 0\) that MetiTarski's axioms state, are the laws engines over the reals rely on. The analytic model proves the named real-domain laws and \(3<\pi<4\) through the model bridges.
Kernel derivation of the axial table entries¶
The four valid directions 1, −1, i and −i are finite and nonzero by G2, G3 and finite-product cancellation. G5 distinguishes D(1) from D(−1). If an imaginary axis had the direction of a real axis, G1 would make i (or −i) a positive real multiple of a real value, contradicting G3's nonreality of i. If D(−i)=D(i), G1 would give −i=c·i for a positive real c; multiplication by inv(i) gives c=−1, contradicting positivity. Thus all four directions are distinct. G1 also excludes finiteness, Indeterminate and ComplexInfinity for each. Unfolding F-1 and applying the proved conditional branch laws now gives every axial entry of F-2, with its right-hand side generated from the committed reference. These are kernel proofs of the definitions' values; no sampled limit is used as evidence.
Algebraic proofs of the nonfinite table and poles¶
The axial and open-quadrant values use only the choice definitions, G1, G2 and G3; no analytic limit is supplied to the kernel as evidence. The table codes remain generated from the independent reference.
For coordinate uniqueness, suppose real a, b, u, v satisfy
a + i*b = u + i*v. Finite field cancellation gives
i*(b-v) = u-a. If b-v is nonzero, division expresses i as the
quotient of two reals, contradicting G3's not real(i). Hence b=v and
then a=u. The choice witnesses defining Re and Im therefore recover any
exhibited pair of real coordinates. The fraction normalizer checks each
algebraic rearrangement.
Use the four representative directions 1+i, -1+i, -1-i, 1-i.
G1 says that any finite nonzero witness for the same directed infinity is
a positive real multiple of the representative. Distribution and coordinate
uniqueness give its signed coordinates; G4 preserves their signs.
Each axis is excluded by its zero coordinate, which would contradict the
representative's corresponding coordinate. The finite, Indeterminate,
ComplexInfinity and axial branches of F-2 are thus excluded before selecting
the two sign branches. This also proves that the choice of witness cannot
change the selected quadrant value.
At zero, the reciprocal inverse-function definitions use inv(0) =
ComplexInfinity. The already proved values of arccos, arcsin, arccosh and
arcsinh there give arcsec(0), arccsc(0), arcsech(0) and arccsch(0).
For arctan(±i) and arctanh(±1), G3 reduces the logarithm arguments to 0
and 2. G7 gives log(0) = -Infinity and finiteness of log(2); G6 evaluates
the resulting difference. Multiplication by 1/2 or i/2 gives the stated
directed infinity, with G1 removing the positive factor 1/2.
The other selected F-3 values use the principal-root and analytic
bridge lemmas of the analytic library.
The recorded construction names the nine shared facts for each quadrant
before its 24 value theorems: the three classification facts, four axial
inequalities, and the two coordinate sign tests. Each is a Proven lemma
with a retained closed recipe. Value proofs cite those lemmas, so exporting
one value does not duplicate their full coordinate derivations. This is
proof sharing only; the F-2 equations and their premises are unchanged.