math(3erl)

πŸ’– NAME πŸ’–

math β€” Mathematical functions. Yes bestie, that's the whole name, she's iconic like that. ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so real talk: this module is basically a little doorway into a whole pile of mathematical functions. It provides an interface to a number of mathematical functions. That's it, that's the gig. πŸŽ€

πŸ™ˆ Note (read this one, fr fr)

Not all functions are provided on all platforms. In particular, the erf/1 and erfc/1 functions are not provided on Windows. So if you're on Windows and those two are giving "who is she" energy β€” that's why. 😭


✨ EXPORTS ✨

Okay so this next bunch all share the same glow-up: they're a collection of mathematical functions that return floats, and the arguments are numbers. Every single one of them. No cap. 🫢

  • acos(X) -> float() πŸ’…
  • acosh(X) -> float() πŸ’…
  • asin(X) -> float() πŸ’…
  • asinh(X) -> float() πŸ’…
  • atan(X) -> float() πŸ’…
  • atan2(Y, X) -> float() πŸ’…
  • atanh(X) -> float() πŸ’…
  • ceil(X) -> float() πŸ’…
  • cos(X) -> float() πŸ’…
  • cosh(X) -> float() πŸ’…
  • exp(X) -> float() πŸ’…
  • floor(X) -> float() πŸ’…
  • fmod(X, Y) -> float() πŸ’…
  • log(X) -> float() πŸ’…
  • log10(X) -> float() πŸ’…
  • log2(X) -> float() πŸ’…
  • pow(X, Y) -> float() πŸ’…
  • sin(X) -> float() πŸ’…
  • sinh(X) -> float() πŸ’…
  • sqrt(X) -> float() πŸ’…
  • tan(X) -> float() πŸ’…
  • tanh(X) -> float() πŸ’…

Types for the whole squad above:

Y = X = number()

A collection of mathematical functions that return floats. Arguments are numbers. Periodt. ✨


🌸 erf(X) -> float()

Types:

X = number()

Returns the error function of X, where:

erf(X) = 2/sqrt(pi)*integral from 0 to X of exp(-t*t) dt.

She's math. She's mysterious. Copy the formula exactly, bestie, don't improvise. πŸ’œ


πŸ“ erfc(X) -> float()

Types:

X = number()

So erfc(X) returns 1.0 - erf(X), and the way it's computed uses methods that avoid cancellation for large X. Which is lowkey the whole point β€” big X energy handled gracefully. πŸ‘‘


⭐ pi() -> float()

A useful number. That's literally the documentation. A useful number. And honestly? She ate. πŸ₯§


πŸ’€ LIMITATIONS πŸ’€

As these are the C library, the same limitations apply. So whatever the C library is going through, we're going through it together. No extra promises, no cap. 🫢


Quick vibe check πŸŽ€: every function up there returns a float(), the args are number(), and the shared description applies to that whole big list β€” don't forget the Windows situation with erf/1 and erfc/1. That's the tea. β˜•

And that's the page, bestie! This whole thing is Ericsson AB's work β€” stdlib version 4.3.1.3, and it's the math page from the Erlang Module Definition set, aka math(3erl). Go be mathematically iconic. πŸ’–βœ¨πŸ¦‹πŸŒΈπŸŽ€

πŸ“¦ where this page comes from