
(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 10 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 0.03999999910593033)
(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 (+ x (hypot 1.0 x))) x)))))
float code(float x) {
float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
float tmp;
if (t_0 <= -0.20000000298023224f) {
tmp = copysignf(logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.03999999910593033f) {
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((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) t_0 = copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) tmp = Float32(0.0) if (t_0 <= Float32(-0.20000000298023224)) tmp = copysign(log(Float32(hypot(Float32(1.0), x) - x)), x); elseif (t_0 <= Float32(0.03999999910593033)) 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(log(Float32(x + hypot(Float32(1.0), 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(0.03999999910593033)) 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((x + hypot(single(1.0), 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 0.03999999910593033:\\
\;\;\;\;\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(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) < -0.200000003Initial program 50.4%
+-commutative50.4%
hypot-1-def99.9%
Simplified99.9%
flip-+6.9%
frac-2neg6.9%
log-div6.8%
Applied egg-rr12.1%
sub-neg12.1%
fma-undefine12.1%
unpow212.1%
distribute-neg-in12.1%
metadata-eval12.1%
associate-+r+47.0%
sub-neg47.0%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
neg-sub099.9%
associate--r-99.9%
neg-sub099.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
*-un-lft-identity99.9%
add-sqr-sqrt-0.0%
sqrt-unprod99.9%
sqr-neg99.9%
sqrt-unprod98.7%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
*-lft-identity99.9%
Simplified99.9%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.0399999991Initial program 20.4%
+-commutative20.4%
hypot-1-def20.4%
Simplified20.4%
flip-+20.4%
div-sub20.6%
pow220.6%
add-sqr-sqrt11.0%
fabs-sqr11.0%
add-sqr-sqrt20.6%
add-sqr-sqrt11.0%
fabs-sqr11.0%
add-sqr-sqrt19.2%
Applied egg-rr20.6%
div-sub20.5%
remove-double-neg20.5%
distribute-frac-neg220.5%
neg-mul-120.5%
associate-/r*20.5%
distribute-neg-frac220.5%
fma-undefine20.5%
unpow220.5%
associate--r+20.5%
sub-neg20.5%
+-inverses20.5%
metadata-eval20.5%
metadata-eval20.5%
metadata-eval20.5%
neg-sub020.5%
associate--r-20.5%
neg-sub020.5%
+-commutative20.5%
sub-neg20.5%
Simplified20.5%
Taylor expanded in x around 0 100.0%
if 0.0399999991 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 51.4%
+-commutative51.4%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around 0 51.4%
rem-square-sqrt51.3%
fabs-sqr51.3%
metadata-eval51.3%
unpow251.3%
hypot-undefine99.9%
rem-square-sqrt100.0%
Simplified100.0%
Final simplification100.0%
(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 0.03999999910593033)
(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 <= -0.20000000298023224f) {
tmp = copysignf(logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.03999999910593033f) {
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(-0.20000000298023224)) tmp = copysign(log(Float32(hypot(Float32(1.0), x) - x)), x); elseif (t_0 <= Float32(0.03999999910593033)) 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
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(0.03999999910593033)) tmp = sign(x) * abs((x * (single(1.0) + ((x ^ single(2.0)) * (((x ^ single(2.0)) * 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}
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 0.03999999910593033:\\
\;\;\;\;\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) < -0.200000003Initial program 50.4%
+-commutative50.4%
hypot-1-def99.9%
Simplified99.9%
flip-+6.9%
frac-2neg6.9%
log-div6.8%
Applied egg-rr12.1%
sub-neg12.1%
fma-undefine12.1%
unpow212.1%
distribute-neg-in12.1%
metadata-eval12.1%
associate-+r+47.0%
sub-neg47.0%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
neg-sub099.9%
associate--r-99.9%
neg-sub099.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
*-un-lft-identity99.9%
add-sqr-sqrt-0.0%
sqrt-unprod99.9%
sqr-neg99.9%
sqrt-unprod98.7%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
*-lft-identity99.9%
Simplified99.9%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.0399999991Initial program 20.4%
+-commutative20.4%
hypot-1-def20.4%
Simplified20.4%
flip-+20.4%
div-sub20.6%
pow220.6%
add-sqr-sqrt11.0%
fabs-sqr11.0%
add-sqr-sqrt20.6%
add-sqr-sqrt11.0%
fabs-sqr11.0%
add-sqr-sqrt19.2%
Applied egg-rr20.6%
div-sub20.5%
remove-double-neg20.5%
distribute-frac-neg220.5%
neg-mul-120.5%
associate-/r*20.5%
distribute-neg-frac220.5%
fma-undefine20.5%
unpow220.5%
associate--r+20.5%
sub-neg20.5%
+-inverses20.5%
metadata-eval20.5%
metadata-eval20.5%
metadata-eval20.5%
neg-sub020.5%
associate--r-20.5%
neg-sub020.5%
+-commutative20.5%
sub-neg20.5%
Simplified20.5%
Taylor expanded in x around 0 99.9%
if 0.0399999991 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 51.4%
+-commutative51.4%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around 0 51.4%
rem-square-sqrt51.3%
fabs-sqr51.3%
metadata-eval51.3%
unpow251.3%
hypot-undefine99.9%
rem-square-sqrt100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -0.10000000149011612)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= x 0.03999999910593033)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -0.10000000149011612f) {
tmp = copysignf(logf((1.0f / (hypotf(1.0f, x) - x))), x);
} else if (x <= 0.03999999910593033f) {
tmp = copysignf((x * (1.0f + ((x * x) * -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.10000000149011612)) tmp = copysign(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.03999999910593033)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * 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.10000000149011612)) tmp = sign(x) * abs(log((single(1.0) / (hypot(single(1.0), x) - x)))); elseif (x <= single(0.03999999910593033)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * 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.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.03999999910593033:\\
\;\;\;\;\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 + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -0.100000001Initial program 52.0%
+-commutative52.0%
hypot-1-def99.6%
Simplified99.6%
flip-+10.1%
div-sub10.0%
pow210.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt4.3%
Applied egg-rr12.4%
div-sub15.2%
remove-double-neg15.2%
distribute-frac-neg215.2%
neg-mul-115.2%
associate-/r*15.2%
distribute-neg-frac215.2%
fma-undefine15.2%
unpow215.2%
associate--r+48.7%
sub-neg48.7%
+-inverses99.7%
metadata-eval99.7%
metadata-eval99.7%
metadata-eval99.7%
neg-sub099.7%
associate--r-99.7%
neg-sub099.7%
+-commutative99.7%
sub-neg99.7%
Simplified99.7%
if -0.100000001 < x < 0.0399999991Initial program 19.2%
+-commutative19.2%
hypot-1-def19.3%
Simplified19.3%
flip-+19.3%
div-sub19.4%
pow219.4%
add-sqr-sqrt11.2%
fabs-sqr11.2%
add-sqr-sqrt19.4%
add-sqr-sqrt11.2%
fabs-sqr11.2%
add-sqr-sqrt18.8%
Applied egg-rr19.4%
div-sub19.3%
remove-double-neg19.3%
distribute-frac-neg219.3%
neg-mul-119.3%
associate-/r*19.3%
distribute-neg-frac219.3%
fma-undefine19.3%
unpow219.3%
associate--r+19.4%
sub-neg19.4%
+-inverses19.4%
metadata-eval19.4%
metadata-eval19.4%
metadata-eval19.4%
neg-sub019.4%
associate--r-19.4%
neg-sub019.4%
+-commutative19.4%
sub-neg19.4%
Simplified19.4%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
unpow2100.0%
Applied egg-rr100.0%
if 0.0399999991 < x Initial program 51.4%
+-commutative51.4%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around 0 51.4%
rem-square-sqrt51.3%
fabs-sqr51.3%
metadata-eval51.3%
unpow251.3%
hypot-undefine99.9%
rem-square-sqrt100.0%
Simplified100.0%
(FPCore (x)
:precision binary32
(if (<= x -0.10000000149011612)
(copysign (log (- (hypot 1.0 x) x)) x)
(if (<= x 0.03999999910593033)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -0.10000000149011612f) {
tmp = copysignf(logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.03999999910593033f) {
tmp = copysignf((x * (1.0f + ((x * x) * -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.10000000149011612)) tmp = copysign(log(Float32(hypot(Float32(1.0), x) - x)), x); elseif (x <= Float32(0.03999999910593033)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * 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.10000000149011612)) tmp = sign(x) * abs(log((hypot(single(1.0), x) - x))); elseif (x <= single(0.03999999910593033)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * 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.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.03999999910593033:\\
\;\;\;\;\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 + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -0.100000001Initial program 52.0%
+-commutative52.0%
hypot-1-def99.6%
Simplified99.6%
flip-+10.1%
frac-2neg10.1%
log-div10.0%
Applied egg-rr15.1%
sub-neg15.1%
fma-undefine15.1%
unpow215.1%
distribute-neg-in15.1%
metadata-eval15.1%
associate-+r+48.7%
sub-neg48.7%
+-inverses99.6%
metadata-eval99.6%
metadata-eval99.6%
metadata-eval99.6%
neg-sub099.6%
neg-sub099.6%
associate--r-99.6%
neg-sub099.6%
+-commutative99.6%
sub-neg99.6%
Simplified99.6%
*-un-lft-identity99.6%
add-sqr-sqrt-0.0%
sqrt-unprod99.6%
sqr-neg99.6%
sqrt-unprod98.4%
add-sqr-sqrt99.6%
Applied egg-rr99.6%
*-lft-identity99.6%
Simplified99.6%
if -0.100000001 < x < 0.0399999991Initial program 19.2%
+-commutative19.2%
hypot-1-def19.3%
Simplified19.3%
flip-+19.3%
div-sub19.4%
pow219.4%
add-sqr-sqrt11.2%
fabs-sqr11.2%
add-sqr-sqrt19.4%
add-sqr-sqrt11.2%
fabs-sqr11.2%
add-sqr-sqrt18.8%
Applied egg-rr19.4%
div-sub19.3%
remove-double-neg19.3%
distribute-frac-neg219.3%
neg-mul-119.3%
associate-/r*19.3%
distribute-neg-frac219.3%
fma-undefine19.3%
unpow219.3%
associate--r+19.4%
sub-neg19.4%
+-inverses19.4%
metadata-eval19.4%
metadata-eval19.4%
metadata-eval19.4%
neg-sub019.4%
associate--r-19.4%
neg-sub019.4%
+-commutative19.4%
sub-neg19.4%
Simplified19.4%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
unpow2100.0%
Applied egg-rr100.0%
if 0.0399999991 < x Initial program 51.4%
+-commutative51.4%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around 0 51.4%
rem-square-sqrt51.3%
fabs-sqr51.3%
metadata-eval51.3%
unpow251.3%
hypot-undefine99.9%
rem-square-sqrt100.0%
Simplified100.0%
(FPCore (x)
:precision binary32
(if (<= x -100.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.03999999910593033)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -100.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.03999999910593033f) {
tmp = copysignf((x * (1.0f + ((x * x) * -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(-100.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.03999999910593033)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * 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(-100.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.03999999910593033)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * 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 -100:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.03999999910593033:\\
\;\;\;\;\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 + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -100Initial program 48.5%
+-commutative48.5%
hypot-1-def100.0%
Simplified100.0%
flip-+3.2%
div-sub3.1%
pow23.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt3.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt1.6%
Applied egg-rr5.7%
div-sub8.6%
remove-double-neg8.6%
distribute-frac-neg28.6%
neg-mul-18.6%
associate-/r*8.6%
distribute-neg-frac28.6%
fma-undefine8.6%
unpow28.6%
associate--r+44.9%
sub-neg44.9%
+-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%
Simplified100.0%
Taylor expanded in x around -inf 99.7%
if -100 < x < 0.0399999991Initial program 21.6%
+-commutative21.6%
hypot-1-def21.6%
Simplified21.6%
flip-+21.6%
div-sub21.7%
pow221.7%
add-sqr-sqrt10.8%
fabs-sqr10.8%
add-sqr-sqrt21.7%
add-sqr-sqrt10.8%
fabs-sqr10.8%
add-sqr-sqrt19.4%
Applied egg-rr21.7%
div-sub21.7%
remove-double-neg21.7%
distribute-frac-neg221.7%
neg-mul-121.7%
associate-/r*21.7%
distribute-neg-frac221.7%
fma-undefine21.7%
unpow221.7%
associate--r+21.7%
sub-neg21.7%
+-inverses21.7%
metadata-eval21.7%
metadata-eval21.7%
metadata-eval21.7%
neg-sub021.7%
associate--r-21.7%
neg-sub021.7%
+-commutative21.7%
sub-neg21.7%
Simplified21.7%
Taylor expanded in x around 0 98.8%
*-commutative98.8%
Simplified98.8%
unpow298.8%
Applied egg-rr98.8%
if 0.0399999991 < x Initial program 51.4%
+-commutative51.4%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around 0 51.4%
rem-square-sqrt51.3%
fabs-sqr51.3%
metadata-eval51.3%
unpow251.3%
hypot-undefine99.9%
rem-square-sqrt100.0%
Simplified100.0%
(FPCore (x)
:precision binary32
(if (<= x -100.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.03999999910593033)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -100.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.03999999910593033f) {
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(-100.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.03999999910593033)) 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(-100.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.03999999910593033)) 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 -100:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.03999999910593033:\\
\;\;\;\;\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 < -100Initial program 48.5%
+-commutative48.5%
hypot-1-def100.0%
Simplified100.0%
flip-+3.2%
div-sub3.1%
pow23.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt3.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt1.6%
Applied egg-rr5.7%
div-sub8.6%
remove-double-neg8.6%
distribute-frac-neg28.6%
neg-mul-18.6%
associate-/r*8.6%
distribute-neg-frac28.6%
fma-undefine8.6%
unpow28.6%
associate--r+44.9%
sub-neg44.9%
+-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%
Simplified100.0%
Taylor expanded in x around -inf 99.7%
if -100 < x < 0.0399999991Initial program 21.6%
+-commutative21.6%
hypot-1-def21.6%
Simplified21.6%
flip-+21.6%
div-sub21.7%
pow221.7%
add-sqr-sqrt10.8%
fabs-sqr10.8%
add-sqr-sqrt21.7%
add-sqr-sqrt10.8%
fabs-sqr10.8%
add-sqr-sqrt19.4%
Applied egg-rr21.7%
div-sub21.7%
remove-double-neg21.7%
distribute-frac-neg221.7%
neg-mul-121.7%
associate-/r*21.7%
distribute-neg-frac221.7%
fma-undefine21.7%
unpow221.7%
associate--r+21.7%
sub-neg21.7%
+-inverses21.7%
metadata-eval21.7%
metadata-eval21.7%
metadata-eval21.7%
neg-sub021.7%
associate--r-21.7%
neg-sub021.7%
+-commutative21.7%
sub-neg21.7%
Simplified21.7%
Taylor expanded in x around 0 98.8%
*-commutative98.8%
Simplified98.8%
unpow298.8%
Applied egg-rr98.8%
if 0.0399999991 < x Initial program 51.4%
+-commutative51.4%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 98.2%
+-commutative98.2%
rem-square-sqrt98.2%
fabs-sqr98.2%
rem-square-sqrt98.2%
*-inverses98.2%
metadata-eval98.2%
Simplified98.2%
(FPCore (x)
:precision binary32
(if (<= x -100.0)
(copysign (log (- x)) x)
(if (<= x 0.03999999910593033)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -100.0f) {
tmp = copysignf(logf(-x), x);
} else if (x <= 0.03999999910593033f) {
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(-100.0)) tmp = copysign(log(Float32(-x)), x); elseif (x <= Float32(0.03999999910593033)) 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(-100.0)) tmp = sign(x) * abs(log(-x)); elseif (x <= single(0.03999999910593033)) 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 -100:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{elif}\;x \leq 0.03999999910593033:\\
\;\;\;\;\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 < -100Initial program 48.5%
+-commutative48.5%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 45.6%
mul-1-neg45.6%
Simplified45.6%
if -100 < x < 0.0399999991Initial program 21.6%
+-commutative21.6%
hypot-1-def21.6%
Simplified21.6%
flip-+21.6%
div-sub21.7%
pow221.7%
add-sqr-sqrt10.8%
fabs-sqr10.8%
add-sqr-sqrt21.7%
add-sqr-sqrt10.8%
fabs-sqr10.8%
add-sqr-sqrt19.4%
Applied egg-rr21.7%
div-sub21.7%
remove-double-neg21.7%
distribute-frac-neg221.7%
neg-mul-121.7%
associate-/r*21.7%
distribute-neg-frac221.7%
fma-undefine21.7%
unpow221.7%
associate--r+21.7%
sub-neg21.7%
+-inverses21.7%
metadata-eval21.7%
metadata-eval21.7%
metadata-eval21.7%
neg-sub021.7%
associate--r-21.7%
neg-sub021.7%
+-commutative21.7%
sub-neg21.7%
Simplified21.7%
Taylor expanded in x around 0 98.8%
*-commutative98.8%
Simplified98.8%
unpow298.8%
Applied egg-rr98.8%
if 0.0399999991 < x Initial program 51.4%
+-commutative51.4%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 98.2%
+-commutative98.2%
rem-square-sqrt98.2%
fabs-sqr98.2%
rem-square-sqrt98.2%
*-inverses98.2%
metadata-eval98.2%
Simplified98.2%
(FPCore (x) :precision binary32 (if (<= x -0.5) (copysign (log (- x)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -0.5f) {
tmp = copysignf(logf(-x), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.5)) 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 -0.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 < -0.5Initial program 49.5%
+-commutative49.5%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 45.3%
mul-1-neg45.3%
Simplified45.3%
if -0.5 < x Initial program 32.3%
+-commutative32.3%
hypot-1-def50.5%
Simplified50.5%
Taylor expanded in x around 0 27.6%
log1p-define75.4%
rem-square-sqrt49.1%
fabs-sqr49.1%
rem-square-sqrt75.4%
Simplified75.4%
(FPCore (x) :precision binary32 (if (<= x 5.0) (copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 5.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(5.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 5:\\
\;\;\;\;\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 < 5Initial program 29.3%
+-commutative29.3%
hypot-1-def43.4%
Simplified43.4%
flip-+17.0%
div-sub17.0%
pow217.0%
add-sqr-sqrt8.3%
fabs-sqr8.3%
add-sqr-sqrt17.0%
add-sqr-sqrt8.3%
fabs-sqr8.3%
add-sqr-sqrt15.0%
Applied egg-rr17.8%
div-sub18.5%
remove-double-neg18.5%
distribute-frac-neg218.5%
neg-mul-118.5%
associate-/r*18.5%
distribute-neg-frac218.5%
fma-undefine18.5%
unpow218.5%
associate--r+28.4%
sub-neg28.4%
+-inverses43.4%
metadata-eval43.4%
metadata-eval43.4%
metadata-eval43.4%
neg-sub043.4%
associate--r-43.4%
neg-sub043.4%
+-commutative43.4%
sub-neg43.4%
Simplified43.4%
Taylor expanded in x around 0 73.6%
*-commutative73.6%
Simplified73.6%
unpow273.6%
Applied egg-rr73.6%
if 5 < x Initial program 50.8%
+-commutative50.8%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around 0 44.2%
log1p-define44.2%
rem-square-sqrt44.2%
fabs-sqr44.2%
rem-square-sqrt44.2%
Simplified44.2%
(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-def60.2%
Simplified60.2%
flip-+14.1%
div-sub14.1%
pow214.1%
add-sqr-sqrt7.7%
fabs-sqr7.7%
add-sqr-sqrt14.1%
add-sqr-sqrt7.1%
fabs-sqr7.1%
add-sqr-sqrt12.6%
Applied egg-rr14.5%
div-sub15.1%
remove-double-neg15.1%
distribute-frac-neg215.1%
neg-mul-115.1%
associate-/r*15.1%
distribute-neg-frac215.1%
fma-undefine15.1%
unpow215.1%
associate--r+22.1%
sub-neg22.1%
+-inverses32.6%
metadata-eval32.6%
metadata-eval32.6%
metadata-eval32.6%
neg-sub034.3%
associate--r-34.3%
neg-sub034.3%
+-commutative34.3%
sub-neg34.3%
Simplified34.3%
Taylor expanded in x around 0 54.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 2024185
(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))