
(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 12 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 (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.004999999888241291)
(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 (+ (fabs 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(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.004999999888241291f) {
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((fabsf(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(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.004999999888241291)) 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(abs(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(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.004999999888241291)) 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((abs(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(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.004999999888241291:\\
\;\;\;\;\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(\left|x\right| + \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 55.5%
flip-+9.6%
frac-2neg9.6%
log-div9.6%
Applied egg-rr14.8%
neg-sub014.8%
associate--r-14.8%
neg-sub014.8%
+-commutative14.8%
fma-undefine14.3%
unpow214.3%
+-commutative14.3%
associate-+l+52.4%
sub-neg52.4%
+-inverses99.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%
if -1 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.00499999989Initial program 20.7%
*-un-lft-identity20.7%
*-commutative20.7%
log-prod20.7%
*-un-lft-identity20.7%
*-un-lft-identity20.7%
add-sqr-sqrt9.1%
fabs-sqr9.1%
add-sqr-sqrt20.9%
+-commutative20.9%
hypot-1-def21.0%
metadata-eval21.0%
Applied egg-rr21.0%
+-rgt-identity21.0%
Simplified21.0%
Taylor expanded in x around 0 100.0%
if 0.00499999989 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 61.1%
+-commutative61.1%
hypot-1-def98.6%
Simplified98.6%
Final simplification99.6%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.05000000074505806)
(copysign (log (/ -1.0 (- x (hypot 1.0 x)))) x)
(if (<= t_0 0.004999999888241291)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log (+ (fabs 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.05000000074505806f) {
tmp = copysignf(logf((-1.0f / (x - hypotf(1.0f, x)))), x);
} else if (t_0 <= 0.004999999888241291f) {
tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
} else {
tmp = copysignf(logf((fabsf(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.05000000074505806)) tmp = copysign(log(Float32(Float32(-1.0) / Float32(x - hypot(Float32(1.0), x)))), x); elseif (t_0 <= Float32(0.004999999888241291)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x); else tmp = copysign(log(Float32(abs(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.05000000074505806)) tmp = sign(x) * abs(log((single(-1.0) / (x - hypot(single(1.0), x))))); elseif (t_0 <= single(0.004999999888241291)) tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666)))); else tmp = sign(x) * abs(log((abs(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.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-1}{x - \mathsf{hypot}\left(1, x\right)}\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.004999999888241291:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \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.0500000007Initial program 57.3%
+-commutative57.3%
hypot-1-def99.6%
flip-+13.6%
hypot-1-def13.6%
hypot-1-def13.4%
add-sqr-sqrt13.4%
+-commutative13.4%
hypot-1-def13.5%
+-commutative13.5%
div-sub13.1%
Applied egg-rr16.5%
div-sub18.7%
remove-double-neg18.7%
remove-double-neg18.7%
fma-undefine18.2%
unpow218.2%
associate--r+54.5%
+-inverses99.6%
metadata-eval99.6%
Simplified99.6%
if -0.0500000007 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.00499999989Initial program 19.0%
*-un-lft-identity19.0%
*-commutative19.0%
log-prod19.0%
*-un-lft-identity19.0%
*-un-lft-identity19.0%
add-sqr-sqrt9.4%
fabs-sqr9.4%
add-sqr-sqrt19.2%
+-commutative19.2%
hypot-1-def19.3%
metadata-eval19.3%
Applied egg-rr19.3%
+-rgt-identity19.3%
Simplified19.3%
Taylor expanded in x around 0 100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
*-commutative100.0%
associate-*r*100.0%
unpow2100.0%
cube-mult100.0%
Simplified100.0%
if 0.00499999989 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 61.1%
+-commutative61.1%
hypot-1-def98.6%
Simplified98.6%
(FPCore (x)
:precision binary32
(if (<= x -0.05000000074505806)
(copysign (log (/ -1.0 (- x (hypot 1.0 x)))) x)
(if (<= x 0.004999999888241291)
(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 <= -0.05000000074505806f) {
tmp = copysignf(logf((-1.0f / (x - hypotf(1.0f, x)))), x);
} else if (x <= 0.004999999888241291f) {
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(-0.05000000074505806)) tmp = copysign(log(Float32(Float32(-1.0) / Float32(x - hypot(Float32(1.0), x)))), x); elseif (x <= Float32(0.004999999888241291)) 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(-0.05000000074505806)) tmp = sign(x) * abs(log((single(-1.0) / (x - hypot(single(1.0), x))))); elseif (x <= single(0.004999999888241291)) 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 -0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-1}{x - \mathsf{hypot}\left(1, x\right)}\right), x\right)\\
\mathbf{elif}\;x \leq 0.004999999888241291:\\
\;\;\;\;\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 < -0.0500000007Initial program 57.3%
+-commutative57.3%
hypot-1-def99.6%
flip-+13.6%
hypot-1-def13.6%
hypot-1-def13.4%
add-sqr-sqrt13.4%
+-commutative13.4%
hypot-1-def13.5%
+-commutative13.5%
div-sub13.1%
Applied egg-rr16.5%
div-sub18.7%
remove-double-neg18.7%
remove-double-neg18.7%
fma-undefine18.2%
unpow218.2%
associate--r+54.5%
+-inverses99.6%
metadata-eval99.6%
Simplified99.6%
if -0.0500000007 < x < 0.00499999989Initial program 19.0%
*-un-lft-identity19.0%
*-commutative19.0%
log-prod19.0%
*-un-lft-identity19.0%
*-un-lft-identity19.0%
add-sqr-sqrt9.4%
fabs-sqr9.4%
add-sqr-sqrt19.2%
+-commutative19.2%
hypot-1-def19.3%
metadata-eval19.3%
Applied egg-rr19.3%
+-rgt-identity19.3%
Simplified19.3%
Taylor expanded in x around 0 100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
*-commutative100.0%
associate-*r*100.0%
unpow2100.0%
cube-mult100.0%
Simplified100.0%
if 0.00499999989 < x Initial program 61.1%
*-un-lft-identity61.1%
*-commutative61.1%
log-prod61.1%
*-un-lft-identity61.1%
*-un-lft-identity61.1%
add-sqr-sqrt61.0%
fabs-sqr61.0%
add-sqr-sqrt61.1%
+-commutative61.1%
hypot-1-def98.6%
metadata-eval98.6%
Applied egg-rr98.6%
+-rgt-identity98.6%
Simplified98.6%
(FPCore (x)
:precision binary32
(if (<= x -0.05000000074505806)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.004999999888241291)
(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 <= -0.05000000074505806f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.004999999888241291f) {
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(-0.05000000074505806)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.004999999888241291)) 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(-0.05000000074505806)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (x <= single(0.004999999888241291)) 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 -0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.004999999888241291:\\
\;\;\;\;\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 < -0.0500000007Initial program 57.3%
flip-+13.6%
frac-2neg13.6%
log-div13.6%
Applied egg-rr18.6%
neg-sub018.6%
associate--r-18.6%
neg-sub018.6%
+-commutative18.6%
fma-undefine18.1%
unpow218.1%
+-commutative18.1%
associate-+l+54.4%
sub-neg54.4%
+-inverses99.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%
if -0.0500000007 < x < 0.00499999989Initial program 19.0%
*-un-lft-identity19.0%
*-commutative19.0%
log-prod19.0%
*-un-lft-identity19.0%
*-un-lft-identity19.0%
add-sqr-sqrt9.4%
fabs-sqr9.4%
add-sqr-sqrt19.2%
+-commutative19.2%
hypot-1-def19.3%
metadata-eval19.3%
Applied egg-rr19.3%
+-rgt-identity19.3%
Simplified19.3%
Taylor expanded in x around 0 100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
*-commutative100.0%
associate-*r*100.0%
unpow2100.0%
cube-mult100.0%
Simplified100.0%
if 0.00499999989 < x Initial program 61.1%
*-un-lft-identity61.1%
*-commutative61.1%
log-prod61.1%
*-un-lft-identity61.1%
*-un-lft-identity61.1%
add-sqr-sqrt61.0%
fabs-sqr61.0%
add-sqr-sqrt61.1%
+-commutative61.1%
hypot-1-def98.6%
metadata-eval98.6%
Applied egg-rr98.6%
+-rgt-identity98.6%
Simplified98.6%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (- (fabs x) x)) x)
(if (<= x 0.004999999888241291)
(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 <= -2.0f) {
tmp = copysignf(logf((fabsf(x) - x)), x);
} else if (x <= 0.004999999888241291f) {
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(-2.0)) tmp = copysign(log(Float32(abs(x) - x)), x); elseif (x <= Float32(0.004999999888241291)) 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(-2.0)) tmp = sign(x) * abs(log((abs(x) - x))); elseif (x <= single(0.004999999888241291)) 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 -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.004999999888241291:\\
\;\;\;\;\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 < -2Initial program 55.5%
Taylor expanded in x around -inf 96.8%
neg-mul-196.8%
Simplified96.8%
if -2 < x < 0.00499999989Initial program 20.7%
*-un-lft-identity20.7%
*-commutative20.7%
log-prod20.7%
*-un-lft-identity20.7%
*-un-lft-identity20.7%
add-sqr-sqrt9.1%
fabs-sqr9.1%
add-sqr-sqrt20.9%
+-commutative20.9%
hypot-1-def21.0%
metadata-eval21.0%
Applied egg-rr21.0%
+-rgt-identity21.0%
Simplified21.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.00499999989 < x Initial program 61.1%
*-un-lft-identity61.1%
*-commutative61.1%
log-prod61.1%
*-un-lft-identity61.1%
*-un-lft-identity61.1%
add-sqr-sqrt61.0%
fabs-sqr61.0%
add-sqr-sqrt61.1%
+-commutative61.1%
hypot-1-def98.6%
metadata-eval98.6%
Applied egg-rr98.6%
+-rgt-identity98.6%
Simplified98.6%
Final simplification98.6%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.004999999888241291)
(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 <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.004999999888241291f) {
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(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.004999999888241291)) 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(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.004999999888241291)) 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 -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.004999999888241291:\\
\;\;\;\;\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 < -2Initial program 55.5%
*-un-lft-identity55.5%
*-commutative55.5%
log-prod55.5%
*-un-lft-identity55.5%
*-un-lft-identity55.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt15.1%
+-commutative15.1%
hypot-1-def15.1%
metadata-eval15.1%
Applied egg-rr15.1%
+-rgt-identity15.1%
Simplified15.1%
Taylor expanded in x around -inf 96.7%
if -2 < x < 0.00499999989Initial program 20.7%
*-un-lft-identity20.7%
*-commutative20.7%
log-prod20.7%
*-un-lft-identity20.7%
*-un-lft-identity20.7%
add-sqr-sqrt9.1%
fabs-sqr9.1%
add-sqr-sqrt20.9%
+-commutative20.9%
hypot-1-def21.0%
metadata-eval21.0%
Applied egg-rr21.0%
+-rgt-identity21.0%
Simplified21.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.00499999989 < x Initial program 61.1%
*-un-lft-identity61.1%
*-commutative61.1%
log-prod61.1%
*-un-lft-identity61.1%
*-un-lft-identity61.1%
add-sqr-sqrt61.0%
fabs-sqr61.0%
add-sqr-sqrt61.1%
+-commutative61.1%
hypot-1-def98.6%
metadata-eval98.6%
Applied egg-rr98.6%
+-rgt-identity98.6%
Simplified98.6%
(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 x) (log 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 + (powf(x, 3.0f) * -0.16666666666666666f)), x);
} else {
tmp = copysignf((logf(x) + logf(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(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x); else tmp = copysign(Float32(log(x) + log(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 + ((x ^ single(3.0)) * single(-0.16666666666666666)))); else tmp = sign(x) * abs((log(x) + log(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}^{3} \cdot -0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x + \log 2, x\right)\\
\end{array}
\end{array}
if x < -2Initial program 55.5%
*-un-lft-identity55.5%
*-commutative55.5%
log-prod55.5%
*-un-lft-identity55.5%
*-un-lft-identity55.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt15.1%
+-commutative15.1%
hypot-1-def15.1%
metadata-eval15.1%
Applied egg-rr15.1%
+-rgt-identity15.1%
Simplified15.1%
Taylor expanded in x around -inf 96.7%
if -2 < x < 1Initial program 21.8%
*-un-lft-identity21.8%
*-commutative21.8%
log-prod21.8%
*-un-lft-identity21.8%
*-un-lft-identity21.8%
add-sqr-sqrt10.4%
fabs-sqr10.4%
add-sqr-sqrt22.1%
+-commutative22.1%
hypot-1-def22.2%
metadata-eval22.2%
Applied egg-rr22.2%
+-rgt-identity22.2%
Simplified22.2%
Taylor expanded in x around 0 98.8%
distribute-lft-in98.9%
*-rgt-identity98.9%
*-commutative98.9%
associate-*r*98.9%
unpow298.9%
cube-mult98.9%
Simplified98.9%
if 1 < x Initial program 59.9%
add-cbrt-cube45.1%
pow1/344.6%
log-pow44.5%
pow344.5%
log-pow59.4%
*-un-lft-identity59.4%
*-un-lft-identity59.4%
Applied egg-rr97.7%
Taylor expanded in x around inf 95.3%
*-commutative95.3%
Simplified95.3%
associate-*r*96.1%
metadata-eval96.1%
*-un-lft-identity96.1%
log-prod96.6%
Applied egg-rr96.6%
(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 (* 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 + (powf(x, 3.0f) * -0.16666666666666666f)), 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(Float32(x + Float32((x ^ Float32(3.0)) * 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(-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((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}^{3} \cdot -0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 55.5%
*-un-lft-identity55.5%
*-commutative55.5%
log-prod55.5%
*-un-lft-identity55.5%
*-un-lft-identity55.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt15.1%
+-commutative15.1%
hypot-1-def15.1%
metadata-eval15.1%
Applied egg-rr15.1%
+-rgt-identity15.1%
Simplified15.1%
Taylor expanded in x around -inf 96.7%
if -2 < x < 1Initial program 21.8%
*-un-lft-identity21.8%
*-commutative21.8%
log-prod21.8%
*-un-lft-identity21.8%
*-un-lft-identity21.8%
add-sqr-sqrt10.4%
fabs-sqr10.4%
add-sqr-sqrt22.1%
+-commutative22.1%
hypot-1-def22.2%
metadata-eval22.2%
Applied egg-rr22.2%
+-rgt-identity22.2%
Simplified22.2%
Taylor expanded in x around 0 98.8%
distribute-lft-in98.9%
*-rgt-identity98.9%
*-commutative98.9%
associate-*r*98.9%
unpow298.9%
cube-mult98.9%
Simplified98.9%
if 1 < x Initial program 59.9%
add-cbrt-cube45.1%
pow1/344.6%
log-pow44.5%
pow344.5%
log-pow59.4%
*-un-lft-identity59.4%
*-un-lft-identity59.4%
Applied egg-rr97.7%
Taylor expanded in x around inf 95.3%
*-commutative95.3%
Simplified95.3%
associate-*r*96.1%
metadata-eval96.1%
*-un-lft-identity96.1%
*-un-lft-identity96.1%
log-prod96.1%
metadata-eval96.1%
Applied egg-rr96.1%
+-lft-identity96.1%
Simplified96.1%
(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 55.5%
*-un-lft-identity55.5%
*-commutative55.5%
log-prod55.5%
*-un-lft-identity55.5%
*-un-lft-identity55.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt15.1%
+-commutative15.1%
hypot-1-def15.1%
metadata-eval15.1%
Applied egg-rr15.1%
+-rgt-identity15.1%
Simplified15.1%
Taylor expanded in x around -inf 96.7%
if -2 < x < 1Initial program 21.8%
add-cbrt-cube21.8%
pow1/321.8%
log-pow21.8%
pow321.8%
log-pow21.8%
*-un-lft-identity21.8%
*-un-lft-identity21.8%
Applied egg-rr22.2%
Taylor expanded in x around 0 96.2%
*-commutative96.2%
Simplified96.2%
Taylor expanded in x around 0 97.1%
if 1 < x Initial program 59.9%
add-cbrt-cube45.1%
pow1/344.6%
log-pow44.5%
pow344.5%
log-pow59.4%
*-un-lft-identity59.4%
*-un-lft-identity59.4%
Applied egg-rr97.7%
Taylor expanded in x around inf 95.3%
*-commutative95.3%
Simplified95.3%
associate-*r*96.1%
metadata-eval96.1%
*-un-lft-identity96.1%
*-un-lft-identity96.1%
log-prod96.1%
metadata-eval96.1%
Applied egg-rr96.1%
+-lft-identity96.1%
Simplified96.1%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign x x) (copysign (log (* x 2.0)) x)))
float code(float x) {
float tmp;
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(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(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 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 < 1Initial program 32.1%
add-cbrt-cube28.7%
pow1/328.6%
log-pow28.6%
pow328.6%
log-pow32.0%
*-un-lft-identity32.0%
*-un-lft-identity32.0%
Applied egg-rr20.0%
Taylor expanded in x around 0 70.5%
*-commutative70.5%
Simplified70.5%
Taylor expanded in x around 0 71.1%
if 1 < x Initial program 59.9%
add-cbrt-cube45.1%
pow1/344.6%
log-pow44.5%
pow344.5%
log-pow59.4%
*-un-lft-identity59.4%
*-un-lft-identity59.4%
Applied egg-rr97.7%
Taylor expanded in x around inf 95.3%
*-commutative95.3%
Simplified95.3%
associate-*r*96.1%
metadata-eval96.1%
*-un-lft-identity96.1%
*-un-lft-identity96.1%
log-prod96.1%
metadata-eval96.1%
Applied egg-rr96.1%
+-lft-identity96.1%
Simplified96.1%
(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 32.1%
add-cbrt-cube28.7%
pow1/328.6%
log-pow28.6%
pow328.6%
log-pow32.0%
*-un-lft-identity32.0%
*-un-lft-identity32.0%
Applied egg-rr20.0%
Taylor expanded in x around 0 70.5%
*-commutative70.5%
Simplified70.5%
Taylor expanded in x around 0 71.1%
if 1 < x Initial program 59.9%
Taylor expanded in x around 0 43.7%
log1p-define43.7%
rem-square-sqrt43.7%
fabs-sqr43.7%
rem-square-sqrt43.7%
Simplified43.7%
(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 39.0%
add-cbrt-cube32.8%
pow1/332.5%
log-pow32.5%
pow332.5%
log-pow38.7%
*-un-lft-identity38.7%
*-un-lft-identity38.7%
Applied egg-rr39.1%
Taylor expanded in x around 0 56.1%
*-commutative56.1%
Simplified56.1%
Taylor expanded in x around 0 56.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 2024107
(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))