Rust f32::asinh

Percentage Accurate: 38.5% → 99.5%
Time: 8.8s
Alternatives: 16
Speedup: 3.8×

Specification

?
\[\begin{array}{l} \\ \sinh^{-1} x \end{array} \]
(FPCore (x) :precision binary32 (asinh x))
float code(float x) {
	return asinhf(x);
}
function code(x)
	return asinh(x)
end
function tmp = code(x)
	tmp = asinh(x);
end
\begin{array}{l}

\\
\sinh^{-1} x
\end{array}

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 16 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 38.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \end{array} \]
(FPCore (x)
 :precision binary32
 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
float code(float x) {
	return copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
}
function code(x)
	return copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x)
end
function tmp = code(x)
	tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0))))));
end
\begin{array}{l}

\\
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\end{array}

Alternative 1: 99.5% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\ t_1 := \left|x\right| + 1\\ \mathbf{if}\;t_0 \leq -0.20000000298023224:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \mathbf{elif}\;t_0 \leq 0.004999999888241291:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{fma}\left(0.5, \frac{{x}^{2}}{t_1}, \mathsf{log1p}\left(\left|x\right|\right)\right) + \left(\frac{3}{t_1} + \frac{3}{{t_1}^{2}}\right) \cdot \left(-0.041666666666666664 \cdot {x}^{4}\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
        (t_1 (+ (fabs x) 1.0)))
   (if (<= t_0 -0.20000000298023224)
     (copysign (log (+ (fabs x) (hypot 1.0 x))) x)
     (if (<= t_0 0.004999999888241291)
       (copysign
        (+
         (fma 0.5 (/ (pow x 2.0) t_1) (log1p (fabs x)))
         (*
          (+ (/ 3.0 t_1) (/ 3.0 (pow t_1 2.0)))
          (* -0.041666666666666664 (pow x 4.0))))
        x)
       (copysign (log (+ x (hypot 1.0 x))) x)))))
float code(float x) {
	float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
	float t_1 = fabsf(x) + 1.0f;
	float tmp;
	if (t_0 <= -0.20000000298023224f) {
		tmp = copysignf(logf((fabsf(x) + hypotf(1.0f, x))), x);
	} else if (t_0 <= 0.004999999888241291f) {
		tmp = copysignf((fmaf(0.5f, (powf(x, 2.0f) / t_1), log1pf(fabsf(x))) + (((3.0f / t_1) + (3.0f / powf(t_1, 2.0f))) * (-0.041666666666666664f * powf(x, 4.0f)))), x);
	} else {
		tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
	}
	return tmp;
}
function code(x)
	t_0 = copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x)
	t_1 = Float32(abs(x) + Float32(1.0))
	tmp = Float32(0.0)
	if (t_0 <= Float32(-0.20000000298023224))
		tmp = copysign(log(Float32(abs(x) + hypot(Float32(1.0), x))), x);
	elseif (t_0 <= Float32(0.004999999888241291))
		tmp = copysign(Float32(fma(Float32(0.5), Float32((x ^ Float32(2.0)) / t_1), log1p(abs(x))) + Float32(Float32(Float32(Float32(3.0) / t_1) + Float32(Float32(3.0) / (t_1 ^ Float32(2.0)))) * Float32(Float32(-0.041666666666666664) * (x ^ Float32(4.0))))), x);
	else
		tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x);
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
t_1 := \left|x\right| + 1\\
\mathbf{if}\;t_0 \leq -0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\

\mathbf{elif}\;t_0 \leq 0.004999999888241291:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{fma}\left(0.5, \frac{{x}^{2}}{t_1}, \mathsf{log1p}\left(\left|x\right|\right)\right) + \left(\frac{3}{t_1} + \frac{3}{{t_1}^{2}}\right) \cdot \left(-0.041666666666666664 \cdot {x}^{4}\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 2: 99.4% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\ \mathbf{if}\;t_0 \leq -0.20000000298023224:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \mathbf{elif}\;t_0 \leq 0.004999999888241291:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{fma}\left(\frac{{x}^{2}}{x + 1}, 0.5, \mathsf{log1p}\left(x\right)\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
   (if (<= t_0 -0.20000000298023224)
     (copysign (log (+ (fabs x) (hypot 1.0 x))) x)
     (if (<= t_0 0.004999999888241291)
       (copysign (fma (/ (pow x 2.0) (+ x 1.0)) 0.5 (log1p x)) x)
       (copysign (log (+ x (hypot 1.0 x))) x)))))
float code(float x) {
	float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
	float tmp;
	if (t_0 <= -0.20000000298023224f) {
		tmp = copysignf(logf((fabsf(x) + hypotf(1.0f, x))), x);
	} else if (t_0 <= 0.004999999888241291f) {
		tmp = copysignf(fmaf((powf(x, 2.0f) / (x + 1.0f)), 0.5f, log1pf(x)), x);
	} else {
		tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
	}
	return tmp;
}
function code(x)
	t_0 = copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x)
	tmp = Float32(0.0)
	if (t_0 <= Float32(-0.20000000298023224))
		tmp = copysign(log(Float32(abs(x) + hypot(Float32(1.0), x))), x);
	elseif (t_0 <= Float32(0.004999999888241291))
		tmp = copysign(fma(Float32((x ^ Float32(2.0)) / Float32(x + Float32(1.0))), Float32(0.5), log1p(x)), x);
	else
		tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x);
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t_0 \leq -0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\

\mathbf{elif}\;t_0 \leq 0.004999999888241291:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{fma}\left(\frac{{x}^{2}}{x + 1}, 0.5, \mathsf{log1p}\left(x\right)\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 3: 99.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\ \mathbf{if}\;t_0 \leq -0.004999999888241291:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \mathbf{elif}\;t_0 \leq 0.004999999888241291:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right|\right) + 0.5 \cdot \left(x \cdot \frac{x}{x + 1}\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
   (if (<= t_0 -0.004999999888241291)
     (copysign (log (+ (fabs x) (hypot 1.0 x))) x)
     (if (<= t_0 0.004999999888241291)
       (copysign (+ (log1p (fabs x)) (* 0.5 (* x (/ x (+ x 1.0))))) x)
       (copysign (log (+ x (hypot 1.0 x))) x)))))
float code(float x) {
	float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
	float tmp;
	if (t_0 <= -0.004999999888241291f) {
		tmp = copysignf(logf((fabsf(x) + hypotf(1.0f, x))), x);
	} else if (t_0 <= 0.004999999888241291f) {
		tmp = copysignf((log1pf(fabsf(x)) + (0.5f * (x * (x / (x + 1.0f))))), x);
	} else {
		tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
	}
	return tmp;
}
function code(x)
	t_0 = copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x)
	tmp = Float32(0.0)
	if (t_0 <= Float32(-0.004999999888241291))
		tmp = copysign(log(Float32(abs(x) + hypot(Float32(1.0), x))), x);
	elseif (t_0 <= Float32(0.004999999888241291))
		tmp = copysign(Float32(log1p(abs(x)) + Float32(Float32(0.5) * Float32(x * Float32(x / Float32(x + Float32(1.0)))))), x);
	else
		tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x);
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t_0 \leq -0.004999999888241291:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\

\mathbf{elif}\;t_0 \leq 0.004999999888241291:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right|\right) + 0.5 \cdot \left(x \cdot \frac{x}{x + 1}\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 4: 99.1% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -0.004999999888241291:\\ \;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \left(\frac{-1}{x - \mathsf{hypot}\left(1, x\right)}\right)\right), x\right)\\ \mathbf{elif}\;x \leq 0.004999999888241291:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right|\right) + 0.5 \cdot \left(x \cdot \frac{x}{x + 1}\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -0.004999999888241291)
   (copysign
    (* 0.3333333333333333 (* 3.0 (log (/ -1.0 (- x (hypot 1.0 x))))))
    x)
   (if (<= x 0.004999999888241291)
     (copysign (+ (log1p (fabs x)) (* 0.5 (* x (/ x (+ x 1.0))))) x)
     (copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
	float tmp;
	if (x <= -0.004999999888241291f) {
		tmp = copysignf((0.3333333333333333f * (3.0f * logf((-1.0f / (x - hypotf(1.0f, x)))))), x);
	} else if (x <= 0.004999999888241291f) {
		tmp = copysignf((log1pf(fabsf(x)) + (0.5f * (x * (x / (x + 1.0f))))), x);
	} else {
		tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-0.004999999888241291))
		tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(Float32(3.0) * log(Float32(Float32(-1.0) / Float32(x - hypot(Float32(1.0), x)))))), x);
	elseif (x <= Float32(0.004999999888241291))
		tmp = copysign(Float32(log1p(abs(x)) + Float32(Float32(0.5) * Float32(x * Float32(x / Float32(x + Float32(1.0)))))), x);
	else
		tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x);
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.004999999888241291:\\
\;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \left(\frac{-1}{x - \mathsf{hypot}\left(1, x\right)}\right)\right), x\right)\\

\mathbf{elif}\;x \leq 0.004999999888241291:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right|\right) + 0.5 \cdot \left(x \cdot \frac{x}{x + 1}\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 5: 98.7% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -0.20000000298023224:\\ \;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \left(\frac{-1}{x - \mathsf{hypot}\left(1, x\right)}\right)\right), x\right)\\ \mathbf{elif}\;x \leq 0.004999999888241291:\\ \;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(-0.5 \cdot {x}^{3} + x \cdot 3\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -0.20000000298023224)
   (copysign
    (* 0.3333333333333333 (* 3.0 (log (/ -1.0 (- x (hypot 1.0 x))))))
    x)
   (if (<= x 0.004999999888241291)
     (copysign (* 0.3333333333333333 (+ (* -0.5 (pow x 3.0)) (* x 3.0))) x)
     (copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
	float tmp;
	if (x <= -0.20000000298023224f) {
		tmp = copysignf((0.3333333333333333f * (3.0f * logf((-1.0f / (x - hypotf(1.0f, x)))))), x);
	} else if (x <= 0.004999999888241291f) {
		tmp = copysignf((0.3333333333333333f * ((-0.5f * powf(x, 3.0f)) + (x * 3.0f))), x);
	} else {
		tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-0.20000000298023224))
		tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(Float32(3.0) * log(Float32(Float32(-1.0) / Float32(x - hypot(Float32(1.0), x)))))), x);
	elseif (x <= Float32(0.004999999888241291))
		tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(Float32(Float32(-0.5) * (x ^ Float32(3.0))) + Float32(x * Float32(3.0)))), x);
	else
		tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(-0.20000000298023224))
		tmp = sign(x) * abs((single(0.3333333333333333) * (single(3.0) * log((single(-1.0) / (x - hypot(single(1.0), x)))))));
	elseif (x <= single(0.004999999888241291))
		tmp = sign(x) * abs((single(0.3333333333333333) * ((single(-0.5) * (x ^ single(3.0))) + (x * single(3.0)))));
	else
		tmp = sign(x) * abs(log((x + hypot(single(1.0), x))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \left(\frac{-1}{x - \mathsf{hypot}\left(1, x\right)}\right)\right), x\right)\\

\mathbf{elif}\;x \leq 0.004999999888241291:\\
\;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(-0.5 \cdot {x}^{3} + x \cdot 3\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 6: 98.5% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left|x\right| - x\right) + \frac{-0.5}{x}\right), x\right)\\ \mathbf{elif}\;x \leq 0.004999999888241291:\\ \;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(-0.5 \cdot {x}^{3} + x \cdot 3\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -2.0)
   (copysign (log (+ (- (fabs x) x) (/ -0.5 x))) x)
   (if (<= x 0.004999999888241291)
     (copysign (* 0.3333333333333333 (+ (* -0.5 (pow x 3.0)) (* x 3.0))) x)
     (copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
	float tmp;
	if (x <= -2.0f) {
		tmp = copysignf(logf(((fabsf(x) - x) + (-0.5f / x))), x);
	} else if (x <= 0.004999999888241291f) {
		tmp = copysignf((0.3333333333333333f * ((-0.5f * powf(x, 3.0f)) + (x * 3.0f))), x);
	} else {
		tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-2.0))
		tmp = copysign(log(Float32(Float32(abs(x) - x) + Float32(Float32(-0.5) / x))), x);
	elseif (x <= Float32(0.004999999888241291))
		tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(Float32(Float32(-0.5) * (x ^ Float32(3.0))) + Float32(x * Float32(3.0)))), x);
	else
		tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(-2.0))
		tmp = sign(x) * abs(log(((abs(x) - x) + (single(-0.5) / x))));
	elseif (x <= single(0.004999999888241291))
		tmp = sign(x) * abs((single(0.3333333333333333) * ((single(-0.5) * (x ^ single(3.0))) + (x * single(3.0)))));
	else
		tmp = sign(x) * abs(log((x + hypot(single(1.0), x))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left|x\right| - x\right) + \frac{-0.5}{x}\right), x\right)\\

\mathbf{elif}\;x \leq 0.004999999888241291:\\
\;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(-0.5 \cdot {x}^{3} + x \cdot 3\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 7: 98.1% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| - x\right), x\right)\\ \mathbf{elif}\;x \leq 0.004999999888241291:\\ \;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(-0.5 \cdot {x}^{3} + x \cdot 3\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -2.0)
   (copysign (log (- (fabs x) x)) x)
   (if (<= x 0.004999999888241291)
     (copysign (* 0.3333333333333333 (+ (* -0.5 (pow x 3.0)) (* x 3.0))) x)
     (copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
	float tmp;
	if (x <= -2.0f) {
		tmp = copysignf(logf((fabsf(x) - x)), x);
	} else if (x <= 0.004999999888241291f) {
		tmp = copysignf((0.3333333333333333f * ((-0.5f * powf(x, 3.0f)) + (x * 3.0f))), x);
	} else {
		tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-2.0))
		tmp = copysign(log(Float32(abs(x) - x)), x);
	elseif (x <= Float32(0.004999999888241291))
		tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(Float32(Float32(-0.5) * (x ^ Float32(3.0))) + Float32(x * Float32(3.0)))), x);
	else
		tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(-2.0))
		tmp = sign(x) * abs(log((abs(x) - x)));
	elseif (x <= single(0.004999999888241291))
		tmp = sign(x) * abs((single(0.3333333333333333) * ((single(-0.5) * (x ^ single(3.0))) + (x * single(3.0)))));
	else
		tmp = sign(x) * abs(log((x + hypot(single(1.0), x))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| - x\right), x\right)\\

\mathbf{elif}\;x \leq 0.004999999888241291:\\
\;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(-0.5 \cdot {x}^{3} + x \cdot 3\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 8: 96.8% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| - x\right), x\right)\\ \mathbf{elif}\;x \leq 0.004999999888241291:\\ \;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(-0.5 \cdot {x}^{3} + x \cdot 3\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \left(x \cdot 2 + 0.5 \cdot \frac{1}{x}\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -2.0)
   (copysign (log (- (fabs x) x)) x)
   (if (<= x 0.004999999888241291)
     (copysign (* 0.3333333333333333 (+ (* -0.5 (pow x 3.0)) (* x 3.0))) x)
     (copysign
      (* 0.3333333333333333 (* 3.0 (log (+ (* x 2.0) (* 0.5 (/ 1.0 x))))))
      x))))
float code(float x) {
	float tmp;
	if (x <= -2.0f) {
		tmp = copysignf(logf((fabsf(x) - x)), x);
	} else if (x <= 0.004999999888241291f) {
		tmp = copysignf((0.3333333333333333f * ((-0.5f * powf(x, 3.0f)) + (x * 3.0f))), x);
	} else {
		tmp = copysignf((0.3333333333333333f * (3.0f * logf(((x * 2.0f) + (0.5f * (1.0f / x)))))), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-2.0))
		tmp = copysign(log(Float32(abs(x) - x)), x);
	elseif (x <= Float32(0.004999999888241291))
		tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(Float32(Float32(-0.5) * (x ^ Float32(3.0))) + Float32(x * Float32(3.0)))), x);
	else
		tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(Float32(3.0) * log(Float32(Float32(x * Float32(2.0)) + Float32(Float32(0.5) * Float32(Float32(1.0) / x)))))), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(-2.0))
		tmp = sign(x) * abs(log((abs(x) - x)));
	elseif (x <= single(0.004999999888241291))
		tmp = sign(x) * abs((single(0.3333333333333333) * ((single(-0.5) * (x ^ single(3.0))) + (x * single(3.0)))));
	else
		tmp = sign(x) * abs((single(0.3333333333333333) * (single(3.0) * log(((x * single(2.0)) + (single(0.5) * (single(1.0) / x)))))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| - x\right), x\right)\\

\mathbf{elif}\;x \leq 0.004999999888241291:\\
\;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(-0.5 \cdot {x}^{3} + x \cdot 3\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \left(x \cdot 2 + 0.5 \cdot \frac{1}{x}\right)\right), x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 9: 96.7% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2:\\ \;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \left(\frac{-0.5}{x}\right)\right), x\right)\\ \mathbf{elif}\;x \leq 0.004999999888241291:\\ \;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(-0.5 \cdot {x}^{3} + x \cdot 3\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \left(x \cdot 2 + 0.5 \cdot \frac{1}{x}\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -2.0)
   (copysign (* 0.3333333333333333 (* 3.0 (log (/ -0.5 x)))) x)
   (if (<= x 0.004999999888241291)
     (copysign (* 0.3333333333333333 (+ (* -0.5 (pow x 3.0)) (* x 3.0))) x)
     (copysign
      (* 0.3333333333333333 (* 3.0 (log (+ (* x 2.0) (* 0.5 (/ 1.0 x))))))
      x))))
float code(float x) {
	float tmp;
	if (x <= -2.0f) {
		tmp = copysignf((0.3333333333333333f * (3.0f * logf((-0.5f / x)))), x);
	} else if (x <= 0.004999999888241291f) {
		tmp = copysignf((0.3333333333333333f * ((-0.5f * powf(x, 3.0f)) + (x * 3.0f))), x);
	} else {
		tmp = copysignf((0.3333333333333333f * (3.0f * logf(((x * 2.0f) + (0.5f * (1.0f / x)))))), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-2.0))
		tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(Float32(3.0) * log(Float32(Float32(-0.5) / x)))), x);
	elseif (x <= Float32(0.004999999888241291))
		tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(Float32(Float32(-0.5) * (x ^ Float32(3.0))) + Float32(x * Float32(3.0)))), x);
	else
		tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(Float32(3.0) * log(Float32(Float32(x * Float32(2.0)) + Float32(Float32(0.5) * Float32(Float32(1.0) / x)))))), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(-2.0))
		tmp = sign(x) * abs((single(0.3333333333333333) * (single(3.0) * log((single(-0.5) / x)))));
	elseif (x <= single(0.004999999888241291))
		tmp = sign(x) * abs((single(0.3333333333333333) * ((single(-0.5) * (x ^ single(3.0))) + (x * single(3.0)))));
	else
		tmp = sign(x) * abs((single(0.3333333333333333) * (single(3.0) * log(((x * single(2.0)) + (single(0.5) * (single(1.0) / x)))))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \left(\frac{-0.5}{x}\right)\right), x\right)\\

\mathbf{elif}\;x \leq 0.004999999888241291:\\
\;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(-0.5 \cdot {x}^{3} + x \cdot 3\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \left(x \cdot 2 + 0.5 \cdot \frac{1}{x}\right)\right), x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 10: 96.4% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2:\\ \;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \left(\frac{-0.5}{x}\right)\right), x\right)\\ \mathbf{elif}\;x \leq 0.004999999888241291:\\ \;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(-0.5 \cdot {x}^{3} + x \cdot 3\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \left(x \cdot 2\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -2.0)
   (copysign (* 0.3333333333333333 (* 3.0 (log (/ -0.5 x)))) x)
   (if (<= x 0.004999999888241291)
     (copysign (* 0.3333333333333333 (+ (* -0.5 (pow x 3.0)) (* x 3.0))) x)
     (copysign (* 0.3333333333333333 (* 3.0 (log (* x 2.0)))) x))))
float code(float x) {
	float tmp;
	if (x <= -2.0f) {
		tmp = copysignf((0.3333333333333333f * (3.0f * logf((-0.5f / x)))), x);
	} else if (x <= 0.004999999888241291f) {
		tmp = copysignf((0.3333333333333333f * ((-0.5f * powf(x, 3.0f)) + (x * 3.0f))), x);
	} else {
		tmp = copysignf((0.3333333333333333f * (3.0f * logf((x * 2.0f)))), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-2.0))
		tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(Float32(3.0) * log(Float32(Float32(-0.5) / x)))), x);
	elseif (x <= Float32(0.004999999888241291))
		tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(Float32(Float32(-0.5) * (x ^ Float32(3.0))) + Float32(x * Float32(3.0)))), x);
	else
		tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(Float32(3.0) * log(Float32(x * Float32(2.0))))), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(-2.0))
		tmp = sign(x) * abs((single(0.3333333333333333) * (single(3.0) * log((single(-0.5) / x)))));
	elseif (x <= single(0.004999999888241291))
		tmp = sign(x) * abs((single(0.3333333333333333) * ((single(-0.5) * (x ^ single(3.0))) + (x * single(3.0)))));
	else
		tmp = sign(x) * abs((single(0.3333333333333333) * (single(3.0) * log((x * single(2.0))))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \left(\frac{-0.5}{x}\right)\right), x\right)\\

\mathbf{elif}\;x \leq 0.004999999888241291:\\
\;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(-0.5 \cdot {x}^{3} + x \cdot 3\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \left(x \cdot 2\right)\right), x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 11: 82.6% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2:\\ \;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{x}\right), x\right)\\ \mathbf{elif}\;x \leq 0.004999999888241291:\\ \;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(x \cdot 3\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \left(x \cdot 2\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -2.0)
   (copysign (- (log (/ -1.0 x))) x)
   (if (<= x 0.004999999888241291)
     (copysign (* 0.3333333333333333 (* x 3.0)) x)
     (copysign (* 0.3333333333333333 (* 3.0 (log (* x 2.0)))) x))))
float code(float x) {
	float tmp;
	if (x <= -2.0f) {
		tmp = copysignf(-logf((-1.0f / x)), x);
	} else if (x <= 0.004999999888241291f) {
		tmp = copysignf((0.3333333333333333f * (x * 3.0f)), x);
	} else {
		tmp = copysignf((0.3333333333333333f * (3.0f * logf((x * 2.0f)))), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-2.0))
		tmp = copysign(Float32(-log(Float32(Float32(-1.0) / x))), x);
	elseif (x <= Float32(0.004999999888241291))
		tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(x * Float32(3.0))), x);
	else
		tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(Float32(3.0) * log(Float32(x * Float32(2.0))))), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(-2.0))
		tmp = sign(x) * abs(-log((single(-1.0) / x)));
	elseif (x <= single(0.004999999888241291))
		tmp = sign(x) * abs((single(0.3333333333333333) * (x * single(3.0))));
	else
		tmp = sign(x) * abs((single(0.3333333333333333) * (single(3.0) * log((x * single(2.0))))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{x}\right), x\right)\\

\mathbf{elif}\;x \leq 0.004999999888241291:\\
\;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(x \cdot 3\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \left(x \cdot 2\right)\right), x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 12: 95.9% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2:\\ \;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \left(\frac{-0.5}{x}\right)\right), x\right)\\ \mathbf{elif}\;x \leq 0.004999999888241291:\\ \;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(x \cdot 3\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \left(x \cdot 2\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -2.0)
   (copysign (* 0.3333333333333333 (* 3.0 (log (/ -0.5 x)))) x)
   (if (<= x 0.004999999888241291)
     (copysign (* 0.3333333333333333 (* x 3.0)) x)
     (copysign (* 0.3333333333333333 (* 3.0 (log (* x 2.0)))) x))))
float code(float x) {
	float tmp;
	if (x <= -2.0f) {
		tmp = copysignf((0.3333333333333333f * (3.0f * logf((-0.5f / x)))), x);
	} else if (x <= 0.004999999888241291f) {
		tmp = copysignf((0.3333333333333333f * (x * 3.0f)), x);
	} else {
		tmp = copysignf((0.3333333333333333f * (3.0f * logf((x * 2.0f)))), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-2.0))
		tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(Float32(3.0) * log(Float32(Float32(-0.5) / x)))), x);
	elseif (x <= Float32(0.004999999888241291))
		tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(x * Float32(3.0))), x);
	else
		tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(Float32(3.0) * log(Float32(x * Float32(2.0))))), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(-2.0))
		tmp = sign(x) * abs((single(0.3333333333333333) * (single(3.0) * log((single(-0.5) / x)))));
	elseif (x <= single(0.004999999888241291))
		tmp = sign(x) * abs((single(0.3333333333333333) * (x * single(3.0))));
	else
		tmp = sign(x) * abs((single(0.3333333333333333) * (single(3.0) * log((x * single(2.0))))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \left(\frac{-0.5}{x}\right)\right), x\right)\\

\mathbf{elif}\;x \leq 0.004999999888241291:\\
\;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(x \cdot 3\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \left(x \cdot 2\right)\right), x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 13: 69.9% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2:\\ \;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{x}\right), x\right)\\ \mathbf{elif}\;x \leq 2:\\ \;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(x \cdot 3\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{1}{x}\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -2.0)
   (copysign (- (log (/ -1.0 x))) x)
   (if (<= x 2.0)
     (copysign (* 0.3333333333333333 (* x 3.0)) x)
     (copysign (- (log (/ 1.0 x))) x))))
float code(float x) {
	float tmp;
	if (x <= -2.0f) {
		tmp = copysignf(-logf((-1.0f / x)), x);
	} else if (x <= 2.0f) {
		tmp = copysignf((0.3333333333333333f * (x * 3.0f)), x);
	} else {
		tmp = copysignf(-logf((1.0f / x)), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-2.0))
		tmp = copysign(Float32(-log(Float32(Float32(-1.0) / x))), x);
	elseif (x <= Float32(2.0))
		tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(x * Float32(3.0))), x);
	else
		tmp = copysign(Float32(-log(Float32(Float32(1.0) / x))), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(-2.0))
		tmp = sign(x) * abs(-log((single(-1.0) / x)));
	elseif (x <= single(2.0))
		tmp = sign(x) * abs((single(0.3333333333333333) * (x * single(3.0))));
	else
		tmp = sign(x) * abs(-log((single(1.0) / x)));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{x}\right), x\right)\\

\mathbf{elif}\;x \leq 2:\\
\;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(x \cdot 3\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{1}{x}\right), x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 14: 69.9% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2:\\ \;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{x}\right), x\right)\\ \mathbf{elif}\;x \leq 2:\\ \;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(x \cdot 3\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -2.0)
   (copysign (- (log (/ -1.0 x))) x)
   (if (<= x 2.0)
     (copysign (* 0.3333333333333333 (* x 3.0)) x)
     (copysign (log x) x))))
float code(float x) {
	float tmp;
	if (x <= -2.0f) {
		tmp = copysignf(-logf((-1.0f / x)), x);
	} else if (x <= 2.0f) {
		tmp = copysignf((0.3333333333333333f * (x * 3.0f)), x);
	} else {
		tmp = copysignf(logf(x), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-2.0))
		tmp = copysign(Float32(-log(Float32(Float32(-1.0) / x))), x);
	elseif (x <= Float32(2.0))
		tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(x * Float32(3.0))), x);
	else
		tmp = copysign(log(x), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(-2.0))
		tmp = sign(x) * abs(-log((single(-1.0) / x)));
	elseif (x <= single(2.0))
		tmp = sign(x) * abs((single(0.3333333333333333) * (x * single(3.0))));
	else
		tmp = sign(x) * abs(log(x));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{x}\right), x\right)\\

\mathbf{elif}\;x \leq 2:\\
\;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(x \cdot 3\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 15: 61.5% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 2:\\ \;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(x \cdot 3\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x 2.0)
   (copysign (* 0.3333333333333333 (* x 3.0)) x)
   (copysign (log x) x)))
float code(float x) {
	float tmp;
	if (x <= 2.0f) {
		tmp = copysignf((0.3333333333333333f * (x * 3.0f)), x);
	} else {
		tmp = copysignf(logf(x), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(2.0))
		tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(x * Float32(3.0))), x);
	else
		tmp = copysign(log(x), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(2.0))
		tmp = sign(x) * abs((single(0.3333333333333333) * (x * single(3.0))));
	else
		tmp = sign(x) * abs(log(x));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 2:\\
\;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(x \cdot 3\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 16: 53.3% accurate, 3.8× speedup?

\[\begin{array}{l} \\ \mathsf{copysign}\left(0.3333333333333333 \cdot \left(x \cdot 3\right), x\right) \end{array} \]
(FPCore (x) :precision binary32 (copysign (* 0.3333333333333333 (* x 3.0)) x))
float code(float x) {
	return copysignf((0.3333333333333333f * (x * 3.0f)), x);
}
function code(x)
	return copysign(Float32(Float32(0.3333333333333333) * Float32(x * Float32(3.0))), x)
end
function tmp = code(x)
	tmp = sign(x) * abs((single(0.3333333333333333) * (x * single(3.0))));
end
\begin{array}{l}

\\
\mathsf{copysign}\left(0.3333333333333333 \cdot \left(x \cdot 3\right), x\right)
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Developer target: 99.6% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{\left|x\right|}\\ \mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right| + \frac{\left|x\right|}{\mathsf{hypot}\left(1, t_0\right) + t_0}\right), x\right) \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (let* ((t_0 (/ 1.0 (fabs x))))
   (copysign (log1p (+ (fabs x) (/ (fabs x) (+ (hypot 1.0 t_0) t_0)))) x)))
float code(float x) {
	float t_0 = 1.0f / fabsf(x);
	return copysignf(log1pf((fabsf(x) + (fabsf(x) / (hypotf(1.0f, t_0) + t_0)))), x);
}
function code(x)
	t_0 = Float32(Float32(1.0) / abs(x))
	return copysign(log1p(Float32(abs(x) + Float32(abs(x) / Float32(hypot(Float32(1.0), t_0) + t_0)))), x)
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1}{\left|x\right|}\\
\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right| + \frac{\left|x\right|}{\mathsf{hypot}\left(1, t_0\right) + t_0}\right), x\right)
\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024003 
(FPCore (x)
  :name "Rust f32::asinh"
  :precision binary32

  :herbie-target
  (copysign (log1p (+ (fabs x) (/ (fabs x) (+ (hypot 1.0 (/ 1.0 (fabs x))) (/ 1.0 (fabs x)))))) x)

  (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))