
(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 14 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.05000000074505806)
(copysign
(+ x (* (pow x 3.0) (fma (pow x 2.0) 0.075 -0.16666666666666666)))
x)
(copysign (log1p (+ -1.0 (+ 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.05000000074505806f) {
tmp = copysignf((x + (powf(x, 3.0f) * fmaf(powf(x, 2.0f), 0.075f, -0.16666666666666666f))), x);
} else {
tmp = copysignf(log1pf((-1.0f + (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.05000000074505806)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * fma((x ^ Float32(2.0)), Float32(0.075), Float32(-0.16666666666666666)))), x); else tmp = copysign(log1p(Float32(Float32(-1.0) + 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(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot \mathsf{fma}\left({x}^{2}, 0.075, -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(-1 + \left(x + \mathsf{hypot}\left(1, x\right)\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 56.4%
flip-+6.9%
frac-2neg6.9%
log-div6.9%
pow26.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt6.9%
add-sqr-sqrt6.8%
fma-define7.0%
Applied egg-rr12.9%
neg-sub012.9%
associate--r-12.9%
neg-sub012.9%
+-commutative12.9%
fma-undefine12.2%
unpow212.2%
+-commutative12.2%
associate-+l+53.3%
sub-neg53.3%
+-inverses98.8%
metadata-eval98.8%
metadata-eval98.8%
neg-sub098.8%
neg-sub098.8%
associate--r-98.8%
neg-sub098.8%
+-commutative98.8%
sub-neg98.8%
Simplified98.8%
if -1 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.0500000007Initial program 19.7%
add-sqr-sqrt18.9%
pow218.9%
log-pow18.8%
*-un-lft-identity18.8%
*-un-lft-identity18.8%
add-sqr-sqrt9.3%
fabs-sqr9.3%
add-sqr-sqrt19.4%
+-commutative19.4%
hypot-1-def19.3%
Applied egg-rr19.3%
Taylor expanded in x around 0 99.9%
distribute-rgt-in100.0%
*-lft-identity100.0%
*-commutative100.0%
associate-*r*100.0%
unpow2100.0%
cube-mult100.0%
*-commutative100.0%
fma-neg100.0%
metadata-eval100.0%
Simplified100.0%
if 0.0500000007 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 45.7%
log1p-expm1-u45.7%
expm1-undefine45.7%
add-exp-log45.7%
add-sqr-sqrt45.7%
fabs-sqr45.7%
add-sqr-sqrt45.7%
+-commutative45.7%
hypot-1-def99.9%
Applied egg-rr99.9%
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 (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.05000000074505806)
(copysign
(*
x
(+ 1.0 (* (pow x 2.0) (- (* (pow x 2.0) 0.075) 0.16666666666666666))))
x)
(copysign (log1p (+ -1.0 (+ 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.05000000074505806f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * ((powf(x, 2.0f) * 0.075f) - 0.16666666666666666f)))), x);
} else {
tmp = copysignf(log1pf((-1.0f + (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.05000000074505806)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32((x ^ Float32(2.0)) * Float32(Float32((x ^ Float32(2.0)) * Float32(0.075)) - Float32(0.16666666666666666))))), x); else tmp = copysign(log1p(Float32(Float32(-1.0) + 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(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot \left({x}^{2} \cdot 0.075 - 0.16666666666666666\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(-1 + \left(x + \mathsf{hypot}\left(1, x\right)\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 56.4%
flip-+6.9%
frac-2neg6.9%
log-div6.9%
pow26.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt6.9%
add-sqr-sqrt6.8%
fma-define7.0%
Applied egg-rr12.9%
neg-sub012.9%
associate--r-12.9%
neg-sub012.9%
+-commutative12.9%
fma-undefine12.2%
unpow212.2%
+-commutative12.2%
associate-+l+53.3%
sub-neg53.3%
+-inverses98.8%
metadata-eval98.8%
metadata-eval98.8%
neg-sub098.8%
neg-sub098.8%
associate--r-98.8%
neg-sub098.8%
+-commutative98.8%
sub-neg98.8%
Simplified98.8%
if -1 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.0500000007Initial program 19.7%
add-sqr-sqrt18.9%
pow218.9%
log-pow18.8%
*-un-lft-identity18.8%
*-un-lft-identity18.8%
add-sqr-sqrt9.3%
fabs-sqr9.3%
add-sqr-sqrt19.4%
+-commutative19.4%
hypot-1-def19.3%
Applied egg-rr19.3%
Taylor expanded in x around 0 99.9%
if 0.0500000007 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 45.7%
log1p-expm1-u45.7%
expm1-undefine45.7%
add-exp-log45.7%
add-sqr-sqrt45.7%
fabs-sqr45.7%
add-sqr-sqrt45.7%
+-commutative45.7%
hypot-1-def99.9%
Applied egg-rr99.9%
Final simplification99.6%
(FPCore (x)
:precision binary32
(if (<= x -0.05000000074505806)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.05000000074505806)
(copysign (* x (+ 1.0 (* (pow x 2.0) -0.16666666666666666))) x)
(copysign (log1p (+ -1.0 (+ 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.05000000074505806f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * -0.16666666666666666f))), x);
} else {
tmp = copysignf(log1pf((-1.0f + (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.05000000074505806)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32((x ^ Float32(2.0)) * Float32(-0.16666666666666666)))), x); else tmp = copysign(log1p(Float32(Float32(-1.0) + Float32(x + hypot(Float32(1.0), x)))), x); end return 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.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(-1 + \left(x + \mathsf{hypot}\left(1, x\right)\right)\right), x\right)\\
\end{array}
\end{array}
if x < -0.0500000007Initial program 57.2%
flip-+9.0%
frac-2neg9.0%
log-div9.0%
pow29.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.0%
add-sqr-sqrt9.1%
fma-define9.2%
Applied egg-rr14.9%
neg-sub014.9%
associate--r-14.9%
neg-sub014.9%
+-commutative14.9%
fma-undefine14.1%
unpow214.1%
+-commutative14.1%
associate-+l+54.3%
sub-neg54.3%
+-inverses98.5%
metadata-eval98.5%
metadata-eval98.5%
neg-sub098.5%
neg-sub098.5%
associate--r-98.5%
neg-sub098.5%
+-commutative98.5%
sub-neg98.5%
Simplified98.5%
if -0.0500000007 < x < 0.0500000007Initial program 18.4%
add-sqr-sqrt17.6%
pow217.6%
log-pow17.5%
*-un-lft-identity17.5%
*-un-lft-identity17.5%
add-sqr-sqrt9.5%
fabs-sqr9.5%
add-sqr-sqrt18.1%
+-commutative18.1%
hypot-1-def18.0%
Applied egg-rr18.0%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
if 0.0500000007 < x Initial program 45.7%
log1p-expm1-u45.7%
expm1-undefine45.7%
add-exp-log45.7%
add-sqr-sqrt45.7%
fabs-sqr45.7%
add-sqr-sqrt45.7%
+-commutative45.7%
hypot-1-def99.9%
Applied egg-rr99.9%
Final simplification99.5%
(FPCore (x)
:precision binary32
(if (<= x -0.05000000074505806)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.05000000074505806)
(copysign (* x (+ 1.0 (* (pow x 2.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.05000000074505806f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.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.05000000074505806)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32((x ^ Float32(2.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.05000000074505806)) tmp = sign(x) * abs((x * (single(1.0) + ((x ^ single(2.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.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot -0.16666666666666666\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 < -0.0500000007Initial program 57.2%
flip-+9.0%
frac-2neg9.0%
log-div9.0%
pow29.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.0%
add-sqr-sqrt9.1%
fma-define9.2%
Applied egg-rr14.9%
neg-sub014.9%
associate--r-14.9%
neg-sub014.9%
+-commutative14.9%
fma-undefine14.1%
unpow214.1%
+-commutative14.1%
associate-+l+54.3%
sub-neg54.3%
+-inverses98.5%
metadata-eval98.5%
metadata-eval98.5%
neg-sub098.5%
neg-sub098.5%
associate--r-98.5%
neg-sub098.5%
+-commutative98.5%
sub-neg98.5%
Simplified98.5%
if -0.0500000007 < x < 0.0500000007Initial program 18.4%
add-sqr-sqrt17.6%
pow217.6%
log-pow17.5%
*-un-lft-identity17.5%
*-un-lft-identity17.5%
add-sqr-sqrt9.5%
fabs-sqr9.5%
add-sqr-sqrt18.1%
+-commutative18.1%
hypot-1-def18.0%
Applied egg-rr18.0%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
if 0.0500000007 < x Initial program 45.7%
*-un-lft-identity45.7%
*-commutative45.7%
log-prod45.7%
*-un-lft-identity45.7%
*-un-lft-identity45.7%
add-sqr-sqrt45.6%
fabs-sqr45.6%
add-sqr-sqrt45.7%
+-commutative45.7%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (* 2.0 (* 0.5 (log (/ -0.5 x)))) x)
(if (<= x 0.05000000074505806)
(copysign (* x (+ 1.0 (* (pow x 2.0) -0.16666666666666666))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf((2.0f * (0.5f * logf((-0.5f / x)))), x);
} else if (x <= 0.05000000074505806f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.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(-1.0)) tmp = copysign(Float32(Float32(2.0) * Float32(Float32(0.5) * log(Float32(Float32(-0.5) / x)))), x); elseif (x <= Float32(0.05000000074505806)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32((x ^ Float32(2.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(-1.0)) tmp = sign(x) * abs((single(2.0) * (single(0.5) * log((single(-0.5) / x))))); elseif (x <= single(0.05000000074505806)) tmp = sign(x) * abs((x * (single(1.0) + ((x ^ single(2.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 -1:\\
\;\;\;\;\mathsf{copysign}\left(2 \cdot \left(0.5 \cdot \log \left(\frac{-0.5}{x}\right)\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot -0.16666666666666666\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 < -1Initial program 56.4%
add-sqr-sqrt56.4%
pow256.4%
log-pow56.4%
*-un-lft-identity56.4%
*-un-lft-identity56.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.7%
+-commutative12.7%
hypot-1-def12.7%
Applied egg-rr12.7%
Taylor expanded in x around -inf 97.4%
pow1/297.4%
log-pow97.5%
Applied egg-rr97.5%
if -1 < x < 0.0500000007Initial program 19.7%
add-sqr-sqrt18.9%
pow218.9%
log-pow18.8%
*-un-lft-identity18.8%
*-un-lft-identity18.8%
add-sqr-sqrt9.3%
fabs-sqr9.3%
add-sqr-sqrt19.4%
+-commutative19.4%
hypot-1-def19.3%
Applied egg-rr19.3%
Taylor expanded in x around 0 99.8%
*-commutative99.8%
Simplified99.8%
if 0.0500000007 < x Initial program 45.7%
*-un-lft-identity45.7%
*-commutative45.7%
log-prod45.7%
*-un-lft-identity45.7%
*-un-lft-identity45.7%
add-sqr-sqrt45.6%
fabs-sqr45.6%
add-sqr-sqrt45.7%
+-commutative45.7%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (* 2.0 (* 0.5 (log (/ -0.5 x)))) x)
(if (<= x 1.0)
(copysign (* x (+ 1.0 (* (pow x 2.0) -0.16666666666666666))) x)
(copysign (- (log (/ 0.5 x))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf((2.0f * (0.5f * logf((-0.5f / x)))), x);
} else if (x <= 1.0f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * -0.16666666666666666f))), x);
} else {
tmp = copysignf(-logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(Float32(Float32(2.0) * Float32(Float32(0.5) * 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(-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(-1.0)) tmp = sign(x) * abs((single(2.0) * (single(0.5) * log((single(-0.5) / x))))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x * (single(1.0) + ((x ^ single(2.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 -1:\\
\;\;\;\;\mathsf{copysign}\left(2 \cdot \left(0.5 \cdot \log \left(\frac{-0.5}{x}\right)\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 56.4%
add-sqr-sqrt56.4%
pow256.4%
log-pow56.4%
*-un-lft-identity56.4%
*-un-lft-identity56.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.7%
+-commutative12.7%
hypot-1-def12.7%
Applied egg-rr12.7%
Taylor expanded in x around -inf 97.4%
pow1/297.4%
log-pow97.5%
Applied egg-rr97.5%
if -1 < x < 1Initial program 21.8%
add-sqr-sqrt20.9%
pow220.9%
log-pow20.8%
*-un-lft-identity20.8%
*-un-lft-identity20.8%
add-sqr-sqrt11.5%
fabs-sqr11.5%
add-sqr-sqrt21.3%
+-commutative21.3%
hypot-1-def21.3%
Applied egg-rr21.3%
Taylor expanded in x around 0 98.8%
*-commutative98.8%
Simplified98.8%
if 1 < x Initial program 43.3%
flip-+4.8%
frac-2neg4.8%
log-div4.8%
pow24.8%
add-sqr-sqrt4.6%
fabs-sqr4.6%
add-sqr-sqrt4.8%
add-sqr-sqrt4.6%
fma-define4.6%
Applied egg-rr4.6%
neg-sub04.6%
associate--r-4.6%
neg-sub04.6%
+-commutative4.6%
fma-undefine4.6%
unpow24.6%
+-commutative4.6%
associate-+l+6.8%
sub-neg6.8%
+-inverses10.7%
metadata-eval10.7%
metadata-eval10.7%
neg-sub010.7%
neg-sub010.7%
associate--r-10.7%
neg-sub010.7%
+-commutative10.7%
sub-neg10.7%
Simplified10.7%
Taylor expanded in x around inf 98.4%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (* 2.0 (* 0.5 (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 <= -1.0f) {
tmp = copysignf((2.0f * (0.5f * 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(-1.0)) tmp = copysign(Float32(Float32(2.0) * Float32(Float32(0.5) * 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(Float32(Float32(0.5) / x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.0)) tmp = sign(x) * abs((single(2.0) * (single(0.5) * 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 -1:\\
\;\;\;\;\mathsf{copysign}\left(2 \cdot \left(0.5 \cdot \log \left(\frac{-0.5}{x}\right)\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 < -1Initial program 56.4%
add-sqr-sqrt56.4%
pow256.4%
log-pow56.4%
*-un-lft-identity56.4%
*-un-lft-identity56.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.7%
+-commutative12.7%
hypot-1-def12.7%
Applied egg-rr12.7%
Taylor expanded in x around -inf 97.4%
pow1/297.4%
log-pow97.5%
Applied egg-rr97.5%
if -1 < x < 1Initial program 21.8%
add-sqr-sqrt20.9%
pow220.9%
log-pow20.8%
*-un-lft-identity20.8%
*-un-lft-identity20.8%
add-sqr-sqrt11.5%
fabs-sqr11.5%
add-sqr-sqrt21.3%
+-commutative21.3%
hypot-1-def21.3%
Applied egg-rr21.3%
Taylor expanded in x around 0 98.8%
distribute-rgt-in98.7%
*-lft-identity98.7%
*-commutative98.7%
*-commutative98.7%
associate-*r*98.7%
unpow298.7%
cube-mult98.7%
Simplified98.7%
if 1 < x Initial program 43.3%
flip-+4.8%
frac-2neg4.8%
log-div4.8%
pow24.8%
add-sqr-sqrt4.6%
fabs-sqr4.6%
add-sqr-sqrt4.8%
add-sqr-sqrt4.6%
fma-define4.6%
Applied egg-rr4.6%
neg-sub04.6%
associate--r-4.6%
neg-sub04.6%
+-commutative4.6%
fma-undefine4.6%
unpow24.6%
+-commutative4.6%
associate-+l+6.8%
sub-neg6.8%
+-inverses10.7%
metadata-eval10.7%
metadata-eval10.7%
neg-sub010.7%
neg-sub010.7%
associate--r-10.7%
neg-sub010.7%
+-commutative10.7%
sub-neg10.7%
Simplified10.7%
Taylor expanded in x around inf 98.4%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (* x -2.0))) 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 <= -1.0f) {
tmp = copysignf(-logf((x * -2.0f)), 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(-1.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(1.0)) 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(-1.0)) tmp = sign(x) * abs(-log((x * single(-2.0)))); 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 -1:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\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 < -1Initial program 56.4%
flip-+6.9%
frac-2neg6.9%
log-div6.9%
pow26.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt6.9%
add-sqr-sqrt6.8%
fma-define7.0%
Applied egg-rr12.9%
neg-sub012.9%
associate--r-12.9%
neg-sub012.9%
+-commutative12.9%
fma-undefine12.2%
unpow212.2%
+-commutative12.2%
associate-+l+53.3%
sub-neg53.3%
+-inverses98.8%
metadata-eval98.8%
metadata-eval98.8%
neg-sub098.8%
neg-sub098.8%
associate--r-98.8%
neg-sub098.8%
+-commutative98.8%
sub-neg98.8%
Simplified98.8%
Taylor expanded in x around -inf 96.2%
*-commutative96.2%
Simplified96.2%
if -1 < x < 1Initial program 21.8%
add-sqr-sqrt20.9%
pow220.9%
log-pow20.8%
*-un-lft-identity20.8%
*-un-lft-identity20.8%
add-sqr-sqrt11.5%
fabs-sqr11.5%
add-sqr-sqrt21.3%
+-commutative21.3%
hypot-1-def21.3%
Applied egg-rr21.3%
Taylor expanded in x around 0 98.8%
distribute-rgt-in98.7%
*-lft-identity98.7%
*-commutative98.7%
*-commutative98.7%
associate-*r*98.7%
unpow298.7%
cube-mult98.7%
Simplified98.7%
if 1 < x Initial program 43.3%
flip-+4.8%
frac-2neg4.8%
log-div4.8%
pow24.8%
add-sqr-sqrt4.6%
fabs-sqr4.6%
add-sqr-sqrt4.8%
add-sqr-sqrt4.6%
fma-define4.6%
Applied egg-rr4.6%
neg-sub04.6%
associate--r-4.6%
neg-sub04.6%
+-commutative4.6%
fma-undefine4.6%
unpow24.6%
+-commutative4.6%
associate-+l+6.8%
sub-neg6.8%
+-inverses10.7%
metadata-eval10.7%
metadata-eval10.7%
neg-sub010.7%
neg-sub010.7%
associate--r-10.7%
neg-sub010.7%
+-commutative10.7%
sub-neg10.7%
Simplified10.7%
Taylor expanded in x around inf 98.4%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (- (log (* x -2.0))) x) (if (<= x 1.0) (copysign x x) (copysign (- (log (/ 0.5 x))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(-logf((x * -2.0f)), 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(-1.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(1.0)) 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(-1.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((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\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(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 56.4%
flip-+6.9%
frac-2neg6.9%
log-div6.9%
pow26.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt6.9%
add-sqr-sqrt6.8%
fma-define7.0%
Applied egg-rr12.9%
neg-sub012.9%
associate--r-12.9%
neg-sub012.9%
+-commutative12.9%
fma-undefine12.2%
unpow212.2%
+-commutative12.2%
associate-+l+53.3%
sub-neg53.3%
+-inverses98.8%
metadata-eval98.8%
metadata-eval98.8%
neg-sub098.8%
neg-sub098.8%
associate--r-98.8%
neg-sub098.8%
+-commutative98.8%
sub-neg98.8%
Simplified98.8%
Taylor expanded in x around -inf 96.2%
*-commutative96.2%
Simplified96.2%
if -1 < x < 1Initial program 21.8%
add-sqr-sqrt20.9%
pow220.9%
log-pow20.8%
*-un-lft-identity20.8%
*-un-lft-identity20.8%
add-sqr-sqrt11.5%
fabs-sqr11.5%
add-sqr-sqrt21.3%
+-commutative21.3%
hypot-1-def21.3%
Applied egg-rr21.3%
Taylor expanded in x around 0 96.7%
if 1 < x Initial program 43.3%
flip-+4.8%
frac-2neg4.8%
log-div4.8%
pow24.8%
add-sqr-sqrt4.6%
fabs-sqr4.6%
add-sqr-sqrt4.8%
add-sqr-sqrt4.6%
fma-define4.6%
Applied egg-rr4.6%
neg-sub04.6%
associate--r-4.6%
neg-sub04.6%
+-commutative4.6%
fma-undefine4.6%
unpow24.6%
+-commutative4.6%
associate-+l+6.8%
sub-neg6.8%
+-inverses10.7%
metadata-eval10.7%
metadata-eval10.7%
neg-sub010.7%
neg-sub010.7%
associate--r-10.7%
neg-sub010.7%
+-commutative10.7%
sub-neg10.7%
Simplified10.7%
Taylor expanded in x around inf 98.4%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (- (log (* x -2.0))) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -1.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(-1.0)) tmp = copysign(Float32(-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 -1:\\
\;\;\;\;\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 < -1Initial program 56.4%
flip-+6.9%
frac-2neg6.9%
log-div6.9%
pow26.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt6.9%
add-sqr-sqrt6.8%
fma-define7.0%
Applied egg-rr12.9%
neg-sub012.9%
associate--r-12.9%
neg-sub012.9%
+-commutative12.9%
fma-undefine12.2%
unpow212.2%
+-commutative12.2%
associate-+l+53.3%
sub-neg53.3%
+-inverses98.8%
metadata-eval98.8%
metadata-eval98.8%
neg-sub098.8%
neg-sub098.8%
associate--r-98.8%
neg-sub098.8%
+-commutative98.8%
sub-neg98.8%
Simplified98.8%
Taylor expanded in x around -inf 96.2%
*-commutative96.2%
Simplified96.2%
if -1 < x Initial program 29.6%
Taylor expanded in x around 0 27.7%
log1p-define75.8%
rem-square-sqrt46.8%
fabs-sqr46.8%
rem-square-sqrt75.8%
Simplified75.8%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign x x) (copysign (log (+ x 1.0)) x)))
float code(float x) {
float tmp;
if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + 1.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(1.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(1.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 + 1\right), x\right)\\
\end{array}
\end{array}
if x < 1Initial program 35.4%
add-sqr-sqrt34.9%
pow234.9%
log-pow34.8%
*-un-lft-identity34.8%
*-un-lft-identity34.8%
add-sqr-sqrt7.0%
fabs-sqr7.0%
add-sqr-sqrt17.9%
+-commutative17.9%
hypot-1-def17.9%
Applied egg-rr17.9%
Taylor expanded in x around 0 63.1%
if 1 < x Initial program 43.3%
Taylor expanded in x around 0 45.1%
rem-square-sqrt45.1%
fabs-sqr45.1%
rem-square-sqrt45.1%
Simplified45.1%
Final simplification58.4%
(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 35.4%
add-sqr-sqrt34.9%
pow234.9%
log-pow34.8%
*-un-lft-identity34.8%
*-un-lft-identity34.8%
add-sqr-sqrt7.0%
fabs-sqr7.0%
add-sqr-sqrt17.9%
+-commutative17.9%
hypot-1-def17.9%
Applied egg-rr17.9%
Taylor expanded in x around 0 63.1%
if 1 < x Initial program 43.3%
Taylor expanded in x around 0 45.1%
log1p-define45.1%
rem-square-sqrt45.1%
fabs-sqr45.1%
rem-square-sqrt45.1%
Simplified45.1%
(FPCore (x) :precision binary32 (if (<= x 0.4000000059604645) (copysign x x) (copysign (log x) x)))
float code(float x) {
float tmp;
if (x <= 0.4000000059604645f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.4000000059604645)) 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(0.4000000059604645)) 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 0.4000000059604645:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\end{array}
if x < 0.400000006Initial program 35.1%
add-sqr-sqrt34.5%
pow234.5%
log-pow34.5%
*-un-lft-identity34.5%
*-un-lft-identity34.5%
add-sqr-sqrt6.5%
fabs-sqr6.5%
add-sqr-sqrt17.5%
+-commutative17.5%
hypot-1-def17.5%
Applied egg-rr17.5%
Taylor expanded in x around 0 63.2%
if 0.400000006 < x Initial program 44.1%
Taylor expanded in x around inf 45.1%
mul-1-neg45.1%
log-rec45.1%
remove-double-neg45.1%
Simplified45.1%
(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.4%
add-sqr-sqrt37.0%
pow237.0%
log-pow37.0%
*-un-lft-identity37.0%
*-un-lft-identity37.0%
add-sqr-sqrt16.3%
fabs-sqr16.3%
add-sqr-sqrt24.4%
+-commutative24.4%
hypot-1-def39.0%
Applied egg-rr39.0%
Taylor expanded in x around 0 49.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 2024086
(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))