
(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 -1.0)
(copysign (* 2.0 (log (sqrt (- (hypot 1.0 x) x)))) x)
(if (<= t_0 0.20000000298023224)
(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 <= -1.0f) {
tmp = copysignf((2.0f * logf(sqrtf((hypotf(1.0f, x) - x)))), x);
} else if (t_0 <= 0.20000000298023224f) {
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(-1.0)) tmp = copysign(Float32(Float32(2.0) * log(sqrt(Float32(hypot(Float32(1.0), x) - x)))), x); elseif (t_0 <= Float32(0.20000000298023224)) 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(-1.0)) tmp = sign(x) * abs((single(2.0) * log(sqrt((hypot(single(1.0), x) - x))))); elseif (t_0 <= single(0.20000000298023224)) 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 -1:\\
\;\;\;\;\mathsf{copysign}\left(2 \cdot \log \left(\sqrt{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.20000000298023224:\\
\;\;\;\;\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) < -1Initial program 51.7%
flip-+11.3%
clear-num11.3%
log-div11.3%
metadata-eval11.3%
+-commutative11.3%
hypot-1-def11.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt11.9%
Applied egg-rr14.5%
neg-sub014.5%
div-sub14.5%
*-rgt-identity14.5%
associate-/l*14.5%
fma-neg14.5%
fma-undefine14.5%
unpow214.5%
associate--r+14.5%
+-inverses14.5%
metadata-eval14.5%
metadata-eval14.5%
*-rgt-identity14.5%
associate-/l*14.5%
fma-undefine14.5%
unpow214.5%
associate--r+48.3%
Simplified98.4%
add-sqr-sqrt-0.0%
sqrt-unprod98.4%
sqr-neg98.4%
sqrt-unprod96.9%
add-sqr-sqrt98.4%
add-sqr-sqrt98.4%
log-prod98.5%
Applied egg-rr98.5%
count-298.5%
Simplified98.5%
if -1 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.200000003Initial program 20.3%
+-commutative20.3%
hypot-1-def20.2%
flip-+20.1%
hypot-1-def20.2%
hypot-1-def20.1%
add-sqr-sqrt20.4%
+-commutative20.4%
hypot-1-def20.3%
+-commutative20.3%
div-sub20.4%
Applied egg-rr20.4%
div-sub20.3%
remove-double-neg20.3%
distribute-frac-neg220.3%
neg-sub020.3%
associate--r-20.3%
neg-sub020.3%
+-commutative20.3%
sub-neg20.3%
distribute-frac-neg20.3%
sub-neg20.3%
+-commutative20.3%
distribute-neg-in20.3%
remove-double-neg20.3%
fma-undefine20.3%
unpow220.3%
+-commutative20.3%
associate-+l+20.4%
sub-neg20.4%
+-inverses20.4%
metadata-eval20.4%
Simplified20.4%
Taylor expanded in x around 0 100.0%
if 0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 55.1%
Taylor expanded in x around 0 55.1%
rem-square-sqrt55.1%
fabs-sqr55.1%
rem-square-sqrt55.1%
metadata-eval55.1%
unpow255.1%
hypot-undefine100.0%
Simplified100.0%
Final simplification99.6%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -1.0)
(copysign (* 2.0 (log (sqrt (- (hypot 1.0 x) x)))) x)
(if (<= t_0 0.20000000298023224)
(copysign
(* x (+ 1.0 (* (pow x 2.0) (- (* (* x x) 0.075) 0.16666666666666666))))
x)
(copysign (log (+ x (hypot 1.0 x))) x)))))
float code(float x) {
float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
float tmp;
if (t_0 <= -1.0f) {
tmp = copysignf((2.0f * logf(sqrtf((hypotf(1.0f, x) - x)))), x);
} else if (t_0 <= 0.20000000298023224f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * (((x * x) * 0.075f) - 0.16666666666666666f)))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) t_0 = copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) tmp = Float32(0.0) if (t_0 <= Float32(-1.0)) tmp = copysign(Float32(Float32(2.0) * log(sqrt(Float32(hypot(Float32(1.0), x) - x)))), x); elseif (t_0 <= Float32(0.20000000298023224)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32((x ^ Float32(2.0)) * Float32(Float32(Float32(x * x) * Float32(0.075)) - Float32(0.16666666666666666))))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); tmp = single(0.0); if (t_0 <= single(-1.0)) tmp = sign(x) * abs((single(2.0) * log(sqrt((hypot(single(1.0), x) - x))))); elseif (t_0 <= single(0.20000000298023224)) tmp = sign(x) * abs((x * (single(1.0) + ((x ^ single(2.0)) * (((x * x) * single(0.075)) - single(0.16666666666666666)))))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t\_0 \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(2 \cdot \log \left(\sqrt{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot \left(\left(x \cdot x\right) \cdot 0.075 - 0.16666666666666666\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < -1Initial program 51.7%
flip-+11.3%
clear-num11.3%
log-div11.3%
metadata-eval11.3%
+-commutative11.3%
hypot-1-def11.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt11.9%
Applied egg-rr14.5%
neg-sub014.5%
div-sub14.5%
*-rgt-identity14.5%
associate-/l*14.5%
fma-neg14.5%
fma-undefine14.5%
unpow214.5%
associate--r+14.5%
+-inverses14.5%
metadata-eval14.5%
metadata-eval14.5%
*-rgt-identity14.5%
associate-/l*14.5%
fma-undefine14.5%
unpow214.5%
associate--r+48.3%
Simplified98.4%
add-sqr-sqrt-0.0%
sqrt-unprod98.4%
sqr-neg98.4%
sqrt-unprod96.9%
add-sqr-sqrt98.4%
add-sqr-sqrt98.4%
log-prod98.5%
Applied egg-rr98.5%
count-298.5%
Simplified98.5%
if -1 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.200000003Initial program 20.3%
+-commutative20.3%
hypot-1-def20.2%
flip-+20.1%
hypot-1-def20.2%
hypot-1-def20.1%
add-sqr-sqrt20.4%
+-commutative20.4%
hypot-1-def20.3%
+-commutative20.3%
div-sub20.4%
Applied egg-rr20.4%
div-sub20.3%
remove-double-neg20.3%
distribute-frac-neg220.3%
neg-sub020.3%
associate--r-20.3%
neg-sub020.3%
+-commutative20.3%
sub-neg20.3%
distribute-frac-neg20.3%
sub-neg20.3%
+-commutative20.3%
distribute-neg-in20.3%
remove-double-neg20.3%
fma-undefine20.3%
unpow220.3%
+-commutative20.3%
associate-+l+20.4%
sub-neg20.4%
+-inverses20.4%
metadata-eval20.4%
Simplified20.4%
Taylor expanded in x around 0 99.9%
unpow299.9%
Applied egg-rr99.9%
if 0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 55.1%
Taylor expanded in x around 0 55.1%
rem-square-sqrt55.1%
fabs-sqr55.1%
rem-square-sqrt55.1%
metadata-eval55.1%
unpow255.1%
hypot-undefine100.0%
Simplified100.0%
Final simplification99.6%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (- (hypot 1.0 x) x)) x)
(if (<= x 0.20000000298023224)
(copysign
(* x (+ 1.0 (* (pow x 2.0) (- (* (* x x) 0.075) 0.16666666666666666))))
x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.20000000298023224f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * (((x * x) * 0.075f) - 0.16666666666666666f)))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(log(Float32(hypot(Float32(1.0), x) - x)), x); elseif (x <= Float32(0.20000000298023224)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32((x ^ Float32(2.0)) * Float32(Float32(Float32(x * x) * Float32(0.075)) - Float32(0.16666666666666666))))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.0)) tmp = sign(x) * abs(log((hypot(single(1.0), x) - x))); elseif (x <= single(0.20000000298023224)) tmp = sign(x) * abs((x * (single(1.0) + ((x ^ single(2.0)) * (((x * x) * single(0.075)) - single(0.16666666666666666)))))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot \left(\left(x \cdot x\right) \cdot 0.075 - 0.16666666666666666\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 51.7%
flip-+11.3%
clear-num11.3%
log-div11.3%
metadata-eval11.3%
+-commutative11.3%
hypot-1-def11.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt11.9%
Applied egg-rr14.5%
neg-sub014.5%
div-sub14.5%
*-rgt-identity14.5%
associate-/l*14.5%
fma-neg14.5%
fma-undefine14.5%
unpow214.5%
associate--r+14.5%
+-inverses14.5%
metadata-eval14.5%
metadata-eval14.5%
*-rgt-identity14.5%
associate-/l*14.5%
fma-undefine14.5%
unpow214.5%
associate--r+48.3%
Simplified98.4%
*-un-lft-identity98.4%
add-sqr-sqrt-0.0%
sqrt-unprod98.4%
sqr-neg98.4%
sqrt-unprod96.9%
add-sqr-sqrt98.4%
Applied egg-rr98.4%
*-lft-identity98.4%
Simplified98.4%
if -2 < x < 0.200000003Initial program 20.3%
+-commutative20.3%
hypot-1-def20.2%
flip-+20.1%
hypot-1-def20.2%
hypot-1-def20.1%
add-sqr-sqrt20.4%
+-commutative20.4%
hypot-1-def20.3%
+-commutative20.3%
div-sub20.4%
Applied egg-rr20.4%
div-sub20.3%
remove-double-neg20.3%
distribute-frac-neg220.3%
neg-sub020.3%
associate--r-20.3%
neg-sub020.3%
+-commutative20.3%
sub-neg20.3%
distribute-frac-neg20.3%
sub-neg20.3%
+-commutative20.3%
distribute-neg-in20.3%
remove-double-neg20.3%
fma-undefine20.3%
unpow220.3%
+-commutative20.3%
associate-+l+20.4%
sub-neg20.4%
+-inverses20.4%
metadata-eval20.4%
Simplified20.4%
Taylor expanded in x around 0 99.9%
unpow299.9%
Applied egg-rr99.9%
if 0.200000003 < x Initial program 55.1%
Taylor expanded in x around 0 55.1%
rem-square-sqrt55.1%
fabs-sqr55.1%
rem-square-sqrt55.1%
metadata-eval55.1%
unpow255.1%
hypot-undefine100.0%
Simplified100.0%
Final simplification99.6%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.20000000298023224)
(copysign
(* x (+ 1.0 (* (pow x 2.0) (- (* (* x x) 0.075) 0.16666666666666666))))
x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.20000000298023224f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * (((x * x) * 0.075f) - 0.16666666666666666f)))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.20000000298023224)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32((x ^ Float32(2.0)) * Float32(Float32(Float32(x * x) * Float32(0.075)) - Float32(0.16666666666666666))))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.20000000298023224)) tmp = sign(x) * abs((x * (single(1.0) + ((x ^ single(2.0)) * (((x * x) * single(0.075)) - single(0.16666666666666666)))))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot \left(\left(x \cdot x\right) \cdot 0.075 - 0.16666666666666666\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 51.7%
+-commutative51.7%
hypot-1-def98.4%
flip-+11.4%
hypot-1-def11.2%
hypot-1-def11.0%
add-sqr-sqrt10.8%
+-commutative10.8%
hypot-1-def10.7%
+-commutative10.7%
div-sub10.7%
Applied egg-rr13.4%
div-sub16.6%
remove-double-neg16.6%
distribute-frac-neg216.6%
neg-sub016.6%
associate--r-16.6%
neg-sub016.6%
+-commutative16.6%
sub-neg16.6%
distribute-frac-neg16.6%
sub-neg16.6%
+-commutative16.6%
distribute-neg-in16.6%
remove-double-neg16.6%
fma-undefine16.6%
unpow216.6%
+-commutative16.6%
associate-+l+48.3%
sub-neg48.3%
+-inverses98.4%
metadata-eval98.4%
Simplified98.4%
Taylor expanded in x around -inf 96.0%
if -2 < x < 0.200000003Initial program 20.3%
+-commutative20.3%
hypot-1-def20.2%
flip-+20.1%
hypot-1-def20.2%
hypot-1-def20.1%
add-sqr-sqrt20.4%
+-commutative20.4%
hypot-1-def20.3%
+-commutative20.3%
div-sub20.4%
Applied egg-rr20.4%
div-sub20.3%
remove-double-neg20.3%
distribute-frac-neg220.3%
neg-sub020.3%
associate--r-20.3%
neg-sub020.3%
+-commutative20.3%
sub-neg20.3%
distribute-frac-neg20.3%
sub-neg20.3%
+-commutative20.3%
distribute-neg-in20.3%
remove-double-neg20.3%
fma-undefine20.3%
unpow220.3%
+-commutative20.3%
associate-+l+20.4%
sub-neg20.4%
+-inverses20.4%
metadata-eval20.4%
Simplified20.4%
Taylor expanded in x around 0 99.9%
unpow299.9%
Applied egg-rr99.9%
if 0.200000003 < x Initial program 55.1%
Taylor expanded in x around 0 55.1%
rem-square-sqrt55.1%
fabs-sqr55.1%
rem-square-sqrt55.1%
metadata-eval55.1%
unpow255.1%
hypot-undefine100.0%
Simplified100.0%
Final simplification99.0%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(copysign
(* x (+ 1.0 (* (pow x 2.0) (- (* (* x x) 0.075) 0.16666666666666666))))
x)
(copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * (((x * x) * 0.075f) - 0.16666666666666666f)))), x);
} else {
tmp = copysignf(logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32((x ^ Float32(2.0)) * Float32(Float32(Float32(x * x) * Float32(0.075)) - Float32(0.16666666666666666))))), x); else tmp = copysign(log(Float32(Float32(0.5) / x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x * (single(1.0) + ((x ^ single(2.0)) * (((x * x) * single(0.075)) - single(0.16666666666666666)))))); else tmp = sign(x) * abs(log((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot \left(\left(x \cdot x\right) \cdot 0.075 - 0.16666666666666666\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 51.7%
+-commutative51.7%
hypot-1-def98.4%
flip-+11.4%
hypot-1-def11.2%
hypot-1-def11.0%
add-sqr-sqrt10.8%
+-commutative10.8%
hypot-1-def10.7%
+-commutative10.7%
div-sub10.7%
Applied egg-rr13.4%
div-sub16.6%
remove-double-neg16.6%
distribute-frac-neg216.6%
neg-sub016.6%
associate--r-16.6%
neg-sub016.6%
+-commutative16.6%
sub-neg16.6%
distribute-frac-neg16.6%
sub-neg16.6%
+-commutative16.6%
distribute-neg-in16.6%
remove-double-neg16.6%
fma-undefine16.6%
unpow216.6%
+-commutative16.6%
associate-+l+48.3%
sub-neg48.3%
+-inverses98.4%
metadata-eval98.4%
Simplified98.4%
Taylor expanded in x around -inf 96.0%
if -2 < x < 1Initial program 21.6%
+-commutative21.6%
hypot-1-def21.5%
flip-+21.4%
hypot-1-def21.5%
hypot-1-def21.4%
add-sqr-sqrt21.7%
+-commutative21.7%
hypot-1-def21.6%
+-commutative21.6%
div-sub21.7%
Applied egg-rr21.6%
div-sub21.6%
remove-double-neg21.6%
distribute-frac-neg221.6%
neg-sub021.6%
associate--r-21.6%
neg-sub021.6%
+-commutative21.6%
sub-neg21.6%
distribute-frac-neg21.6%
sub-neg21.6%
+-commutative21.6%
distribute-neg-in21.6%
remove-double-neg21.6%
fma-undefine21.6%
unpow221.6%
+-commutative21.6%
associate-+l+21.7%
sub-neg21.7%
+-inverses21.7%
metadata-eval21.7%
Simplified21.7%
Taylor expanded in x around 0 99.4%
unpow299.4%
Applied egg-rr99.4%
if 1 < x Initial program 53.8%
flip-+4.9%
clear-num4.8%
log-div4.8%
metadata-eval4.8%
+-commutative4.8%
hypot-1-def4.7%
add-sqr-sqrt5.4%
fabs-sqr5.4%
add-sqr-sqrt4.7%
Applied egg-rr4.7%
neg-sub04.7%
div-sub4.7%
*-rgt-identity4.7%
associate-/l*4.7%
fma-neg4.7%
fma-undefine4.7%
unpow24.7%
associate--r+4.7%
+-inverses4.7%
metadata-eval4.7%
metadata-eval4.7%
*-rgt-identity4.7%
associate-/l*4.7%
fma-undefine4.7%
unpow24.7%
associate--r+7.6%
Simplified10.7%
*-un-lft-identity10.7%
add-sqr-sqrt10.8%
sqrt-unprod10.7%
sqr-neg10.7%
sqrt-unprod-0.0%
add-sqr-sqrt10.7%
Applied egg-rr10.7%
*-lft-identity10.7%
Simplified10.7%
Taylor expanded in x around inf 97.9%
Final simplification98.2%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
} else {
tmp = copysignf(logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x); else tmp = copysign(log(Float32(Float32(0.5) / x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x + ((x ^ single(3.0)) * 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 -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 51.7%
+-commutative51.7%
hypot-1-def98.4%
flip-+11.4%
hypot-1-def11.2%
hypot-1-def11.0%
add-sqr-sqrt10.8%
+-commutative10.8%
hypot-1-def10.7%
+-commutative10.7%
div-sub10.7%
Applied egg-rr13.4%
div-sub16.6%
remove-double-neg16.6%
distribute-frac-neg216.6%
neg-sub016.6%
associate--r-16.6%
neg-sub016.6%
+-commutative16.6%
sub-neg16.6%
distribute-frac-neg16.6%
sub-neg16.6%
+-commutative16.6%
distribute-neg-in16.6%
remove-double-neg16.6%
fma-undefine16.6%
unpow216.6%
+-commutative16.6%
associate-+l+48.3%
sub-neg48.3%
+-inverses98.4%
metadata-eval98.4%
Simplified98.4%
Taylor expanded in x around -inf 96.0%
if -2 < x < 1Initial program 21.6%
+-commutative21.6%
hypot-1-def21.5%
flip-+21.4%
hypot-1-def21.5%
hypot-1-def21.4%
add-sqr-sqrt21.7%
+-commutative21.7%
hypot-1-def21.6%
+-commutative21.6%
div-sub21.7%
Applied egg-rr21.6%
div-sub21.6%
remove-double-neg21.6%
distribute-frac-neg221.6%
neg-sub021.6%
associate--r-21.6%
neg-sub021.6%
+-commutative21.6%
sub-neg21.6%
distribute-frac-neg21.6%
sub-neg21.6%
+-commutative21.6%
distribute-neg-in21.6%
remove-double-neg21.6%
fma-undefine21.6%
unpow221.6%
+-commutative21.6%
associate-+l+21.7%
sub-neg21.7%
+-inverses21.7%
metadata-eval21.7%
Simplified21.7%
Taylor expanded in x around 0 98.6%
distribute-rgt-in98.6%
*-lft-identity98.6%
*-commutative98.6%
*-commutative98.6%
associate-*r*98.6%
unpow298.6%
cube-mult98.6%
Simplified98.6%
if 1 < x Initial program 53.8%
flip-+4.9%
clear-num4.8%
log-div4.8%
metadata-eval4.8%
+-commutative4.8%
hypot-1-def4.7%
add-sqr-sqrt5.4%
fabs-sqr5.4%
add-sqr-sqrt4.7%
Applied egg-rr4.7%
neg-sub04.7%
div-sub4.7%
*-rgt-identity4.7%
associate-/l*4.7%
fma-neg4.7%
fma-undefine4.7%
unpow24.7%
associate--r+4.7%
+-inverses4.7%
metadata-eval4.7%
metadata-eval4.7%
*-rgt-identity4.7%
associate-/l*4.7%
fma-undefine4.7%
unpow24.7%
associate--r+7.6%
Simplified10.7%
*-un-lft-identity10.7%
add-sqr-sqrt10.8%
sqrt-unprod10.7%
sqr-neg10.7%
sqrt-unprod-0.0%
add-sqr-sqrt10.7%
Applied egg-rr10.7%
*-lft-identity10.7%
Simplified10.7%
Taylor expanded in x around inf 97.9%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (log (/ -0.5 x)) x) (if (<= x 1.0) (copysign x x) (copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) tmp = copysign(x, x); else tmp = copysign(log(Float32(Float32(0.5) / x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 51.7%
+-commutative51.7%
hypot-1-def98.4%
flip-+11.4%
hypot-1-def11.2%
hypot-1-def11.0%
add-sqr-sqrt10.8%
+-commutative10.8%
hypot-1-def10.7%
+-commutative10.7%
div-sub10.7%
Applied egg-rr13.4%
div-sub16.6%
remove-double-neg16.6%
distribute-frac-neg216.6%
neg-sub016.6%
associate--r-16.6%
neg-sub016.6%
+-commutative16.6%
sub-neg16.6%
distribute-frac-neg16.6%
sub-neg16.6%
+-commutative16.6%
distribute-neg-in16.6%
remove-double-neg16.6%
fma-undefine16.6%
unpow216.6%
+-commutative16.6%
associate-+l+48.3%
sub-neg48.3%
+-inverses98.4%
metadata-eval98.4%
Simplified98.4%
Taylor expanded in x around -inf 96.0%
if -2 < x < 1Initial program 21.6%
Taylor expanded in x around 0 17.4%
+-commutative17.4%
rem-square-sqrt7.9%
fabs-sqr7.9%
rem-square-sqrt17.5%
Simplified17.5%
Taylor expanded in x around 0 96.7%
if 1 < x Initial program 53.8%
flip-+4.9%
clear-num4.8%
log-div4.8%
metadata-eval4.8%
+-commutative4.8%
hypot-1-def4.7%
add-sqr-sqrt5.4%
fabs-sqr5.4%
add-sqr-sqrt4.7%
Applied egg-rr4.7%
neg-sub04.7%
div-sub4.7%
*-rgt-identity4.7%
associate-/l*4.7%
fma-neg4.7%
fma-undefine4.7%
unpow24.7%
associate--r+4.7%
+-inverses4.7%
metadata-eval4.7%
metadata-eval4.7%
*-rgt-identity4.7%
associate-/l*4.7%
fma-undefine4.7%
unpow24.7%
associate--r+7.6%
Simplified10.7%
*-un-lft-identity10.7%
add-sqr-sqrt10.8%
sqrt-unprod10.7%
sqr-neg10.7%
sqrt-unprod-0.0%
add-sqr-sqrt10.7%
Applied egg-rr10.7%
*-lft-identity10.7%
Simplified10.7%
Taylor expanded in x around inf 97.9%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (log (/ -0.5 x)) x) (if (<= x 1.0) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x * Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x * single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 51.7%
+-commutative51.7%
hypot-1-def98.4%
flip-+11.4%
hypot-1-def11.2%
hypot-1-def11.0%
add-sqr-sqrt10.8%
+-commutative10.8%
hypot-1-def10.7%
+-commutative10.7%
div-sub10.7%
Applied egg-rr13.4%
div-sub16.6%
remove-double-neg16.6%
distribute-frac-neg216.6%
neg-sub016.6%
associate--r-16.6%
neg-sub016.6%
+-commutative16.6%
sub-neg16.6%
distribute-frac-neg16.6%
sub-neg16.6%
+-commutative16.6%
distribute-neg-in16.6%
remove-double-neg16.6%
fma-undefine16.6%
unpow216.6%
+-commutative16.6%
associate-+l+48.3%
sub-neg48.3%
+-inverses98.4%
metadata-eval98.4%
Simplified98.4%
Taylor expanded in x around -inf 96.0%
if -2 < x < 1Initial program 21.6%
Taylor expanded in x around 0 17.4%
+-commutative17.4%
rem-square-sqrt7.9%
fabs-sqr7.9%
rem-square-sqrt17.5%
Simplified17.5%
Taylor expanded in x around 0 96.7%
if 1 < x Initial program 53.8%
Taylor expanded in x around inf 97.9%
+-commutative97.9%
rem-square-sqrt97.9%
fabs-sqr97.9%
rem-square-sqrt97.9%
*-inverses97.9%
metadata-eval97.9%
Simplified97.9%
(FPCore (x) :precision binary32 (if (<= x -10.0) (copysign (log (- x)) x) (if (<= x 1.0) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf(-x), x);
} else if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(log(Float32(-x)), x); elseif (x <= Float32(1.0)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x * Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-10.0)) tmp = sign(x) * abs(log(-x)); elseif (x <= single(1.0)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x * single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 50.9%
Taylor expanded in x around -inf 44.2%
neg-mul-144.2%
Simplified44.2%
if -10 < x < 1Initial program 22.2%
Taylor expanded in x around 0 17.6%
+-commutative17.6%
rem-square-sqrt7.8%
fabs-sqr7.8%
rem-square-sqrt17.3%
Simplified17.3%
Taylor expanded in x around 0 96.2%
if 1 < x Initial program 53.8%
Taylor expanded in x around inf 97.9%
+-commutative97.9%
rem-square-sqrt97.9%
fabs-sqr97.9%
rem-square-sqrt97.9%
*-inverses97.9%
metadata-eval97.9%
Simplified97.9%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (log (- x)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf(-x), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.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 -2:\\
\;\;\;\;\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 < -2Initial program 51.7%
Taylor expanded in x around -inf 44.0%
neg-mul-144.0%
Simplified44.0%
if -2 < x Initial program 33.4%
Taylor expanded in x around 0 27.2%
log1p-define75.6%
rem-square-sqrt41.4%
fabs-sqr41.4%
rem-square-sqrt75.6%
Simplified75.6%
(FPCore (x) :precision binary32 (if (<= x 2.0) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 2.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(2.0)) tmp = copysign(x, x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < 2Initial program 32.0%
Taylor expanded in x around 0 26.4%
+-commutative26.4%
rem-square-sqrt5.4%
fabs-sqr5.4%
rem-square-sqrt11.7%
Simplified11.7%
Taylor expanded in x around 0 68.0%
if 2 < x Initial program 53.2%
Taylor expanded in x around 0 44.4%
log1p-define44.4%
rem-square-sqrt44.4%
fabs-sqr44.4%
rem-square-sqrt44.4%
Simplified44.4%
(FPCore (x) :precision binary32 (if (<= x 2.0) (copysign x x) (copysign (log x) x)))
float code(float x) {
float tmp;
if (x <= 2.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(2.0)) tmp = copysign(x, x); else tmp = copysign(log(x), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(2.0)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log(x)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\end{array}
if x < 2Initial program 32.0%
Taylor expanded in x around 0 26.4%
+-commutative26.4%
rem-square-sqrt5.4%
fabs-sqr5.4%
rem-square-sqrt11.7%
Simplified11.7%
Taylor expanded in x around 0 68.0%
if 2 < x Initial program 53.2%
Taylor expanded in x around inf 44.3%
mul-1-neg44.3%
log-rec44.3%
remove-double-neg44.3%
Simplified44.3%
(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.8%
Taylor expanded in x around 0 31.3%
+-commutative31.3%
rem-square-sqrt16.1%
fabs-sqr16.1%
rem-square-sqrt20.6%
Simplified20.6%
Taylor expanded in x around 0 52.4%
(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 2024132
(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))