
(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:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
(t_1 (pow (+ x 1.0) 2.0)))
(if (<= t_0 -0.20000000298023224)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= t_0 1.0)
(copysign
(fma
(* -0.041666666666666664 (+ (/ 3.0 (+ x 1.0)) (/ 3.0 t_1)))
(pow x 4.0)
(fma
(*
0.001388888888888889
(+
(/ 45.0 t_1)
(+ (/ 45.0 (+ x 1.0)) (/ 30.0 (pow (+ x 1.0) 3.0)))))
(pow x 6.0)
(fma 0.5 (/ (* x x) (+ x 1.0)) (log1p x))))
x)
(copysign (log (/ 0.5 x)) x)))))
float code(float x) {
float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
float t_1 = powf((x + 1.0f), 2.0f);
float tmp;
if (t_0 <= -0.20000000298023224f) {
tmp = copysignf(logf((1.0f / (hypotf(1.0f, x) - x))), x);
} else if (t_0 <= 1.0f) {
tmp = copysignf(fmaf((-0.041666666666666664f * ((3.0f / (x + 1.0f)) + (3.0f / t_1))), powf(x, 4.0f), fmaf((0.001388888888888889f * ((45.0f / t_1) + ((45.0f / (x + 1.0f)) + (30.0f / powf((x + 1.0f), 3.0f))))), powf(x, 6.0f), fmaf(0.5f, ((x * x) / (x + 1.0f)), log1pf(x)))), x);
} else {
tmp = copysignf(logf((0.5f / 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(x + Float32(1.0)) ^ Float32(2.0) tmp = Float32(0.0) if (t_0 <= Float32(-0.20000000298023224)) tmp = copysign(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(1.0)) tmp = copysign(fma(Float32(Float32(-0.041666666666666664) * Float32(Float32(Float32(3.0) / Float32(x + Float32(1.0))) + Float32(Float32(3.0) / t_1))), (x ^ Float32(4.0)), fma(Float32(Float32(0.001388888888888889) * Float32(Float32(Float32(45.0) / t_1) + Float32(Float32(Float32(45.0) / Float32(x + Float32(1.0))) + Float32(Float32(30.0) / (Float32(x + Float32(1.0)) ^ Float32(3.0)))))), (x ^ Float32(6.0)), fma(Float32(0.5), Float32(Float32(x * x) / Float32(x + Float32(1.0))), log1p(x)))), x); else tmp = copysign(log(Float32(Float32(0.5) / 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 + 1\right)}^{2}\\
\mathbf{if}\;t_0 \leq -0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;t_0 \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{fma}\left(-0.041666666666666664 \cdot \left(\frac{3}{x + 1} + \frac{3}{t_1}\right), {x}^{4}, \mathsf{fma}\left(0.001388888888888889 \cdot \left(\frac{45}{t_1} + \left(\frac{45}{x + 1} + \frac{30}{{\left(x + 1\right)}^{3}}\right)\right), {x}^{6}, \mathsf{fma}\left(0.5, \frac{x \cdot x}{x + 1}, \mathsf{log1p}\left(x\right)\right)\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < -0.200000003Initial program 58.1%
+-commutative58.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.4%
flip-+10.5%
add-sqr-sqrt12.1%
fma-def12.1%
+-commutative12.1%
hypot-1-def12.1%
Applied egg-rr12.1%
fma-udef12.1%
+-commutative12.1%
associate--l+55.3%
+-inverses98.5%
metadata-eval98.5%
Simplified98.5%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 1Initial program 23.7%
Taylor expanded in x around 0 23.7%
associate-*r*23.7%
fma-def23.7%
Simplified99.4%
if 1 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 53.9%
Taylor expanded in x around inf 95.1%
associate-*r/95.1%
metadata-eval95.1%
rem-square-sqrt95.0%
fabs-sqr95.0%
rem-square-sqrt95.1%
Simplified95.1%
Taylor expanded in x around 0 97.8%
Final simplification98.7%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.20000000298023224)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= t_0 1.0)
(copysign
(+ (* -0.16666666666666666 (pow x 3.0)) (+ x (* 0.075 (pow x 5.0))))
x)
(copysign (log (/ 0.5 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((1.0f / (hypotf(1.0f, x) - x))), x);
} else if (t_0 <= 1.0f) {
tmp = copysignf(((-0.16666666666666666f * powf(x, 3.0f)) + (x + (0.075f * powf(x, 5.0f)))), x);
} else {
tmp = copysignf(logf((0.5f / 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(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(1.0)) tmp = copysign(Float32(Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0))) + Float32(x + Float32(Float32(0.075) * (x ^ Float32(5.0))))), x); else tmp = copysign(log(Float32(Float32(0.5) / x)), x); end return tmp end
function tmp_2 = code(x) t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); tmp = single(0.0); if (t_0 <= single(-0.20000000298023224)) tmp = sign(x) * abs(log((single(1.0) / (hypot(single(1.0), x) - x)))); elseif (t_0 <= single(1.0)) tmp = sign(x) * abs(((single(-0.16666666666666666) * (x ^ single(3.0))) + (x + (single(0.075) * (x ^ single(5.0)))))); else tmp = sign(x) * abs(log((single(0.5) / x))); end tmp_2 = 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(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;t_0 \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot {x}^{3} + \left(x + 0.075 \cdot {x}^{5}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < -0.200000003Initial program 58.1%
+-commutative58.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.4%
flip-+10.5%
add-sqr-sqrt12.1%
fma-def12.1%
+-commutative12.1%
hypot-1-def12.1%
Applied egg-rr12.1%
fma-udef12.1%
+-commutative12.1%
associate--l+55.3%
+-inverses98.5%
metadata-eval98.5%
Simplified98.5%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 1Initial program 23.7%
+-commutative23.7%
add-sqr-sqrt12.4%
fabs-sqr12.4%
add-sqr-sqrt23.8%
flip-+23.6%
add-sqr-sqrt23.5%
fma-def23.5%
+-commutative23.5%
hypot-1-def23.7%
Applied egg-rr23.7%
fma-udef23.7%
+-commutative23.7%
associate--l+23.8%
+-inverses23.8%
metadata-eval23.8%
Simplified23.8%
Taylor expanded in x around 0 99.4%
if 1 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 53.9%
Taylor expanded in x around inf 95.1%
associate-*r/95.1%
metadata-eval95.1%
rem-square-sqrt95.0%
fabs-sqr95.0%
rem-square-sqrt95.1%
Simplified95.1%
Taylor expanded in x around 0 97.8%
Final simplification98.7%
(FPCore (x)
:precision binary32
(if (<= x -0.05000000074505806)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= x 1.0)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -0.05000000074505806f) {
tmp = copysignf(logf((1.0f / (hypotf(1.0f, x) - x))), x);
} else if (x <= 1.0f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.05000000074505806)) tmp = copysign(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(Float32(0.5) / x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-0.05000000074505806)) tmp = sign(x) * abs(log((single(1.0) / (hypot(single(1.0), x) - x)))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -0.0500000007Initial program 58.6%
+-commutative58.6%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt14.6%
flip-+11.7%
add-sqr-sqrt13.4%
fma-def13.4%
+-commutative13.4%
hypot-1-def13.4%
Applied egg-rr13.4%
fma-udef13.4%
+-commutative13.4%
associate--l+55.9%
+-inverses98.4%
metadata-eval98.4%
Simplified98.4%
if -0.0500000007 < x < 1Initial program 23.2%
+-commutative23.2%
add-sqr-sqrt12.5%
fabs-sqr12.5%
add-sqr-sqrt23.2%
flip-+23.0%
add-sqr-sqrt23.0%
fma-def23.0%
+-commutative23.0%
hypot-1-def23.1%
Applied egg-rr23.1%
fma-udef23.1%
+-commutative23.1%
associate--l+23.2%
+-inverses23.2%
metadata-eval23.2%
Simplified23.2%
Taylor expanded in x around 0 99.2%
if 1 < x Initial program 53.9%
Taylor expanded in x around inf 95.1%
associate-*r/95.1%
metadata-eval95.1%
rem-square-sqrt95.0%
fabs-sqr95.0%
rem-square-sqrt95.1%
Simplified95.1%
Taylor expanded in x around 0 97.8%
Final simplification98.6%
(FPCore (x)
:precision binary32
(if (<= x -0.05000000074505806)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 1.0)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -0.05000000074505806f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 1.0f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.05000000074505806)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(Float32(0.5) / x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-0.05000000074505806)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -0.0500000007Initial program 58.6%
+-commutative58.6%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt14.6%
flip-+11.7%
log-div11.7%
add-sqr-sqrt13.3%
fma-def13.3%
+-commutative13.3%
hypot-1-def13.4%
Applied egg-rr13.4%
fma-udef13.4%
+-commutative13.4%
associate--l+55.8%
+-inverses98.3%
metadata-eval98.3%
metadata-eval98.3%
neg-sub098.3%
Simplified98.3%
if -0.0500000007 < x < 1Initial program 23.2%
+-commutative23.2%
add-sqr-sqrt12.5%
fabs-sqr12.5%
add-sqr-sqrt23.2%
flip-+23.0%
add-sqr-sqrt23.0%
fma-def23.0%
+-commutative23.0%
hypot-1-def23.1%
Applied egg-rr23.1%
fma-udef23.1%
+-commutative23.1%
associate--l+23.2%
+-inverses23.2%
metadata-eval23.2%
Simplified23.2%
Taylor expanded in x around 0 99.2%
if 1 < x Initial program 53.9%
Taylor expanded in x around inf 95.1%
associate-*r/95.1%
metadata-eval95.1%
rem-square-sqrt95.0%
fabs-sqr95.0%
rem-square-sqrt95.1%
Simplified95.1%
Taylor expanded in x around 0 97.8%
Final simplification98.6%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (log (/ 1.0 (+ (/ -0.5 x) (* x -2.0)))) x)
(if (<= x 1.0)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf((1.0f / ((-0.5f / x) + (x * -2.0f)))), x);
} else if (x <= 1.0f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(log(Float32(Float32(1.0) / Float32(Float32(Float32(-0.5) / x) + Float32(x * Float32(-2.0))))), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(Float32(0.5) / x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-10.0)) tmp = sign(x) * abs(log((single(1.0) / ((single(-0.5) / x) + (x * single(-2.0)))))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\frac{-0.5}{x} + x \cdot -2}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 56.8%
+-commutative56.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.8%
flip-+7.7%
add-sqr-sqrt9.4%
fma-def9.4%
+-commutative9.4%
hypot-1-def9.4%
Applied egg-rr9.4%
fma-udef9.4%
+-commutative9.4%
associate--l+53.9%
+-inverses98.5%
metadata-eval98.5%
Simplified98.5%
Taylor expanded in x around -inf 98.4%
cancel-sign-sub-inv98.4%
metadata-eval98.4%
div-inv98.4%
+-commutative98.4%
*-commutative98.4%
Applied egg-rr98.4%
if -10 < x < 1Initial program 24.9%
+-commutative24.9%
add-sqr-sqrt12.2%
fabs-sqr12.2%
add-sqr-sqrt25.0%
flip-+24.8%
add-sqr-sqrt24.7%
fma-def24.7%
+-commutative24.7%
hypot-1-def24.9%
Applied egg-rr24.9%
fma-udef24.9%
+-commutative24.9%
associate--l+25.0%
+-inverses25.0%
metadata-eval25.0%
Simplified25.0%
Taylor expanded in x around 0 98.3%
if 1 < x Initial program 53.9%
Taylor expanded in x around inf 95.1%
associate-*r/95.1%
metadata-eval95.1%
rem-square-sqrt95.0%
fabs-sqr95.0%
rem-square-sqrt95.1%
Simplified95.1%
Taylor expanded in x around 0 97.8%
Final simplification98.2%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(Float32(0.5) / x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-10.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 56.8%
+-commutative56.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.8%
flip-+7.7%
add-sqr-sqrt9.4%
fma-def9.4%
+-commutative9.4%
hypot-1-def9.4%
Applied egg-rr9.4%
fma-udef9.4%
+-commutative9.4%
associate--l+53.9%
+-inverses98.5%
metadata-eval98.5%
Simplified98.5%
Taylor expanded in x around -inf 98.2%
if -10 < x < 1Initial program 24.9%
+-commutative24.9%
add-sqr-sqrt12.2%
fabs-sqr12.2%
add-sqr-sqrt25.0%
flip-+24.8%
add-sqr-sqrt24.7%
fma-def24.7%
+-commutative24.7%
hypot-1-def24.9%
Applied egg-rr24.9%
fma-udef24.9%
+-commutative24.9%
associate--l+25.0%
+-inverses25.0%
metadata-eval25.0%
Simplified25.0%
Taylor expanded in x around 0 98.3%
if 1 < x Initial program 53.9%
Taylor expanded in x around inf 95.1%
associate-*r/95.1%
metadata-eval95.1%
rem-square-sqrt95.0%
fabs-sqr95.0%
rem-square-sqrt95.1%
Simplified95.1%
Taylor expanded in x around 0 97.8%
Final simplification98.2%
(FPCore (x) :precision binary32 (if (<= x -10.0) (copysign (log (* x -2.0)) x) (if (<= x 1.0) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf((x * -2.0f)), x);
} else if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(log(Float32(x * Float32(-2.0))), x); elseif (x <= Float32(1.0)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x + x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-10.0)) tmp = sign(x) * abs(log((x * single(-2.0)))); elseif (x <= single(1.0)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 56.8%
+-commutative56.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.8%
flip-+7.7%
add-sqr-sqrt9.4%
fma-def9.4%
+-commutative9.4%
hypot-1-def9.4%
Applied egg-rr9.4%
fma-udef9.4%
+-commutative9.4%
associate--l+53.9%
+-inverses98.5%
metadata-eval98.5%
Simplified98.5%
Taylor expanded in x around -inf 98.4%
Taylor expanded in x around 0 96.8%
*-commutative96.8%
Simplified96.8%
if -10 < x < 1Initial program 24.9%
+-commutative24.9%
add-sqr-sqrt12.2%
fabs-sqr12.2%
add-sqr-sqrt25.0%
flip-+24.8%
add-sqr-sqrt24.7%
fma-def24.7%
+-commutative24.7%
hypot-1-def24.9%
Applied egg-rr24.9%
fma-udef24.9%
+-commutative24.9%
associate--l+25.0%
+-inverses25.0%
metadata-eval25.0%
Simplified25.0%
Taylor expanded in x around 0 96.5%
if 1 < x Initial program 53.9%
Taylor expanded in x around inf 93.9%
rem-square-sqrt93.8%
fabs-sqr93.8%
rem-square-sqrt93.9%
Simplified93.9%
Final simplification95.9%
(FPCore (x) :precision binary32 (if (<= x -10.0) (copysign (log (/ -0.5 x)) x) (if (<= x 1.0) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x + x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-10.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 56.8%
+-commutative56.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.8%
flip-+7.7%
add-sqr-sqrt9.4%
fma-def9.4%
+-commutative9.4%
hypot-1-def9.4%
Applied egg-rr9.4%
fma-udef9.4%
+-commutative9.4%
associate--l+53.9%
+-inverses98.5%
metadata-eval98.5%
Simplified98.5%
Taylor expanded in x around -inf 98.2%
if -10 < x < 1Initial program 24.9%
+-commutative24.9%
add-sqr-sqrt12.2%
fabs-sqr12.2%
add-sqr-sqrt25.0%
flip-+24.8%
add-sqr-sqrt24.7%
fma-def24.7%
+-commutative24.7%
hypot-1-def24.9%
Applied egg-rr24.9%
fma-udef24.9%
+-commutative24.9%
associate--l+25.0%
+-inverses25.0%
metadata-eval25.0%
Simplified25.0%
Taylor expanded in x around 0 96.5%
if 1 < x Initial program 53.9%
Taylor expanded in x around inf 93.9%
rem-square-sqrt93.8%
fabs-sqr93.8%
rem-square-sqrt93.9%
Simplified93.9%
Final simplification96.2%
(FPCore (x) :precision binary32 (if (<= x -10.0) (copysign (log (/ -0.5 x)) x) (if (<= x 1.0) (copysign x x) (copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) tmp = copysign(x, x); else tmp = copysign(log(Float32(Float32(0.5) / x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-10.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 56.8%
+-commutative56.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.8%
flip-+7.7%
add-sqr-sqrt9.4%
fma-def9.4%
+-commutative9.4%
hypot-1-def9.4%
Applied egg-rr9.4%
fma-udef9.4%
+-commutative9.4%
associate--l+53.9%
+-inverses98.5%
metadata-eval98.5%
Simplified98.5%
Taylor expanded in x around -inf 98.2%
if -10 < x < 1Initial program 24.9%
+-commutative24.9%
add-sqr-sqrt12.2%
fabs-sqr12.2%
add-sqr-sqrt25.0%
flip-+24.8%
add-sqr-sqrt24.7%
fma-def24.7%
+-commutative24.7%
hypot-1-def24.9%
Applied egg-rr24.9%
fma-udef24.9%
+-commutative24.9%
associate--l+25.0%
+-inverses25.0%
metadata-eval25.0%
Simplified25.0%
Taylor expanded in x around 0 96.5%
if 1 < x Initial program 53.9%
Taylor expanded in x around inf 95.1%
associate-*r/95.1%
metadata-eval95.1%
rem-square-sqrt95.0%
fabs-sqr95.0%
rem-square-sqrt95.1%
Simplified95.1%
Taylor expanded in x around 0 97.8%
Final simplification97.3%
(FPCore (x) :precision binary32 (if (<= x -10.0) (copysign (log (* x -2.0)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf((x * -2.0f)), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(log(Float32(x * Float32(-2.0))), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot -2\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 56.8%
+-commutative56.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.8%
flip-+7.7%
add-sqr-sqrt9.4%
fma-def9.4%
+-commutative9.4%
hypot-1-def9.4%
Applied egg-rr9.4%
fma-udef9.4%
+-commutative9.4%
associate--l+53.9%
+-inverses98.5%
metadata-eval98.5%
Simplified98.5%
Taylor expanded in x around -inf 98.4%
Taylor expanded in x around 0 96.8%
*-commutative96.8%
Simplified96.8%
if -10 < x Initial program 35.3%
Taylor expanded in x around 0 28.9%
log1p-def75.1%
rem-square-sqrt46.5%
fabs-sqr46.5%
rem-square-sqrt75.0%
Simplified75.0%
Final simplification80.4%
(FPCore (x) :precision binary32 (if (<= x -10.0) (copysign 15.333333333333334 x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(15.333333333333334f, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(Float32(15.333333333333334), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\mathsf{copysign}\left(15.333333333333334, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 56.8%
Taylor expanded in x around inf -0.0%
associate-*r/-0.0%
metadata-eval-0.0%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt-0.0%
Simplified-0.0%
Taylor expanded in x around 0 -0.0%
Simplified27.8%
if -10 < x Initial program 35.3%
Taylor expanded in x around 0 28.9%
log1p-def75.1%
rem-square-sqrt46.5%
fabs-sqr46.5%
rem-square-sqrt75.0%
Simplified75.0%
Final simplification63.4%
(FPCore (x) :precision binary32 (if (<= x -10.0) (copysign 15.333333333333334 x) (if (<= x 10.0) (copysign x x) (copysign 15.333333333333334 x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(15.333333333333334f, x);
} else if (x <= 10.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(15.333333333333334f, x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(Float32(15.333333333333334), x); elseif (x <= Float32(10.0)) tmp = copysign(x, x); else tmp = copysign(Float32(15.333333333333334), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-10.0)) tmp = sign(x) * abs(single(15.333333333333334)); elseif (x <= single(10.0)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(single(15.333333333333334)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\mathsf{copysign}\left(15.333333333333334, x\right)\\
\mathbf{elif}\;x \leq 10:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(15.333333333333334, x\right)\\
\end{array}
\end{array}
if x < -10 or 10 < x Initial program 54.6%
Taylor expanded in x around inf 49.4%
associate-*r/49.4%
metadata-eval49.4%
rem-square-sqrt49.3%
fabs-sqr49.3%
rem-square-sqrt49.4%
Simplified49.4%
Taylor expanded in x around 0 1.0%
Simplified27.7%
if -10 < x < 10Initial program 26.1%
+-commutative26.1%
add-sqr-sqrt13.6%
fabs-sqr13.6%
add-sqr-sqrt26.2%
flip-+25.8%
add-sqr-sqrt25.8%
fma-def25.8%
+-commutative25.8%
hypot-1-def25.9%
Applied egg-rr25.9%
fma-udef25.9%
+-commutative25.9%
associate--l+26.0%
+-inverses26.0%
metadata-eval26.0%
Simplified26.0%
Taylor expanded in x around 0 95.4%
Final simplification61.0%
(FPCore (x) :precision binary32 (copysign -6.0 x))
float code(float x) {
return copysignf(-6.0f, x);
}
function code(x) return copysign(Float32(-6.0), x) end
function tmp = code(x) tmp = sign(x) * abs(single(-6.0)); end
\begin{array}{l}
\\
\mathsf{copysign}\left(-6, x\right)
\end{array}
Initial program 40.6%
Taylor expanded in x around inf 28.2%
associate-*r/28.2%
metadata-eval28.2%
rem-square-sqrt28.1%
fabs-sqr28.1%
rem-square-sqrt28.2%
Simplified28.2%
Taylor expanded in x around 0 3.7%
Simplified17.8%
Final simplification17.8%
(FPCore (x) :precision binary32 (copysign 15.333333333333334 x))
float code(float x) {
return copysignf(15.333333333333334f, x);
}
function code(x) return copysign(Float32(15.333333333333334), x) end
function tmp = code(x) tmp = sign(x) * abs(single(15.333333333333334)); end
\begin{array}{l}
\\
\mathsf{copysign}\left(15.333333333333334, x\right)
\end{array}
Initial program 40.6%
Taylor expanded in x around inf 28.2%
associate-*r/28.2%
metadata-eval28.2%
rem-square-sqrt28.1%
fabs-sqr28.1%
rem-square-sqrt28.2%
Simplified28.2%
Taylor expanded in x around 0 3.1%
Simplified19.2%
Final simplification19.2%
(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}
herbie shell --seed 2023174
(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))