IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: 1.0.0b1
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

exp_approx_f32

exp_approx_f32[W: Int](x: SIMD[DType.float32, W]) -> SIMD[DType.float32, W]

Computes a fast approximate e^x for SIMD vectors of 32-bit floats using the base-2 approximation as a backend.

This function converts the natural exponential input z to base-2 space using the identity e^z = 2^(z * log2(e)), then calls the internal _exp2_approx_f32 function to evaluate the FA-4 polynomial approximation of 2^x. It is optimized for small SIMD widths and is fully inlined for high performance.

Constraints:

The input must be a SIMD vector of 32-bit floating-point values.

Parameters:

  • W (Int): The width of the SIMD vector.

Args:

Returns:

SIMD[DType.float32, W]: A SIMD vector containing the approximate value of e^x.