
(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 11 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 -0.11599999666213989)
(copysign (log (/ -1.0 (- x (hypot 1.0 x)))) x)
(if (<= t_0 0.10000000149011612)
(copysign
(* x (+ 1.0 (* (pow x 2.0) (- (* (* x x) 0.075) 0.16666666666666666))))
x)
(copysign (log1p (+ (hypot 1.0 x) (+ x -1.0))) x)))))
float code(float x) {
float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
float tmp;
if (t_0 <= -0.11599999666213989f) {
tmp = copysignf(logf((-1.0f / (x - hypotf(1.0f, x)))), x);
} else if (t_0 <= 0.10000000149011612f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * (((x * x) * 0.075f) - 0.16666666666666666f)))), x);
} else {
tmp = copysignf(log1pf((hypotf(1.0f, x) + (x + -1.0f))), 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.11599999666213989)) tmp = copysign(log(Float32(Float32(-1.0) / Float32(x - hypot(Float32(1.0), x)))), x); elseif (t_0 <= Float32(0.10000000149011612)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32((x ^ Float32(2.0)) * Float32(Float32(Float32(x * x) * Float32(0.075)) - Float32(0.16666666666666666))))), x); else tmp = copysign(log1p(Float32(hypot(Float32(1.0), x) + Float32(x + Float32(-1.0)))), 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.11599999666213989:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-1}{x - \mathsf{hypot}\left(1, x\right)}\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot \left(\left(x \cdot x\right) \cdot 0.075 - 0.16666666666666666\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\mathsf{hypot}\left(1, x\right) + \left(x + -1\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) < -0.115999997Initial program 50.9%
+-commutative50.9%
hypot-1-def99.8%
Simplified99.8%
flip-+9.1%
div-sub9.0%
pow29.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt3.2%
Applied egg-rr11.6%
div-sub13.1%
fma-undefine13.1%
unpow213.1%
associate--r+47.6%
sub-neg47.6%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
if -0.115999997 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.100000001Initial program 22.2%
+-commutative22.2%
hypot-1-def22.3%
Simplified22.3%
log1p-expm1-u22.3%
expm1-undefine22.3%
add-exp-log22.3%
add-sqr-sqrt10.5%
fabs-sqr10.5%
add-sqr-sqrt22.6%
Applied egg-rr22.6%
Taylor expanded in x around 0 99.9%
unpow299.9%
Applied egg-rr99.9%
if 0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 49.2%
+-commutative49.2%
hypot-1-def99.9%
Simplified99.9%
log1p-expm1-u99.9%
expm1-undefine99.9%
add-exp-log99.9%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
+-commutative99.9%
associate--l+99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -0.11800000071525574)
(copysign (log (/ -1.0 (- x (hypot 1.0 x)))) x)
(if (<= x 0.10000000149011612)
(copysign
(* x (+ 1.0 (* (pow x 2.0) (- (* (* x x) 0.075) 0.16666666666666666))))
x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -0.11800000071525574f) {
tmp = copysignf(logf((-1.0f / (x - hypotf(1.0f, x)))), x);
} else if (x <= 0.10000000149011612f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * (((x * x) * 0.075f) - 0.16666666666666666f)))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.11800000071525574)) tmp = copysign(log(Float32(Float32(-1.0) / Float32(x - hypot(Float32(1.0), x)))), x); elseif (x <= Float32(0.10000000149011612)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32((x ^ Float32(2.0)) * Float32(Float32(Float32(x * x) * Float32(0.075)) - Float32(0.16666666666666666))))), 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.11800000071525574)) tmp = sign(x) * abs(log((single(-1.0) / (x - hypot(single(1.0), x))))); elseif (x <= single(0.10000000149011612)) tmp = sign(x) * abs((x * (single(1.0) + ((x ^ single(2.0)) * (((x * x) * single(0.075)) - single(0.16666666666666666)))))); 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.11800000071525574:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-1}{x - \mathsf{hypot}\left(1, x\right)}\right), x\right)\\
\mathbf{elif}\;x \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot \left(\left(x \cdot x\right) \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 x < -0.118000001Initial program 50.9%
+-commutative50.9%
hypot-1-def99.8%
Simplified99.8%
flip-+9.1%
div-sub9.0%
pow29.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt3.2%
Applied egg-rr11.6%
div-sub13.1%
fma-undefine13.1%
unpow213.1%
associate--r+47.6%
sub-neg47.6%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
if -0.118000001 < x < 0.100000001Initial program 22.2%
+-commutative22.2%
hypot-1-def22.3%
Simplified22.3%
log1p-expm1-u22.3%
expm1-undefine22.3%
add-exp-log22.3%
add-sqr-sqrt10.5%
fabs-sqr10.5%
add-sqr-sqrt22.6%
Applied egg-rr22.6%
Taylor expanded in x around 0 99.9%
unpow299.9%
Applied egg-rr99.9%
if 0.100000001 < x Initial program 49.2%
+-commutative49.2%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around 0 49.2%
rem-square-sqrt49.2%
fabs-sqr49.2%
rem-square-sqrt49.2%
metadata-eval49.2%
unpow249.2%
hypot-undefine99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -0.20000000298023224)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.10000000149011612)
(copysign
(* x (+ 1.0 (* (pow x 2.0) (- (* (* x x) 0.075) 0.16666666666666666))))
x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -0.20000000298023224f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.10000000149011612f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * (((x * x) * 0.075f) - 0.16666666666666666f)))), 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(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.10000000149011612)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32((x ^ Float32(2.0)) * Float32(Float32(Float32(x * x) * Float32(0.075)) - Float32(0.16666666666666666))))), 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(-log((hypot(single(1.0), x) - x))); elseif (x <= single(0.10000000149011612)) tmp = sign(x) * abs((x * (single(1.0) + ((x ^ single(2.0)) * (((x * x) * single(0.075)) - single(0.16666666666666666)))))); 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(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot \left(\left(x \cdot x\right) \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 x < -0.200000003Initial program 50.3%
+-commutative50.3%
hypot-1-def100.0%
Simplified100.0%
flip-+7.8%
frac-2neg7.8%
log-div7.8%
Applied egg-rr11.7%
fma-undefine11.7%
unpow211.7%
associate--r+46.8%
sub-neg46.8%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
if -0.200000003 < x < 0.100000001Initial program 22.8%
+-commutative22.8%
hypot-1-def22.8%
Simplified22.8%
log1p-expm1-u22.8%
expm1-undefine22.8%
add-exp-log22.8%
add-sqr-sqrt10.4%
fabs-sqr10.4%
add-sqr-sqrt23.2%
Applied egg-rr23.2%
Taylor expanded in x around 0 99.9%
unpow299.9%
Applied egg-rr99.9%
if 0.100000001 < x Initial program 49.2%
+-commutative49.2%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around 0 49.2%
rem-square-sqrt49.2%
fabs-sqr49.2%
rem-square-sqrt49.2%
metadata-eval49.2%
unpow249.2%
hypot-undefine99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.10000000149011612)
(copysign
(* x (+ 1.0 (* (pow x 2.0) (- (* (* x x) 0.075) 0.16666666666666666))))
x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.10000000149011612f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * (((x * x) * 0.075f) - 0.16666666666666666f)))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.10000000149011612)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32((x ^ Float32(2.0)) * Float32(Float32(Float32(x * x) * Float32(0.075)) - Float32(0.16666666666666666))))), 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(-5.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.10000000149011612)) tmp = sign(x) * abs((x * (single(1.0) + ((x ^ single(2.0)) * (((x * x) * single(0.075)) - single(0.16666666666666666)))))); 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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot \left(\left(x \cdot x\right) \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 x < -5Initial program 49.5%
+-commutative49.5%
hypot-1-def100.0%
Simplified100.0%
add-log-exp10.9%
*-un-lft-identity10.9%
exp-prod10.9%
log-pow99.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.2%
Applied egg-rr12.2%
rem-log-exp12.2%
*-rgt-identity12.2%
+-commutative12.2%
Applied egg-rr12.2%
Taylor expanded in x around -inf 97.4%
if -5 < x < 0.100000001Initial program 23.3%
+-commutative23.3%
hypot-1-def23.4%
Simplified23.4%
log1p-expm1-u23.4%
expm1-undefine23.4%
add-exp-log23.4%
add-sqr-sqrt10.4%
fabs-sqr10.4%
add-sqr-sqrt23.7%
Applied egg-rr23.7%
Taylor expanded in x around 0 99.6%
unpow299.6%
Applied egg-rr99.6%
if 0.100000001 < x Initial program 49.2%
+-commutative49.2%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around 0 49.2%
rem-square-sqrt49.2%
fabs-sqr49.2%
rem-square-sqrt49.2%
metadata-eval49.2%
unpow249.2%
hypot-undefine99.9%
Simplified99.9%
Final simplification99.1%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 2.0)
(copysign
(* x (+ 1.0 (* (pow x 2.0) (- (* (* x x) 0.075) 0.16666666666666666))))
x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 2.0f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * (((x * x) * 0.075f) - 0.16666666666666666f)))), x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(2.0)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32((x ^ Float32(2.0)) * Float32(Float32(Float32(x * x) * Float32(0.075)) - Float32(0.16666666666666666))))), 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(-5.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(2.0)) tmp = sign(x) * abs((x * (single(1.0) + ((x ^ single(2.0)) * (((x * x) * single(0.075)) - single(0.16666666666666666)))))); 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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 2:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot \left(\left(x \cdot x\right) \cdot 0.075 - 0.16666666666666666\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 49.5%
+-commutative49.5%
hypot-1-def100.0%
Simplified100.0%
add-log-exp10.9%
*-un-lft-identity10.9%
exp-prod10.9%
log-pow99.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.2%
Applied egg-rr12.2%
rem-log-exp12.2%
*-rgt-identity12.2%
+-commutative12.2%
Applied egg-rr12.2%
Taylor expanded in x around -inf 97.4%
if -5 < x < 2Initial program 24.5%
+-commutative24.5%
hypot-1-def24.5%
Simplified24.5%
log1p-expm1-u24.5%
expm1-undefine24.5%
add-exp-log24.5%
add-sqr-sqrt11.7%
fabs-sqr11.7%
add-sqr-sqrt24.8%
Applied egg-rr24.8%
Taylor expanded in x around 0 98.7%
unpow298.7%
Applied egg-rr98.7%
if 2 < x Initial program 47.4%
+-commutative47.4%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 98.9%
+-commutative98.9%
rem-square-sqrt98.9%
fabs-sqr98.9%
rem-square-sqrt98.9%
*-inverses98.9%
metadata-eval98.9%
Simplified98.9%
Final simplification98.4%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.2000000476837158)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.2000000476837158f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.2000000476837158)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), 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(-5.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.2000000476837158)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); 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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1.2000000476837158:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 49.5%
+-commutative49.5%
hypot-1-def100.0%
Simplified100.0%
add-log-exp10.9%
*-un-lft-identity10.9%
exp-prod10.9%
log-pow99.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.2%
Applied egg-rr12.2%
rem-log-exp12.2%
*-rgt-identity12.2%
+-commutative12.2%
Applied egg-rr12.2%
Taylor expanded in x around -inf 97.4%
if -5 < x < 1.20000005Initial program 23.9%
+-commutative23.9%
hypot-1-def23.9%
Simplified23.9%
log1p-expm1-u24.0%
expm1-undefine24.0%
add-exp-log24.0%
add-sqr-sqrt11.0%
fabs-sqr11.0%
add-sqr-sqrt24.3%
Applied egg-rr24.3%
Taylor expanded in x around 0 98.4%
distribute-rgt-in98.4%
*-lft-identity98.4%
associate-*l*98.4%
unpow298.4%
unpow398.4%
Simplified98.4%
if 1.20000005 < x Initial program 48.3%
+-commutative48.3%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 97.8%
+-commutative97.8%
rem-square-sqrt97.8%
fabs-sqr97.8%
rem-square-sqrt97.8%
*-inverses97.8%
metadata-eval97.8%
Simplified97.8%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 2.0)
(copysign
(*
x
(+ 1.0 (* (* x x) (- (* x (+ 0.125 (* x -0.05))) 0.16666666666666666))))
x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 2.0f) {
tmp = copysignf((x * (1.0f + ((x * x) * ((x * (0.125f + (x * -0.05f))) - 0.16666666666666666f)))), x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(2.0)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(Float32(x * Float32(Float32(0.125) + Float32(x * Float32(-0.05)))) - Float32(0.16666666666666666))))), 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(-5.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(2.0)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * ((x * (single(0.125) + (x * single(-0.05)))) - single(0.16666666666666666)))))); 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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 2:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot \left(x \cdot \left(0.125 + x \cdot -0.05\right) - 0.16666666666666666\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 49.5%
+-commutative49.5%
hypot-1-def100.0%
Simplified100.0%
add-log-exp10.9%
*-un-lft-identity10.9%
exp-prod10.9%
log-pow99.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.2%
Applied egg-rr12.2%
rem-log-exp12.2%
*-rgt-identity12.2%
+-commutative12.2%
Applied egg-rr12.2%
Taylor expanded in x around -inf 97.4%
if -5 < x < 2Initial program 24.5%
+-commutative24.5%
hypot-1-def24.5%
Simplified24.5%
log1p-expm1-u24.5%
expm1-undefine24.5%
add-exp-log24.5%
add-sqr-sqrt11.7%
fabs-sqr11.7%
add-sqr-sqrt24.8%
Applied egg-rr24.8%
Taylor expanded in x around 0 97.0%
*-commutative97.0%
Simplified97.0%
Taylor expanded in x around 0 97.1%
unpow298.7%
Applied egg-rr97.1%
if 2 < x Initial program 47.4%
+-commutative47.4%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 98.9%
+-commutative98.9%
rem-square-sqrt98.9%
fabs-sqr98.9%
rem-square-sqrt98.9%
*-inverses98.9%
metadata-eval98.9%
Simplified98.9%
Final simplification97.6%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (- x)) x)
(if (<= x 2.0)
(copysign
(*
x
(+ 1.0 (* (* x x) (- (* x (+ 0.125 (* x -0.05))) 0.16666666666666666))))
x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf(-x), x);
} else if (x <= 2.0f) {
tmp = copysignf((x * (1.0f + ((x * x) * ((x * (0.125f + (x * -0.05f))) - 0.16666666666666666f)))), x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(log(Float32(-x)), x); elseif (x <= Float32(2.0)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(Float32(x * Float32(Float32(0.125) + Float32(x * Float32(-0.05)))) - Float32(0.16666666666666666))))), 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(-5.0)) tmp = sign(x) * abs(log(-x)); elseif (x <= single(2.0)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * ((x * (single(0.125) + (x * single(-0.05)))) - single(0.16666666666666666)))))); 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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{elif}\;x \leq 2:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot \left(x \cdot \left(0.125 + x \cdot -0.05\right) - 0.16666666666666666\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 49.5%
+-commutative49.5%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 44.4%
mul-1-neg44.4%
Simplified44.4%
if -5 < x < 2Initial program 24.5%
+-commutative24.5%
hypot-1-def24.5%
Simplified24.5%
log1p-expm1-u24.5%
expm1-undefine24.5%
add-exp-log24.5%
add-sqr-sqrt11.7%
fabs-sqr11.7%
add-sqr-sqrt24.8%
Applied egg-rr24.8%
Taylor expanded in x around 0 97.0%
*-commutative97.0%
Simplified97.0%
Taylor expanded in x around 0 97.1%
unpow298.7%
Applied egg-rr97.1%
if 2 < x Initial program 47.4%
+-commutative47.4%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 98.9%
+-commutative98.9%
rem-square-sqrt98.9%
fabs-sqr98.9%
rem-square-sqrt98.9%
*-inverses98.9%
metadata-eval98.9%
Simplified98.9%
Final simplification84.6%
(FPCore (x) :precision binary32 (if (<= x -5.0) (copysign (log (- x)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf(-x), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(log(Float32(-x)), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 49.5%
+-commutative49.5%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 44.4%
mul-1-neg44.4%
Simplified44.4%
if -5 < x Initial program 31.2%
+-commutative31.2%
hypot-1-def46.8%
Simplified46.8%
Taylor expanded in x around 0 26.9%
log1p-define78.0%
rem-square-sqrt45.4%
fabs-sqr45.4%
rem-square-sqrt77.9%
Simplified77.9%
(FPCore (x) :precision binary32 (if (<= x 2.0) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 2.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(2.0)) tmp = copysign(x, x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < 2Initial program 32.4%
+-commutative32.4%
hypot-1-def48.4%
Simplified48.4%
log1p-expm1-u48.4%
expm1-undefine48.4%
add-exp-log48.4%
add-sqr-sqrt8.0%
fabs-sqr8.0%
add-sqr-sqrt20.8%
Applied egg-rr20.8%
Taylor expanded in x around 0 69.1%
if 2 < x Initial program 47.4%
+-commutative47.4%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around 0 44.6%
log1p-define44.6%
rem-square-sqrt44.6%
fabs-sqr44.6%
rem-square-sqrt44.6%
Simplified44.6%
(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 35.7%
+-commutative35.7%
hypot-1-def59.9%
Simplified59.9%
log1p-expm1-u59.9%
expm1-undefine59.9%
add-exp-log59.9%
add-sqr-sqrt28.5%
fabs-sqr28.5%
add-sqr-sqrt38.4%
Applied egg-rr38.4%
Taylor expanded in x around 0 56.1%
(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 2024113
(FPCore (x)
:name "Rust f32::asinh"
:precision binary32
:alt
(! :herbie-platform default (let* ((ax (fabs x)) (ix (/ 1 ax))) (copysign (log1p (+ ax (/ ax (+ (hypot 1 ix) ix)))) x)))
(copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))