
(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.20000000298023224)
(copysign (log (- (hypot 1.0 x) x)) x)
(if (<= t_0 1.0)
(copysign
(*
x
(+
1.0
(*
(pow x 2.0)
(-
(* (pow x 2.0) (+ 0.075 (* (pow x 2.0) -0.044642857142857144)))
0.16666666666666666))))
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((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 1.0f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * ((powf(x, 2.0f) * (0.075f + (powf(x, 2.0f) * -0.044642857142857144f))) - 0.16666666666666666f)))), 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(hypot(Float32(1.0), x) - x)), x); elseif (t_0 <= Float32(1.0)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32((x ^ Float32(2.0)) * Float32(Float32((x ^ Float32(2.0)) * Float32(Float32(0.075) + Float32((x ^ Float32(2.0)) * Float32(-0.044642857142857144)))) - Float32(0.16666666666666666))))), x); else tmp = copysign(Float32(-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((hypot(single(1.0), x) - x))); elseif (t_0 <= single(1.0)) tmp = sign(x) * abs((x * (single(1.0) + ((x ^ single(2.0)) * (((x ^ single(2.0)) * (single(0.075) + ((x ^ single(2.0)) * single(-0.044642857142857144)))) - single(0.16666666666666666)))))); 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(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot \left({x}^{2} \cdot \left(0.075 + {x}^{2} \cdot -0.044642857142857144\right) - 0.16666666666666666\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) #s(literal 1 binary32))))) x) < -0.200000003Initial program 53.9%
flip-+7.0%
clear-num7.1%
log-div7.1%
metadata-eval7.1%
+-commutative7.1%
hypot-1-def7.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.9%
Applied egg-rr9.5%
neg-sub09.5%
div-sub9.5%
*-rgt-identity9.5%
associate-/l*9.5%
*-rgt-identity9.5%
associate-/l*9.5%
fma-undefine8.9%
unpow28.9%
associate--r+9.6%
+-inverses9.6%
metadata-eval9.6%
metadata-eval9.6%
*-commutative9.6%
neg-mul-19.6%
neg-sub09.6%
fma-undefine8.9%
unpow28.9%
Simplified99.8%
*-un-lft-identity99.8%
add-sqr-sqrt-0.0%
sqrt-unprod99.8%
sqr-neg99.8%
sqrt-unprod98.5%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
*-lft-identity99.8%
Simplified99.8%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 1Initial program 24.0%
+-commutative24.0%
hypot-1-def24.1%
flip-+24.0%
hypot-1-def24.1%
hypot-1-def24.0%
add-sqr-sqrt24.0%
+-commutative24.0%
hypot-1-def23.9%
+-commutative23.9%
div-sub24.0%
Applied egg-rr23.9%
div-sub24.0%
remove-double-neg24.0%
distribute-frac-neg224.0%
distribute-frac-neg24.0%
neg-sub024.0%
associate--r-24.0%
neg-sub024.0%
+-commutative24.0%
fma-undefine24.0%
unpow224.0%
+-commutative24.0%
associate-+l+23.9%
sub-neg23.9%
+-inverses23.9%
metadata-eval23.9%
neg-sub023.9%
associate--r-23.9%
neg-sub023.9%
+-commutative23.9%
sub-neg23.9%
Simplified23.9%
Taylor expanded in x around 0 99.7%
if 1 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 53.2%
flip-+3.6%
clear-num3.6%
log-div3.6%
metadata-eval3.6%
+-commutative3.6%
hypot-1-def3.4%
add-sqr-sqrt4.1%
fabs-sqr4.1%
add-sqr-sqrt3.4%
Applied egg-rr3.5%
neg-sub03.5%
div-sub3.5%
*-rgt-identity3.5%
associate-/l*3.5%
*-rgt-identity3.5%
associate-/l*3.5%
fma-undefine3.5%
unpow23.5%
associate--r+3.5%
+-inverses3.5%
metadata-eval3.5%
metadata-eval3.5%
*-commutative3.5%
neg-mul-13.5%
neg-sub03.5%
fma-undefine3.5%
unpow23.5%
Simplified9.7%
Taylor expanded in x around inf 98.9%
Final simplification99.5%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.11999999731779099)
(copysign (log (- (hypot 1.0 x) x)) x)
(if (<= t_0 1.0)
(copysign
(+ x (* (fma (* x x) 0.075 -0.16666666666666666) (pow x 3.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.11999999731779099f) {
tmp = copysignf(logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 1.0f) {
tmp = copysignf((x + (fmaf((x * x), 0.075f, -0.16666666666666666f) * powf(x, 3.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.11999999731779099)) tmp = copysign(log(Float32(hypot(Float32(1.0), x) - x)), x); elseif (t_0 <= Float32(1.0)) tmp = copysign(Float32(x + Float32(fma(Float32(x * x), Float32(0.075), Float32(-0.16666666666666666)) * (x ^ Float32(3.0)))), x); else tmp = copysign(Float32(-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)\\
\mathbf{if}\;t\_0 \leq -0.11999999731779099:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x + \mathsf{fma}\left(x \cdot x, 0.075, -0.16666666666666666\right) \cdot {x}^{3}, 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) #s(literal 1 binary32))))) x) < -0.119999997Initial program 54.7%
flip-+8.6%
clear-num8.7%
log-div8.7%
metadata-eval8.7%
+-commutative8.7%
hypot-1-def8.6%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.4%
Applied egg-rr11.1%
neg-sub011.1%
div-sub11.1%
*-rgt-identity11.1%
associate-/l*11.1%
*-rgt-identity11.1%
associate-/l*11.1%
fma-undefine10.5%
unpow210.5%
associate--r+11.2%
+-inverses11.2%
metadata-eval11.2%
metadata-eval11.2%
*-commutative11.2%
neg-mul-111.2%
neg-sub011.2%
fma-undefine10.5%
unpow210.5%
Simplified99.7%
*-un-lft-identity99.7%
add-sqr-sqrt-0.0%
sqrt-unprod99.7%
sqr-neg99.7%
sqrt-unprod98.5%
add-sqr-sqrt99.7%
Applied egg-rr99.7%
*-lft-identity99.7%
Simplified99.7%
if -0.119999997 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 1Initial program 23.5%
+-commutative23.5%
hypot-1-def23.5%
flip-+23.5%
hypot-1-def23.6%
hypot-1-def23.4%
add-sqr-sqrt23.5%
+-commutative23.5%
hypot-1-def23.4%
+-commutative23.4%
div-sub23.4%
Applied egg-rr23.4%
div-sub23.4%
remove-double-neg23.4%
distribute-frac-neg223.4%
distribute-frac-neg23.4%
neg-sub023.4%
associate--r-23.4%
neg-sub023.4%
+-commutative23.4%
fma-undefine23.4%
unpow223.4%
+-commutative23.4%
associate-+l+23.4%
sub-neg23.4%
+-inverses23.4%
metadata-eval23.4%
neg-sub023.4%
associate--r-23.4%
neg-sub023.4%
+-commutative23.4%
sub-neg23.4%
Simplified23.4%
Taylor expanded in x around 0 99.6%
distribute-rgt-in99.7%
*-lft-identity99.7%
*-commutative99.7%
associate-*l*99.7%
*-commutative99.7%
fma-neg99.7%
metadata-eval99.7%
unpow299.7%
unpow399.7%
Simplified99.7%
unpow299.7%
Applied egg-rr99.7%
if 1 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 53.2%
flip-+3.6%
clear-num3.6%
log-div3.6%
metadata-eval3.6%
+-commutative3.6%
hypot-1-def3.4%
add-sqr-sqrt4.1%
fabs-sqr4.1%
add-sqr-sqrt3.4%
Applied egg-rr3.5%
neg-sub03.5%
div-sub3.5%
*-rgt-identity3.5%
associate-/l*3.5%
*-rgt-identity3.5%
associate-/l*3.5%
fma-undefine3.5%
unpow23.5%
associate--r+3.5%
+-inverses3.5%
metadata-eval3.5%
metadata-eval3.5%
*-commutative3.5%
neg-mul-13.5%
neg-sub03.5%
fma-undefine3.5%
unpow23.5%
Simplified9.7%
Taylor expanded in x around inf 98.9%
(FPCore (x)
:precision binary32
(if (<= x -0.10000000149011612)
(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.10000000149011612f) {
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.10000000149011612)) tmp = copysign(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(Float32(-log(Float32(Float32(0.5) / x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-0.10000000149011612)) 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.10000000149011612:\\
\;\;\;\;\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.100000001Initial program 55.4%
flip-+10.2%
clear-num10.2%
log-div10.2%
metadata-eval10.2%
+-commutative10.2%
hypot-1-def10.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt11.8%
Applied egg-rr12.6%
neg-sub012.6%
div-sub12.6%
*-rgt-identity12.6%
associate-/l*12.6%
*-rgt-identity12.6%
associate-/l*12.6%
fma-undefine12.0%
unpow212.0%
associate--r+12.7%
+-inverses12.7%
metadata-eval12.7%
metadata-eval12.7%
*-commutative12.7%
neg-mul-112.7%
neg-sub012.7%
fma-undefine12.0%
unpow212.0%
Simplified99.7%
*-un-lft-identity99.7%
add-sqr-sqrt-0.0%
sqrt-unprod99.7%
sqr-neg99.7%
sqrt-unprod98.5%
add-sqr-sqrt99.7%
Applied egg-rr99.7%
*-lft-identity99.7%
Simplified99.7%
if -0.100000001 < x < 1Initial program 23.0%
+-commutative23.0%
hypot-1-def23.0%
flip-+22.9%
hypot-1-def23.0%
hypot-1-def22.9%
add-sqr-sqrt23.0%
+-commutative23.0%
hypot-1-def22.9%
+-commutative22.9%
div-sub23.0%
Applied egg-rr22.9%
div-sub22.9%
remove-double-neg22.9%
distribute-frac-neg222.9%
distribute-frac-neg22.9%
neg-sub022.9%
associate--r-22.9%
neg-sub022.9%
+-commutative22.9%
fma-undefine22.9%
unpow222.9%
+-commutative22.9%
associate-+l+22.9%
sub-neg22.9%
+-inverses22.9%
metadata-eval22.9%
neg-sub022.9%
associate--r-22.9%
neg-sub022.9%
+-commutative22.9%
sub-neg22.9%
Simplified22.9%
Taylor expanded in x around 0 99.5%
distribute-rgt-in99.5%
*-lft-identity99.5%
associate-*l*99.5%
unpow299.5%
unpow399.5%
Simplified99.5%
if 1 < x Initial program 53.2%
flip-+3.6%
clear-num3.6%
log-div3.6%
metadata-eval3.6%
+-commutative3.6%
hypot-1-def3.4%
add-sqr-sqrt4.1%
fabs-sqr4.1%
add-sqr-sqrt3.4%
Applied egg-rr3.5%
neg-sub03.5%
div-sub3.5%
*-rgt-identity3.5%
associate-/l*3.5%
*-rgt-identity3.5%
associate-/l*3.5%
fma-undefine3.5%
unpow23.5%
associate--r+3.5%
+-inverses3.5%
metadata-eval3.5%
metadata-eval3.5%
*-commutative3.5%
neg-mul-13.5%
neg-sub03.5%
fma-undefine3.5%
unpow23.5%
Simplified9.7%
Taylor expanded in x around inf 98.9%
(FPCore (x)
:precision binary32
(if (<= x -500.0)
(copysign (- (log (* 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 <= -500.0f) {
tmp = copysignf(-logf((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(-500.0)) tmp = copysign(Float32(-log(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(Float32(-log(Float32(Float32(0.5) / x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-500.0)) tmp = sign(x) * abs(-log((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 -500:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(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 < -500Initial program 51.4%
+-commutative51.4%
hypot-1-def100.0%
flip-+1.9%
hypot-1-def1.9%
hypot-1-def1.9%
add-sqr-sqrt1.9%
+-commutative1.9%
hypot-1-def1.9%
+-commutative1.9%
div-sub1.8%
Applied egg-rr5.6%
div-sub7.2%
remove-double-neg7.2%
distribute-frac-neg27.2%
distribute-frac-neg7.2%
neg-sub07.2%
associate--r-7.2%
neg-sub07.2%
+-commutative7.2%
fma-undefine6.6%
unpow26.6%
+-commutative6.6%
associate-+l+48.0%
sub-neg48.0%
+-inverses99.9%
metadata-eval99.9%
neg-sub099.9%
associate--r-99.9%
neg-sub099.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around -inf 99.9%
clear-num99.9%
log-rec99.9%
div-inv99.9%
metadata-eval99.9%
Applied egg-rr99.9%
if -500 < x < 1Initial program 25.5%
+-commutative25.5%
hypot-1-def25.6%
flip-+25.5%
hypot-1-def25.6%
hypot-1-def25.4%
add-sqr-sqrt25.6%
+-commutative25.6%
hypot-1-def25.4%
+-commutative25.4%
div-sub25.4%
Applied egg-rr25.4%
div-sub25.5%
remove-double-neg25.5%
distribute-frac-neg225.5%
distribute-frac-neg25.5%
neg-sub025.5%
associate--r-25.5%
neg-sub025.5%
+-commutative25.5%
fma-undefine25.5%
unpow225.5%
+-commutative25.5%
associate-+l+25.4%
sub-neg25.4%
+-inverses25.4%
metadata-eval25.4%
neg-sub025.4%
associate--r-25.4%
neg-sub025.4%
+-commutative25.4%
sub-neg25.4%
Simplified25.4%
Taylor expanded in x around 0 98.2%
distribute-rgt-in98.2%
*-lft-identity98.2%
associate-*l*98.2%
unpow298.2%
unpow398.2%
Simplified98.2%
if 1 < x Initial program 53.2%
flip-+3.6%
clear-num3.6%
log-div3.6%
metadata-eval3.6%
+-commutative3.6%
hypot-1-def3.4%
add-sqr-sqrt4.1%
fabs-sqr4.1%
add-sqr-sqrt3.4%
Applied egg-rr3.5%
neg-sub03.5%
div-sub3.5%
*-rgt-identity3.5%
associate-/l*3.5%
*-rgt-identity3.5%
associate-/l*3.5%
fma-undefine3.5%
unpow23.5%
associate--r+3.5%
+-inverses3.5%
metadata-eval3.5%
metadata-eval3.5%
*-commutative3.5%
neg-mul-13.5%
neg-sub03.5%
fma-undefine3.5%
unpow23.5%
Simplified9.7%
Taylor expanded in x around inf 98.9%
(FPCore (x)
:precision binary32
(if (<= x -500.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 1.0)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (- (log (/ 0.5 x))) x))))
float code(float x) {
float tmp;
if (x <= -500.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 1.0f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
} else {
tmp = copysignf(-logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-500.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), 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(-500.0)) tmp = sign(x) * abs(-log((x * single(-2.0)))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * single(-0.16666666666666666))))); 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 -500:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -500Initial program 51.4%
+-commutative51.4%
hypot-1-def100.0%
flip-+1.9%
hypot-1-def1.9%
hypot-1-def1.9%
add-sqr-sqrt1.9%
+-commutative1.9%
hypot-1-def1.9%
+-commutative1.9%
div-sub1.8%
Applied egg-rr5.6%
div-sub7.2%
remove-double-neg7.2%
distribute-frac-neg27.2%
distribute-frac-neg7.2%
neg-sub07.2%
associate--r-7.2%
neg-sub07.2%
+-commutative7.2%
fma-undefine6.6%
unpow26.6%
+-commutative6.6%
associate-+l+48.0%
sub-neg48.0%
+-inverses99.9%
metadata-eval99.9%
neg-sub099.9%
associate--r-99.9%
neg-sub099.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around -inf 99.9%
clear-num99.9%
log-rec99.9%
div-inv99.9%
metadata-eval99.9%
Applied egg-rr99.9%
if -500 < x < 1Initial program 25.5%
+-commutative25.5%
hypot-1-def25.6%
flip-+25.5%
hypot-1-def25.6%
hypot-1-def25.4%
add-sqr-sqrt25.6%
+-commutative25.6%
hypot-1-def25.4%
+-commutative25.4%
div-sub25.4%
Applied egg-rr25.4%
div-sub25.5%
remove-double-neg25.5%
distribute-frac-neg225.5%
distribute-frac-neg25.5%
neg-sub025.5%
associate--r-25.5%
neg-sub025.5%
+-commutative25.5%
fma-undefine25.5%
unpow225.5%
+-commutative25.5%
associate-+l+25.4%
sub-neg25.4%
+-inverses25.4%
metadata-eval25.4%
neg-sub025.4%
associate--r-25.4%
neg-sub025.4%
+-commutative25.4%
sub-neg25.4%
Simplified25.4%
Taylor expanded in x around 0 98.2%
*-commutative98.2%
Simplified98.2%
unpow298.9%
Applied egg-rr98.2%
if 1 < x Initial program 53.2%
flip-+3.6%
clear-num3.6%
log-div3.6%
metadata-eval3.6%
+-commutative3.6%
hypot-1-def3.4%
add-sqr-sqrt4.1%
fabs-sqr4.1%
add-sqr-sqrt3.4%
Applied egg-rr3.5%
neg-sub03.5%
div-sub3.5%
*-rgt-identity3.5%
associate-/l*3.5%
*-rgt-identity3.5%
associate-/l*3.5%
fma-undefine3.5%
unpow23.5%
associate--r+3.5%
+-inverses3.5%
metadata-eval3.5%
metadata-eval3.5%
*-commutative3.5%
neg-mul-13.5%
neg-sub03.5%
fma-undefine3.5%
unpow23.5%
Simplified9.7%
Taylor expanded in x around inf 98.9%
(FPCore (x)
:precision binary32
(if (<= x -500.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 1.0)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -500.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 1.0f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-500.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * 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(-500.0)) tmp = sign(x) * abs(-log((x * single(-2.0)))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * 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 -500:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -500Initial program 51.4%
+-commutative51.4%
hypot-1-def100.0%
flip-+1.9%
hypot-1-def1.9%
hypot-1-def1.9%
add-sqr-sqrt1.9%
+-commutative1.9%
hypot-1-def1.9%
+-commutative1.9%
div-sub1.8%
Applied egg-rr5.6%
div-sub7.2%
remove-double-neg7.2%
distribute-frac-neg27.2%
distribute-frac-neg7.2%
neg-sub07.2%
associate--r-7.2%
neg-sub07.2%
+-commutative7.2%
fma-undefine6.6%
unpow26.6%
+-commutative6.6%
associate-+l+48.0%
sub-neg48.0%
+-inverses99.9%
metadata-eval99.9%
neg-sub099.9%
associate--r-99.9%
neg-sub099.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around -inf 99.9%
clear-num99.9%
log-rec99.9%
div-inv99.9%
metadata-eval99.9%
Applied egg-rr99.9%
if -500 < x < 1Initial program 25.5%
+-commutative25.5%
hypot-1-def25.6%
flip-+25.5%
hypot-1-def25.6%
hypot-1-def25.4%
add-sqr-sqrt25.6%
+-commutative25.6%
hypot-1-def25.4%
+-commutative25.4%
div-sub25.4%
Applied egg-rr25.4%
div-sub25.5%
remove-double-neg25.5%
distribute-frac-neg225.5%
distribute-frac-neg25.5%
neg-sub025.5%
associate--r-25.5%
neg-sub025.5%
+-commutative25.5%
fma-undefine25.5%
unpow225.5%
+-commutative25.5%
associate-+l+25.4%
sub-neg25.4%
+-inverses25.4%
metadata-eval25.4%
neg-sub025.4%
associate--r-25.4%
neg-sub025.4%
+-commutative25.4%
sub-neg25.4%
Simplified25.4%
Taylor expanded in x around 0 98.2%
*-commutative98.2%
Simplified98.2%
unpow298.9%
Applied egg-rr98.2%
if 1 < x Initial program 53.2%
Taylor expanded in x around inf 95.8%
rem-square-sqrt95.7%
fabs-sqr95.7%
rem-square-sqrt95.8%
*-inverses95.8%
metadata-eval95.8%
Simplified95.8%
(FPCore (x)
:precision binary32
(if (<= x -500.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -500.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-500.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * 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(-500.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * 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 -500:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -500Initial program 51.4%
+-commutative51.4%
hypot-1-def100.0%
flip-+1.9%
hypot-1-def1.9%
hypot-1-def1.9%
add-sqr-sqrt1.9%
+-commutative1.9%
hypot-1-def1.9%
+-commutative1.9%
div-sub1.8%
Applied egg-rr5.6%
div-sub7.2%
remove-double-neg7.2%
distribute-frac-neg27.2%
distribute-frac-neg7.2%
neg-sub07.2%
associate--r-7.2%
neg-sub07.2%
+-commutative7.2%
fma-undefine6.6%
unpow26.6%
+-commutative6.6%
associate-+l+48.0%
sub-neg48.0%
+-inverses99.9%
metadata-eval99.9%
neg-sub099.9%
associate--r-99.9%
neg-sub099.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around -inf 99.9%
if -500 < x < 1Initial program 25.5%
+-commutative25.5%
hypot-1-def25.6%
flip-+25.5%
hypot-1-def25.6%
hypot-1-def25.4%
add-sqr-sqrt25.6%
+-commutative25.6%
hypot-1-def25.4%
+-commutative25.4%
div-sub25.4%
Applied egg-rr25.4%
div-sub25.5%
remove-double-neg25.5%
distribute-frac-neg225.5%
distribute-frac-neg25.5%
neg-sub025.5%
associate--r-25.5%
neg-sub025.5%
+-commutative25.5%
fma-undefine25.5%
unpow225.5%
+-commutative25.5%
associate-+l+25.4%
sub-neg25.4%
+-inverses25.4%
metadata-eval25.4%
neg-sub025.4%
associate--r-25.4%
neg-sub025.4%
+-commutative25.4%
sub-neg25.4%
Simplified25.4%
Taylor expanded in x around 0 98.2%
*-commutative98.2%
Simplified98.2%
unpow298.9%
Applied egg-rr98.2%
if 1 < x Initial program 53.2%
Taylor expanded in x around inf 95.8%
rem-square-sqrt95.7%
fabs-sqr95.7%
rem-square-sqrt95.8%
*-inverses95.8%
metadata-eval95.8%
Simplified95.8%
(FPCore (x)
:precision binary32
(if (<= x -500.0)
(copysign (log (- x)) x)
(if (<= x 1.0)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -500.0f) {
tmp = copysignf(logf(-x), x);
} else if (x <= 1.0f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-500.0)) tmp = copysign(log(Float32(-x)), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * 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(-500.0)) tmp = sign(x) * abs(log(-x)); elseif (x <= single(1.0)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * 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 -500:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -500Initial program 51.4%
Taylor expanded in x around -inf 44.5%
neg-mul-144.5%
Simplified44.5%
if -500 < x < 1Initial program 25.5%
+-commutative25.5%
hypot-1-def25.6%
flip-+25.5%
hypot-1-def25.6%
hypot-1-def25.4%
add-sqr-sqrt25.6%
+-commutative25.6%
hypot-1-def25.4%
+-commutative25.4%
div-sub25.4%
Applied egg-rr25.4%
div-sub25.5%
remove-double-neg25.5%
distribute-frac-neg225.5%
distribute-frac-neg25.5%
neg-sub025.5%
associate--r-25.5%
neg-sub025.5%
+-commutative25.5%
fma-undefine25.5%
unpow225.5%
+-commutative25.5%
associate-+l+25.4%
sub-neg25.4%
+-inverses25.4%
metadata-eval25.4%
neg-sub025.4%
associate--r-25.4%
neg-sub025.4%
+-commutative25.4%
sub-neg25.4%
Simplified25.4%
Taylor expanded in x around 0 98.2%
*-commutative98.2%
Simplified98.2%
unpow298.9%
Applied egg-rr98.2%
if 1 < x Initial program 53.2%
Taylor expanded in x around inf 95.8%
rem-square-sqrt95.7%
fabs-sqr95.7%
rem-square-sqrt95.8%
*-inverses95.8%
metadata-eval95.8%
Simplified95.8%
(FPCore (x)
:precision binary32
(if (<= x -500.0)
(copysign (log (- x)) x)
(if (<= x 1.0)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (log1p x) x))))
float code(float x) {
float tmp;
if (x <= -500.0f) {
tmp = copysignf(logf(-x), x);
} else if (x <= 1.0f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-500.0)) tmp = copysign(log(Float32(-x)), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -500:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -500Initial program 51.4%
Taylor expanded in x around -inf 44.5%
neg-mul-144.5%
Simplified44.5%
if -500 < x < 1Initial program 25.5%
+-commutative25.5%
hypot-1-def25.6%
flip-+25.5%
hypot-1-def25.6%
hypot-1-def25.4%
add-sqr-sqrt25.6%
+-commutative25.6%
hypot-1-def25.4%
+-commutative25.4%
div-sub25.4%
Applied egg-rr25.4%
div-sub25.5%
remove-double-neg25.5%
distribute-frac-neg225.5%
distribute-frac-neg25.5%
neg-sub025.5%
associate--r-25.5%
neg-sub025.5%
+-commutative25.5%
fma-undefine25.5%
unpow225.5%
+-commutative25.5%
associate-+l+25.4%
sub-neg25.4%
+-inverses25.4%
metadata-eval25.4%
neg-sub025.4%
associate--r-25.4%
neg-sub025.4%
+-commutative25.4%
sub-neg25.4%
Simplified25.4%
Taylor expanded in x around 0 98.2%
*-commutative98.2%
Simplified98.2%
unpow298.9%
Applied egg-rr98.2%
if 1 < x Initial program 53.2%
Taylor expanded in x around 0 44.8%
log1p-define44.8%
rem-square-sqrt44.8%
fabs-sqr44.8%
rem-square-sqrt44.8%
Simplified44.8%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 1.0f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(1.0)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < 1Initial program 32.4%
+-commutative32.4%
hypot-1-def45.3%
flip-+19.2%
hypot-1-def19.3%
hypot-1-def19.2%
add-sqr-sqrt19.3%
+-commutative19.3%
hypot-1-def19.2%
+-commutative19.2%
div-sub19.2%
Applied egg-rr20.2%
div-sub20.6%
remove-double-neg20.6%
distribute-frac-neg220.6%
distribute-frac-neg20.6%
neg-sub020.6%
associate--r-20.6%
neg-sub020.6%
+-commutative20.6%
fma-undefine20.5%
unpow220.5%
+-commutative20.5%
associate-+l+31.4%
sub-neg31.4%
+-inverses45.2%
metadata-eval45.2%
neg-sub045.2%
associate--r-45.2%
neg-sub045.2%
+-commutative45.2%
sub-neg45.2%
Simplified45.2%
Taylor expanded in x around 0 74.1%
*-commutative74.1%
Simplified74.1%
unpow274.5%
Applied egg-rr74.1%
if 1 < x Initial program 53.2%
Taylor expanded in x around 0 44.8%
log1p-define44.8%
rem-square-sqrt44.8%
fabs-sqr44.8%
rem-square-sqrt44.8%
Simplified44.8%
(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 37.3%
+-commutative37.3%
hypot-1-def57.4%
flip-+15.6%
hypot-1-def15.6%
hypot-1-def15.5%
add-sqr-sqrt15.6%
+-commutative15.6%
hypot-1-def15.5%
+-commutative15.5%
div-sub15.5%
Applied egg-rr16.3%
div-sub16.6%
remove-double-neg16.6%
distribute-frac-neg216.6%
distribute-frac-neg16.6%
neg-sub016.6%
associate--r-16.6%
neg-sub016.6%
+-commutative16.6%
fma-undefine16.5%
unpow216.5%
+-commutative16.5%
associate-+l+24.9%
sub-neg24.9%
+-inverses35.4%
metadata-eval35.4%
neg-sub036.8%
associate--r-36.8%
neg-sub036.8%
+-commutative36.8%
sub-neg36.8%
Simplified36.8%
Taylor expanded in x around 0 58.5%
(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 2024141
(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))