
(FPCore (x) :precision binary32 (asinh x))
float code(float x) {
return asinhf(x);
}
function code(x) return asinh(x) end
function tmp = code(x) tmp = asinh(x); end
\begin{array}{l}
\\
\sinh^{-1} x
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary32 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
float code(float x) {
return copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
}
function code(x) return copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) end
function tmp = code(x) tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); end
\begin{array}{l}
\\
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\end{array}
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.20000000298023224)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.05000000074505806)
(copysign
(+ x (* (fma (pow x 2.0) 0.075 -0.16666666666666666) (pow x 3.0)))
x)
(copysign (* 2.0 (log (sqrt (+ 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.20000000298023224f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.05000000074505806f) {
tmp = copysignf((x + (fmaf(powf(x, 2.0f), 0.075f, -0.16666666666666666f) * powf(x, 3.0f))), x);
} else {
tmp = copysignf((2.0f * logf(sqrtf((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.20000000298023224)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.05000000074505806)) tmp = copysign(Float32(x + Float32(fma((x ^ Float32(2.0)), Float32(0.075), Float32(-0.16666666666666666)) * (x ^ Float32(3.0)))), x); else tmp = copysign(Float32(Float32(2.0) * log(sqrt(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 -0.20000000298023224:\\
\;\;\;\;\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 + \mathsf{fma}\left({x}^{2}, 0.075, -0.16666666666666666\right) \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(2 \cdot \log \left(\sqrt{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) < -0.200000003Initial program 58.4%
flip-+7.3%
frac-2neg7.3%
log-div7.3%
add-sqr-sqrt7.3%
pow27.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt7.3%
fma-define7.3%
Applied egg-rr13.9%
fma-undefine13.9%
unpow213.9%
associate--r+55.5%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
Simplified100.0%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.0500000007Initial program 19.7%
expm1-log1p-u19.7%
expm1-undefine19.1%
*-un-lft-identity19.1%
*-un-lft-identity19.1%
+-commutative19.1%
hypot-1-def19.1%
add-sqr-sqrt9.9%
fabs-sqr9.9%
add-sqr-sqrt19.4%
Applied egg-rr19.4%
expm1-define19.7%
Simplified19.7%
Taylor expanded in x around 0 99.9%
distribute-rgt-in100.0%
*-lft-identity100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
fma-neg100.0%
metadata-eval100.0%
unpow2100.0%
unpow3100.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 50.3%
add-sqr-sqrt50.3%
pow250.3%
log-pow50.3%
*-un-lft-identity50.3%
*-un-lft-identity50.3%
add-sqr-sqrt50.3%
fabs-sqr50.3%
add-sqr-sqrt50.3%
+-commutative50.3%
hypot-1-def100.0%
Applied egg-rr100.0%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.20000000298023224)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.05000000074505806)
(copysign
(*
x
(+ (* (pow x 2.0) (- (* (pow x 2.0) 0.075) 0.16666666666666666)) 1.0))
x)
(copysign (* 2.0 (log (sqrt (+ 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.20000000298023224f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.05000000074505806f) {
tmp = copysignf((x * ((powf(x, 2.0f) * ((powf(x, 2.0f) * 0.075f) - 0.16666666666666666f)) + 1.0f)), x);
} else {
tmp = copysignf((2.0f * logf(sqrtf((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.20000000298023224)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.05000000074505806)) tmp = copysign(Float32(x * Float32(Float32((x ^ Float32(2.0)) * Float32(Float32((x ^ Float32(2.0)) * Float32(0.075)) - Float32(0.16666666666666666))) + Float32(1.0))), x); else tmp = copysign(Float32(Float32(2.0) * log(sqrt(Float32(x + hypot(Float32(1.0), x))))), x); end return tmp end
function tmp_2 = code(x) t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); tmp = single(0.0); if (t_0 <= single(-0.20000000298023224)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.05000000074505806)) tmp = sign(x) * abs((x * (((x ^ single(2.0)) * (((x ^ single(2.0)) * single(0.075)) - single(0.16666666666666666))) + single(1.0)))); else tmp = sign(x) * abs((single(2.0) * log(sqrt((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.20000000298023224:\\
\;\;\;\;\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({x}^{2} \cdot \left({x}^{2} \cdot 0.075 - 0.16666666666666666\right) + 1\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(2 \cdot \log \left(\sqrt{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) < -0.200000003Initial program 58.4%
flip-+7.3%
frac-2neg7.3%
log-div7.3%
add-sqr-sqrt7.3%
pow27.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt7.3%
fma-define7.3%
Applied egg-rr13.9%
fma-undefine13.9%
unpow213.9%
associate--r+55.5%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
Simplified100.0%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.0500000007Initial program 19.7%
expm1-log1p-u19.7%
expm1-undefine19.1%
*-un-lft-identity19.1%
*-un-lft-identity19.1%
+-commutative19.1%
hypot-1-def19.1%
add-sqr-sqrt9.9%
fabs-sqr9.9%
add-sqr-sqrt19.4%
Applied egg-rr19.4%
expm1-define19.7%
Simplified19.7%
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 50.3%
add-sqr-sqrt50.3%
pow250.3%
log-pow50.3%
*-un-lft-identity50.3%
*-un-lft-identity50.3%
add-sqr-sqrt50.3%
fabs-sqr50.3%
add-sqr-sqrt50.3%
+-commutative50.3%
hypot-1-def100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x)
:precision binary32
(if (<= x -0.4000000059604645)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.05000000074505806)
(copysign
(*
x
(+ (* (pow x 2.0) (- (* (pow x 2.0) 0.075) 0.16666666666666666)) 1.0))
x)
(copysign (log (+ (fabs x) (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -0.4000000059604645f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.05000000074505806f) {
tmp = copysignf((x * ((powf(x, 2.0f) * ((powf(x, 2.0f) * 0.075f) - 0.16666666666666666f)) + 1.0f)), x);
} else {
tmp = copysignf(logf((fabsf(x) + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.4000000059604645)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.05000000074505806)) tmp = copysign(Float32(x * Float32(Float32((x ^ Float32(2.0)) * Float32(Float32((x ^ Float32(2.0)) * Float32(0.075)) - Float32(0.16666666666666666))) + Float32(1.0))), x); else tmp = copysign(log(Float32(abs(x) + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-0.4000000059604645)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (x <= single(0.05000000074505806)) tmp = sign(x) * abs((x * (((x ^ single(2.0)) * (((x ^ single(2.0)) * single(0.075)) - single(0.16666666666666666))) + single(1.0)))); else tmp = sign(x) * abs(log((abs(x) + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.4000000059604645:\\
\;\;\;\;\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({x}^{2} \cdot \left({x}^{2} \cdot 0.075 - 0.16666666666666666\right) + 1\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 x < -0.400000006Initial program 58.4%
flip-+7.3%
frac-2neg7.3%
log-div7.3%
add-sqr-sqrt7.3%
pow27.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt7.3%
fma-define7.3%
Applied egg-rr13.9%
fma-undefine13.9%
unpow213.9%
associate--r+55.5%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
Simplified100.0%
if -0.400000006 < x < 0.0500000007Initial program 19.7%
expm1-log1p-u19.7%
expm1-undefine19.1%
*-un-lft-identity19.1%
*-un-lft-identity19.1%
+-commutative19.1%
hypot-1-def19.1%
add-sqr-sqrt9.9%
fabs-sqr9.9%
add-sqr-sqrt19.4%
Applied egg-rr19.4%
expm1-define19.7%
Simplified19.7%
Taylor expanded in x around 0 99.9%
if 0.0500000007 < x Initial program 50.3%
+-commutative50.3%
hypot-1-def100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x)
:precision binary32
(if (<= x -0.4000000059604645)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.05000000074505806)
(copysign
(*
x
(+ (* (pow x 2.0) (- (* (pow x 2.0) 0.075) 0.16666666666666666)) 1.0))
x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -0.4000000059604645f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.05000000074505806f) {
tmp = copysignf((x * ((powf(x, 2.0f) * ((powf(x, 2.0f) * 0.075f) - 0.16666666666666666f)) + 1.0f)), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.4000000059604645)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.05000000074505806)) tmp = copysign(Float32(x * Float32(Float32((x ^ Float32(2.0)) * Float32(Float32((x ^ Float32(2.0)) * Float32(0.075)) - Float32(0.16666666666666666))) + Float32(1.0))), 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.4000000059604645)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (x <= single(0.05000000074505806)) tmp = sign(x) * abs((x * (((x ^ single(2.0)) * (((x ^ single(2.0)) * single(0.075)) - single(0.16666666666666666))) + single(1.0)))); 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.4000000059604645:\\
\;\;\;\;\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({x}^{2} \cdot \left({x}^{2} \cdot 0.075 - 0.16666666666666666\right) + 1\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.400000006Initial program 58.4%
flip-+7.3%
frac-2neg7.3%
log-div7.3%
add-sqr-sqrt7.3%
pow27.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt7.3%
fma-define7.3%
Applied egg-rr13.9%
fma-undefine13.9%
unpow213.9%
associate--r+55.5%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
Simplified100.0%
if -0.400000006 < x < 0.0500000007Initial program 19.7%
expm1-log1p-u19.7%
expm1-undefine19.1%
*-un-lft-identity19.1%
*-un-lft-identity19.1%
+-commutative19.1%
hypot-1-def19.1%
add-sqr-sqrt9.9%
fabs-sqr9.9%
add-sqr-sqrt19.4%
Applied egg-rr19.4%
expm1-define19.7%
Simplified19.7%
Taylor expanded in x around 0 99.9%
if 0.0500000007 < x Initial program 50.3%
expm1-log1p-u50.2%
expm1-undefine50.2%
*-un-lft-identity50.2%
*-un-lft-identity50.2%
+-commutative50.2%
hypot-1-def99.9%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
expm1-define99.9%
Simplified99.9%
expm1-log1p-u100.0%
+-commutative100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x)
:precision binary32
(if (<= x -0.05000000074505806)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.05000000074505806)
(copysign (* x (+ (* (pow x 2.0) -0.16666666666666666) 1.0)) 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 * ((powf(x, 2.0f) * -0.16666666666666666f) + 1.0f)), 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((x ^ Float32(2.0)) * Float32(-0.16666666666666666)) + Float32(1.0))), 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 * (((x ^ single(2.0)) * single(-0.16666666666666666)) + single(1.0)))); 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({x}^{2} \cdot -0.16666666666666666 + 1\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 58.8%
flip-+8.5%
frac-2neg8.5%
log-div8.5%
add-sqr-sqrt8.4%
pow28.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.4%
fma-define8.4%
Applied egg-rr14.9%
fma-undefine14.9%
unpow214.9%
associate--r+56.0%
+-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
neg-sub099.8%
associate--r-99.8%
neg-sub099.8%
+-commutative99.8%
sub-neg99.8%
neg-sub099.8%
Simplified99.8%
if -0.0500000007 < x < 0.0500000007Initial program 19.1%
expm1-log1p-u19.1%
expm1-undefine18.5%
*-un-lft-identity18.5%
*-un-lft-identity18.5%
+-commutative18.5%
hypot-1-def18.5%
add-sqr-sqrt9.9%
fabs-sqr9.9%
add-sqr-sqrt18.8%
Applied egg-rr18.8%
expm1-define19.1%
Simplified19.1%
Taylor expanded in x around 0 99.9%
*-commutative99.9%
Simplified99.9%
if 0.0500000007 < x Initial program 50.3%
expm1-log1p-u50.2%
expm1-undefine50.2%
*-un-lft-identity50.2%
*-un-lft-identity50.2%
+-commutative50.2%
hypot-1-def99.9%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
expm1-define99.9%
Simplified99.9%
expm1-log1p-u100.0%
+-commutative100.0%
Applied egg-rr100.0%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.05000000074505806)
(copysign (* x (+ (* (pow x 2.0) -0.16666666666666666) 1.0)) 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.05000000074505806f) {
tmp = copysignf((x * ((powf(x, 2.0f) * -0.16666666666666666f) + 1.0f)), 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.05000000074505806)) tmp = copysign(Float32(x * Float32(Float32((x ^ Float32(2.0)) * Float32(-0.16666666666666666)) + Float32(1.0))), 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.05000000074505806)) tmp = sign(x) * abs((x * (((x ^ single(2.0)) * single(-0.16666666666666666)) + single(1.0)))); 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.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left({x}^{2} \cdot -0.16666666666666666 + 1\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 57.8%
Taylor expanded in x around -inf 99.2%
mul-1-neg99.2%
distribute-rgt-neg-in99.2%
mul-1-neg99.2%
unsub-neg99.2%
sub-neg99.2%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt11.4%
associate-*r/11.4%
metadata-eval11.4%
distribute-neg-frac11.4%
metadata-eval11.4%
Simplified11.4%
Taylor expanded in x around 0 98.0%
if -2 < x < 0.0500000007Initial program 20.3%
expm1-log1p-u20.3%
expm1-undefine19.7%
*-un-lft-identity19.7%
*-un-lft-identity19.7%
+-commutative19.7%
hypot-1-def19.7%
add-sqr-sqrt9.8%
fabs-sqr9.8%
add-sqr-sqrt20.0%
Applied egg-rr20.0%
expm1-define20.4%
Simplified20.4%
Taylor expanded in x around 0 99.4%
*-commutative99.4%
Simplified99.4%
if 0.0500000007 < x Initial program 50.3%
expm1-log1p-u50.2%
expm1-undefine50.2%
*-un-lft-identity50.2%
*-un-lft-identity50.2%
+-commutative50.2%
hypot-1-def99.9%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
expm1-define99.9%
Simplified99.9%
expm1-log1p-u100.0%
+-commutative100.0%
Applied egg-rr100.0%
Final simplification99.2%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.05000000074505806)
(copysign (* x (+ (* (pow x 2.0) -0.16666666666666666) 1.0)) x)
(copysign (log (+ x (fabs x))) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.05000000074505806f) {
tmp = copysignf((x * ((powf(x, 2.0f) * -0.16666666666666666f) + 1.0f)), x);
} else {
tmp = copysignf(logf((x + fabsf(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.05000000074505806)) tmp = copysign(Float32(x * Float32(Float32((x ^ Float32(2.0)) * Float32(-0.16666666666666666)) + Float32(1.0))), x); else tmp = copysign(log(Float32(x + abs(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.05000000074505806)) tmp = sign(x) * abs((x * (((x ^ single(2.0)) * single(-0.16666666666666666)) + single(1.0)))); else tmp = sign(x) * abs(log((x + abs(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.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left({x}^{2} \cdot -0.16666666666666666 + 1\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \left|x\right|\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 57.8%
Taylor expanded in x around -inf 99.2%
mul-1-neg99.2%
distribute-rgt-neg-in99.2%
mul-1-neg99.2%
unsub-neg99.2%
sub-neg99.2%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt11.4%
associate-*r/11.4%
metadata-eval11.4%
distribute-neg-frac11.4%
metadata-eval11.4%
Simplified11.4%
Taylor expanded in x around 0 98.0%
if -2 < x < 0.0500000007Initial program 20.3%
expm1-log1p-u20.3%
expm1-undefine19.7%
*-un-lft-identity19.7%
*-un-lft-identity19.7%
+-commutative19.7%
hypot-1-def19.7%
add-sqr-sqrt9.8%
fabs-sqr9.8%
add-sqr-sqrt20.0%
Applied egg-rr20.0%
expm1-define20.4%
Simplified20.4%
Taylor expanded in x around 0 99.4%
*-commutative99.4%
Simplified99.4%
if 0.0500000007 < x Initial program 50.3%
Taylor expanded in x around inf 97.3%
Final simplification98.5%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.05000000074505806)
(copysign (* x (+ (* (pow x 2.0) -0.16666666666666666) 1.0)) 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 <= 0.05000000074505806f) {
tmp = copysignf((x * ((powf(x, 2.0f) * -0.16666666666666666f) + 1.0f)), 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(0.05000000074505806)) tmp = copysign(Float32(x * Float32(Float32((x ^ Float32(2.0)) * Float32(-0.16666666666666666)) + Float32(1.0))), 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(0.05000000074505806)) tmp = sign(x) * abs((x * (((x ^ single(2.0)) * single(-0.16666666666666666)) + single(1.0)))); 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 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left({x}^{2} \cdot -0.16666666666666666 + 1\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 57.8%
Taylor expanded in x around -inf 99.2%
mul-1-neg99.2%
distribute-rgt-neg-in99.2%
mul-1-neg99.2%
unsub-neg99.2%
sub-neg99.2%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt11.4%
associate-*r/11.4%
metadata-eval11.4%
distribute-neg-frac11.4%
metadata-eval11.4%
Simplified11.4%
Taylor expanded in x around 0 98.0%
if -2 < x < 0.0500000007Initial program 20.3%
expm1-log1p-u20.3%
expm1-undefine19.7%
*-un-lft-identity19.7%
*-un-lft-identity19.7%
+-commutative19.7%
hypot-1-def19.7%
add-sqr-sqrt9.8%
fabs-sqr9.8%
add-sqr-sqrt20.0%
Applied egg-rr20.0%
expm1-define20.4%
Simplified20.4%
Taylor expanded in x around 0 99.4%
*-commutative99.4%
Simplified99.4%
if 0.0500000007 < x Initial program 50.3%
expm1-log1p-u50.2%
expm1-undefine50.2%
*-un-lft-identity50.2%
*-un-lft-identity50.2%
+-commutative50.2%
hypot-1-def99.9%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
expm1-define99.9%
Simplified99.9%
Taylor expanded in x around inf 97.3%
*-commutative97.3%
Simplified97.3%
Final simplification98.5%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.05000000074505806)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) 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 <= 0.05000000074505806f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), 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(0.05000000074505806)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), 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(0.05000000074505806)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); 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 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 57.8%
Taylor expanded in x around -inf 99.2%
mul-1-neg99.2%
distribute-rgt-neg-in99.2%
mul-1-neg99.2%
unsub-neg99.2%
sub-neg99.2%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt11.4%
associate-*r/11.4%
metadata-eval11.4%
distribute-neg-frac11.4%
metadata-eval11.4%
Simplified11.4%
Taylor expanded in x around 0 98.0%
if -2 < x < 0.0500000007Initial program 20.3%
expm1-log1p-u20.3%
expm1-undefine19.7%
*-un-lft-identity19.7%
*-un-lft-identity19.7%
+-commutative19.7%
hypot-1-def19.7%
add-sqr-sqrt9.8%
fabs-sqr9.8%
add-sqr-sqrt20.0%
Applied egg-rr20.0%
expm1-define20.4%
Simplified20.4%
Taylor expanded in x around 0 99.4%
distribute-rgt-in99.4%
*-lft-identity99.4%
associate-*l*99.4%
unpow299.4%
unpow399.4%
Simplified99.4%
if 0.0500000007 < x Initial program 50.3%
expm1-log1p-u50.2%
expm1-undefine50.2%
*-un-lft-identity50.2%
*-un-lft-identity50.2%
+-commutative50.2%
hypot-1-def99.9%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
expm1-define99.9%
Simplified99.9%
Taylor expanded in x around inf 97.3%
*-commutative97.3%
Simplified97.3%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.05000000074505806)
(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 <= 0.05000000074505806f) {
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(0.05000000074505806)) 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(0.05000000074505806)) 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 0.05000000074505806:\\
\;\;\;\;\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 57.8%
Taylor expanded in x around -inf 99.2%
mul-1-neg99.2%
distribute-rgt-neg-in99.2%
mul-1-neg99.2%
unsub-neg99.2%
sub-neg99.2%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt11.4%
associate-*r/11.4%
metadata-eval11.4%
distribute-neg-frac11.4%
metadata-eval11.4%
Simplified11.4%
Taylor expanded in x around 0 98.0%
if -2 < x < 0.0500000007Initial program 20.3%
flip-+20.3%
frac-2neg20.3%
log-div20.6%
add-sqr-sqrt20.6%
pow220.6%
add-sqr-sqrt10.3%
fabs-sqr10.3%
add-sqr-sqrt20.6%
fma-define20.6%
Applied egg-rr20.6%
fma-undefine20.6%
unpow220.6%
associate--r+20.6%
+-inverses20.6%
metadata-eval20.6%
metadata-eval20.6%
metadata-eval20.6%
neg-sub020.6%
associate--r-20.6%
neg-sub020.6%
+-commutative20.6%
sub-neg20.6%
neg-sub020.6%
Simplified20.6%
Taylor expanded in x around 0 98.1%
neg-mul-198.1%
Simplified98.1%
if 0.0500000007 < x Initial program 50.3%
expm1-log1p-u50.2%
expm1-undefine50.2%
*-un-lft-identity50.2%
*-un-lft-identity50.2%
+-commutative50.2%
hypot-1-def99.9%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
expm1-define99.9%
Simplified99.9%
Taylor expanded in x around inf 97.3%
*-commutative97.3%
Simplified97.3%
Final simplification97.9%
(FPCore (x) :precision binary32 (if (<= x 0.05000000074505806) (copysign x x) (copysign (log (* x 2.0)) x)))
float code(float x) {
float tmp;
if (x <= 0.05000000074505806f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.05000000074505806)) 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(0.05000000074505806)) 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 0.05000000074505806:\\
\;\;\;\;\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 < 0.0500000007Initial program 34.2%
expm1-log1p-u34.1%
expm1-undefine33.7%
*-un-lft-identity33.7%
*-un-lft-identity33.7%
+-commutative33.7%
hypot-1-def49.3%
add-sqr-sqrt6.2%
fabs-sqr6.2%
add-sqr-sqrt17.2%
Applied egg-rr17.2%
expm1-define17.4%
Simplified17.4%
Taylor expanded in x around 0 65.7%
distribute-rgt-in65.7%
*-lft-identity65.7%
associate-*l*65.7%
unpow265.7%
unpow365.7%
Simplified65.7%
Taylor expanded in x around 0 66.1%
if 0.0500000007 < x Initial program 50.3%
expm1-log1p-u50.2%
expm1-undefine50.2%
*-un-lft-identity50.2%
*-un-lft-identity50.2%
+-commutative50.2%
hypot-1-def99.9%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
expm1-define99.9%
Simplified99.9%
Taylor expanded in x around inf 97.3%
*-commutative97.3%
Simplified97.3%
(FPCore (x) :precision binary32 (if (<= x 0.05000000074505806) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 0.05000000074505806f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.05000000074505806)) 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.05000000074505806:\\
\;\;\;\;\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.0500000007Initial program 34.2%
expm1-log1p-u34.1%
expm1-undefine33.7%
*-un-lft-identity33.7%
*-un-lft-identity33.7%
+-commutative33.7%
hypot-1-def49.3%
add-sqr-sqrt6.2%
fabs-sqr6.2%
add-sqr-sqrt17.2%
Applied egg-rr17.2%
expm1-define17.4%
Simplified17.4%
Taylor expanded in x around 0 65.7%
distribute-rgt-in65.7%
*-lft-identity65.7%
associate-*l*65.7%
unpow265.7%
unpow365.7%
Simplified65.7%
Taylor expanded in x around 0 66.1%
if 0.0500000007 < x Initial program 50.3%
Taylor expanded in x around 0 44.2%
log1p-define44.2%
rem-square-sqrt44.2%
fabs-sqr44.2%
rem-square-sqrt44.2%
Simplified44.2%
(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 38.2%
expm1-log1p-u38.1%
expm1-undefine37.9%
*-un-lft-identity37.9%
*-un-lft-identity37.9%
+-commutative37.9%
hypot-1-def62.0%
add-sqr-sqrt29.6%
fabs-sqr29.6%
add-sqr-sqrt37.9%
Applied egg-rr37.9%
expm1-define38.0%
Simplified38.0%
Taylor expanded in x around 0 51.3%
distribute-rgt-in51.3%
*-lft-identity51.3%
associate-*l*51.3%
unpow251.3%
unpow351.3%
Simplified51.3%
Taylor expanded in x around 0 52.4%
(FPCore (x) :precision binary32 (let* ((t_0 (/ 1.0 (fabs x)))) (copysign (log1p (+ (fabs x) (/ (fabs x) (+ (hypot 1.0 t_0) t_0)))) x)))
float code(float x) {
float t_0 = 1.0f / fabsf(x);
return copysignf(log1pf((fabsf(x) + (fabsf(x) / (hypotf(1.0f, t_0) + t_0)))), x);
}
function code(x) t_0 = Float32(Float32(1.0) / abs(x)) return copysign(log1p(Float32(abs(x) + Float32(abs(x) / Float32(hypot(Float32(1.0), t_0) + t_0)))), x) end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\left|x\right|}\\
\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right| + \frac{\left|x\right|}{\mathsf{hypot}\left(1, t\_0\right) + t\_0}\right), x\right)
\end{array}
\end{array}
herbie shell --seed 2024103
(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))