
(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 10 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.05000000074505806)
(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.5f) {
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 + (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.5)) 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(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.5)) 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) + ((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.5:\\
\;\;\;\;\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 \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.5Initial program 45.0%
flip-+6.0%
clear-num6.1%
log-div6.1%
metadata-eval6.1%
+-commutative6.1%
hypot-1-def6.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt6.6%
Applied egg-rr7.3%
neg-sub07.3%
div-sub7.3%
*-rgt-identity7.3%
associate-/l*7.3%
fma-undefine7.2%
unpow27.2%
associate--r+7.3%
+-inverses7.3%
metadata-eval7.3%
metadata-eval7.3%
*-commutative7.3%
neg-mul-17.3%
neg-sub07.3%
*-rgt-identity7.3%
associate-/l*7.3%
fma-undefine7.3%
unpow27.3%
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.0500000007Initial program 21.5%
add-cube-cbrt20.4%
pow320.4%
log-pow20.3%
+-commutative20.3%
hypot-1-def20.3%
add-sqr-sqrt9.3%
fabs-sqr9.3%
add-sqr-sqrt21.2%
Applied egg-rr21.2%
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 53.2%
Taylor expanded in x around 0 53.2%
rem-square-sqrt53.1%
fabs-sqr53.1%
metadata-eval53.1%
unpow253.1%
hypot-undefine99.9%
rem-square-sqrt99.9%
Simplified99.9%
Final simplification100.0%
(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.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 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.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) 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.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) 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.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}
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.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 (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < -0.5Initial program 45.0%
flip-+6.0%
clear-num6.1%
log-div6.1%
metadata-eval6.1%
+-commutative6.1%
hypot-1-def6.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt6.6%
Applied egg-rr7.3%
neg-sub07.3%
div-sub7.3%
*-rgt-identity7.3%
associate-/l*7.3%
fma-undefine7.2%
unpow27.2%
associate--r+7.3%
+-inverses7.3%
metadata-eval7.3%
metadata-eval7.3%
*-commutative7.3%
neg-mul-17.3%
neg-sub07.3%
*-rgt-identity7.3%
associate-/l*7.3%
fma-undefine7.3%
unpow27.3%
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.0500000007Initial program 21.5%
add-cube-cbrt20.4%
pow320.4%
log-pow20.3%
+-commutative20.3%
hypot-1-def20.3%
add-sqr-sqrt9.3%
fabs-sqr9.3%
add-sqr-sqrt21.2%
Applied egg-rr21.2%
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 53.2%
Taylor expanded in x around 0 53.2%
rem-square-sqrt53.1%
fabs-sqr53.1%
metadata-eval53.1%
unpow253.1%
hypot-undefine99.9%
rem-square-sqrt99.9%
Simplified99.9%
Final simplification100.0%
(FPCore (x)
:precision binary32
(if (<= x -0.05000000074505806)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.05000000074505806)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -0.05000000074505806f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.05000000074505806f) {
tmp = copysignf((x + (powf(x, 3.0f) * -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.05000000074505806)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.05000000074505806)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * 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.05000000074505806)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (x <= single(0.05000000074505806)) tmp = sign(x) * abs((x + ((x ^ single(3.0)) * 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.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, 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 46.4%
flip-+8.3%
clear-num8.4%
log-div8.4%
metadata-eval8.4%
+-commutative8.4%
hypot-1-def8.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.0%
Applied egg-rr9.8%
neg-sub09.8%
div-sub9.8%
*-rgt-identity9.8%
associate-/l*9.8%
fma-undefine9.7%
unpow29.7%
associate--r+9.8%
+-inverses9.8%
metadata-eval9.8%
metadata-eval9.8%
*-commutative9.8%
neg-mul-19.8%
neg-sub09.8%
*-rgt-identity9.8%
associate-/l*9.8%
fma-undefine9.8%
unpow29.8%
Simplified99.9%
if -0.0500000007 < x < 0.0500000007Initial program 20.3%
add-cube-cbrt19.4%
pow319.3%
log-pow19.2%
+-commutative19.2%
hypot-1-def19.3%
add-sqr-sqrt9.4%
fabs-sqr9.4%
add-sqr-sqrt20.1%
Applied egg-rr20.1%
Taylor expanded in x around 0 100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
*-commutative100.0%
associate-*r*100.0%
unpow2100.0%
cube-mult100.0%
Simplified100.0%
if 0.0500000007 < x Initial program 53.2%
Taylor expanded in x around 0 53.2%
rem-square-sqrt53.1%
fabs-sqr53.1%
metadata-eval53.1%
unpow253.1%
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.05000000074505806)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) 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.05000000074505806f) {
tmp = copysignf((x + (powf(x, 3.0f) * -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(-10.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.05000000074505806)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * 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(-10.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.05000000074505806)) tmp = sign(x) * abs((x + ((x ^ single(3.0)) * 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 -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, 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 43.3%
Taylor expanded in x around -inf 99.8%
mul-1-neg99.8%
*-commutative99.8%
distribute-rgt-neg-in99.8%
mul-1-neg99.8%
unsub-neg99.8%
sub-neg99.8%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt9.2%
associate-*r/9.2%
metadata-eval9.2%
distribute-neg-frac9.2%
metadata-eval9.2%
Simplified9.2%
Taylor expanded in x around 0 98.9%
if -10 < x < 0.0500000007Initial program 22.7%
add-cube-cbrt21.6%
pow321.5%
log-pow21.5%
+-commutative21.5%
hypot-1-def21.5%
add-sqr-sqrt9.1%
fabs-sqr9.1%
add-sqr-sqrt22.3%
Applied egg-rr22.3%
Taylor expanded in x around 0 98.9%
distribute-lft-in98.9%
*-rgt-identity98.9%
*-commutative98.9%
associate-*r*98.9%
unpow298.9%
cube-mult98.9%
Simplified98.9%
if 0.0500000007 < x Initial program 53.2%
Taylor expanded in x around 0 53.2%
rem-square-sqrt53.1%
fabs-sqr53.1%
metadata-eval53.1%
unpow253.1%
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 (* (pow x 3.0) -0.16666666666666666)) 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 + (powf(x, 3.0f) * -0.16666666666666666f)), 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((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), 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 + ((x ^ single(3.0)) * single(-0.16666666666666666)))); 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}^{3} \cdot -0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 43.3%
Taylor expanded in x around -inf 99.8%
mul-1-neg99.8%
*-commutative99.8%
distribute-rgt-neg-in99.8%
mul-1-neg99.8%
unsub-neg99.8%
sub-neg99.8%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt9.2%
associate-*r/9.2%
metadata-eval9.2%
distribute-neg-frac9.2%
metadata-eval9.2%
Simplified9.2%
Taylor expanded in x around 0 98.9%
if -10 < x < 0.200000003Initial program 23.3%
add-cube-cbrt22.1%
pow322.1%
log-pow22.1%
+-commutative22.1%
hypot-1-def22.1%
add-sqr-sqrt9.8%
fabs-sqr9.8%
add-sqr-sqrt22.9%
Applied egg-rr22.9%
Taylor expanded in x around 0 98.7%
distribute-lft-in98.7%
*-rgt-identity98.7%
*-commutative98.7%
associate-*r*98.7%
unpow298.7%
cube-mult98.7%
Simplified98.7%
if 0.200000003 < x Initial program 52.4%
Taylor expanded in x around inf 95.8%
+-commutative95.8%
rem-square-sqrt95.8%
fabs-sqr95.8%
rem-square-sqrt95.8%
*-inverses95.8%
metadata-eval95.8%
Simplified95.8%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.20000000298023224)
(copysign
(* 3.0 (* x (+ 0.3333333333333333 (* (* x x) -0.05555555555555555))))
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((3.0f * (x * (0.3333333333333333f + ((x * x) * -0.05555555555555555f)))), 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(Float32(3.0) * Float32(x * Float32(Float32(0.3333333333333333) + Float32(Float32(x * x) * Float32(-0.05555555555555555))))), 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((single(3.0) * (x * (single(0.3333333333333333) + ((x * x) * single(-0.05555555555555555)))))); 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(3 \cdot \left(x \cdot \left(0.3333333333333333 + \left(x \cdot x\right) \cdot -0.05555555555555555\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 43.3%
Taylor expanded in x around -inf 99.8%
mul-1-neg99.8%
*-commutative99.8%
distribute-rgt-neg-in99.8%
mul-1-neg99.8%
unsub-neg99.8%
sub-neg99.8%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt9.2%
associate-*r/9.2%
metadata-eval9.2%
distribute-neg-frac9.2%
metadata-eval9.2%
Simplified9.2%
Taylor expanded in x around 0 98.9%
if -10 < x < 0.200000003Initial program 23.3%
add-cube-cbrt22.1%
pow322.1%
log-pow22.1%
+-commutative22.1%
hypot-1-def22.1%
add-sqr-sqrt9.8%
fabs-sqr9.8%
add-sqr-sqrt22.9%
Applied egg-rr22.9%
Taylor expanded in x around 0 97.5%
*-commutative97.5%
Simplified97.5%
unpow297.5%
Applied egg-rr97.5%
if 0.200000003 < x Initial program 52.4%
Taylor expanded in x around inf 95.8%
+-commutative95.8%
rem-square-sqrt95.8%
fabs-sqr95.8%
rem-square-sqrt95.8%
*-inverses95.8%
metadata-eval95.8%
Simplified95.8%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (log (- x)) x)
(if (<= x 0.20000000298023224)
(copysign
(* 3.0 (* x (+ 0.3333333333333333 (* (* x x) -0.05555555555555555))))
x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf(-x), x);
} else if (x <= 0.20000000298023224f) {
tmp = copysignf((3.0f * (x * (0.3333333333333333f + ((x * x) * -0.05555555555555555f)))), 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(-x)), x); elseif (x <= Float32(0.20000000298023224)) tmp = copysign(Float32(Float32(3.0) * Float32(x * Float32(Float32(0.3333333333333333) + Float32(Float32(x * x) * Float32(-0.05555555555555555))))), 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(-x)); elseif (x <= single(0.20000000298023224)) tmp = sign(x) * abs((single(3.0) * (x * (single(0.3333333333333333) + ((x * x) * single(-0.05555555555555555)))))); 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(-x\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(3 \cdot \left(x \cdot \left(0.3333333333333333 + \left(x \cdot x\right) \cdot -0.05555555555555555\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 43.3%
Taylor expanded in x around -inf 45.1%
neg-mul-145.1%
Simplified45.1%
if -10 < x < 0.200000003Initial program 23.3%
add-cube-cbrt22.1%
pow322.1%
log-pow22.1%
+-commutative22.1%
hypot-1-def22.1%
add-sqr-sqrt9.8%
fabs-sqr9.8%
add-sqr-sqrt22.9%
Applied egg-rr22.9%
Taylor expanded in x around 0 97.5%
*-commutative97.5%
Simplified97.5%
unpow297.5%
Applied egg-rr97.5%
if 0.200000003 < x Initial program 52.4%
Taylor expanded in x around inf 95.8%
+-commutative95.8%
rem-square-sqrt95.8%
fabs-sqr95.8%
rem-square-sqrt95.8%
*-inverses95.8%
metadata-eval95.8%
Simplified95.8%
(FPCore (x) :precision binary32 (if (<= x -10.0) (copysign (log (- x)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf(-x), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.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 -10:\\
\;\;\;\;\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 < -10Initial program 43.3%
Taylor expanded in x around -inf 45.1%
neg-mul-145.1%
Simplified45.1%
if -10 < x Initial program 32.0%
Taylor expanded in x around 0 26.5%
log1p-define78.5%
rem-square-sqrt44.1%
fabs-sqr44.1%
rem-square-sqrt78.4%
Simplified78.4%
(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 29.9%
Taylor expanded in x around 0 27.8%
log1p-define77.4%
rem-square-sqrt29.6%
fabs-sqr29.6%
rem-square-sqrt62.4%
Simplified62.4%
Taylor expanded in x around 0 68.0%
if 0.200000003 < x Initial program 52.4%
Taylor expanded in x around 0 43.7%
log1p-define43.7%
rem-square-sqrt43.7%
fabs-sqr43.7%
rem-square-sqrt43.7%
Simplified43.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 34.9%
Taylor expanded in x around 0 31.3%
log1p-define69.9%
rem-square-sqrt32.7%
fabs-sqr32.7%
rem-square-sqrt58.2%
Simplified58.2%
Taylor expanded in x around 0 55.5%
(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 2024158
(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))