
(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 13 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.10000000149011612)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.10000000149011612)
(copysign
(*
x
(+ 1.0 (* (pow x 2.0) (- (* (pow x 2.0) 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.10000000149011612f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.10000000149011612f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * ((powf(x, 2.0f) * 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.10000000149011612)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.10000000149011612)) 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(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.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.10000000149011612:\\
\;\;\;\;\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(\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.100000001Initial program 62.7%
+-commutative62.7%
hypot-1-def99.9%
Simplified99.9%
flip-+8.2%
clear-num8.2%
log-div8.1%
metadata-eval8.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.9%
pow210.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.9%
hypot-1-def10.9%
hypot-1-def10.9%
add-sqr-sqrt11.0%
+-commutative11.0%
Applied egg-rr11.5%
neg-sub011.5%
div-sub11.5%
fma-undefine11.0%
unpow211.0%
associate--r+11.6%
+-inverses11.6%
metadata-eval11.6%
*-rgt-identity11.6%
associate-/l*11.6%
metadata-eval11.6%
*-commutative11.6%
fma-undefine11.0%
unpow211.0%
associate--r+60.2%
+-inverses99.9%
metadata-eval99.9%
*-rgt-identity99.9%
associate-/l*99.9%
metadata-eval99.9%
*-commutative99.9%
neg-mul-199.9%
Simplified99.9%
if -0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.100000001Initial program 21.3%
+-commutative21.3%
hypot-1-def21.3%
Simplified21.3%
log1p-expm1-u21.3%
expm1-undefine21.3%
add-exp-log21.3%
add-sqr-sqrt11.6%
fabs-sqr11.6%
add-sqr-sqrt21.8%
Applied egg-rr21.8%
Taylor expanded in x around 0 99.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.4%
+-commutative49.4%
hypot-1-def98.6%
Simplified98.6%
log1p-expm1-u98.6%
expm1-undefine98.6%
add-exp-log98.6%
add-sqr-sqrt98.7%
fabs-sqr98.7%
add-sqr-sqrt98.6%
Applied egg-rr98.6%
+-commutative98.6%
associate--l+98.7%
Applied egg-rr98.7%
Final simplification99.5%
(FPCore (x)
:precision binary32
(if (<= x -0.10000000149011612)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.019999999552965164)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log1p (+ (hypot 1.0 x) (+ x -1.0))) x))))
float code(float x) {
float tmp;
if (x <= -0.10000000149011612f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.019999999552965164f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(log1pf((hypotf(1.0f, x) + (x + -1.0f))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.10000000149011612)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.019999999552965164)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), 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}
\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.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, 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 x < -0.100000001Initial program 62.7%
+-commutative62.7%
hypot-1-def99.9%
Simplified99.9%
flip-+8.2%
clear-num8.2%
log-div8.1%
metadata-eval8.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.9%
pow210.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.9%
hypot-1-def10.9%
hypot-1-def10.9%
add-sqr-sqrt11.0%
+-commutative11.0%
Applied egg-rr11.5%
neg-sub011.5%
div-sub11.5%
fma-undefine11.0%
unpow211.0%
associate--r+11.6%
+-inverses11.6%
metadata-eval11.6%
*-rgt-identity11.6%
associate-/l*11.6%
metadata-eval11.6%
*-commutative11.6%
fma-undefine11.0%
unpow211.0%
associate--r+60.2%
+-inverses99.9%
metadata-eval99.9%
*-rgt-identity99.9%
associate-/l*99.9%
metadata-eval99.9%
*-commutative99.9%
neg-mul-199.9%
Simplified99.9%
if -0.100000001 < x < 0.0199999996Initial program 20.7%
+-commutative20.7%
hypot-1-def20.7%
Simplified20.7%
log1p-expm1-u20.7%
expm1-undefine20.7%
add-exp-log20.7%
add-sqr-sqrt10.9%
fabs-sqr10.9%
add-sqr-sqrt21.2%
Applied egg-rr21.2%
Taylor expanded in x around 0 99.9%
distribute-rgt-in100.0%
*-lft-identity100.0%
associate-*l*100.0%
unpow2100.0%
unpow3100.0%
Simplified100.0%
if 0.0199999996 < x Initial program 49.9%
+-commutative49.9%
hypot-1-def98.5%
Simplified98.5%
log1p-expm1-u98.6%
expm1-undefine98.6%
add-exp-log98.6%
add-sqr-sqrt98.6%
fabs-sqr98.6%
add-sqr-sqrt98.6%
Applied egg-rr98.6%
+-commutative98.6%
associate--l+98.6%
Applied egg-rr98.6%
Final simplification99.5%
(FPCore (x)
:precision binary32
(if (<= x -0.10000000149011612)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.019999999552965164)
(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 <= -0.10000000149011612f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.019999999552965164f) {
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(-0.10000000149011612)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.019999999552965164)) 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(-0.10000000149011612)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (x <= single(0.019999999552965164)) 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 -0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\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 < -0.100000001Initial program 62.7%
+-commutative62.7%
hypot-1-def99.9%
Simplified99.9%
flip-+8.2%
clear-num8.2%
log-div8.1%
metadata-eval8.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.9%
pow210.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.9%
hypot-1-def10.9%
hypot-1-def10.9%
add-sqr-sqrt11.0%
+-commutative11.0%
Applied egg-rr11.5%
neg-sub011.5%
div-sub11.5%
fma-undefine11.0%
unpow211.0%
associate--r+11.6%
+-inverses11.6%
metadata-eval11.6%
*-rgt-identity11.6%
associate-/l*11.6%
metadata-eval11.6%
*-commutative11.6%
fma-undefine11.0%
unpow211.0%
associate--r+60.2%
+-inverses99.9%
metadata-eval99.9%
*-rgt-identity99.9%
associate-/l*99.9%
metadata-eval99.9%
*-commutative99.9%
neg-mul-199.9%
Simplified99.9%
if -0.100000001 < x < 0.0199999996Initial program 20.7%
+-commutative20.7%
hypot-1-def20.7%
Simplified20.7%
log1p-expm1-u20.7%
expm1-undefine20.7%
add-exp-log20.7%
add-sqr-sqrt10.9%
fabs-sqr10.9%
add-sqr-sqrt21.2%
Applied egg-rr21.2%
Taylor expanded in x around 0 99.9%
distribute-rgt-in100.0%
*-lft-identity100.0%
associate-*l*100.0%
unpow2100.0%
unpow3100.0%
Simplified100.0%
if 0.0199999996 < x Initial program 49.9%
+-commutative49.9%
hypot-1-def98.5%
Simplified98.5%
*-un-lft-identity98.5%
*-commutative98.5%
log-prod98.5%
add-sqr-sqrt98.6%
fabs-sqr98.6%
add-sqr-sqrt98.5%
metadata-eval98.5%
Applied egg-rr98.5%
+-rgt-identity98.5%
Simplified98.5%
(FPCore (x)
:precision binary32
(if (<= x -4.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.019999999552965164)
(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 <= -4.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.019999999552965164f) {
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(-4.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.019999999552965164)) 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(-4.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.019999999552965164)) 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 -4:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\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 < -4Initial program 61.7%
+-commutative61.7%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.2%
mul-1-neg99.2%
neg-sub099.2%
+-commutative99.2%
distribute-rgt-in99.2%
*-lft-identity99.2%
associate--r+99.2%
Simplified7.2%
*-un-lft-identity7.2%
log-prod7.2%
metadata-eval7.2%
associate-/l*10.0%
*-inverses10.0%
*-commutative10.0%
*-un-lft-identity10.0%
Applied egg-rr10.0%
+-lft-identity10.0%
+-commutative10.0%
associate--l+98.3%
+-inverses98.3%
+-rgt-identity98.3%
Simplified98.3%
if -4 < x < 0.0199999996Initial program 22.0%
+-commutative22.0%
hypot-1-def22.0%
Simplified22.0%
log1p-expm1-u22.0%
expm1-undefine22.0%
add-exp-log22.0%
add-sqr-sqrt10.7%
fabs-sqr10.7%
add-sqr-sqrt22.4%
Applied egg-rr22.4%
Taylor expanded in x around 0 99.3%
distribute-rgt-in99.3%
*-lft-identity99.3%
associate-*l*99.3%
unpow299.3%
unpow399.3%
Simplified99.3%
if 0.0199999996 < x Initial program 49.9%
+-commutative49.9%
hypot-1-def98.5%
Simplified98.5%
*-un-lft-identity98.5%
*-commutative98.5%
log-prod98.5%
add-sqr-sqrt98.6%
fabs-sqr98.6%
add-sqr-sqrt98.5%
metadata-eval98.5%
Applied egg-rr98.5%
+-rgt-identity98.5%
Simplified98.5%
(FPCore (x)
:precision binary32
(if (<= x -4.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.2000000476837158)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (+ (log 2.0) (log x)) x))))
float code(float x) {
float tmp;
if (x <= -4.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(2.0f) + logf(x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-4.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(Float32(log(Float32(2.0)) + log(x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-4.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(single(2.0)) + log(x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4:\\
\;\;\;\;\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 2 + \log x, x\right)\\
\end{array}
\end{array}
if x < -4Initial program 61.7%
+-commutative61.7%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.2%
mul-1-neg99.2%
neg-sub099.2%
+-commutative99.2%
distribute-rgt-in99.2%
*-lft-identity99.2%
associate--r+99.2%
Simplified7.2%
*-un-lft-identity7.2%
log-prod7.2%
metadata-eval7.2%
associate-/l*10.0%
*-inverses10.0%
*-commutative10.0%
*-un-lft-identity10.0%
Applied egg-rr10.0%
+-lft-identity10.0%
+-commutative10.0%
associate--l+98.3%
+-inverses98.3%
+-rgt-identity98.3%
Simplified98.3%
if -4 < x < 1.20000005Initial program 24.4%
+-commutative24.4%
hypot-1-def24.4%
Simplified24.4%
log1p-expm1-u24.4%
expm1-undefine24.4%
add-exp-log24.4%
add-sqr-sqrt13.5%
fabs-sqr13.5%
add-sqr-sqrt24.9%
Applied egg-rr24.9%
Taylor expanded in x around 0 97.8%
distribute-rgt-in97.8%
*-lft-identity97.8%
associate-*l*97.8%
unpow297.8%
unpow397.8%
Simplified97.8%
if 1.20000005 < x Initial program 47.4%
+-commutative47.4%
hypot-1-def98.7%
Simplified98.7%
log1p-expm1-u98.7%
expm1-undefine98.7%
add-exp-log98.7%
add-sqr-sqrt98.7%
fabs-sqr98.7%
add-sqr-sqrt98.7%
Applied egg-rr98.7%
Taylor expanded in x around inf 97.2%
mul-1-neg97.2%
log-rec97.2%
remove-double-neg97.2%
Simplified97.2%
(FPCore (x)
:precision binary32
(if (<= x -4.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.2000000476837158)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log1p (* x (+ 2.0 (/ -1.0 x)))) x))))
float code(float x) {
float tmp;
if (x <= -4.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(log1pf((x * (2.0f + (-1.0f / x)))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-4.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(log1p(Float32(x * Float32(Float32(2.0) + Float32(Float32(-1.0) / x)))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4:\\
\;\;\;\;\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(\mathsf{log1p}\left(x \cdot \left(2 + \frac{-1}{x}\right)\right), x\right)\\
\end{array}
\end{array}
if x < -4Initial program 61.7%
+-commutative61.7%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.2%
mul-1-neg99.2%
neg-sub099.2%
+-commutative99.2%
distribute-rgt-in99.2%
*-lft-identity99.2%
associate--r+99.2%
Simplified7.2%
*-un-lft-identity7.2%
log-prod7.2%
metadata-eval7.2%
associate-/l*10.0%
*-inverses10.0%
*-commutative10.0%
*-un-lft-identity10.0%
Applied egg-rr10.0%
+-lft-identity10.0%
+-commutative10.0%
associate--l+98.3%
+-inverses98.3%
+-rgt-identity98.3%
Simplified98.3%
if -4 < x < 1.20000005Initial program 24.4%
+-commutative24.4%
hypot-1-def24.4%
Simplified24.4%
log1p-expm1-u24.4%
expm1-undefine24.4%
add-exp-log24.4%
add-sqr-sqrt13.5%
fabs-sqr13.5%
add-sqr-sqrt24.9%
Applied egg-rr24.9%
Taylor expanded in x around 0 97.8%
distribute-rgt-in97.8%
*-lft-identity97.8%
associate-*l*97.8%
unpow297.8%
unpow397.8%
Simplified97.8%
if 1.20000005 < x Initial program 47.4%
+-commutative47.4%
hypot-1-def98.7%
Simplified98.7%
log1p-expm1-u98.7%
expm1-undefine98.7%
add-exp-log98.7%
add-sqr-sqrt98.7%
fabs-sqr98.7%
add-sqr-sqrt98.7%
Applied egg-rr98.7%
Taylor expanded in x around inf 96.5%
Final simplification97.6%
(FPCore (x)
:precision binary32
(if (<= x -4.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.2000000476837158)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (* x (+ 1.0 (/ x x)))) x))))
float code(float x) {
float tmp;
if (x <= -4.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 * (1.0f + (x / x)))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-4.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(Float32(1.0) + Float32(x / x)))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-4.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(1.0) + (x / x))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4:\\
\;\;\;\;\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 \left(1 + \frac{x}{x}\right)\right), x\right)\\
\end{array}
\end{array}
if x < -4Initial program 61.7%
+-commutative61.7%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.2%
mul-1-neg99.2%
neg-sub099.2%
+-commutative99.2%
distribute-rgt-in99.2%
*-lft-identity99.2%
associate--r+99.2%
Simplified7.2%
*-un-lft-identity7.2%
log-prod7.2%
metadata-eval7.2%
associate-/l*10.0%
*-inverses10.0%
*-commutative10.0%
*-un-lft-identity10.0%
Applied egg-rr10.0%
+-lft-identity10.0%
+-commutative10.0%
associate--l+98.3%
+-inverses98.3%
+-rgt-identity98.3%
Simplified98.3%
if -4 < x < 1.20000005Initial program 24.4%
+-commutative24.4%
hypot-1-def24.4%
Simplified24.4%
log1p-expm1-u24.4%
expm1-undefine24.4%
add-exp-log24.4%
add-sqr-sqrt13.5%
fabs-sqr13.5%
add-sqr-sqrt24.9%
Applied egg-rr24.9%
Taylor expanded in x around 0 97.8%
distribute-rgt-in97.8%
*-lft-identity97.8%
associate-*l*97.8%
unpow297.8%
unpow397.8%
Simplified97.8%
if 1.20000005 < x Initial program 47.4%
+-commutative47.4%
hypot-1-def98.7%
Simplified98.7%
Taylor expanded in x around inf 96.5%
rem-square-sqrt96.5%
fabs-sqr96.5%
rem-square-sqrt96.5%
Simplified96.5%
(FPCore (x)
:precision binary32
(if (<= x -4.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.2000000476837158)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log1p (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -4.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(log1pf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-4.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(log1p(Float32(x * Float32(2.0))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4:\\
\;\;\;\;\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(\mathsf{log1p}\left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -4Initial program 61.7%
+-commutative61.7%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.2%
mul-1-neg99.2%
neg-sub099.2%
+-commutative99.2%
distribute-rgt-in99.2%
*-lft-identity99.2%
associate--r+99.2%
Simplified7.2%
*-un-lft-identity7.2%
log-prod7.2%
metadata-eval7.2%
associate-/l*10.0%
*-inverses10.0%
*-commutative10.0%
*-un-lft-identity10.0%
Applied egg-rr10.0%
+-lft-identity10.0%
+-commutative10.0%
associate--l+98.3%
+-inverses98.3%
+-rgt-identity98.3%
Simplified98.3%
if -4 < x < 1.20000005Initial program 24.4%
+-commutative24.4%
hypot-1-def24.4%
Simplified24.4%
log1p-expm1-u24.4%
expm1-undefine24.4%
add-exp-log24.4%
add-sqr-sqrt13.5%
fabs-sqr13.5%
add-sqr-sqrt24.9%
Applied egg-rr24.9%
Taylor expanded in x around 0 97.8%
distribute-rgt-in97.8%
*-lft-identity97.8%
associate-*l*97.8%
unpow297.8%
unpow397.8%
Simplified97.8%
if 1.20000005 < x Initial program 47.4%
+-commutative47.4%
hypot-1-def98.7%
Simplified98.7%
log1p-expm1-u98.7%
expm1-undefine98.7%
add-exp-log98.7%
add-sqr-sqrt98.7%
fabs-sqr98.7%
add-sqr-sqrt98.7%
Applied egg-rr98.7%
Taylor expanded in x around inf 95.1%
*-commutative95.1%
Simplified95.1%
(FPCore (x) :precision binary32 (if (<= x -4.0) (copysign (log (/ -0.5 x)) x) (if (<= x 0.5) (copysign (log1p x) x) (copysign (log1p (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -4.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.5f) {
tmp = copysignf(log1pf(x), x);
} else {
tmp = copysignf(log1pf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-4.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.5)) tmp = copysign(log1p(x), x); else tmp = copysign(log1p(Float32(x * Float32(2.0))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -4Initial program 61.7%
+-commutative61.7%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.2%
mul-1-neg99.2%
neg-sub099.2%
+-commutative99.2%
distribute-rgt-in99.2%
*-lft-identity99.2%
associate--r+99.2%
Simplified7.2%
*-un-lft-identity7.2%
log-prod7.2%
metadata-eval7.2%
associate-/l*10.0%
*-inverses10.0%
*-commutative10.0%
*-un-lft-identity10.0%
Applied egg-rr10.0%
+-lft-identity10.0%
+-commutative10.0%
associate--l+98.3%
+-inverses98.3%
+-rgt-identity98.3%
Simplified98.3%
if -4 < x < 0.5Initial program 23.2%
+-commutative23.2%
hypot-1-def23.2%
Simplified23.2%
Taylor expanded in x around 0 20.0%
log1p-define93.3%
rem-square-sqrt43.9%
fabs-sqr43.9%
rem-square-sqrt93.3%
Simplified93.3%
if 0.5 < x Initial program 48.7%
+-commutative48.7%
hypot-1-def98.6%
Simplified98.6%
log1p-expm1-u98.7%
expm1-undefine98.7%
add-exp-log98.7%
add-sqr-sqrt98.7%
fabs-sqr98.7%
add-sqr-sqrt98.7%
Applied egg-rr98.7%
Taylor expanded in x around inf 93.5%
*-commutative93.5%
Simplified93.5%
(FPCore (x) :precision binary32 (if (<= x -4.0) (copysign (log (/ -0.5 x)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -4.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-4.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -4Initial program 61.7%
+-commutative61.7%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.2%
mul-1-neg99.2%
neg-sub099.2%
+-commutative99.2%
distribute-rgt-in99.2%
*-lft-identity99.2%
associate--r+99.2%
Simplified7.2%
*-un-lft-identity7.2%
log-prod7.2%
metadata-eval7.2%
associate-/l*10.0%
*-inverses10.0%
*-commutative10.0%
*-un-lft-identity10.0%
Applied egg-rr10.0%
+-lft-identity10.0%
+-commutative10.0%
associate--l+98.3%
+-inverses98.3%
+-rgt-identity98.3%
Simplified98.3%
if -4 < x Initial program 33.0%
+-commutative33.0%
hypot-1-def52.2%
Simplified52.2%
Taylor expanded in x around 0 29.5%
log1p-define74.6%
rem-square-sqrt44.3%
fabs-sqr44.3%
rem-square-sqrt74.6%
Simplified74.6%
(FPCore (x) :precision binary32 (if (<= x -4.0) (copysign (log (- x)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -4.0f) {
tmp = copysignf(logf(-x), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-4.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 -4:\\
\;\;\;\;\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 < -4Initial program 61.7%
+-commutative61.7%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 43.8%
mul-1-neg43.8%
Simplified43.8%
if -4 < x Initial program 33.0%
+-commutative33.0%
hypot-1-def52.2%
Simplified52.2%
Taylor expanded in x around 0 29.5%
log1p-define74.6%
rem-square-sqrt44.3%
fabs-sqr44.3%
rem-square-sqrt74.6%
Simplified74.6%
(FPCore (x) :precision binary32 (copysign (log1p x) x))
float code(float x) {
return copysignf(log1pf(x), x);
}
function code(x) return copysign(log1p(x), x) end
\begin{array}{l}
\\
\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)
\end{array}
Initial program 39.8%
+-commutative39.8%
hypot-1-def63.6%
Simplified63.6%
Taylor expanded in x around 0 33.0%
log1p-define67.3%
rem-square-sqrt33.7%
fabs-sqr33.7%
rem-square-sqrt56.8%
Simplified56.8%
(FPCore (x) :precision binary32 (copysign (log1p -1.0) x))
float code(float x) {
return copysignf(log1pf(-1.0f), x);
}
function code(x) return copysign(log1p(Float32(-1.0)), x) end
\begin{array}{l}
\\
\mathsf{copysign}\left(\mathsf{log1p}\left(-1\right), x\right)
\end{array}
Initial program 39.8%
+-commutative39.8%
hypot-1-def63.6%
Simplified63.6%
log1p-expm1-u63.6%
expm1-undefine63.6%
add-exp-log63.6%
add-sqr-sqrt34.6%
fabs-sqr34.6%
add-sqr-sqrt42.7%
Applied egg-rr42.7%
Taylor expanded in x around -inf 5.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 2024089
(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))