
(FPCore (x) :precision binary32 (asinh x))
float code(float x) {
return asinhf(x);
}
function code(x) return asinh(x) end
function tmp = code(x) tmp = asinh(x); end
\begin{array}{l}
\\
\sinh^{-1} x
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary32 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
float code(float x) {
return copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
}
function code(x) return copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) end
function tmp = code(x) tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); end
\begin{array}{l}
\\
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\end{array}
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -5.0)
(copysign (log (/ -0.5 x)) x)
(if (<= t_0 1.0)
(copysign
(*
x
(+
1.0
(*
(pow x 2.0)
(-
(* (pow x 2.0) (+ 0.075 (* (pow x 2.0) -0.044642857142857144)))
0.16666666666666666))))
x)
(copysign (log (/ 0.5 x)) x)))))
float code(float x) {
float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
float tmp;
if (t_0 <= -5.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (t_0 <= 1.0f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * ((powf(x, 2.0f) * (0.075f + (powf(x, 2.0f) * -0.044642857142857144f))) - 0.16666666666666666f)))), x);
} else {
tmp = copysignf(logf((0.5f / x)), x);
}
return tmp;
}
function code(x) t_0 = copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) tmp = Float32(0.0) if (t_0 <= Float32(-5.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (t_0 <= Float32(1.0)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32((x ^ Float32(2.0)) * Float32(Float32((x ^ Float32(2.0)) * Float32(Float32(0.075) + Float32((x ^ Float32(2.0)) * Float32(-0.044642857142857144)))) - Float32(0.16666666666666666))))), x); else tmp = copysign(log(Float32(Float32(0.5) / x)), x); end return tmp end
function tmp_2 = code(x) t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); tmp = single(0.0); if (t_0 <= single(-5.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (t_0 <= single(1.0)) tmp = sign(x) * abs((x * (single(1.0) + ((x ^ single(2.0)) * (((x ^ single(2.0)) * (single(0.075) + ((x ^ single(2.0)) * single(-0.044642857142857144)))) - single(0.16666666666666666)))))); else tmp = sign(x) * abs(log((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t\_0 \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot \left({x}^{2} \cdot \left(0.075 + {x}^{2} \cdot -0.044642857142857144\right) - 0.16666666666666666\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < -5Initial program 53.2%
Taylor expanded in x around -inf 98.7%
mul-1-neg98.7%
*-commutative98.7%
distribute-rgt-neg-in98.7%
mul-1-neg98.7%
unsub-neg98.7%
sub-neg98.7%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt8.8%
associate-*r/8.8%
metadata-eval8.8%
distribute-neg-frac8.8%
metadata-eval8.8%
Simplified8.8%
Taylor expanded in x around 0 99.5%
if -5 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 1Initial program 26.8%
+-commutative26.8%
hypot-1-def26.8%
flip-+26.5%
hypot-1-def26.5%
hypot-1-def26.4%
add-sqr-sqrt26.6%
+-commutative26.6%
hypot-1-def26.6%
+-commutative26.6%
div-sub26.6%
Applied egg-rr26.5%
div-sub26.5%
remove-double-neg26.5%
distribute-frac-neg226.5%
neg-sub026.5%
associate--r-26.5%
neg-sub026.5%
+-commutative26.5%
sub-neg26.5%
distribute-frac-neg26.5%
sub-neg26.5%
+-commutative26.5%
distribute-neg-in26.5%
remove-double-neg26.5%
fma-undefine26.5%
unpow226.5%
+-commutative26.5%
associate-+l+26.6%
sub-neg26.6%
+-inverses26.6%
metadata-eval26.6%
Simplified26.6%
Taylor expanded in x around 0 99.4%
if 1 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 51.8%
+-commutative51.8%
hypot-1-def98.5%
flip-+3.1%
hypot-1-def3.1%
hypot-1-def3.1%
add-sqr-sqrt2.9%
+-commutative2.9%
hypot-1-def2.9%
+-commutative2.9%
div-sub2.9%
Applied egg-rr2.9%
div-sub2.9%
remove-double-neg2.9%
distribute-frac-neg22.9%
neg-sub02.9%
associate--r-2.9%
neg-sub02.9%
+-commutative2.9%
sub-neg2.9%
distribute-frac-neg2.9%
sub-neg2.9%
+-commutative2.9%
distribute-neg-in2.9%
remove-double-neg2.9%
fma-undefine2.9%
unpow22.9%
+-commutative2.9%
associate-+l+5.6%
sub-neg5.6%
+-inverses8.9%
metadata-eval8.9%
Simplified8.9%
inv-pow8.9%
sub-neg8.9%
add-sqr-sqrt-0.0%
sqrt-unprod51.8%
sqr-neg51.8%
sqrt-unprod98.5%
add-sqr-sqrt98.5%
+-commutative98.5%
Applied egg-rr98.5%
unpow-198.5%
Simplified98.5%
Taylor expanded in x around inf 99.9%
Final simplification99.6%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -5.0)
(copysign (log (/ -0.5 x)) x)
(if (<= t_0 1.0)
(copysign
(*
x
(+ 1.0 (* (pow x 2.0) (- (* (pow x 2.0) 0.075) 0.16666666666666666))))
x)
(copysign (log (/ 0.5 x)) x)))))
float code(float x) {
float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
float tmp;
if (t_0 <= -5.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (t_0 <= 1.0f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * ((powf(x, 2.0f) * 0.075f) - 0.16666666666666666f)))), x);
} else {
tmp = copysignf(logf((0.5f / x)), x);
}
return tmp;
}
function code(x) t_0 = copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) tmp = Float32(0.0) if (t_0 <= Float32(-5.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (t_0 <= Float32(1.0)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32((x ^ Float32(2.0)) * Float32(Float32((x ^ Float32(2.0)) * Float32(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) t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); tmp = single(0.0); if (t_0 <= single(-5.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (t_0 <= single(1.0)) tmp = sign(x) * abs((x * (single(1.0) + ((x ^ single(2.0)) * (((x ^ single(2.0)) * single(0.075)) - single(0.16666666666666666)))))); else tmp = sign(x) * abs(log((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t\_0 \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\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(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < -5Initial program 53.2%
Taylor expanded in x around -inf 98.7%
mul-1-neg98.7%
*-commutative98.7%
distribute-rgt-neg-in98.7%
mul-1-neg98.7%
unsub-neg98.7%
sub-neg98.7%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt8.8%
associate-*r/8.8%
metadata-eval8.8%
distribute-neg-frac8.8%
metadata-eval8.8%
Simplified8.8%
Taylor expanded in x around 0 99.5%
if -5 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 1Initial program 26.8%
+-commutative26.8%
hypot-1-def26.8%
flip-+26.5%
hypot-1-def26.5%
hypot-1-def26.4%
add-sqr-sqrt26.6%
+-commutative26.6%
hypot-1-def26.6%
+-commutative26.6%
div-sub26.6%
Applied egg-rr26.5%
div-sub26.5%
remove-double-neg26.5%
distribute-frac-neg226.5%
neg-sub026.5%
associate--r-26.5%
neg-sub026.5%
+-commutative26.5%
sub-neg26.5%
distribute-frac-neg26.5%
sub-neg26.5%
+-commutative26.5%
distribute-neg-in26.5%
remove-double-neg26.5%
fma-undefine26.5%
unpow226.5%
+-commutative26.5%
associate-+l+26.6%
sub-neg26.6%
+-inverses26.6%
metadata-eval26.6%
Simplified26.6%
Taylor expanded in x around 0 99.2%
if 1 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 51.8%
+-commutative51.8%
hypot-1-def98.5%
flip-+3.1%
hypot-1-def3.1%
hypot-1-def3.1%
add-sqr-sqrt2.9%
+-commutative2.9%
hypot-1-def2.9%
+-commutative2.9%
div-sub2.9%
Applied egg-rr2.9%
div-sub2.9%
remove-double-neg2.9%
distribute-frac-neg22.9%
neg-sub02.9%
associate--r-2.9%
neg-sub02.9%
+-commutative2.9%
sub-neg2.9%
distribute-frac-neg2.9%
sub-neg2.9%
+-commutative2.9%
distribute-neg-in2.9%
remove-double-neg2.9%
fma-undefine2.9%
unpow22.9%
+-commutative2.9%
associate-+l+5.6%
sub-neg5.6%
+-inverses8.9%
metadata-eval8.9%
Simplified8.9%
inv-pow8.9%
sub-neg8.9%
add-sqr-sqrt-0.0%
sqrt-unprod51.8%
sqr-neg51.8%
sqrt-unprod98.5%
add-sqr-sqrt98.5%
+-commutative98.5%
Applied egg-rr98.5%
unpow-198.5%
Simplified98.5%
Taylor expanded in x around inf 99.9%
Final simplification99.5%
(FPCore (x)
:precision binary32
(if (<= x -100.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.03999999910593033)
(copysign (+ x (* (pow x 3.0) -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 + (powf(x, 3.0f) * -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((x ^ Float32(3.0)) * 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 + ((x ^ single(3.0)) * 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 + {x}^{3} \cdot -0.16666666666666666, 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 53.2%
Taylor expanded in x around -inf 98.7%
mul-1-neg98.7%
*-commutative98.7%
distribute-rgt-neg-in98.7%
mul-1-neg98.7%
unsub-neg98.7%
sub-neg98.7%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt8.8%
associate-*r/8.8%
metadata-eval8.8%
distribute-neg-frac8.8%
metadata-eval8.8%
Simplified8.8%
Taylor expanded in x around 0 99.5%
if -100 < x < 0.0399999991Initial program 25.0%
+-commutative25.0%
hypot-1-def25.0%
flip-+24.8%
hypot-1-def24.8%
hypot-1-def24.7%
add-sqr-sqrt25.0%
+-commutative25.0%
hypot-1-def25.0%
+-commutative25.0%
div-sub24.9%
Applied egg-rr24.8%
div-sub24.8%
remove-double-neg24.8%
distribute-frac-neg224.8%
neg-sub024.8%
associate--r-24.8%
neg-sub024.8%
+-commutative24.8%
sub-neg24.8%
distribute-frac-neg24.8%
sub-neg24.8%
+-commutative24.8%
distribute-neg-in24.8%
remove-double-neg24.8%
fma-undefine24.8%
unpow224.8%
+-commutative24.8%
associate-+l+25.0%
sub-neg25.0%
+-inverses25.0%
metadata-eval25.0%
Simplified25.0%
Taylor expanded in x around 0 99.5%
distribute-lft-in99.5%
*-rgt-identity99.5%
*-commutative99.5%
associate-*r*99.5%
unpow299.5%
cube-mult99.5%
Simplified99.5%
if 0.0399999991 < x Initial program 53.8%
Taylor expanded in x around 0 53.8%
rem-square-sqrt53.8%
fabs-sqr53.8%
rem-square-sqrt53.8%
metadata-eval53.8%
unpow253.8%
hypot-undefine98.5%
Simplified98.5%
(FPCore (x)
:precision binary32
(if (<= x -100.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 <= -100.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(-100.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(-100.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 -100:\\
\;\;\;\;\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 < -100Initial program 53.2%
Taylor expanded in x around -inf 98.7%
mul-1-neg98.7%
*-commutative98.7%
distribute-rgt-neg-in98.7%
mul-1-neg98.7%
unsub-neg98.7%
sub-neg98.7%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt8.8%
associate-*r/8.8%
metadata-eval8.8%
distribute-neg-frac8.8%
metadata-eval8.8%
Simplified8.8%
Taylor expanded in x around 0 99.5%
if -100 < x < 1Initial program 26.8%
+-commutative26.8%
hypot-1-def26.8%
flip-+26.5%
hypot-1-def26.5%
hypot-1-def26.4%
add-sqr-sqrt26.6%
+-commutative26.6%
hypot-1-def26.6%
+-commutative26.6%
div-sub26.6%
Applied egg-rr26.5%
div-sub26.5%
remove-double-neg26.5%
distribute-frac-neg226.5%
neg-sub026.5%
associate--r-26.5%
neg-sub026.5%
+-commutative26.5%
sub-neg26.5%
distribute-frac-neg26.5%
sub-neg26.5%
+-commutative26.5%
distribute-neg-in26.5%
remove-double-neg26.5%
fma-undefine26.5%
unpow226.5%
+-commutative26.5%
associate-+l+26.6%
sub-neg26.6%
+-inverses26.6%
metadata-eval26.6%
Simplified26.6%
Taylor expanded in x around 0 98.7%
distribute-lft-in98.7%
*-rgt-identity98.7%
*-commutative98.7%
associate-*r*98.7%
unpow298.7%
cube-mult98.7%
Simplified98.7%
if 1 < x Initial program 51.8%
+-commutative51.8%
hypot-1-def98.5%
flip-+3.1%
hypot-1-def3.1%
hypot-1-def3.1%
add-sqr-sqrt2.9%
+-commutative2.9%
hypot-1-def2.9%
+-commutative2.9%
div-sub2.9%
Applied egg-rr2.9%
div-sub2.9%
remove-double-neg2.9%
distribute-frac-neg22.9%
neg-sub02.9%
associate--r-2.9%
neg-sub02.9%
+-commutative2.9%
sub-neg2.9%
distribute-frac-neg2.9%
sub-neg2.9%
+-commutative2.9%
distribute-neg-in2.9%
remove-double-neg2.9%
fma-undefine2.9%
unpow22.9%
+-commutative2.9%
associate-+l+5.6%
sub-neg5.6%
+-inverses8.9%
metadata-eval8.9%
Simplified8.9%
inv-pow8.9%
sub-neg8.9%
add-sqr-sqrt-0.0%
sqrt-unprod51.8%
sqr-neg51.8%
sqrt-unprod98.5%
add-sqr-sqrt98.5%
+-commutative98.5%
Applied egg-rr98.5%
unpow-198.5%
Simplified98.5%
Taylor expanded in x around inf 99.9%
(FPCore (x) :precision binary32 (if (<= x -100.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 <= -100.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(-100.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(-100.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 -100:\\
\;\;\;\;\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 < -100Initial program 53.2%
Taylor expanded in x around -inf 98.7%
mul-1-neg98.7%
*-commutative98.7%
distribute-rgt-neg-in98.7%
mul-1-neg98.7%
unsub-neg98.7%
sub-neg98.7%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt8.8%
associate-*r/8.8%
metadata-eval8.8%
distribute-neg-frac8.8%
metadata-eval8.8%
Simplified8.8%
Taylor expanded in x around 0 99.5%
if -100 < x < 1Initial program 26.8%
Taylor expanded in x around 0 22.1%
log1p-define91.4%
rem-square-sqrt42.1%
fabs-sqr42.1%
rem-square-sqrt91.4%
Simplified91.4%
Taylor expanded in x around 0 96.4%
if 1 < x Initial program 51.8%
+-commutative51.8%
hypot-1-def98.5%
flip-+3.1%
hypot-1-def3.1%
hypot-1-def3.1%
add-sqr-sqrt2.9%
+-commutative2.9%
hypot-1-def2.9%
+-commutative2.9%
div-sub2.9%
Applied egg-rr2.9%
div-sub2.9%
remove-double-neg2.9%
distribute-frac-neg22.9%
neg-sub02.9%
associate--r-2.9%
neg-sub02.9%
+-commutative2.9%
sub-neg2.9%
distribute-frac-neg2.9%
sub-neg2.9%
+-commutative2.9%
distribute-neg-in2.9%
remove-double-neg2.9%
fma-undefine2.9%
unpow22.9%
+-commutative2.9%
associate-+l+5.6%
sub-neg5.6%
+-inverses8.9%
metadata-eval8.9%
Simplified8.9%
inv-pow8.9%
sub-neg8.9%
add-sqr-sqrt-0.0%
sqrt-unprod51.8%
sqr-neg51.8%
sqrt-unprod98.5%
add-sqr-sqrt98.5%
+-commutative98.5%
Applied egg-rr98.5%
unpow-198.5%
Simplified98.5%
Taylor expanded in x around inf 99.9%
(FPCore (x) :precision binary32 (if (<= x -100.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 <= -100.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(-100.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(-100.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 -100:\\
\;\;\;\;\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 < -100Initial program 53.2%
Taylor expanded in x around -inf 98.7%
mul-1-neg98.7%
*-commutative98.7%
distribute-rgt-neg-in98.7%
mul-1-neg98.7%
unsub-neg98.7%
sub-neg98.7%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt8.8%
associate-*r/8.8%
metadata-eval8.8%
distribute-neg-frac8.8%
metadata-eval8.8%
Simplified8.8%
Taylor expanded in x around 0 99.5%
if -100 < x < 1Initial program 26.8%
Taylor expanded in x around 0 22.1%
log1p-define91.4%
rem-square-sqrt42.1%
fabs-sqr42.1%
rem-square-sqrt91.4%
Simplified91.4%
Taylor expanded in x around 0 96.4%
if 1 < x Initial program 51.8%
Taylor expanded in x around inf 98.5%
+-commutative98.5%
rem-square-sqrt98.5%
fabs-sqr98.5%
rem-square-sqrt98.5%
*-inverses98.5%
metadata-eval98.5%
Simplified98.5%
(FPCore (x) :precision binary32 (if (<= x -100.0) (copysign (log (* x -2.0)) x) (if (<= x 1.0) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -100.0f) {
tmp = copysignf(logf((x * -2.0f)), 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(-100.0)) tmp = copysign(log(Float32(x * Float32(-2.0))), 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(-100.0)) tmp = sign(x) * abs(log((x * single(-2.0)))); 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 -100:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot -2\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 < -100Initial program 53.2%
+-commutative53.2%
hypot-1-def98.7%
flip-+2.6%
hypot-1-def2.6%
hypot-1-def2.5%
add-sqr-sqrt2.6%
+-commutative2.6%
hypot-1-def2.6%
+-commutative2.6%
div-sub2.7%
Applied egg-rr5.8%
div-sub7.2%
remove-double-neg7.2%
distribute-frac-neg27.2%
neg-sub07.2%
associate--r-7.2%
neg-sub07.2%
+-commutative7.2%
sub-neg7.2%
distribute-frac-neg7.2%
sub-neg7.2%
+-commutative7.2%
distribute-neg-in7.2%
remove-double-neg7.2%
fma-undefine7.2%
unpow27.2%
+-commutative7.2%
associate-+l+50.0%
sub-neg50.0%
+-inverses98.6%
metadata-eval98.6%
Simplified98.6%
inv-pow98.6%
sub-neg98.6%
add-sqr-sqrt98.7%
sqrt-unprod53.2%
sqr-neg53.2%
sqrt-unprod-0.0%
add-sqr-sqrt8.7%
+-commutative8.7%
Applied egg-rr8.7%
unpow-18.7%
Simplified8.7%
Taylor expanded in x around -inf 98.2%
*-commutative98.2%
Simplified98.2%
if -100 < x < 1Initial program 26.8%
Taylor expanded in x around 0 22.1%
log1p-define91.4%
rem-square-sqrt42.1%
fabs-sqr42.1%
rem-square-sqrt91.4%
Simplified91.4%
Taylor expanded in x around 0 96.4%
if 1 < x Initial program 51.8%
Taylor expanded in x around inf 98.5%
+-commutative98.5%
rem-square-sqrt98.5%
fabs-sqr98.5%
rem-square-sqrt98.5%
*-inverses98.5%
metadata-eval98.5%
Simplified98.5%
(FPCore (x) :precision binary32 (if (<= x -100.0) (copysign (log (* x -2.0)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -100.0f) {
tmp = copysignf(logf((x * -2.0f)), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-100.0)) tmp = copysign(log(Float32(x * Float32(-2.0))), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -100:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot -2\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -100Initial program 53.2%
+-commutative53.2%
hypot-1-def98.7%
flip-+2.6%
hypot-1-def2.6%
hypot-1-def2.5%
add-sqr-sqrt2.6%
+-commutative2.6%
hypot-1-def2.6%
+-commutative2.6%
div-sub2.7%
Applied egg-rr5.8%
div-sub7.2%
remove-double-neg7.2%
distribute-frac-neg27.2%
neg-sub07.2%
associate--r-7.2%
neg-sub07.2%
+-commutative7.2%
sub-neg7.2%
distribute-frac-neg7.2%
sub-neg7.2%
+-commutative7.2%
distribute-neg-in7.2%
remove-double-neg7.2%
fma-undefine7.2%
unpow27.2%
+-commutative7.2%
associate-+l+50.0%
sub-neg50.0%
+-inverses98.6%
metadata-eval98.6%
Simplified98.6%
inv-pow98.6%
sub-neg98.6%
add-sqr-sqrt98.7%
sqrt-unprod53.2%
sqr-neg53.2%
sqrt-unprod-0.0%
add-sqr-sqrt8.7%
+-commutative8.7%
Applied egg-rr8.7%
unpow-18.7%
Simplified8.7%
Taylor expanded in x around -inf 98.2%
*-commutative98.2%
Simplified98.2%
if -100 < x Initial program 35.4%
Taylor expanded in x around 0 29.8%
log1p-define75.3%
rem-square-sqrt42.9%
fabs-sqr42.9%
rem-square-sqrt75.3%
Simplified75.3%
(FPCore (x) :precision binary32 (if (<= x -100.0) (copysign (log (- x)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -100.0f) {
tmp = copysignf(logf(-x), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-100.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 -100:\\
\;\;\;\;\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 < -100Initial program 53.2%
Taylor expanded in x around -inf 44.9%
neg-mul-144.9%
Simplified44.9%
if -100 < x Initial program 35.4%
Taylor expanded in x around 0 29.8%
log1p-define75.3%
rem-square-sqrt42.9%
fabs-sqr42.9%
rem-square-sqrt75.3%
Simplified75.3%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(1.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 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < 1Initial program 36.5%
Taylor expanded in x around 0 30.4%
log1p-define74.5%
rem-square-sqrt26.7%
fabs-sqr26.7%
rem-square-sqrt58.1%
Simplified58.1%
Taylor expanded in x around 0 65.1%
if 1 < x Initial program 51.8%
Taylor expanded in x around 0 44.5%
log1p-define44.5%
rem-square-sqrt44.5%
fabs-sqr44.5%
rem-square-sqrt44.5%
Simplified44.5%
(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 40.3%
Taylor expanded in x around 0 33.9%
log1p-define67.0%
rem-square-sqrt31.2%
fabs-sqr31.2%
rem-square-sqrt54.7%
Simplified54.7%
Taylor expanded in x around 0 51.5%
(FPCore (x) :precision binary32 (let* ((t_0 (/ 1.0 (fabs x)))) (copysign (log1p (+ (fabs x) (/ (fabs x) (+ (hypot 1.0 t_0) t_0)))) x)))
float code(float x) {
float t_0 = 1.0f / fabsf(x);
return copysignf(log1pf((fabsf(x) + (fabsf(x) / (hypotf(1.0f, t_0) + t_0)))), x);
}
function code(x) t_0 = Float32(Float32(1.0) / abs(x)) return copysign(log1p(Float32(abs(x) + Float32(abs(x) / Float32(hypot(Float32(1.0), t_0) + t_0)))), x) end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\left|x\right|}\\
\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right| + \frac{\left|x\right|}{\mathsf{hypot}\left(1, t\_0\right) + t\_0}\right), x\right)
\end{array}
\end{array}
herbie shell --seed 2024137
(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))