math(3)
๐ math(3) ๐
ok bestie we're doing math(3) today โ yes it's from the Erlang standard library (stdlib), yes it's literally just vibes and trigonometry, and yes i'm gonna hold your hand through every single function. no cap. ๐ฆ
๐ธ NAME ๐ธ
math โ mathematical functions, periodt. โจ
๐ DESCRIPTION ๐
so basically this module is the plug ๐ โ it gives you an interface to a whole bunch of mathematical functions. that's it. that's the description. iconic of it honestly.
๐ง FUNCTIONS ๐ง
acos(X) -> float() when X :: number()
Returns the arc cosine of X in radians. ๐
Examples
1> math:acos(1.0).
0.0
acosh(X) -> float() when X :: number()
Returns the inverse hyperbolic cosine of X.
Examples
1> math:acosh(1.0).
0.0
asin(X) -> float() when X :: number()
Returns the arc sine of X in radians.
Examples
1> math:asin(0.0).
0.0
asinh(X) -> float() when X :: number()
Returns the inverse hyperbolic sine of X.
Examples
1> math:asinh(0.0).
0.0
atan(X) -> float() when X :: number()
Returns the arc tangent of X in radians.
Examples
1> math:atan(0.0).
0.0
atan2(Y, X) -> float() when Y :: number(), X :: number()
Returns the arc tangent of Y/X in radians โ BUT โจ it uses the signs of both arguments to figure out which quadrant the return value lives in. so like, it knows more than just a plain ratio would. main character behavior fr fr.
Examples
1> math:atan2(0.0, -10.0).
3.141592653589793
atanh(X) -> float() when X :: number()
Returns the inverse hyperbolic tangent of X.
Examples
1> math:atanh(0.0).
0.0
ceil(X) -> float() when X :: number()
Returns the ceiling of X โ rounds it UP to the next whole vibe. ๐
Examples
1> math:ceil(7.5).
8.0
2> math:ceil(-5.5).
-5.0
3> math:ceil(1.0).
1.0
cos(X) -> float() when X :: number()
Returns the cosine of X in radians.
Examples
1> math:cos(0.0).
1.0
cosh(X) -> float() when X :: number()
Returns the hyperbolic cosine of X.
Examples
1> math:cosh(0.0).
1.0
erf(X) -> float() when X :: number()
Returns the error function of X. ๐งฎ
See Error function (Wikipedia).
Examples
1> math:erf(0.0).
0.0
2> math:erf(10.0).
1.0
erfc(X) -> float() when X :: number()
Returns 1.0 - erf(X), and it's computed using methods that avoid cancellation for large X ๐โจ (so like, it doesn't fumble the precision when X gets big โ smart queen behavior).
Examples
1> math:erfc(0.0).
1.0
exp(X) -> float() when X :: number()
Returns e raised to the power of X. ๐ฑ
Examples
1> math:exp(0).
1.0
2> trunc(100 * math:exp(1)).
271
floor(X) -> float() when X :: number()
Returns the floor of X โ rounds it DOWN to the floor, respectfully. ๐
Examples
1> math:floor(9.1).
9.0
2> math:floor(-1.5).
-2.0
3> math:floor(1.0).
1.0
fmod(X, Y) -> float() when X :: number(), Y :: number()
Returns the floating point remainder of X divided by Y. ๐
Examples
1> math:fmod(10.5, 8.0).
2.5
log(X) -> float() when X :: number()
Returns the natural logarithm of X.
Examples
1> math:log(1.0).
0.0
2> math:log(2.718281828459045).
1.0
log10(X) -> float() when X :: number()
Returns the logarithm of X to base 10.
Examples
1> math:log10(1.0).
0.0
2> math:log10(10.0).
1.0
3> math:log10(100).
2.0
log2(X) -> float() when X :: number()
Returns the logarithm of X to base 2. (hi computer science besties ๐ซถ)
Examples
1> math:log2(1.0).
0.0
2> math:log2(2.0).
1.0
3> math:log2(64).
6.0
pi() -> float()
Returns the ratio of a circle's circumference to its diameter. ๐ฅง the legend herself.
Examples
1> math:pi().
3.141592653589793
pow(X, N) -> float() when X :: number(), N :: number()
Raise X to the power N. ๐ฅ
Examples
1> math:pow(2, 6).
64.0
2> math:pow(10.0, 3.0).
1000.0
sin(X) -> float() when X :: number()
Returns the sine of X in radians.
Examples
1> math:sin(0.0).
0.0
sinh(X) -> float() when X :: number()
Returns the hyperbolic sine of X.
Examples
1> math:sinh(0.0).
0.0
sqrt(X) -> float() when X :: number()
Returns the non-negative square root of X. ๐ธ (non-negative!! she will not hand you a negative root, don't even ask)
Examples
1> math:sqrt(2).
1.4142135623730951
2> math:sqrt(100.0).
10.0
tan(X) -> float() when X :: number()
Returns the tangent of X in radians.
Examples
1> math:tan(0.0).
0.0
tanh(X) -> float() when X :: number()
Returns the hyperbolic tangent of X.
Examples
1> math:tan(0.0).
0.0
not me noticing thetanhexample literally callsmath:tan(0.0)๐ i'm not touching it, i'm just saying. the docs said what they said, and i am a faithful messenger. ๐
tau() -> float()
Returns the ratio of a circle's circumference to its radius. she's 2 * pi but make it โจaestheticโจ
This constant is equivalent to a full turn when described in radians. ๐
Examples
1> math:tau().
6.283185307179586
2> math:tau() == 2 * math:pi().
true
โญ quick vibe check reminder: every one of these bad boys takesnumber()and hands you back afloat(), exceptpi()andtau()which take nothing at all and just hand you afloat(). zero arguments, all attitude. ๐
That's the whole page bestie!! ๐๐ Go forth and math:sqrt(100.0) with confidence. This lil masterpiece comes courtesy of Ericsson AB, from stdlib version 8.0.4 โ love that for them, mwah, bye! ๐๐ฆโจ
๐ฆ where this page comes from
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 ยท Apache-2.0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms