
(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 9 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.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 (log (+ 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.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(logf((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.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(log(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.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(log((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.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(\log \left(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 59.3%
flip-+6.3%
clear-num6.2%
log-div6.2%
metadata-eval6.2%
+-commutative6.2%
hypot-1-def6.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt5.9%
Applied egg-rr7.4%
neg-sub07.4%
div-sub7.4%
*-rgt-identity7.4%
associate-/l*7.4%
fmm-def7.4%
fma-undefine7.4%
unpow27.4%
associate--r+7.4%
+-inverses7.4%
metadata-eval7.4%
metadata-eval7.4%
*-rgt-identity7.4%
associate-/l*7.4%
fma-undefine7.4%
unpow27.4%
Simplified99.8%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.200000003Initial program 20.8%
+-commutative20.8%
hypot-1-def20.8%
flip-+21.0%
hypot-1-def21.0%
hypot-1-def20.9%
add-sqr-sqrt20.9%
+-commutative20.9%
hypot-1-def21.0%
+-commutative21.0%
div-sub21.0%
Applied egg-rr20.8%
div-sub20.8%
remove-double-neg20.8%
distribute-frac-neg220.8%
neg-mul-120.8%
associate-/r*20.8%
distribute-neg-frac220.8%
fma-undefine20.8%
unpow220.8%
associate--r+20.8%
+-inverses20.8%
metadata-eval20.8%
metadata-eval20.8%
neg-sub020.8%
associate--r-20.8%
neg-sub020.8%
+-commutative20.8%
sub-neg20.8%
Simplified20.8%
Taylor expanded in x around 0 100.0%
if 0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 57.2%
+-commutative57.2%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around 0 57.2%
rem-square-sqrt57.2%
fabs-sqr57.2%
metadata-eval57.2%
unpow257.2%
hypot-undefine100.0%
rem-square-sqrt100.0%
Simplified100.0%
Final simplification99.9%
(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.03999999910593033)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (- (log (/ 1.0 (+ x (hypot 1.0 x))))) x)))))
float code(float x) {
float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
float tmp;
if (t_0 <= -0.20000000298023224f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.03999999910593033f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(-logf((1.0f / (x + hypotf(1.0f, x)))), x);
}
return tmp;
}
function code(x) t_0 = copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) tmp = Float32(0.0) if (t_0 <= Float32(-0.20000000298023224)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.03999999910593033)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(Float32(-log(Float32(Float32(1.0) / 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.03999999910593033)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(-log((single(1.0) / (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.03999999910593033:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{1}{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 59.3%
flip-+6.3%
clear-num6.2%
log-div6.2%
metadata-eval6.2%
+-commutative6.2%
hypot-1-def6.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt5.9%
Applied egg-rr7.4%
neg-sub07.4%
div-sub7.4%
*-rgt-identity7.4%
associate-/l*7.4%
fmm-def7.4%
fma-undefine7.4%
unpow27.4%
associate--r+7.4%
+-inverses7.4%
metadata-eval7.4%
metadata-eval7.4%
*-rgt-identity7.4%
associate-/l*7.4%
fma-undefine7.4%
unpow27.4%
Simplified99.8%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.0399999991Initial program 20.3%
+-commutative20.3%
hypot-1-def20.3%
flip-+20.4%
hypot-1-def20.4%
hypot-1-def20.4%
add-sqr-sqrt20.4%
+-commutative20.4%
hypot-1-def20.4%
+-commutative20.4%
div-sub20.4%
Applied egg-rr20.3%
div-sub20.3%
remove-double-neg20.3%
distribute-frac-neg220.3%
neg-mul-120.3%
associate-/r*20.3%
distribute-neg-frac220.3%
fma-undefine20.3%
unpow220.3%
associate--r+20.3%
+-inverses20.3%
metadata-eval20.3%
metadata-eval20.3%
neg-sub020.3%
associate--r-20.3%
neg-sub020.3%
+-commutative20.3%
sub-neg20.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.0399999991 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 57.8%
flip-+9.2%
clear-num9.2%
log-div9.2%
metadata-eval9.2%
+-commutative9.2%
hypot-1-def9.2%
add-sqr-sqrt9.4%
fabs-sqr9.4%
add-sqr-sqrt9.2%
Applied egg-rr9.2%
neg-sub09.2%
div-sub9.2%
*-rgt-identity9.2%
associate-/l*9.2%
fmm-def9.2%
fma-undefine9.2%
unpow29.2%
associate--r+9.2%
+-inverses9.2%
metadata-eval9.2%
metadata-eval9.2%
*-rgt-identity9.2%
associate-/l*9.2%
fma-undefine9.2%
unpow29.2%
Simplified14.9%
flip--12.5%
div-inv12.5%
hypot-undefine12.5%
hypot-undefine12.5%
metadata-eval12.5%
metadata-eval12.5%
add-sqr-sqrt14.0%
pow214.0%
pow214.0%
+-commutative14.0%
Applied egg-rr14.0%
associate--l+54.9%
+-inverses100.0%
metadata-eval100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
(FPCore (x)
:precision binary32
(if (<= x -0.20000000298023224)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.03999999910593033)
(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.20000000298023224f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.03999999910593033f) {
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.20000000298023224)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.03999999910593033)) 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.20000000298023224)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (x <= single(0.03999999910593033)) 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.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.03999999910593033:\\
\;\;\;\;\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.200000003Initial program 59.3%
flip-+6.3%
clear-num6.2%
log-div6.2%
metadata-eval6.2%
+-commutative6.2%
hypot-1-def6.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt5.9%
Applied egg-rr7.4%
neg-sub07.4%
div-sub7.4%
*-rgt-identity7.4%
associate-/l*7.4%
fmm-def7.4%
fma-undefine7.4%
unpow27.4%
associate--r+7.4%
+-inverses7.4%
metadata-eval7.4%
metadata-eval7.4%
*-rgt-identity7.4%
associate-/l*7.4%
fma-undefine7.4%
unpow27.4%
Simplified99.8%
if -0.200000003 < x < 0.0399999991Initial program 20.3%
+-commutative20.3%
hypot-1-def20.3%
flip-+20.4%
hypot-1-def20.4%
hypot-1-def20.4%
add-sqr-sqrt20.4%
+-commutative20.4%
hypot-1-def20.4%
+-commutative20.4%
div-sub20.4%
Applied egg-rr20.3%
div-sub20.3%
remove-double-neg20.3%
distribute-frac-neg220.3%
neg-mul-120.3%
associate-/r*20.3%
distribute-neg-frac220.3%
fma-undefine20.3%
unpow220.3%
associate--r+20.3%
+-inverses20.3%
metadata-eval20.3%
metadata-eval20.3%
neg-sub020.3%
associate--r-20.3%
neg-sub020.3%
+-commutative20.3%
sub-neg20.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.0399999991 < x Initial program 57.8%
+-commutative57.8%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around 0 57.8%
rem-square-sqrt57.7%
fabs-sqr57.7%
metadata-eval57.7%
unpow257.7%
hypot-undefine99.9%
rem-square-sqrt99.9%
Simplified99.9%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.03999999910593033)
(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 <= -10.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.03999999910593033f) {
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(-10.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.03999999910593033)) 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(-10.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.03999999910593033)) 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 -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.03999999910593033:\\
\;\;\;\;\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 < -10Initial program 57.8%
Taylor expanded in x around -inf 99.7%
mul-1-neg99.7%
distribute-rgt-neg-in99.7%
mul-1-neg99.7%
unsub-neg99.7%
sub-neg99.7%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt8.2%
associate-*r/8.2%
metadata-eval8.2%
distribute-neg-frac8.2%
metadata-eval8.2%
Simplified8.2%
Taylor expanded in x around 0 99.2%
if -10 < x < 0.0399999991Initial program 21.4%
+-commutative21.4%
hypot-1-def21.4%
flip-+21.5%
hypot-1-def21.6%
hypot-1-def21.5%
add-sqr-sqrt21.6%
+-commutative21.6%
hypot-1-def21.5%
+-commutative21.5%
div-sub21.6%
Applied egg-rr21.4%
div-sub21.4%
remove-double-neg21.4%
distribute-frac-neg221.4%
neg-mul-121.4%
associate-/r*21.4%
distribute-neg-frac221.4%
fma-undefine21.4%
unpow221.4%
associate--r+21.4%
+-inverses21.4%
metadata-eval21.4%
metadata-eval21.4%
neg-sub021.4%
associate--r-21.4%
neg-sub021.4%
+-commutative21.4%
sub-neg21.4%
Simplified21.4%
Taylor expanded in x around 0 99.3%
distribute-rgt-in99.3%
*-lft-identity99.3%
associate-*l*99.3%
unpow299.3%
unpow399.3%
Simplified99.3%
if 0.0399999991 < x Initial program 57.8%
+-commutative57.8%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around 0 57.8%
rem-square-sqrt57.7%
fabs-sqr57.7%
metadata-eval57.7%
unpow257.7%
hypot-undefine99.9%
rem-square-sqrt99.9%
Simplified99.9%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.20000000298023224)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.20000000298023224f) {
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(-10.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.20000000298023224)) 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(-10.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.20000000298023224)) 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 -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\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 < -10Initial program 57.8%
Taylor expanded in x around -inf 99.7%
mul-1-neg99.7%
distribute-rgt-neg-in99.7%
mul-1-neg99.7%
unsub-neg99.7%
sub-neg99.7%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt8.2%
associate-*r/8.2%
metadata-eval8.2%
distribute-neg-frac8.2%
metadata-eval8.2%
Simplified8.2%
Taylor expanded in x around 0 99.2%
if -10 < x < 0.200000003Initial program 22.0%
+-commutative22.0%
hypot-1-def21.9%
flip-+22.1%
hypot-1-def22.1%
hypot-1-def22.0%
add-sqr-sqrt22.1%
+-commutative22.1%
hypot-1-def22.0%
+-commutative22.0%
div-sub22.1%
Applied egg-rr21.9%
div-sub21.9%
remove-double-neg21.9%
distribute-frac-neg221.9%
neg-mul-121.9%
associate-/r*21.9%
distribute-neg-frac221.9%
fma-undefine21.9%
unpow221.9%
associate--r+22.0%
+-inverses22.0%
metadata-eval22.0%
metadata-eval22.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.1%
distribute-rgt-in99.1%
*-lft-identity99.1%
associate-*l*99.1%
unpow299.1%
unpow399.1%
Simplified99.1%
if 0.200000003 < x Initial program 57.2%
Taylor expanded in x around inf 96.9%
+-commutative96.9%
rem-square-sqrt96.9%
fabs-sqr96.9%
rem-square-sqrt96.9%
*-inverses96.9%
metadata-eval96.9%
Simplified96.9%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.20000000298023224)
(copysign x x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.20000000298023224f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.20000000298023224)) 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(-10.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.20000000298023224)) 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 -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\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 < -10Initial program 57.8%
Taylor expanded in x around -inf 99.7%
mul-1-neg99.7%
distribute-rgt-neg-in99.7%
mul-1-neg99.7%
unsub-neg99.7%
sub-neg99.7%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt8.2%
associate-*r/8.2%
metadata-eval8.2%
distribute-neg-frac8.2%
metadata-eval8.2%
Simplified8.2%
Taylor expanded in x around 0 99.2%
if -10 < x < 0.200000003Initial program 22.0%
Taylor expanded in x around 0 19.1%
log1p-define94.0%
rem-square-sqrt46.9%
fabs-sqr46.9%
rem-square-sqrt93.9%
Simplified93.9%
Taylor expanded in x around 0 97.8%
if 0.200000003 < x Initial program 57.2%
Taylor expanded in x around inf 96.9%
+-commutative96.9%
rem-square-sqrt96.9%
fabs-sqr96.9%
rem-square-sqrt96.9%
*-inverses96.9%
metadata-eval96.9%
Simplified96.9%
(FPCore (x) :precision binary32 (if (<= x 0.20000000298023224) (copysign x x) (copysign (log (* x 2.0)) x)))
float code(float x) {
float tmp;
if (x <= 0.20000000298023224f) {
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.20000000298023224)) 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.20000000298023224)) 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.20000000298023224:\\
\;\;\;\;\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.200000003Initial program 31.8%
Taylor expanded in x around 0 26.0%
log1p-define80.4%
rem-square-sqrt34.0%
fabs-sqr34.0%
rem-square-sqrt68.2%
Simplified68.2%
Taylor expanded in x around 0 74.0%
if 0.200000003 < x Initial program 57.2%
Taylor expanded in x around inf 96.9%
+-commutative96.9%
rem-square-sqrt96.9%
fabs-sqr96.9%
rem-square-sqrt96.9%
*-inverses96.9%
metadata-eval96.9%
Simplified96.9%
(FPCore (x) :precision binary32 (if (<= x 0.20000000298023224) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 0.20000000298023224f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.20000000298023224)) 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.20000000298023224:\\
\;\;\;\;\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.200000003Initial program 31.8%
Taylor expanded in x around 0 26.0%
log1p-define80.4%
rem-square-sqrt34.0%
fabs-sqr34.0%
rem-square-sqrt68.2%
Simplified68.2%
Taylor expanded in x around 0 74.0%
if 0.200000003 < x Initial program 57.2%
Taylor expanded in x around 0 43.9%
log1p-define43.9%
rem-square-sqrt43.9%
fabs-sqr43.9%
rem-square-sqrt43.9%
Simplified43.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 38.7%
Taylor expanded in x around 0 30.9%
log1p-define70.4%
rem-square-sqrt36.7%
fabs-sqr36.7%
rem-square-sqrt61.5%
Simplified61.5%
Taylor expanded in x around 0 57.0%
(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 2024139
(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))