
(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.009999999776482582)
(copysign
(*
x
(+ 1.0 (* (pow x 2.0) (- (* (pow x 2.0) 0.075) 0.16666666666666666))))
x)
(copysign (log (+ (fabs x) (hypot 1.0 x))) x)))))
float code(float x) {
float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
float tmp;
if (t_0 <= -0.5f) {
tmp = copysignf(logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.009999999776482582f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * ((powf(x, 2.0f) * 0.075f) - 0.16666666666666666f)))), x);
} else {
tmp = copysignf(logf((fabsf(x) + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) t_0 = copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) tmp = Float32(0.0) if (t_0 <= Float32(-0.5)) tmp = copysign(log(Float32(hypot(Float32(1.0), x) - x)), x); elseif (t_0 <= Float32(0.009999999776482582)) 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(abs(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.009999999776482582)) 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((abs(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.009999999776482582:\\
\;\;\;\;\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(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < -0.5Initial program 53.2%
flip-+11.9%
clear-num11.9%
log-div11.9%
metadata-eval11.9%
+-commutative11.9%
hypot-1-def11.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.9%
Applied egg-rr13.9%
neg-sub013.9%
div-sub13.9%
*-rgt-identity13.9%
associate-/l*13.9%
fmm-def13.9%
fma-undefine13.9%
unpow213.9%
associate--r+14.0%
+-inverses14.0%
metadata-eval14.0%
metadata-eval14.0%
*-rgt-identity14.0%
associate-/l*14.0%
fma-undefine14.0%
unpow214.0%
associate--r+50.0%
Simplified100.0%
*-un-lft-identity100.0%
add-sqr-sqrt-0.0%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod98.4%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
Simplified100.0%
if -0.5 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.00999999978Initial program 20.7%
flip-+20.7%
clear-num20.7%
log-div21.0%
metadata-eval21.0%
+-commutative21.0%
hypot-1-def21.0%
add-sqr-sqrt9.8%
fabs-sqr9.8%
add-sqr-sqrt20.8%
Applied egg-rr20.9%
neg-sub020.9%
div-sub20.8%
*-rgt-identity20.8%
associate-/l*20.8%
fmm-def20.8%
fma-undefine20.8%
unpow220.8%
associate--r+20.8%
+-inverses20.8%
metadata-eval20.8%
metadata-eval20.8%
*-rgt-identity20.8%
associate-/l*20.8%
fma-undefine20.8%
unpow220.8%
associate--r+20.8%
Simplified20.8%
Taylor expanded in x around 0 100.0%
if 0.00999999978 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 44.9%
+-commutative44.9%
hypot-1-def98.5%
Simplified98.5%
Final simplification99.6%
(FPCore (x)
:precision binary32
(if (<= x -0.5)
(copysign (log (- (hypot 1.0 x) x)) x)
(if (<= x 0.009999999776482582)
(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.5f) {
tmp = copysignf(logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.009999999776482582f) {
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.5)) tmp = copysign(log(Float32(hypot(Float32(1.0), x) - x)), x); elseif (x <= Float32(0.009999999776482582)) 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.5)) tmp = sign(x) * abs(log((hypot(single(1.0), x) - x))); elseif (x <= single(0.009999999776482582)) 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.5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.009999999776482582:\\
\;\;\;\;\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.5Initial program 53.2%
flip-+11.9%
clear-num11.9%
log-div11.9%
metadata-eval11.9%
+-commutative11.9%
hypot-1-def11.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.9%
Applied egg-rr13.9%
neg-sub013.9%
div-sub13.9%
*-rgt-identity13.9%
associate-/l*13.9%
fmm-def13.9%
fma-undefine13.9%
unpow213.9%
associate--r+14.0%
+-inverses14.0%
metadata-eval14.0%
metadata-eval14.0%
*-rgt-identity14.0%
associate-/l*14.0%
fma-undefine14.0%
unpow214.0%
associate--r+50.0%
Simplified100.0%
*-un-lft-identity100.0%
add-sqr-sqrt-0.0%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod98.4%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
Simplified100.0%
if -0.5 < x < 0.00999999978Initial program 20.7%
flip-+20.7%
clear-num20.7%
log-div21.0%
metadata-eval21.0%
+-commutative21.0%
hypot-1-def21.0%
add-sqr-sqrt9.8%
fabs-sqr9.8%
add-sqr-sqrt20.8%
Applied egg-rr20.9%
neg-sub020.9%
div-sub20.8%
*-rgt-identity20.8%
associate-/l*20.8%
fmm-def20.8%
fma-undefine20.8%
unpow220.8%
associate--r+20.8%
+-inverses20.8%
metadata-eval20.8%
metadata-eval20.8%
*-rgt-identity20.8%
associate-/l*20.8%
fma-undefine20.8%
unpow220.8%
associate--r+20.8%
Simplified20.8%
Taylor expanded in x around 0 100.0%
if 0.00999999978 < x Initial program 44.9%
Taylor expanded in x around 0 44.9%
rem-square-sqrt44.9%
fabs-sqr44.9%
metadata-eval44.9%
unpow244.9%
hypot-undefine98.5%
rem-square-sqrt98.5%
Simplified98.5%
Final simplification99.6%
(FPCore (x)
:precision binary32
(if (<= x -0.05000000074505806)
(copysign (log (- (hypot 1.0 x) x)) x)
(if (<= x 0.009999999776482582)
(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.05000000074505806f) {
tmp = copysignf(logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.009999999776482582f) {
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.05000000074505806)) tmp = copysign(log(Float32(hypot(Float32(1.0), x) - x)), x); elseif (x <= Float32(0.009999999776482582)) 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.05000000074505806)) tmp = sign(x) * abs(log((hypot(single(1.0), x) - x))); elseif (x <= single(0.009999999776482582)) 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.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.009999999776482582:\\
\;\;\;\;\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.0500000007Initial program 53.7%
flip-+13.1%
clear-num13.1%
log-div13.1%
metadata-eval13.1%
+-commutative13.1%
hypot-1-def13.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt15.1%
Applied egg-rr15.1%
neg-sub015.1%
div-sub15.1%
*-rgt-identity15.1%
associate-/l*15.1%
fmm-def15.1%
fma-undefine15.1%
unpow215.1%
associate--r+15.1%
+-inverses15.1%
metadata-eval15.1%
metadata-eval15.1%
*-rgt-identity15.1%
associate-/l*15.1%
fma-undefine15.1%
unpow215.1%
associate--r+50.6%
Simplified99.8%
*-un-lft-identity99.8%
add-sqr-sqrt-0.0%
sqrt-unprod99.8%
sqr-neg99.8%
sqrt-unprod98.2%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
*-lft-identity99.8%
Simplified99.8%
if -0.0500000007 < x < 0.00999999978Initial program 20.1%
flip-+20.2%
clear-num20.2%
log-div20.5%
metadata-eval20.5%
+-commutative20.5%
hypot-1-def20.4%
add-sqr-sqrt9.9%
fabs-sqr9.9%
add-sqr-sqrt20.3%
Applied egg-rr20.3%
neg-sub020.3%
div-sub20.3%
*-rgt-identity20.3%
associate-/l*20.3%
fmm-def20.3%
fma-undefine20.3%
unpow220.3%
associate--r+20.3%
+-inverses20.3%
metadata-eval20.3%
metadata-eval20.3%
*-rgt-identity20.3%
associate-/l*20.3%
fma-undefine20.3%
unpow220.3%
associate--r+20.3%
Simplified20.3%
Taylor expanded in x around 0 100.0%
distribute-rgt-in100.0%
*-lft-identity100.0%
associate-*l*100.0%
unpow2100.0%
unpow3100.0%
Simplified100.0%
if 0.00999999978 < x Initial program 44.9%
Taylor expanded in x around 0 44.9%
rem-square-sqrt44.9%
fabs-sqr44.9%
metadata-eval44.9%
unpow244.9%
hypot-undefine98.5%
rem-square-sqrt98.5%
Simplified98.5%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (* x -2.0)) x)
(if (<= x 0.009999999776482582)
(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.0f) {
tmp = copysignf(logf((x * -2.0f)), x);
} else if (x <= 0.009999999776482582f) {
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.0)) tmp = copysign(log(Float32(x * Float32(-2.0))), x); elseif (x <= Float32(0.009999999776482582)) 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.0)) tmp = sign(x) * abs(log((x * single(-2.0)))); elseif (x <= single(0.009999999776482582)) 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:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.009999999776482582:\\
\;\;\;\;\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 < -1Initial program 52.4%
flip-+10.5%
clear-num10.5%
log-div10.5%
metadata-eval10.5%
+-commutative10.5%
hypot-1-def10.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.6%
Applied egg-rr12.6%
neg-sub012.6%
div-sub12.6%
*-rgt-identity12.6%
associate-/l*12.6%
fmm-def12.6%
fma-undefine12.6%
unpow212.6%
associate--r+12.6%
+-inverses12.6%
metadata-eval12.6%
metadata-eval12.6%
*-rgt-identity12.6%
associate-/l*12.6%
fma-undefine12.6%
unpow212.6%
associate--r+49.2%
Simplified100.0%
Taylor expanded in x around -inf 95.2%
*-commutative95.2%
Simplified95.2%
*-un-lft-identity95.2%
*-commutative95.2%
add-sqr-sqrt-0.0%
sqrt-unprod95.2%
sqr-neg95.2%
sqrt-unprod93.7%
add-sqr-sqrt95.2%
Applied egg-rr95.2%
*-rgt-identity95.2%
Simplified95.2%
if -1 < x < 0.00999999978Initial program 21.3%
flip-+21.4%
clear-num21.4%
log-div21.7%
metadata-eval21.7%
+-commutative21.7%
hypot-1-def21.6%
add-sqr-sqrt9.7%
fabs-sqr9.7%
add-sqr-sqrt21.4%
Applied egg-rr21.5%
neg-sub021.5%
div-sub21.4%
*-rgt-identity21.4%
associate-/l*21.4%
fmm-def21.4%
fma-undefine21.4%
unpow221.4%
associate--r+21.4%
+-inverses21.4%
metadata-eval21.4%
metadata-eval21.4%
*-rgt-identity21.4%
associate-/l*21.4%
fma-undefine21.4%
unpow221.4%
associate--r+21.5%
Simplified21.5%
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.00999999978 < x Initial program 44.9%
Taylor expanded in x around 0 44.9%
rem-square-sqrt44.9%
fabs-sqr44.9%
metadata-eval44.9%
unpow244.9%
hypot-undefine98.5%
rem-square-sqrt98.5%
Simplified98.5%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (* x -2.0)) x)
(if (<= x 1.0)
(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 <= 1.0f) {
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(log(Float32(x * Float32(-2.0))), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(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 + (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 1:\\
\;\;\;\;\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 52.4%
flip-+10.5%
clear-num10.5%
log-div10.5%
metadata-eval10.5%
+-commutative10.5%
hypot-1-def10.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.6%
Applied egg-rr12.6%
neg-sub012.6%
div-sub12.6%
*-rgt-identity12.6%
associate-/l*12.6%
fmm-def12.6%
fma-undefine12.6%
unpow212.6%
associate--r+12.6%
+-inverses12.6%
metadata-eval12.6%
metadata-eval12.6%
*-rgt-identity12.6%
associate-/l*12.6%
fma-undefine12.6%
unpow212.6%
associate--r+49.2%
Simplified100.0%
Taylor expanded in x around -inf 95.2%
*-commutative95.2%
Simplified95.2%
*-un-lft-identity95.2%
*-commutative95.2%
add-sqr-sqrt-0.0%
sqrt-unprod95.2%
sqr-neg95.2%
sqrt-unprod93.7%
add-sqr-sqrt95.2%
Applied egg-rr95.2%
*-rgt-identity95.2%
Simplified95.2%
if -1 < x < 1Initial program 22.5%
flip-+22.6%
clear-num22.6%
log-div22.9%
metadata-eval22.9%
+-commutative22.9%
hypot-1-def22.8%
add-sqr-sqrt11.1%
fabs-sqr11.1%
add-sqr-sqrt22.6%
Applied egg-rr22.7%
neg-sub022.7%
div-sub22.6%
*-rgt-identity22.6%
associate-/l*22.6%
fmm-def22.6%
fma-undefine22.6%
unpow222.6%
associate--r+22.6%
+-inverses22.6%
metadata-eval22.6%
metadata-eval22.6%
*-rgt-identity22.6%
associate-/l*22.6%
fma-undefine22.6%
unpow222.6%
associate--r+22.7%
Simplified22.7%
Taylor expanded in x around 0 98.6%
distribute-rgt-in98.6%
*-lft-identity98.6%
associate-*l*98.6%
unpow298.6%
unpow398.6%
Simplified98.6%
if 1 < x Initial program 43.3%
Taylor expanded in x around -inf 6.0%
mul-1-neg6.0%
*-commutative6.0%
distribute-rgt-neg-in6.0%
mul-1-neg6.0%
unsub-neg6.0%
sub-neg6.0%
rem-square-sqrt10.7%
fabs-sqr10.7%
rem-square-sqrt6.0%
associate-*r/6.0%
metadata-eval6.0%
distribute-neg-frac6.0%
metadata-eval6.0%
Simplified6.0%
neg-sub06.0%
sub-neg6.0%
add-sqr-sqrt-0.0%
sqrt-unprod5.7%
sqr-neg5.7%
sqrt-prod9.7%
add-sqr-sqrt9.7%
Applied egg-rr9.7%
Taylor expanded in x around 0 99.2%
(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(log(Float32(x * Float32(-2.0))), x); elseif (x <= Float32(1.0)) tmp = copysign(x, x); else tmp = copysign(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 52.4%
flip-+10.5%
clear-num10.5%
log-div10.5%
metadata-eval10.5%
+-commutative10.5%
hypot-1-def10.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.6%
Applied egg-rr12.6%
neg-sub012.6%
div-sub12.6%
*-rgt-identity12.6%
associate-/l*12.6%
fmm-def12.6%
fma-undefine12.6%
unpow212.6%
associate--r+12.6%
+-inverses12.6%
metadata-eval12.6%
metadata-eval12.6%
*-rgt-identity12.6%
associate-/l*12.6%
fma-undefine12.6%
unpow212.6%
associate--r+49.2%
Simplified100.0%
Taylor expanded in x around -inf 95.2%
*-commutative95.2%
Simplified95.2%
*-un-lft-identity95.2%
*-commutative95.2%
add-sqr-sqrt-0.0%
sqrt-unprod95.2%
sqr-neg95.2%
sqrt-unprod93.7%
add-sqr-sqrt95.2%
Applied egg-rr95.2%
*-rgt-identity95.2%
Simplified95.2%
if -1 < x < 1Initial program 22.5%
flip-+22.6%
clear-num22.6%
log-div22.9%
metadata-eval22.9%
+-commutative22.9%
hypot-1-def22.8%
add-sqr-sqrt11.1%
fabs-sqr11.1%
add-sqr-sqrt22.6%
Applied egg-rr22.7%
neg-sub022.7%
div-sub22.6%
*-rgt-identity22.6%
associate-/l*22.6%
fmm-def22.6%
fma-undefine22.6%
unpow222.6%
associate--r+22.6%
+-inverses22.6%
metadata-eval22.6%
metadata-eval22.6%
*-rgt-identity22.6%
associate-/l*22.6%
fma-undefine22.6%
unpow222.6%
associate--r+22.7%
Simplified22.7%
Taylor expanded in x around 0 97.2%
if 1 < x Initial program 43.3%
Taylor expanded in x around -inf 6.0%
mul-1-neg6.0%
*-commutative6.0%
distribute-rgt-neg-in6.0%
mul-1-neg6.0%
unsub-neg6.0%
sub-neg6.0%
rem-square-sqrt10.7%
fabs-sqr10.7%
rem-square-sqrt6.0%
associate-*r/6.0%
metadata-eval6.0%
distribute-neg-frac6.0%
metadata-eval6.0%
Simplified6.0%
neg-sub06.0%
sub-neg6.0%
add-sqr-sqrt-0.0%
sqrt-unprod5.7%
sqr-neg5.7%
sqrt-prod9.7%
add-sqr-sqrt9.7%
Applied egg-rr9.7%
Taylor expanded in x around 0 99.2%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (log (* x -2.0)) x) (if (<= x 1.0) (copysign x x) (copysign (log (* x 2.0)) 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((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(x * Float32(-2.0))), x); elseif (x <= Float32(1.0)) 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.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((x * single(2.0)))); 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(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 52.4%
flip-+10.5%
clear-num10.5%
log-div10.5%
metadata-eval10.5%
+-commutative10.5%
hypot-1-def10.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.6%
Applied egg-rr12.6%
neg-sub012.6%
div-sub12.6%
*-rgt-identity12.6%
associate-/l*12.6%
fmm-def12.6%
fma-undefine12.6%
unpow212.6%
associate--r+12.6%
+-inverses12.6%
metadata-eval12.6%
metadata-eval12.6%
*-rgt-identity12.6%
associate-/l*12.6%
fma-undefine12.6%
unpow212.6%
associate--r+49.2%
Simplified100.0%
Taylor expanded in x around -inf 95.2%
*-commutative95.2%
Simplified95.2%
*-un-lft-identity95.2%
*-commutative95.2%
add-sqr-sqrt-0.0%
sqrt-unprod95.2%
sqr-neg95.2%
sqrt-unprod93.7%
add-sqr-sqrt95.2%
Applied egg-rr95.2%
*-rgt-identity95.2%
Simplified95.2%
if -1 < x < 1Initial program 22.5%
flip-+22.6%
clear-num22.6%
log-div22.9%
metadata-eval22.9%
+-commutative22.9%
hypot-1-def22.8%
add-sqr-sqrt11.1%
fabs-sqr11.1%
add-sqr-sqrt22.6%
Applied egg-rr22.7%
neg-sub022.7%
div-sub22.6%
*-rgt-identity22.6%
associate-/l*22.6%
fmm-def22.6%
fma-undefine22.6%
unpow222.6%
associate--r+22.6%
+-inverses22.6%
metadata-eval22.6%
metadata-eval22.6%
*-rgt-identity22.6%
associate-/l*22.6%
fma-undefine22.6%
unpow222.6%
associate--r+22.7%
Simplified22.7%
Taylor expanded in x around 0 97.2%
if 1 < x Initial program 43.3%
Taylor expanded in x around inf 97.7%
rem-square-sqrt97.7%
fabs-sqr97.7%
rem-square-sqrt97.7%
*-inverses97.7%
metadata-eval97.7%
Simplified97.7%
(FPCore (x) :precision binary32 (if (<= x -0.5) (copysign (log (* x -2.0)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -0.5f) {
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(-0.5)) tmp = copysign(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 -0.5:\\
\;\;\;\;\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 < -0.5Initial program 53.2%
flip-+11.9%
clear-num11.9%
log-div11.9%
metadata-eval11.9%
+-commutative11.9%
hypot-1-def11.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.9%
Applied egg-rr13.9%
neg-sub013.9%
div-sub13.9%
*-rgt-identity13.9%
associate-/l*13.9%
fmm-def13.9%
fma-undefine13.9%
unpow213.9%
associate--r+14.0%
+-inverses14.0%
metadata-eval14.0%
metadata-eval14.0%
*-rgt-identity14.0%
associate-/l*14.0%
fma-undefine14.0%
unpow214.0%
associate--r+50.0%
Simplified100.0%
Taylor expanded in x around -inf 94.2%
*-commutative94.2%
Simplified94.2%
*-un-lft-identity94.2%
*-commutative94.2%
add-sqr-sqrt-0.0%
sqrt-unprod94.2%
sqr-neg94.2%
sqrt-unprod92.7%
add-sqr-sqrt94.2%
Applied egg-rr94.2%
*-rgt-identity94.2%
Simplified94.2%
if -0.5 < x Initial program 29.3%
Taylor expanded in x around 0 27.9%
log1p-define77.5%
rem-square-sqrt45.8%
fabs-sqr45.8%
rem-square-sqrt77.5%
Simplified77.5%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (log (- x)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf(-x), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(-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(\log \left(-x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 52.4%
Taylor expanded in x around -inf 43.8%
neg-mul-143.8%
Simplified43.8%
if -1 < x Initial program 29.6%
Taylor expanded in x around 0 28.0%
log1p-define77.2%
rem-square-sqrt45.6%
fabs-sqr45.6%
rem-square-sqrt77.2%
Simplified77.2%
(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 32.5%
flip-+18.5%
clear-num18.5%
log-div18.8%
metadata-eval18.8%
+-commutative18.8%
hypot-1-def18.7%
add-sqr-sqrt7.4%
fabs-sqr7.4%
add-sqr-sqrt19.3%
Applied egg-rr19.4%
neg-sub019.4%
div-sub19.3%
*-rgt-identity19.3%
associate-/l*19.3%
fmm-def19.3%
fma-undefine19.3%
unpow219.3%
associate--r+19.3%
+-inverses19.3%
metadata-eval19.3%
metadata-eval19.3%
*-rgt-identity19.3%
associate-/l*19.3%
fma-undefine19.3%
unpow219.3%
associate--r+31.4%
Simplified48.3%
Taylor expanded in x around 0 68.9%
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 (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.2%
flip-+15.0%
clear-num15.0%
log-div15.2%
metadata-eval15.2%
+-commutative15.2%
hypot-1-def15.1%
add-sqr-sqrt6.9%
fabs-sqr6.9%
add-sqr-sqrt15.6%
Applied egg-rr15.5%
neg-sub015.5%
div-sub15.5%
*-rgt-identity15.5%
associate-/l*15.5%
fmm-def15.5%
fma-undefine15.5%
unpow215.5%
associate--r+15.5%
+-inverses15.5%
metadata-eval15.5%
metadata-eval15.5%
*-rgt-identity15.5%
associate-/l*15.5%
fma-undefine15.5%
unpow215.5%
associate--r+25.0%
Simplified38.5%
Taylor expanded in x around 0 53.8%
(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 2024181
(FPCore (x)
:name "Rust f32::asinh"
:precision binary32
:alt
(! :herbie-platform default (let* ((ax (fabs x)) (ix (/ 1 ax))) (copysign (log1p (+ ax (/ ax (+ (hypot 1 ix) ix)))) x)))
(copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))