
(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 8 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 (* 2.0 (log (sqrt (/ -0.5 x)))) x)
(if (<= t_0 0.05000000074505806)
(copysign
(*
x
(-
1.0
(* (pow x 2.0) (+ 0.16666666666666666 (* (pow x 2.0) -0.075)))))
x)
(copysign (- (log (/ 0.5 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((2.0f * logf(sqrtf((-0.5f / x)))), x);
} else if (t_0 <= 0.05000000074505806f) {
tmp = copysignf((x * (1.0f - (powf(x, 2.0f) * (0.16666666666666666f + (powf(x, 2.0f) * -0.075f))))), x);
} else {
tmp = copysignf(-logf((0.5f / 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(Float32(2.0) * log(sqrt(Float32(Float32(-0.5) / x)))), x); elseif (t_0 <= Float32(0.05000000074505806)) tmp = copysign(Float32(x * Float32(Float32(1.0) - Float32((x ^ Float32(2.0)) * Float32(Float32(0.16666666666666666) + Float32((x ^ Float32(2.0)) * Float32(-0.075)))))), x); else tmp = copysign(Float32(-log(Float32(Float32(0.5) / x))), x); end return tmp end
function tmp_2 = code(x) t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); tmp = single(0.0); if (t_0 <= single(-1.0)) tmp = sign(x) * abs((single(2.0) * log(sqrt((single(-0.5) / x))))); elseif (t_0 <= single(0.05000000074505806)) tmp = sign(x) * abs((x * (single(1.0) - ((x ^ single(2.0)) * (single(0.16666666666666666) + ((x ^ single(2.0)) * single(-0.075))))))); else tmp = sign(x) * abs(-log((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t\_0 \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(2 \cdot \log \left(\sqrt{\frac{-0.5}{x}}\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 - {x}^{2} \cdot \left(0.16666666666666666 + {x}^{2} \cdot -0.075\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{0.5}{x}\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 51.6%
add-sqr-sqrt51.6%
pow251.6%
log-pow51.6%
+-commutative51.6%
hypot-1-def96.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.4%
Applied egg-rr10.4%
Taylor expanded in x around -inf 98.6%
if -1 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.0500000007Initial program 21.6%
flip-+21.7%
frac-2neg21.7%
log-div22.0%
pow222.0%
add-sqr-sqrt10.5%
fabs-sqr10.5%
add-sqr-sqrt22.0%
add-sqr-sqrt22.1%
fma-define22.1%
Applied egg-rr22.0%
neg-sub022.0%
associate--r-22.0%
neg-sub022.0%
+-commutative22.0%
fma-undefine22.0%
unpow222.0%
+-commutative22.0%
associate-+l+22.0%
sub-neg22.0%
+-inverses22.0%
metadata-eval22.0%
metadata-eval22.0%
neg-sub022.0%
neg-sub022.0%
associate--r-22.0%
neg-sub022.0%
+-commutative22.0%
sub-neg22.0%
Simplified22.0%
Taylor expanded in x around 0 100.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 49.2%
flip-+5.3%
frac-2neg5.3%
log-div5.3%
pow25.3%
add-sqr-sqrt5.5%
fabs-sqr5.5%
add-sqr-sqrt5.3%
add-sqr-sqrt5.2%
fma-define5.3%
Applied egg-rr5.3%
neg-sub05.3%
associate--r-5.3%
neg-sub05.3%
+-commutative5.3%
fma-undefine5.2%
unpow25.2%
+-commutative5.2%
associate-+l+7.8%
sub-neg7.8%
+-inverses11.3%
metadata-eval11.3%
metadata-eval11.3%
neg-sub011.3%
neg-sub011.3%
associate--r-11.3%
neg-sub011.3%
+-commutative11.3%
sub-neg11.3%
Simplified11.3%
Taylor expanded in x around inf 97.3%
Final simplification98.9%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (* 2.0 (log (sqrt (/ -0.5 x)))) x)
(if (<= x 0.05000000074505806)
(copysign (- x (* 0.16666666666666666 (pow x 3.0))) x)
(copysign (- (log (/ 0.5 x))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf((2.0f * logf(sqrtf((-0.5f / x)))), x);
} else if (x <= 0.05000000074505806f) {
tmp = copysignf((x - (0.16666666666666666f * powf(x, 3.0f))), 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) * log(sqrt(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(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) * log(sqrt((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((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 \log \left(\sqrt{\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(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 51.6%
add-sqr-sqrt51.6%
pow251.6%
log-pow51.6%
+-commutative51.6%
hypot-1-def96.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.4%
Applied egg-rr10.4%
Taylor expanded in x around -inf 98.6%
if -1 < x < 0.0500000007Initial program 21.6%
flip-+21.7%
frac-2neg21.7%
log-div22.0%
pow222.0%
add-sqr-sqrt10.5%
fabs-sqr10.5%
add-sqr-sqrt22.0%
add-sqr-sqrt22.1%
fma-define22.1%
Applied egg-rr22.0%
neg-sub022.0%
associate--r-22.0%
neg-sub022.0%
+-commutative22.0%
fma-undefine22.0%
unpow222.0%
+-commutative22.0%
associate-+l+22.0%
sub-neg22.0%
+-inverses22.0%
metadata-eval22.0%
metadata-eval22.0%
neg-sub022.0%
neg-sub022.0%
associate--r-22.0%
neg-sub022.0%
+-commutative22.0%
sub-neg22.0%
Simplified22.0%
Taylor expanded in x around 0 99.9%
sub-neg99.9%
metadata-eval99.9%
distribute-lft-in99.9%
*-commutative99.9%
mul-1-neg99.9%
unsub-neg99.9%
*-commutative99.9%
associate-*r*99.9%
unpow299.9%
cube-mult99.9%
Simplified99.9%
if 0.0500000007 < x Initial program 49.2%
flip-+5.3%
frac-2neg5.3%
log-div5.3%
pow25.3%
add-sqr-sqrt5.5%
fabs-sqr5.5%
add-sqr-sqrt5.3%
add-sqr-sqrt5.2%
fma-define5.3%
Applied egg-rr5.3%
neg-sub05.3%
associate--r-5.3%
neg-sub05.3%
+-commutative5.3%
fma-undefine5.2%
unpow25.2%
+-commutative5.2%
associate-+l+7.8%
sub-neg7.8%
+-inverses11.3%
metadata-eval11.3%
metadata-eval11.3%
neg-sub011.3%
neg-sub011.3%
associate--r-11.3%
neg-sub011.3%
+-commutative11.3%
sub-neg11.3%
Simplified11.3%
Taylor expanded in x around inf 97.3%
Final simplification98.9%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.05000000074505806)
(copysign (- x (* 0.16666666666666666 (pow x 3.0))) x)
(copysign (- (log (/ 0.5 x))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
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((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) 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(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((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((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(\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(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 51.6%
flip-+4.5%
frac-2neg4.5%
log-div4.5%
pow24.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt4.5%
add-sqr-sqrt4.4%
fma-define4.4%
Applied egg-rr9.6%
neg-sub09.6%
associate--r-9.6%
neg-sub09.6%
+-commutative9.6%
fma-undefine9.6%
unpow29.6%
+-commutative9.6%
associate-+l+48.3%
sub-neg48.3%
+-inverses96.8%
metadata-eval96.8%
metadata-eval96.8%
neg-sub096.8%
neg-sub096.8%
associate--r-96.8%
neg-sub096.8%
+-commutative96.8%
sub-neg96.8%
Simplified96.8%
if -1 < x < 0.0500000007Initial program 21.6%
flip-+21.7%
frac-2neg21.7%
log-div22.0%
pow222.0%
add-sqr-sqrt10.5%
fabs-sqr10.5%
add-sqr-sqrt22.0%
add-sqr-sqrt22.1%
fma-define22.1%
Applied egg-rr22.0%
neg-sub022.0%
associate--r-22.0%
neg-sub022.0%
+-commutative22.0%
fma-undefine22.0%
unpow222.0%
+-commutative22.0%
associate-+l+22.0%
sub-neg22.0%
+-inverses22.0%
metadata-eval22.0%
metadata-eval22.0%
neg-sub022.0%
neg-sub022.0%
associate--r-22.0%
neg-sub022.0%
+-commutative22.0%
sub-neg22.0%
Simplified22.0%
Taylor expanded in x around 0 99.9%
sub-neg99.9%
metadata-eval99.9%
distribute-lft-in99.9%
*-commutative99.9%
mul-1-neg99.9%
unsub-neg99.9%
*-commutative99.9%
associate-*r*99.9%
unpow299.9%
cube-mult99.9%
Simplified99.9%
if 0.0500000007 < x Initial program 49.2%
flip-+5.3%
frac-2neg5.3%
log-div5.3%
pow25.3%
add-sqr-sqrt5.5%
fabs-sqr5.5%
add-sqr-sqrt5.3%
add-sqr-sqrt5.2%
fma-define5.3%
Applied egg-rr5.3%
neg-sub05.3%
associate--r-5.3%
neg-sub05.3%
+-commutative5.3%
fma-undefine5.2%
unpow25.2%
+-commutative5.2%
associate-+l+7.8%
sub-neg7.8%
+-inverses11.3%
metadata-eval11.3%
metadata-eval11.3%
neg-sub011.3%
neg-sub011.3%
associate--r-11.3%
neg-sub011.3%
+-commutative11.3%
sub-neg11.3%
Simplified11.3%
Taylor expanded in x around inf 97.3%
Final simplification98.5%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.05000000074505806)
(copysign (- x (* 0.16666666666666666 (pow x 3.0))) 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 <= 0.05000000074505806f) {
tmp = copysignf((x - (0.16666666666666666f * powf(x, 3.0f))), 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(0.05000000074505806)) tmp = copysign(Float32(x - Float32(Float32(0.16666666666666666) * (x ^ Float32(3.0)))), 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(0.05000000074505806)) tmp = sign(x) * abs((x - (single(0.16666666666666666) * (x ^ single(3.0))))); 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 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x - 0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 51.6%
flip-+4.5%
frac-2neg4.5%
log-div4.5%
pow24.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt4.5%
add-sqr-sqrt4.4%
fma-define4.4%
Applied egg-rr9.6%
neg-sub09.6%
associate--r-9.6%
neg-sub09.6%
+-commutative9.6%
fma-undefine9.6%
unpow29.6%
+-commutative9.6%
associate-+l+48.3%
sub-neg48.3%
+-inverses96.8%
metadata-eval96.8%
metadata-eval96.8%
neg-sub096.8%
neg-sub096.8%
associate--r-96.8%
neg-sub096.8%
+-commutative96.8%
sub-neg96.8%
Simplified96.8%
Taylor expanded in x around -inf 95.4%
*-commutative95.4%
Simplified95.4%
if -1 < x < 0.0500000007Initial program 21.6%
flip-+21.7%
frac-2neg21.7%
log-div22.0%
pow222.0%
add-sqr-sqrt10.5%
fabs-sqr10.5%
add-sqr-sqrt22.0%
add-sqr-sqrt22.1%
fma-define22.1%
Applied egg-rr22.0%
neg-sub022.0%
associate--r-22.0%
neg-sub022.0%
+-commutative22.0%
fma-undefine22.0%
unpow222.0%
+-commutative22.0%
associate-+l+22.0%
sub-neg22.0%
+-inverses22.0%
metadata-eval22.0%
metadata-eval22.0%
neg-sub022.0%
neg-sub022.0%
associate--r-22.0%
neg-sub022.0%
+-commutative22.0%
sub-neg22.0%
Simplified22.0%
Taylor expanded in x around 0 99.9%
sub-neg99.9%
metadata-eval99.9%
distribute-lft-in99.9%
*-commutative99.9%
mul-1-neg99.9%
unsub-neg99.9%
*-commutative99.9%
associate-*r*99.9%
unpow299.9%
cube-mult99.9%
Simplified99.9%
if 0.0500000007 < x Initial program 49.2%
flip-+5.3%
frac-2neg5.3%
log-div5.3%
pow25.3%
add-sqr-sqrt5.5%
fabs-sqr5.5%
add-sqr-sqrt5.3%
add-sqr-sqrt5.2%
fma-define5.3%
Applied egg-rr5.3%
neg-sub05.3%
associate--r-5.3%
neg-sub05.3%
+-commutative5.3%
fma-undefine5.2%
unpow25.2%
+-commutative5.2%
associate-+l+7.8%
sub-neg7.8%
+-inverses11.3%
metadata-eval11.3%
metadata-eval11.3%
neg-sub011.3%
neg-sub011.3%
associate--r-11.3%
neg-sub011.3%
+-commutative11.3%
sub-neg11.3%
Simplified11.3%
Taylor expanded in x around inf 97.3%
Final simplification98.1%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.05000000074505806)
(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 <= 0.05000000074505806f) {
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(0.05000000074505806)) 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(0.05000000074505806)) 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 0.05000000074505806:\\
\;\;\;\;\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 51.6%
flip-+4.5%
frac-2neg4.5%
log-div4.5%
pow24.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt4.5%
add-sqr-sqrt4.4%
fma-define4.4%
Applied egg-rr9.6%
neg-sub09.6%
associate--r-9.6%
neg-sub09.6%
+-commutative9.6%
fma-undefine9.6%
unpow29.6%
+-commutative9.6%
associate-+l+48.3%
sub-neg48.3%
+-inverses96.8%
metadata-eval96.8%
metadata-eval96.8%
neg-sub096.8%
neg-sub096.8%
associate--r-96.8%
neg-sub096.8%
+-commutative96.8%
sub-neg96.8%
Simplified96.8%
Taylor expanded in x around -inf 95.4%
*-commutative95.4%
Simplified95.4%
if -1 < x < 0.0500000007Initial program 21.6%
Taylor expanded in x around 0 19.7%
rem-square-sqrt9.4%
fabs-sqr9.4%
rem-square-sqrt19.8%
Simplified19.8%
Taylor expanded in x around 0 98.7%
if 0.0500000007 < x Initial program 49.2%
flip-+5.3%
frac-2neg5.3%
log-div5.3%
pow25.3%
add-sqr-sqrt5.5%
fabs-sqr5.5%
add-sqr-sqrt5.3%
add-sqr-sqrt5.2%
fma-define5.3%
Applied egg-rr5.3%
neg-sub05.3%
associate--r-5.3%
neg-sub05.3%
+-commutative5.3%
fma-undefine5.2%
unpow25.2%
+-commutative5.2%
associate-+l+7.8%
sub-neg7.8%
+-inverses11.3%
metadata-eval11.3%
metadata-eval11.3%
neg-sub011.3%
neg-sub011.3%
associate--r-11.3%
neg-sub011.3%
+-commutative11.3%
sub-neg11.3%
Simplified11.3%
Taylor expanded in x around inf 97.3%
(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 51.6%
flip-+4.5%
frac-2neg4.5%
log-div4.5%
pow24.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt4.5%
add-sqr-sqrt4.4%
fma-define4.4%
Applied egg-rr9.6%
neg-sub09.6%
associate--r-9.6%
neg-sub09.6%
+-commutative9.6%
fma-undefine9.6%
unpow29.6%
+-commutative9.6%
associate-+l+48.3%
sub-neg48.3%
+-inverses96.8%
metadata-eval96.8%
metadata-eval96.8%
neg-sub096.8%
neg-sub096.8%
associate--r-96.8%
neg-sub096.8%
+-commutative96.8%
sub-neg96.8%
Simplified96.8%
Taylor expanded in x around -inf 95.4%
*-commutative95.4%
Simplified95.4%
if -1 < x Initial program 31.4%
Taylor expanded in x around 0 28.6%
log1p-define76.9%
rem-square-sqrt46.2%
fabs-sqr46.2%
rem-square-sqrt76.9%
Simplified76.9%
(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 31.0%
Taylor expanded in x around 0 27.6%
rem-square-sqrt6.5%
fabs-sqr6.5%
rem-square-sqrt13.7%
Simplified13.7%
Taylor expanded in x around 0 71.2%
if 0.0500000007 < x Initial program 49.2%
Taylor expanded in x around 0 44.9%
log1p-define44.9%
rem-square-sqrt44.9%
fabs-sqr44.9%
rem-square-sqrt44.9%
Simplified44.9%
(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 35.9%
Taylor expanded in x around 0 32.3%
rem-square-sqrt17.0%
fabs-sqr17.0%
rem-square-sqrt22.2%
Simplified22.2%
Taylor expanded in x around 0 54.6%
(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 2024085
(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))