
(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 -1.0)
(copysign (- (log1p (+ -1.0 (- (hypot 1.0 x) x)))) x)
(if (<= t_0 0.0010000000474974513)
(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(-log1pf((-1.0f + (hypotf(1.0f, x) - x))), x);
} else if (t_0 <= 0.0010000000474974513f) {
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(-log1p(Float32(Float32(-1.0) + Float32(hypot(Float32(1.0), x) - x)))), x); elseif (t_0 <= Float32(0.0010000000474974513)) 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
\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(-\mathsf{log1p}\left(-1 + \left(\mathsf{hypot}\left(1, x\right) - x\right)\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.0010000000474974513:\\
\;\;\;\;\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%
log1p-expm1-u99.9%
expm1-undefine99.9%
add-exp-log99.9%
Applied egg-rr99.9%
if -1 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.00100000005Initial program 20.2%
*-un-lft-identity20.2%
*-commutative20.2%
log-prod20.2%
*-un-lft-identity20.2%
*-un-lft-identity20.2%
add-sqr-sqrt8.6%
fabs-sqr8.6%
add-sqr-sqrt20.4%
+-commutative20.4%
hypot-1-def20.5%
metadata-eval20.5%
Applied egg-rr20.5%
+-rgt-identity20.5%
Simplified20.5%
Taylor expanded in x around 0 100.0%
if 0.00100000005 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 61.5%
+-commutative61.5%
hypot-1-def98.3%
Simplified98.3%
Final simplification99.5%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -1.0)
(copysign (- (log1p (+ -1.0 (- (hypot 1.0 x) x)))) x)
(if (<= t_0 0.00039999998989515007)
(copysign (+ x (* (pow x 3.0) -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(-log1pf((-1.0f + (hypotf(1.0f, x) - x))), x);
} else if (t_0 <= 0.00039999998989515007f) {
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) 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(-log1p(Float32(Float32(-1.0) + Float32(hypot(Float32(1.0), x) - x)))), x); elseif (t_0 <= Float32(0.00039999998989515007)) 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
\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(-\mathsf{log1p}\left(-1 + \left(\mathsf{hypot}\left(1, x\right) - x\right)\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.00039999998989515007:\\
\;\;\;\;\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 (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%
log1p-expm1-u99.9%
expm1-undefine99.9%
add-exp-log99.9%
Applied egg-rr99.9%
if -1 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 3.9999999e-4Initial program 19.8%
*-un-lft-identity19.8%
*-commutative19.8%
log-prod19.8%
*-un-lft-identity19.8%
*-un-lft-identity19.8%
add-sqr-sqrt8.1%
fabs-sqr8.1%
add-sqr-sqrt20.1%
+-commutative20.1%
hypot-1-def20.2%
metadata-eval20.2%
Applied egg-rr20.2%
+-rgt-identity20.2%
Simplified20.2%
Taylor expanded in x around 0 99.4%
distribute-lft-in99.5%
*-rgt-identity99.5%
*-commutative99.5%
associate-*r*99.5%
unpow299.5%
cube-mult99.5%
Simplified99.5%
if 3.9999999e-4 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 61.6%
*-un-lft-identity61.6%
*-commutative61.6%
log-prod61.6%
*-un-lft-identity61.6%
*-un-lft-identity61.6%
add-sqr-sqrt61.4%
fabs-sqr61.4%
add-sqr-sqrt61.6%
+-commutative61.6%
hypot-1-def97.9%
metadata-eval97.9%
Applied egg-rr97.9%
+-rgt-identity97.9%
Simplified97.9%
Final simplification99.2%
(FPCore (x)
:precision binary32
(if (<= x -100.0)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 1.999999987845058e-8)
(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((hypotf(1.0f, x) - x)), x);
} else if (x <= 1.999999987845058e-8f) {
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(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(1.999999987845058e-8)) 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((hypot(single(1.0), x) - x))); elseif (x <= single(1.999999987845058e-8)) 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(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 1.999999987845058 \cdot 10^{-8}:\\
\;\;\;\;\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 51.5%
flip-+2.8%
frac-2neg2.8%
log-div2.8%
Applied egg-rr7.1%
neg-sub07.1%
associate--r-7.1%
neg-sub07.1%
+-commutative7.1%
fma-undefine6.6%
unpow26.6%
+-commutative6.6%
associate-+l+48.1%
sub-neg48.1%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
if -100 < x < 1.99999999e-8Initial program 20.9%
*-un-lft-identity20.9%
*-commutative20.9%
log-prod20.9%
*-un-lft-identity20.9%
*-un-lft-identity20.9%
add-sqr-sqrt4.6%
fabs-sqr4.6%
add-sqr-sqrt20.5%
+-commutative20.5%
hypot-1-def20.6%
metadata-eval20.6%
Applied egg-rr20.6%
+-rgt-identity20.6%
Simplified20.6%
Taylor expanded in x around 0 96.2%
distribute-lft-in96.2%
*-rgt-identity96.2%
*-commutative96.2%
associate-*r*96.2%
unpow296.2%
cube-mult96.2%
Simplified96.2%
if 1.99999999e-8 < x Initial program 59.1%
*-un-lft-identity59.1%
*-commutative59.1%
log-prod59.1%
*-un-lft-identity59.1%
*-un-lft-identity59.1%
add-sqr-sqrt58.9%
fabs-sqr58.9%
add-sqr-sqrt59.1%
+-commutative59.1%
hypot-1-def90.2%
metadata-eval90.2%
Applied egg-rr90.2%
+-rgt-identity90.2%
Simplified90.2%
(FPCore (x)
:precision binary32
(if (<= x -100.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 2.0000000233721948e-7)
(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((x * -2.0f)), x);
} else if (x <= 2.0000000233721948e-7f) {
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(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(2.0000000233721948e-7)) 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((x * single(-2.0)))); elseif (x <= single(2.0000000233721948e-7)) 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(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 2.0000000233721948 \cdot 10^{-7}:\\
\;\;\;\;\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 51.5%
flip-+2.8%
frac-2neg2.8%
log-div2.8%
Applied egg-rr7.1%
neg-sub07.1%
associate--r-7.1%
neg-sub07.1%
+-commutative7.1%
fma-undefine6.6%
unpow26.6%
+-commutative6.6%
associate-+l+48.1%
sub-neg48.1%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.6%
*-commutative99.6%
Simplified99.6%
if -100 < x < 2.00000002e-7Initial program 20.7%
*-un-lft-identity20.7%
*-commutative20.7%
log-prod20.7%
*-un-lft-identity20.7%
*-un-lft-identity20.7%
add-sqr-sqrt4.9%
fabs-sqr4.9%
add-sqr-sqrt20.3%
+-commutative20.3%
hypot-1-def20.4%
metadata-eval20.4%
Applied egg-rr20.4%
+-rgt-identity20.4%
Simplified20.4%
Taylor expanded in x around 0 96.3%
distribute-lft-in96.3%
*-rgt-identity96.3%
*-commutative96.3%
associate-*r*96.3%
unpow296.3%
cube-mult96.3%
Simplified96.3%
if 2.00000002e-7 < x Initial program 61.5%
*-un-lft-identity61.5%
*-commutative61.5%
log-prod61.5%
*-un-lft-identity61.5%
*-un-lft-identity61.5%
add-sqr-sqrt61.3%
fabs-sqr61.3%
add-sqr-sqrt61.5%
+-commutative61.5%
hypot-1-def94.3%
metadata-eval94.3%
Applied egg-rr94.3%
+-rgt-identity94.3%
Simplified94.3%
(FPCore (x)
:precision binary32
(if (<= x -100.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 5.000000058430487e-8)
(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((x * -2.0f)), x);
} else if (x <= 5.000000058430487e-8f) {
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(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(5.000000058430487e-8)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x); else tmp = copysign(Float32(-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((x * single(-2.0)))); elseif (x <= single(5.000000058430487e-8)) 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(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 5.000000058430487 \cdot 10^{-8}:\\
\;\;\;\;\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 51.5%
flip-+2.8%
frac-2neg2.8%
log-div2.8%
Applied egg-rr7.1%
neg-sub07.1%
associate--r-7.1%
neg-sub07.1%
+-commutative7.1%
fma-undefine6.6%
unpow26.6%
+-commutative6.6%
associate-+l+48.1%
sub-neg48.1%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.6%
*-commutative99.6%
Simplified99.6%
if -100 < x < 5.00000006e-8Initial program 20.6%
*-un-lft-identity20.6%
*-commutative20.6%
log-prod20.6%
*-un-lft-identity20.6%
*-un-lft-identity20.6%
add-sqr-sqrt4.7%
fabs-sqr4.7%
add-sqr-sqrt20.2%
+-commutative20.2%
hypot-1-def20.3%
metadata-eval20.3%
Applied egg-rr20.3%
+-rgt-identity20.3%
Simplified20.3%
Taylor expanded in x around 0 96.2%
distribute-lft-in96.3%
*-rgt-identity96.3%
*-commutative96.3%
associate-*r*96.3%
unpow296.3%
cube-mult96.3%
Simplified96.3%
if 5.00000006e-8 < x Initial program 61.1%
flip-+16.0%
frac-2neg16.0%
log-div16.3%
Applied egg-rr16.3%
neg-sub016.3%
associate--r-16.3%
neg-sub016.3%
+-commutative16.3%
fma-undefine16.3%
unpow216.3%
+-commutative16.3%
associate-+l+19.0%
sub-neg19.0%
+-inverses21.3%
metadata-eval21.3%
metadata-eval21.3%
neg-sub021.3%
neg-sub021.3%
associate--r-21.3%
neg-sub021.3%
+-commutative21.3%
sub-neg21.3%
Simplified21.3%
Taylor expanded in x around inf 84.7%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 4.999999987376214e-7)
(copysign x x)
(copysign (- (log (/ 0.5 x))) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 4.999999987376214e-7f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(-logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(4.999999987376214e-7)) tmp = copysign(x, x); else tmp = copysign(Float32(-log(Float32(Float32(0.5) / x))), 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 * single(-2.0)))); elseif (x <= single(4.999999987376214e-7)) 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 -10:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 4.999999987376214 \cdot 10^{-7}:\\
\;\;\;\;\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 < -10Initial program 54.8%
flip-+8.2%
frac-2neg8.2%
log-div8.2%
Applied egg-rr13.5%
neg-sub013.5%
associate--r-13.5%
neg-sub013.5%
+-commutative13.5%
fma-undefine12.9%
unpow212.9%
+-commutative12.9%
associate-+l+51.7%
sub-neg51.7%
+-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%
Taylor expanded in x around -inf 97.7%
*-commutative97.7%
Simplified97.7%
if -10 < x < 4.99999999e-7Initial program 18.3%
add-cbrt-cube18.3%
pow1/318.3%
log-pow18.3%
pow318.3%
log-pow18.3%
*-un-lft-identity18.3%
*-un-lft-identity18.3%
Applied egg-rr18.6%
Taylor expanded in x around 0 96.5%
*-commutative96.5%
Simplified96.5%
Taylor expanded in x around 0 97.4%
if 4.99999999e-7 < x Initial program 61.8%
flip-+15.4%
frac-2neg15.4%
log-div15.7%
Applied egg-rr15.7%
neg-sub015.7%
associate--r-15.7%
neg-sub015.7%
+-commutative15.7%
fma-undefine15.7%
unpow215.7%
+-commutative15.7%
associate-+l+18.4%
sub-neg18.4%
+-inverses20.8%
metadata-eval20.8%
metadata-eval20.8%
neg-sub020.8%
neg-sub020.8%
associate--r-20.8%
neg-sub020.8%
+-commutative20.8%
sub-neg20.8%
Simplified20.8%
Taylor expanded in x around inf 86.6%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 9.999999747378752e-6)
(copysign x x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 9.999999747378752e-6f) {
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(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(9.999999747378752e-6)) 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 * single(-2.0)))); elseif (x <= single(9.999999747378752e-6)) 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 \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 9.999999747378752 \cdot 10^{-6}:\\
\;\;\;\;\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 54.8%
flip-+8.2%
frac-2neg8.2%
log-div8.2%
Applied egg-rr13.5%
neg-sub013.5%
associate--r-13.5%
neg-sub013.5%
+-commutative13.5%
fma-undefine12.9%
unpow212.9%
+-commutative12.9%
associate-+l+51.7%
sub-neg51.7%
+-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%
Taylor expanded in x around -inf 97.7%
*-commutative97.7%
Simplified97.7%
if -10 < x < 9.99999975e-6Initial program 18.8%
add-cbrt-cube18.8%
pow1/318.8%
log-pow18.7%
pow318.8%
log-pow18.8%
*-un-lft-identity18.8%
*-un-lft-identity18.8%
Applied egg-rr19.1%
Taylor expanded in x around 0 96.5%
*-commutative96.5%
Simplified96.5%
Taylor expanded in x around 0 97.4%
if 9.99999975e-6 < x Initial program 61.6%
add-cbrt-cube48.6%
pow1/348.2%
log-pow48.1%
pow348.0%
log-pow61.1%
*-un-lft-identity61.1%
*-un-lft-identity61.1%
Applied egg-rr94.6%
Taylor expanded in x around inf 85.7%
*-commutative85.7%
Simplified85.7%
associate-*r*86.3%
metadata-eval86.3%
*-un-lft-identity86.3%
*-un-lft-identity86.3%
log-prod86.3%
metadata-eval86.3%
Applied egg-rr86.3%
+-lft-identity86.3%
Simplified86.3%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 3.9999998989515007e-5)
(copysign x x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 3.9999998989515007e-5f) {
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(Float32(-0.5) / x)), x); elseif (x <= Float32(3.9999998989515007e-5)) 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((single(-0.5) / x))); elseif (x <= single(3.9999998989515007e-5)) 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(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 3.9999998989515007 \cdot 10^{-5}:\\
\;\;\;\;\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 54.8%
*-un-lft-identity54.8%
*-commutative54.8%
log-prod54.8%
*-un-lft-identity54.8%
*-un-lft-identity54.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.7%
+-commutative13.7%
hypot-1-def13.7%
metadata-eval13.7%
Applied egg-rr13.7%
+-rgt-identity13.7%
Simplified13.7%
Taylor expanded in x around -inf 97.6%
if -10 < x < 3.9999999e-5Initial program 19.1%
add-cbrt-cube19.1%
pow1/319.1%
log-pow19.0%
pow319.1%
log-pow19.1%
*-un-lft-identity19.1%
*-un-lft-identity19.1%
Applied egg-rr19.4%
Taylor expanded in x around 0 96.6%
*-commutative96.6%
Simplified96.6%
Taylor expanded in x around 0 97.4%
if 3.9999999e-5 < x Initial program 61.7%
add-cbrt-cube48.5%
pow1/348.1%
log-pow48.0%
pow347.9%
log-pow61.2%
*-un-lft-identity61.2%
*-un-lft-identity61.2%
Applied egg-rr95.2%
Taylor expanded in x around inf 86.7%
*-commutative86.7%
Simplified86.7%
associate-*r*87.4%
metadata-eval87.4%
*-un-lft-identity87.4%
*-un-lft-identity87.4%
log-prod87.4%
metadata-eval87.4%
Applied egg-rr87.4%
+-lft-identity87.4%
Simplified87.4%
(FPCore (x) :precision binary32 (if (<= x 9.999999747378752e-5) (copysign x x) (copysign (log (* x 2.0)) x)))
float code(float x) {
float tmp;
if (x <= 9.999999747378752e-5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(9.999999747378752e-5)) 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(9.999999747378752e-5)) 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 9.999999747378752 \cdot 10^{-5}:\\
\;\;\;\;\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 < 9.99999975e-5Initial program 30.6%
add-cbrt-cube27.1%
pow1/326.9%
log-pow27.0%
pow327.0%
log-pow30.5%
*-un-lft-identity30.5%
*-un-lft-identity30.5%
Applied egg-rr18.1%
Taylor expanded in x around 0 70.3%
*-commutative70.3%
Simplified70.3%
Taylor expanded in x around 0 70.9%
if 9.99999975e-5 < x Initial program 61.7%
add-cbrt-cube48.1%
pow1/347.7%
log-pow47.6%
pow347.5%
log-pow61.2%
*-un-lft-identity61.2%
*-un-lft-identity61.2%
Applied egg-rr96.1%
Taylor expanded in x around inf 88.8%
*-commutative88.8%
Simplified88.8%
associate-*r*89.4%
metadata-eval89.4%
*-un-lft-identity89.4%
*-un-lft-identity89.4%
log-prod89.4%
metadata-eval89.4%
Applied egg-rr89.4%
+-lft-identity89.4%
Simplified89.4%
(FPCore (x) :precision binary32 (if (<= x -0.009999999776482582) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -0.009999999776482582f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.009999999776482582)) tmp = copysign(x, x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.009999999776482582:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -0.00999999978Initial program 58.1%
add-cbrt-cube47.9%
pow1/347.4%
log-pow47.6%
pow347.6%
log-pow57.7%
*-un-lft-identity57.7%
*-un-lft-identity57.7%
Applied egg-rr21.0%
Taylor expanded in x around 0 15.9%
*-commutative15.9%
Simplified15.9%
Taylor expanded in x around 0 15.9%
if -0.00999999978 < x Initial program 32.6%
Taylor expanded in x around 0 26.0%
log1p-define78.3%
rem-square-sqrt47.4%
fabs-sqr47.4%
rem-square-sqrt78.3%
Simplified78.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 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))