
(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 12 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)))
(if (<= t_0 -2.0)
(copysign (- (log1p (+ (- (hypot 1.0 x) x) -1.0))) x)
(if (<= t_0 0.05000000074505806)
(copysign
(+ x (* (fma (pow x 2.0) 0.075 -0.16666666666666666) (pow x 3.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 <= -2.0f) {
tmp = copysignf(-log1pf(((hypotf(1.0f, x) - x) + -1.0f)), x);
} else if (t_0 <= 0.05000000074505806f) {
tmp = copysignf((x + (fmaf(powf(x, 2.0f), 0.075f, -0.16666666666666666f) * powf(x, 3.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(-2.0)) tmp = copysign(Float32(-log1p(Float32(Float32(hypot(Float32(1.0), x) - x) + Float32(-1.0)))), x); elseif (t_0 <= Float32(0.05000000074505806)) tmp = copysign(Float32(x + Float32(fma((x ^ Float32(2.0)), Float32(0.075), Float32(-0.16666666666666666)) * (x ^ Float32(3.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 -2:\\
\;\;\;\;\mathsf{copysign}\left(-\mathsf{log1p}\left(\left(\mathsf{hypot}\left(1, x\right) - x\right) + -1\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x + \mathsf{fma}\left({x}^{2}, 0.075, -0.16666666666666666\right) \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < -2Initial program 53.9%
flip-+5.9%
frac-2neg5.9%
log-div5.9%
add-sqr-sqrt5.5%
pow25.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt5.5%
fma-define5.5%
Applied egg-rr10.0%
fma-undefine10.0%
unpow210.0%
associate--r+50.7%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
Simplified100.0%
log1p-expm1-u100.0%
expm1-undefine100.0%
add-exp-log100.0%
Applied egg-rr100.0%
if -2 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.0500000007Initial program 23.8%
+-commutative23.8%
hypot-1-def23.7%
flip-+23.9%
hypot-1-def23.8%
hypot-1-def23.8%
add-sqr-sqrt23.8%
+-commutative23.8%
hypot-1-def23.9%
+-commutative23.9%
div-sub23.9%
Applied egg-rr23.9%
div-sub23.9%
fma-undefine23.9%
unpow223.9%
associate--r+24.1%
+-inverses24.1%
metadata-eval24.1%
Simplified24.1%
Taylor expanded in x around 0 100.0%
distribute-rgt-in100.0%
*-lft-identity100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
fmm-def100.0%
metadata-eval100.0%
unpow2100.0%
unpow3100.0%
Simplified100.0%
if 0.0500000007 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 55.1%
*-un-lft-identity55.1%
*-commutative55.1%
log-prod55.1%
*-un-lft-identity55.1%
*-un-lft-identity55.1%
add-sqr-sqrt55.1%
fabs-sqr55.1%
add-sqr-sqrt55.1%
+-commutative55.1%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification100.0%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -2.0)
(copysign (- (log1p (+ (- (hypot 1.0 x) x) -1.0))) x)
(if (<= t_0 0.05000000074505806)
(copysign
(*
x
(+ 1.0 (* (pow x 2.0) (- (* (pow x 2.0) 0.075) 0.16666666666666666))))
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 <= -2.0f) {
tmp = copysignf(-log1pf(((hypotf(1.0f, x) - x) + -1.0f)), x);
} else if (t_0 <= 0.05000000074505806f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * ((powf(x, 2.0f) * 0.075f) - 0.16666666666666666f)))), 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(-2.0)) tmp = copysign(Float32(-log1p(Float32(Float32(hypot(Float32(1.0), x) - x) + Float32(-1.0)))), x); elseif (t_0 <= Float32(0.05000000074505806)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32((x ^ Float32(2.0)) * Float32(Float32((x ^ Float32(2.0)) * Float32(0.075)) - Float32(0.16666666666666666))))), 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 -2:\\
\;\;\;\;\mathsf{copysign}\left(-\mathsf{log1p}\left(\left(\mathsf{hypot}\left(1, x\right) - x\right) + -1\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot \left({x}^{2} \cdot 0.075 - 0.16666666666666666\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}
if (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < -2Initial program 53.9%
flip-+5.9%
frac-2neg5.9%
log-div5.9%
add-sqr-sqrt5.5%
pow25.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt5.5%
fma-define5.5%
Applied egg-rr10.0%
fma-undefine10.0%
unpow210.0%
associate--r+50.7%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
Simplified100.0%
log1p-expm1-u100.0%
expm1-undefine100.0%
add-exp-log100.0%
Applied egg-rr100.0%
if -2 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.0500000007Initial program 23.8%
+-commutative23.8%
hypot-1-def23.7%
flip-+23.9%
hypot-1-def23.8%
hypot-1-def23.8%
add-sqr-sqrt23.8%
+-commutative23.8%
hypot-1-def23.9%
+-commutative23.9%
div-sub23.9%
Applied egg-rr23.9%
div-sub23.9%
fma-undefine23.9%
unpow223.9%
associate--r+24.1%
+-inverses24.1%
metadata-eval24.1%
Simplified24.1%
Taylor expanded in x around 0 100.0%
if 0.0500000007 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 55.1%
*-un-lft-identity55.1%
*-commutative55.1%
log-prod55.1%
*-un-lft-identity55.1%
*-un-lft-identity55.1%
add-sqr-sqrt55.1%
fabs-sqr55.1%
add-sqr-sqrt55.1%
+-commutative55.1%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification100.0%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.05000000074505806)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.05000000074505806f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(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(-10.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.05000000074505806)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (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(-10.0)) tmp = sign(x) * abs(-log((x * single(-2.0)))); elseif (x <= single(0.05000000074505806)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (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 -10:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 53.9%
flip-+5.9%
frac-2neg5.9%
log-div5.9%
add-sqr-sqrt5.5%
pow25.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt5.5%
fma-define5.5%
Applied egg-rr10.0%
fma-undefine10.0%
unpow210.0%
associate--r+50.7%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in x around -inf 98.0%
*-commutative98.0%
Simplified98.0%
if -10 < x < 0.0500000007Initial program 23.8%
+-commutative23.8%
hypot-1-def23.7%
flip-+23.9%
hypot-1-def23.8%
hypot-1-def23.8%
add-sqr-sqrt23.8%
+-commutative23.8%
hypot-1-def23.9%
+-commutative23.9%
div-sub23.9%
Applied egg-rr23.9%
div-sub23.9%
fma-undefine23.9%
unpow223.9%
associate--r+24.1%
+-inverses24.1%
metadata-eval24.1%
Simplified24.1%
Taylor expanded in x around 0 99.9%
distribute-rgt-in99.9%
*-lft-identity99.9%
associate-*l*99.9%
unpow299.9%
unpow399.9%
Simplified99.9%
if 0.0500000007 < x Initial program 55.1%
*-un-lft-identity55.1%
*-commutative55.1%
log-prod55.1%
*-un-lft-identity55.1%
*-un-lft-identity55.1%
add-sqr-sqrt55.1%
fabs-sqr55.1%
add-sqr-sqrt55.1%
+-commutative55.1%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.4%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.05000000074505806)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.05000000074505806f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(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(-10.0)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.05000000074505806)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (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(-10.0)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (x <= single(0.05000000074505806)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (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 -10:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 53.9%
flip-+5.9%
frac-2neg5.9%
log-div5.9%
add-sqr-sqrt5.5%
pow25.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt5.5%
fma-define5.5%
Applied egg-rr10.0%
fma-undefine10.0%
unpow210.0%
associate--r+50.7%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
Simplified100.0%
if -10 < x < 0.0500000007Initial program 23.8%
+-commutative23.8%
hypot-1-def23.7%
flip-+23.9%
hypot-1-def23.8%
hypot-1-def23.8%
add-sqr-sqrt23.8%
+-commutative23.8%
hypot-1-def23.9%
+-commutative23.9%
div-sub23.9%
Applied egg-rr23.9%
div-sub23.9%
fma-undefine23.9%
unpow223.9%
associate--r+24.1%
+-inverses24.1%
metadata-eval24.1%
Simplified24.1%
Taylor expanded in x around 0 99.9%
distribute-rgt-in99.9%
*-lft-identity99.9%
associate-*l*99.9%
unpow299.9%
unpow399.9%
Simplified99.9%
if 0.0500000007 < x Initial program 55.1%
*-un-lft-identity55.1%
*-commutative55.1%
log-prod55.1%
*-un-lft-identity55.1%
*-un-lft-identity55.1%
add-sqr-sqrt55.1%
fabs-sqr55.1%
add-sqr-sqrt55.1%
+-commutative55.1%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (- (log1p (+ (- (hypot 1.0 x) x) -1.0))) x)
(if (<= x 0.05000000074505806)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(-log1pf(((hypotf(1.0f, x) - x) + -1.0f)), x);
} else if (x <= 0.05000000074505806f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(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(-10.0)) tmp = copysign(Float32(-log1p(Float32(Float32(hypot(Float32(1.0), x) - x) + Float32(-1.0)))), x); elseif (x <= Float32(0.05000000074505806)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.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 -10:\\
\;\;\;\;\mathsf{copysign}\left(-\mathsf{log1p}\left(\left(\mathsf{hypot}\left(1, x\right) - x\right) + -1\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 53.9%
flip-+5.9%
frac-2neg5.9%
log-div5.9%
add-sqr-sqrt5.5%
pow25.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt5.5%
fma-define5.5%
Applied egg-rr10.0%
fma-undefine10.0%
unpow210.0%
associate--r+50.7%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
Simplified100.0%
log1p-expm1-u100.0%
expm1-undefine100.0%
add-exp-log100.0%
Applied egg-rr100.0%
if -10 < x < 0.0500000007Initial program 23.8%
+-commutative23.8%
hypot-1-def23.7%
flip-+23.9%
hypot-1-def23.8%
hypot-1-def23.8%
add-sqr-sqrt23.8%
+-commutative23.8%
hypot-1-def23.9%
+-commutative23.9%
div-sub23.9%
Applied egg-rr23.9%
div-sub23.9%
fma-undefine23.9%
unpow223.9%
associate--r+24.1%
+-inverses24.1%
metadata-eval24.1%
Simplified24.1%
Taylor expanded in x around 0 99.9%
distribute-rgt-in99.9%
*-lft-identity99.9%
associate-*l*99.9%
unpow299.9%
unpow399.9%
Simplified99.9%
if 0.0500000007 < x Initial program 55.1%
*-un-lft-identity55.1%
*-commutative55.1%
log-prod55.1%
*-un-lft-identity55.1%
*-un-lft-identity55.1%
add-sqr-sqrt55.1%
fabs-sqr55.1%
add-sqr-sqrt55.1%
+-commutative55.1%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.4000000059604645)
(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((x * -2.0f)), x);
} else if (x <= 0.4000000059604645f) {
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(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.4000000059604645)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(Float32(-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((x * single(-2.0)))); elseif (x <= single(0.4000000059604645)) 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(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.4000000059604645:\\
\;\;\;\;\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 53.9%
flip-+5.9%
frac-2neg5.9%
log-div5.9%
add-sqr-sqrt5.5%
pow25.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt5.5%
fma-define5.5%
Applied egg-rr10.0%
fma-undefine10.0%
unpow210.0%
associate--r+50.7%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in x around -inf 98.0%
*-commutative98.0%
Simplified98.0%
if -10 < x < 0.400000006Initial program 24.4%
+-commutative24.4%
hypot-1-def24.4%
flip-+24.5%
hypot-1-def24.5%
hypot-1-def24.4%
add-sqr-sqrt24.4%
+-commutative24.4%
hypot-1-def24.5%
+-commutative24.5%
div-sub24.5%
Applied egg-rr24.5%
div-sub24.5%
fma-undefine24.5%
unpow224.5%
associate--r+24.7%
+-inverses24.7%
metadata-eval24.7%
Simplified24.7%
Taylor expanded in x around 0 99.6%
distribute-rgt-in99.6%
*-lft-identity99.6%
associate-*l*99.6%
unpow299.6%
unpow399.6%
Simplified99.6%
if 0.400000006 < x Initial program 54.5%
flip-+3.7%
frac-2neg3.7%
log-div3.7%
add-sqr-sqrt3.7%
pow23.7%
add-sqr-sqrt4.3%
fabs-sqr4.3%
add-sqr-sqrt3.7%
fma-define3.7%
Applied egg-rr4.2%
fma-undefine4.2%
unpow24.2%
associate--r+7.1%
+-inverses10.2%
metadata-eval10.2%
metadata-eval10.2%
metadata-eval10.2%
neg-sub010.2%
associate--r-10.2%
neg-sub010.2%
+-commutative10.2%
sub-neg10.2%
neg-sub010.2%
Simplified10.2%
Taylor expanded in x around inf 99.0%
Final simplification99.0%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.4000000059604645)
(copysign x x)
(copysign (- (log (/ 0.5 x))) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.4000000059604645f) {
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(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.4000000059604645)) tmp = copysign(x, x); else tmp = copysign(Float32(-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((x * single(-2.0)))); elseif (x <= single(0.4000000059604645)) 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(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.4000000059604645:\\
\;\;\;\;\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 53.9%
flip-+5.9%
frac-2neg5.9%
log-div5.9%
add-sqr-sqrt5.5%
pow25.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt5.5%
fma-define5.5%
Applied egg-rr10.0%
fma-undefine10.0%
unpow210.0%
associate--r+50.7%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in x around -inf 98.0%
*-commutative98.0%
Simplified98.0%
if -10 < x < 0.400000006Initial program 24.4%
+-commutative24.4%
hypot-1-def24.4%
flip-+24.5%
hypot-1-def24.5%
hypot-1-def24.4%
add-sqr-sqrt24.4%
+-commutative24.4%
hypot-1-def24.5%
+-commutative24.5%
div-sub24.5%
Applied egg-rr24.5%
div-sub24.5%
fma-undefine24.5%
unpow224.5%
associate--r+24.7%
+-inverses24.7%
metadata-eval24.7%
Simplified24.7%
Taylor expanded in x around 0 98.3%
if 0.400000006 < x Initial program 54.5%
flip-+3.7%
frac-2neg3.7%
log-div3.7%
add-sqr-sqrt3.7%
pow23.7%
add-sqr-sqrt4.3%
fabs-sqr4.3%
add-sqr-sqrt3.7%
fma-define3.7%
Applied egg-rr4.2%
fma-undefine4.2%
unpow24.2%
associate--r+7.1%
+-inverses10.2%
metadata-eval10.2%
metadata-eval10.2%
metadata-eval10.2%
neg-sub010.2%
associate--r-10.2%
neg-sub010.2%
+-commutative10.2%
sub-neg10.2%
neg-sub010.2%
Simplified10.2%
Taylor expanded in x around inf 99.0%
Final simplification98.4%
(FPCore (x) :precision binary32 (if (<= x -10.0) (copysign (log (/ -0.5 x)) x) (if (<= x 0.4000000059604645) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.4000000059604645f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), 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(0.4000000059604645)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x * Float32(2.0))), 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(0.4000000059604645)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x * single(2.0)))); 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 0.4000000059604645:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 53.9%
*-un-lft-identity53.9%
*-commutative53.9%
log-prod53.9%
*-un-lft-identity53.9%
*-un-lft-identity53.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt11.5%
+-commutative11.5%
hypot-1-def11.6%
metadata-eval11.6%
Applied egg-rr11.6%
+-rgt-identity11.6%
Simplified11.6%
Taylor expanded in x around -inf 97.9%
if -10 < x < 0.400000006Initial program 24.4%
+-commutative24.4%
hypot-1-def24.4%
flip-+24.5%
hypot-1-def24.5%
hypot-1-def24.4%
add-sqr-sqrt24.4%
+-commutative24.4%
hypot-1-def24.5%
+-commutative24.5%
div-sub24.5%
Applied egg-rr24.5%
div-sub24.5%
fma-undefine24.5%
unpow224.5%
associate--r+24.7%
+-inverses24.7%
metadata-eval24.7%
Simplified24.7%
Taylor expanded in x around 0 98.3%
if 0.400000006 < x Initial program 54.5%
+-commutative54.5%
hypot-1-def100.0%
flip-+4.4%
hypot-1-def4.3%
hypot-1-def3.8%
add-sqr-sqrt4.2%
+-commutative4.2%
hypot-1-def3.6%
+-commutative3.6%
div-sub3.7%
Applied egg-rr4.2%
div-sub4.2%
fma-undefine4.2%
unpow24.2%
associate--r+4.2%
+-inverses4.2%
metadata-eval4.2%
Simplified4.2%
Taylor expanded in x around inf 99.0%
associate-/r/99.0%
metadata-eval99.0%
*-commutative99.0%
Applied egg-rr99.0%
Final simplification98.4%
(FPCore (x) :precision binary32 (if (<= x -10.0) (copysign (- (log (* x -2.0))) x) (if (<= x 0.4000000059604645) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.4000000059604645f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.4000000059604645)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x * Float32(2.0))), 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(0.4000000059604645)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x * single(2.0)))); 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 0.4000000059604645:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 53.9%
flip-+5.9%
frac-2neg5.9%
log-div5.9%
add-sqr-sqrt5.5%
pow25.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt5.5%
fma-define5.5%
Applied egg-rr10.0%
fma-undefine10.0%
unpow210.0%
associate--r+50.7%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in x around -inf 98.0%
*-commutative98.0%
Simplified98.0%
if -10 < x < 0.400000006Initial program 24.4%
+-commutative24.4%
hypot-1-def24.4%
flip-+24.5%
hypot-1-def24.5%
hypot-1-def24.4%
add-sqr-sqrt24.4%
+-commutative24.4%
hypot-1-def24.5%
+-commutative24.5%
div-sub24.5%
Applied egg-rr24.5%
div-sub24.5%
fma-undefine24.5%
unpow224.5%
associate--r+24.7%
+-inverses24.7%
metadata-eval24.7%
Simplified24.7%
Taylor expanded in x around 0 98.3%
if 0.400000006 < x Initial program 54.5%
+-commutative54.5%
hypot-1-def100.0%
flip-+4.4%
hypot-1-def4.3%
hypot-1-def3.8%
add-sqr-sqrt4.2%
+-commutative4.2%
hypot-1-def3.6%
+-commutative3.6%
div-sub3.7%
Applied egg-rr4.2%
div-sub4.2%
fma-undefine4.2%
unpow24.2%
associate--r+4.2%
+-inverses4.2%
metadata-eval4.2%
Simplified4.2%
Taylor expanded in x around inf 99.0%
associate-/r/99.0%
metadata-eval99.0%
*-commutative99.0%
Applied egg-rr99.0%
Final simplification98.4%
(FPCore (x) :precision binary32 (if (<= x 0.4000000059604645) (copysign x x) (copysign (log (* x 2.0)) x)))
float code(float x) {
float tmp;
if (x <= 0.4000000059604645f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.4000000059604645)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x * Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(0.4000000059604645)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x * single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.4000000059604645:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < 0.400000006Initial program 35.2%
+-commutative35.2%
hypot-1-def52.1%
flip-+17.6%
hypot-1-def17.5%
hypot-1-def17.4%
add-sqr-sqrt17.5%
+-commutative17.5%
hypot-1-def17.5%
+-commutative17.5%
div-sub17.4%
Applied egg-rr18.8%
div-sub19.2%
fma-undefine19.2%
unpow219.2%
associate--r+34.2%
+-inverses52.3%
metadata-eval52.3%
Simplified52.3%
Taylor expanded in x around 0 66.2%
if 0.400000006 < x Initial program 54.5%
+-commutative54.5%
hypot-1-def100.0%
flip-+4.4%
hypot-1-def4.3%
hypot-1-def3.8%
add-sqr-sqrt4.2%
+-commutative4.2%
hypot-1-def3.6%
+-commutative3.6%
div-sub3.7%
Applied egg-rr4.2%
div-sub4.2%
fma-undefine4.2%
unpow24.2%
associate--r+4.2%
+-inverses4.2%
metadata-eval4.2%
Simplified4.2%
Taylor expanded in x around inf 99.0%
associate-/r/99.0%
metadata-eval99.0%
*-commutative99.0%
Applied egg-rr99.0%
Final simplification74.9%
(FPCore (x) :precision binary32 (if (<= x 0.4000000059604645) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 0.4000000059604645f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.4000000059604645)) tmp = copysign(x, x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.4000000059604645:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < 0.400000006Initial program 35.2%
+-commutative35.2%
hypot-1-def52.1%
flip-+17.6%
hypot-1-def17.5%
hypot-1-def17.4%
add-sqr-sqrt17.5%
+-commutative17.5%
hypot-1-def17.5%
+-commutative17.5%
div-sub17.4%
Applied egg-rr18.8%
div-sub19.2%
fma-undefine19.2%
unpow219.2%
associate--r+34.2%
+-inverses52.3%
metadata-eval52.3%
Simplified52.3%
Taylor expanded in x around 0 66.2%
if 0.400000006 < x Initial program 54.5%
Taylor expanded in x around 0 44.4%
log1p-define44.4%
rem-square-sqrt44.4%
fabs-sqr44.4%
rem-square-sqrt44.4%
Simplified44.4%
Final simplification60.4%
(FPCore (x) :precision binary32 (copysign x x))
float code(float x) {
return copysignf(x, x);
}
function code(x) return copysign(x, x) end
function tmp = code(x) tmp = sign(x) * abs(x); end
\begin{array}{l}
\\
\mathsf{copysign}\left(x, x\right)
\end{array}
Initial program 40.3%
+-commutative40.3%
hypot-1-def64.8%
flip-+14.1%
hypot-1-def14.0%
hypot-1-def13.8%
add-sqr-sqrt14.0%
+-commutative14.0%
hypot-1-def13.8%
+-commutative13.8%
div-sub13.8%
Applied egg-rr14.9%
div-sub15.2%
fma-undefine15.2%
unpow215.2%
associate--r+26.3%
+-inverses39.5%
metadata-eval39.5%
Simplified39.5%
Taylor expanded in x around 0 51.6%
Final simplification51.6%
(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 2024095
(FPCore (x)
:name "Rust f32::asinh"
:precision binary32
:alt
(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))