
(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 -0.5)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.20000000298023224)
(copysign
(*
x
(+
1.0
(*
(pow x 2.0)
(-
(* (pow x 2.0) (+ 0.075 (* (pow x 2.0) -0.044642857142857144)))
0.16666666666666666))))
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.5f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.20000000298023224f) {
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((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.5)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.20000000298023224)) 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(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.5)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.20000000298023224)) tmp = sign(x) * abs((x * (single(1.0) + ((x ^ single(2.0)) * (((x ^ single(2.0)) * (single(0.075) + ((x ^ single(2.0)) * single(-0.044642857142857144)))) - single(0.16666666666666666)))))); else tmp = sign(x) * abs((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.5:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.20000000298023224:\\
\;\;\;\;\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(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.5Initial program 38.7%
flip-+9.4%
frac-2neg9.4%
log-div9.4%
Applied egg-rr14.4%
neg-sub014.4%
associate--r-14.4%
neg-sub014.4%
+-commutative14.4%
fma-undefine14.4%
unpow214.4%
+-commutative14.4%
associate-+l+34.4%
sub-neg34.4%
+-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.5 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.200000003Initial program 22.2%
*-un-lft-identity22.2%
*-commutative22.2%
log-prod22.2%
+-commutative22.2%
hypot-1-def22.4%
add-sqr-sqrt12.2%
fabs-sqr12.2%
add-sqr-sqrt22.8%
metadata-eval22.8%
Applied egg-rr22.8%
+-rgt-identity22.8%
Simplified22.8%
Taylor expanded in x around 0 99.9%
if 0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 62.8%
add-sqr-sqrt62.7%
pow262.7%
log-pow62.8%
+-commutative62.8%
hypot-1-def98.6%
add-sqr-sqrt98.6%
fabs-sqr98.6%
add-sqr-sqrt98.6%
Applied egg-rr98.6%
Final simplification99.2%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.10000000149011612)
(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 (* 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.10000000149011612f) {
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((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.10000000149011612)) 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(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.10000000149011612)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.05000000074505806)) tmp = sign(x) * abs((x * (single(1.0) + ((x ^ single(2.0)) * (((x ^ single(2.0)) * single(0.075)) - single(0.16666666666666666)))))); else tmp = sign(x) * abs((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.10000000149011612:\\
\;\;\;\;\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(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.100000001Initial program 39.6%
flip-+10.7%
frac-2neg10.7%
log-div10.7%
Applied egg-rr15.8%
neg-sub015.8%
associate--r-15.8%
neg-sub015.8%
+-commutative15.8%
fma-undefine15.8%
unpow215.8%
+-commutative15.8%
associate-+l+35.4%
sub-neg35.4%
+-inverses98.4%
metadata-eval98.4%
metadata-eval98.4%
neg-sub098.4%
neg-sub098.4%
associate--r-98.4%
neg-sub098.4%
+-commutative98.4%
sub-neg98.4%
Simplified98.4%
if -0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.0500000007Initial program 21.0%
*-un-lft-identity21.0%
*-commutative21.0%
log-prod21.0%
+-commutative21.0%
hypot-1-def21.2%
add-sqr-sqrt11.6%
fabs-sqr11.6%
add-sqr-sqrt21.6%
metadata-eval21.6%
Applied egg-rr21.6%
+-rgt-identity21.6%
Simplified21.6%
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 63.2%
add-sqr-sqrt63.2%
pow263.2%
log-pow63.2%
+-commutative63.2%
hypot-1-def98.6%
add-sqr-sqrt98.6%
fabs-sqr98.6%
add-sqr-sqrt98.6%
Applied egg-rr98.6%
Final simplification99.2%
(FPCore (x)
:precision binary32
(if (<= x -0.10000000149011612)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.05000000074505806)
(copysign
(*
x
(+ 1.0 (* (pow x 2.0) (- (* (pow x 2.0) 0.075) 0.16666666666666666))))
x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -0.10000000149011612f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.05000000074505806f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * ((powf(x, 2.0f) * 0.075f) - 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.10000000149011612)) 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(Float32((x ^ Float32(2.0)) * Float32(0.075)) - 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.10000000149011612)) 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)) * (((x ^ single(2.0)) * single(0.075)) - 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.10000000149011612:\\
\;\;\;\;\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 \left({x}^{2} \cdot 0.075 - 0.16666666666666666\right)\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.100000001Initial program 39.6%
flip-+10.7%
frac-2neg10.7%
log-div10.7%
Applied egg-rr15.8%
neg-sub015.8%
associate--r-15.8%
neg-sub015.8%
+-commutative15.8%
fma-undefine15.8%
unpow215.8%
+-commutative15.8%
associate-+l+35.4%
sub-neg35.4%
+-inverses98.4%
metadata-eval98.4%
metadata-eval98.4%
neg-sub098.4%
neg-sub098.4%
associate--r-98.4%
neg-sub098.4%
+-commutative98.4%
sub-neg98.4%
Simplified98.4%
if -0.100000001 < x < 0.0500000007Initial program 21.0%
*-un-lft-identity21.0%
*-commutative21.0%
log-prod21.0%
+-commutative21.0%
hypot-1-def21.2%
add-sqr-sqrt11.6%
fabs-sqr11.6%
add-sqr-sqrt21.6%
metadata-eval21.6%
Applied egg-rr21.6%
+-rgt-identity21.6%
Simplified21.6%
Taylor expanded in x around 0 99.9%
if 0.0500000007 < x Initial program 63.2%
*-un-lft-identity63.2%
*-commutative63.2%
log-prod63.2%
+-commutative63.2%
hypot-1-def98.6%
add-sqr-sqrt98.6%
fabs-sqr98.6%
add-sqr-sqrt98.6%
metadata-eval98.6%
Applied egg-rr98.6%
+-rgt-identity98.6%
Simplified98.6%
Final simplification99.2%
(FPCore (x)
:precision binary32
(if (<= x -1.2000000476837158)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.05000000074505806)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -1.2000000476837158f) {
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 + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.2000000476837158)) 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 + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.2000000476837158)) 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 + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2000000476837158:\\
\;\;\;\;\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 + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -1.20000005Initial program 37.6%
*-un-lft-identity37.6%
*-commutative37.6%
log-prod37.6%
+-commutative37.6%
hypot-1-def98.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.2%
metadata-eval13.2%
Applied egg-rr13.2%
+-rgt-identity13.2%
Simplified13.2%
Taylor expanded in x around -inf 98.0%
if -1.20000005 < x < 0.0500000007Initial program 22.3%
*-un-lft-identity22.3%
*-commutative22.3%
log-prod22.3%
+-commutative22.3%
hypot-1-def22.4%
add-sqr-sqrt11.4%
fabs-sqr11.4%
add-sqr-sqrt22.8%
metadata-eval22.8%
Applied egg-rr22.8%
+-rgt-identity22.8%
Simplified22.8%
Taylor expanded in x around 0 99.1%
distribute-rgt-in99.2%
*-lft-identity99.2%
associate-*l*99.2%
unpow299.2%
unpow399.2%
Simplified99.2%
if 0.0500000007 < x Initial program 63.2%
*-un-lft-identity63.2%
*-commutative63.2%
log-prod63.2%
+-commutative63.2%
hypot-1-def98.6%
add-sqr-sqrt98.6%
fabs-sqr98.6%
add-sqr-sqrt98.6%
metadata-eval98.6%
Applied egg-rr98.6%
+-rgt-identity98.6%
Simplified98.6%
Final simplification98.7%
(FPCore (x)
:precision binary32
(if (<= x -0.10000000149011612)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.05000000074505806)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -0.10000000149011612f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.05000000074505806f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.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.10000000149011612)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - 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 + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-0.10000000149011612)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - 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 + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.10000000149011612:\\
\;\;\;\;\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 + -0.16666666666666666 \cdot {x}^{3}, 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.100000001Initial program 39.6%
flip-+10.7%
frac-2neg10.7%
log-div10.7%
Applied egg-rr15.8%
neg-sub015.8%
associate--r-15.8%
neg-sub015.8%
+-commutative15.8%
fma-undefine15.8%
unpow215.8%
+-commutative15.8%
associate-+l+35.4%
sub-neg35.4%
+-inverses98.4%
metadata-eval98.4%
metadata-eval98.4%
neg-sub098.4%
neg-sub098.4%
associate--r-98.4%
neg-sub098.4%
+-commutative98.4%
sub-neg98.4%
Simplified98.4%
if -0.100000001 < x < 0.0500000007Initial program 21.0%
*-un-lft-identity21.0%
*-commutative21.0%
log-prod21.0%
+-commutative21.0%
hypot-1-def21.2%
add-sqr-sqrt11.6%
fabs-sqr11.6%
add-sqr-sqrt21.6%
metadata-eval21.6%
Applied egg-rr21.6%
+-rgt-identity21.6%
Simplified21.6%
Taylor expanded in x around 0 99.8%
distribute-rgt-in99.9%
*-lft-identity99.9%
associate-*l*99.9%
unpow299.9%
unpow399.9%
Simplified99.9%
if 0.0500000007 < x Initial program 63.2%
*-un-lft-identity63.2%
*-commutative63.2%
log-prod63.2%
+-commutative63.2%
hypot-1-def98.6%
add-sqr-sqrt98.6%
fabs-sqr98.6%
add-sqr-sqrt98.6%
metadata-eval98.6%
Applied egg-rr98.6%
+-rgt-identity98.6%
Simplified98.6%
Final simplification99.2%
(FPCore (x)
:precision binary32
(if (<= x -1.2000000476837158)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.5)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (+ (log x) (log 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -1.2000000476837158f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.5f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf((logf(x) + logf(2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.2000000476837158)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.5)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(Float32(log(x) + log(Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.2000000476837158)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.5)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs((log(x) + log(single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2000000476837158:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x + \log 2, x\right)\\
\end{array}
\end{array}
if x < -1.20000005Initial program 37.6%
*-un-lft-identity37.6%
*-commutative37.6%
log-prod37.6%
+-commutative37.6%
hypot-1-def98.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.2%
metadata-eval13.2%
Applied egg-rr13.2%
+-rgt-identity13.2%
Simplified13.2%
Taylor expanded in x around -inf 98.0%
if -1.20000005 < x < 0.5Initial program 23.5%
*-un-lft-identity23.5%
*-commutative23.5%
log-prod23.5%
+-commutative23.5%
hypot-1-def23.6%
add-sqr-sqrt12.8%
fabs-sqr12.8%
add-sqr-sqrt23.9%
metadata-eval23.9%
Applied egg-rr23.9%
+-rgt-identity23.9%
Simplified23.9%
Taylor expanded in x around 0 98.5%
distribute-rgt-in98.6%
*-lft-identity98.6%
associate-*l*98.6%
unpow298.6%
unpow398.6%
Simplified98.6%
if 0.5 < x Initial program 62.3%
*-un-lft-identity62.3%
*-commutative62.3%
log-prod62.3%
+-commutative62.3%
hypot-1-def98.7%
add-sqr-sqrt98.7%
fabs-sqr98.7%
add-sqr-sqrt98.7%
metadata-eval98.7%
Applied egg-rr98.7%
+-rgt-identity98.7%
Simplified98.7%
Taylor expanded in x around inf 96.4%
+-commutative96.4%
mul-1-neg96.4%
log-rec96.4%
remove-double-neg96.4%
Simplified96.4%
Final simplification97.8%
(FPCore (x)
:precision binary32
(if (<= x -1.2000000476837158)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.5)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -1.2000000476837158f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.5f) {
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(-1.2000000476837158)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.5)) 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(-1.2000000476837158)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.5)) 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 -1.2000000476837158:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\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 < -1.20000005Initial program 37.6%
*-un-lft-identity37.6%
*-commutative37.6%
log-prod37.6%
+-commutative37.6%
hypot-1-def98.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.2%
metadata-eval13.2%
Applied egg-rr13.2%
+-rgt-identity13.2%
Simplified13.2%
Taylor expanded in x around -inf 98.0%
if -1.20000005 < x < 0.5Initial program 23.5%
*-un-lft-identity23.5%
*-commutative23.5%
log-prod23.5%
+-commutative23.5%
hypot-1-def23.6%
add-sqr-sqrt12.8%
fabs-sqr12.8%
add-sqr-sqrt23.9%
metadata-eval23.9%
Applied egg-rr23.9%
+-rgt-identity23.9%
Simplified23.9%
Taylor expanded in x around 0 98.5%
distribute-rgt-in98.6%
*-lft-identity98.6%
associate-*l*98.6%
unpow298.6%
unpow398.6%
Simplified98.6%
if 0.5 < x Initial program 62.3%
*-un-lft-identity62.3%
*-commutative62.3%
log-prod62.3%
+-commutative62.3%
hypot-1-def98.7%
add-sqr-sqrt98.7%
fabs-sqr98.7%
add-sqr-sqrt98.7%
metadata-eval98.7%
Applied egg-rr98.7%
+-rgt-identity98.7%
Simplified98.7%
Taylor expanded in x around inf 96.3%
*-commutative96.3%
Simplified96.3%
Final simplification97.8%
(FPCore (x) :precision binary32 (if (<= x -1.2000000476837158) (copysign (log (/ -0.5 x)) x) (if (<= x 0.5) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -1.2000000476837158f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.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(-1.2000000476837158)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.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(-1.2000000476837158)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.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 -1.2000000476837158:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.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 < -1.20000005Initial program 37.6%
*-un-lft-identity37.6%
*-commutative37.6%
log-prod37.6%
+-commutative37.6%
hypot-1-def98.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.2%
metadata-eval13.2%
Applied egg-rr13.2%
+-rgt-identity13.2%
Simplified13.2%
Taylor expanded in x around -inf 98.0%
if -1.20000005 < x < 0.5Initial program 23.5%
*-un-lft-identity23.5%
*-commutative23.5%
log-prod23.5%
+-commutative23.5%
hypot-1-def23.6%
add-sqr-sqrt12.8%
fabs-sqr12.8%
add-sqr-sqrt23.9%
metadata-eval23.9%
Applied egg-rr23.9%
+-rgt-identity23.9%
Simplified23.9%
Taylor expanded in x around 0 97.1%
if 0.5 < x Initial program 62.3%
*-un-lft-identity62.3%
*-commutative62.3%
log-prod62.3%
+-commutative62.3%
hypot-1-def98.7%
add-sqr-sqrt98.7%
fabs-sqr98.7%
add-sqr-sqrt98.7%
metadata-eval98.7%
Applied egg-rr98.7%
+-rgt-identity98.7%
Simplified98.7%
Taylor expanded in x around inf 96.3%
*-commutative96.3%
Simplified96.3%
Final simplification97.1%
(FPCore (x) :precision binary32 (if (<= x 0.5) (copysign x x) (copysign (log (* x 2.0)) x)))
float code(float x) {
float tmp;
if (x <= 0.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(0.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(0.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 0.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 < 0.5Initial program 28.1%
*-un-lft-identity28.1%
*-commutative28.1%
log-prod28.1%
+-commutative28.1%
hypot-1-def48.0%
add-sqr-sqrt8.6%
fabs-sqr8.6%
add-sqr-sqrt20.5%
metadata-eval20.5%
Applied egg-rr20.5%
+-rgt-identity20.5%
Simplified20.5%
Taylor expanded in x around 0 69.0%
if 0.5 < x Initial program 62.3%
*-un-lft-identity62.3%
*-commutative62.3%
log-prod62.3%
+-commutative62.3%
hypot-1-def98.7%
add-sqr-sqrt98.7%
fabs-sqr98.7%
add-sqr-sqrt98.7%
metadata-eval98.7%
Applied egg-rr98.7%
+-rgt-identity98.7%
Simplified98.7%
Taylor expanded in x around inf 96.3%
*-commutative96.3%
Simplified96.3%
Final simplification76.7%
(FPCore (x) :precision binary32 (if (<= x 0.5) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.5)) 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.5:\\
\;\;\;\;\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.5Initial program 28.1%
*-un-lft-identity28.1%
*-commutative28.1%
log-prod28.1%
+-commutative28.1%
hypot-1-def48.0%
add-sqr-sqrt8.6%
fabs-sqr8.6%
add-sqr-sqrt20.5%
metadata-eval20.5%
Applied egg-rr20.5%
+-rgt-identity20.5%
Simplified20.5%
Taylor expanded in x around 0 69.0%
if 0.5 < x Initial program 62.3%
Taylor expanded in x around 0 43.2%
log1p-define43.2%
rem-square-sqrt43.2%
fabs-sqr43.2%
rem-square-sqrt43.2%
Simplified43.2%
Final simplification61.7%
(FPCore (x) :precision binary32 (copysign x x))
float code(float x) {
return copysignf(x, x);
}
function code(x) return copysign(x, x) end
function tmp = code(x) tmp = sign(x) * abs(x); end
\begin{array}{l}
\\
\mathsf{copysign}\left(x, x\right)
\end{array}
Initial program 37.7%
*-un-lft-identity37.7%
*-commutative37.7%
log-prod37.7%
+-commutative37.7%
hypot-1-def62.3%
add-sqr-sqrt33.9%
fabs-sqr33.9%
add-sqr-sqrt42.5%
metadata-eval42.5%
Applied egg-rr42.5%
+-rgt-identity42.5%
Simplified42.5%
Taylor expanded in x around 0 53.1%
Final simplification53.1%
(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 2024061
(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))