Built-in functions
Every transcendental the language offers, in one place.
This worksheet exists for the golden-file suite more than for the reader. The claim the whole design rests on is that transcendentals come from a libm compiled into the artifact rather than the host's, so that two machines agree to the last bit. Nothing else under examples/ calls one, so without this file the native-versus-WASM comparison in phase 7 would pass without testing the thing it exists to test.
=
=
Trigonometric. Arguments are dimensionless; rad, ° and % all qualify.
===
===
===
==
Inverses, including the two-argument form.
==
==
==
==
Hyperbolic.
===
===
===
Exponential and logarithmic.
===
===
===
===
Numeric. sqrt halves the dimension, so it is exercised on a real area.
=
===
===
===
===
===
The reciprocal three, written as reciprocals so they cannot drift from the three they come from.
===
===
===
The inverse hyperbolics.
===
===
==
A logarithm always states its base; log10, log2 and ln are the shorthands.
===
Numeric, on quantities. mod keeps the sign of its dividend and nthroot divides the dimension, which is what rational dimension exponents are for.
==
==
==
==
Collections. product multiplies dimensions where sum requires them to agree; the rest need one dimension across the collection.
=
==
===
===
===[0.001 m, 0.003 m, 0.005 m, 0.009 m]
===[0.003 m, 0.009 m, 0.001 m, 0.005 m]
Matrices.
=
===
===[[-1, 2], [0, -1]]
The identity that would catch a mismatched pair.
===