
(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 14 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
(+
(* -0.16666666666666666 (pow x 3.0))
(+ (* 0.075 (pow x 5.0)) (+ x (* -0.044642857142857144 (pow x 7.0)))))
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(((-0.16666666666666666f * powf(x, 3.0f)) + ((0.075f * powf(x, 5.0f)) + (x + (-0.044642857142857144f * powf(x, 7.0f))))), 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(Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0))) + Float32(Float32(Float32(0.075) * (x ^ Float32(5.0))) + Float32(x + Float32(Float32(-0.044642857142857144) * (x ^ Float32(7.0)))))), 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(((single(-0.16666666666666666) * (x ^ single(3.0))) + ((single(0.075) * (x ^ single(5.0))) + (x + (single(-0.044642857142857144) * (x ^ single(7.0))))))); 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(-0.16666666666666666 \cdot {x}^{3} + \left(0.075 \cdot {x}^{5} + \left(x + -0.044642857142857144 \cdot {x}^{7}\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) 1)))) x) < -0.200000003Initial program 54.6%
+-commutative54.6%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt14.2%
flip-+12.4%
log-div12.4%
add-sqr-sqrt13.2%
fma-def13.6%
+-commutative13.6%
hypot-1-def13.6%
Applied egg-rr13.6%
fma-udef13.2%
+-commutative13.2%
associate--l+51.4%
+-inverses98.5%
metadata-eval98.5%
metadata-eval98.5%
neg-sub098.5%
Simplified98.5%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.200000003Initial program 21.8%
*-un-lft-identity21.8%
*-commutative21.8%
log-prod21.8%
add-sqr-sqrt7.6%
fabs-sqr7.6%
add-sqr-sqrt22.4%
+-commutative22.4%
hypot-1-def22.5%
metadata-eval22.5%
Applied egg-rr22.5%
+-rgt-identity22.5%
Simplified22.5%
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) 1)))) x) Initial program 69.1%
*-un-lft-identity69.1%
*-commutative69.1%
log-prod69.1%
add-sqr-sqrt69.1%
fabs-sqr69.1%
add-sqr-sqrt69.1%
+-commutative69.1%
hypot-1-def99.8%
metadata-eval99.8%
Applied egg-rr99.8%
+-rgt-identity99.8%
Simplified99.8%
Final simplification99.6%
(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
(+ (* -0.16666666666666666 (pow x 3.0)) (+ x (* 0.075 (pow x 5.0))))
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(((-0.16666666666666666f * powf(x, 3.0f)) + (x + (0.075f * powf(x, 5.0f)))), 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(Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0))) + Float32(x + Float32(Float32(0.075) * (x ^ Float32(5.0))))), 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(((single(-0.16666666666666666) * (x ^ single(3.0))) + (x + (single(0.075) * (x ^ single(5.0)))))); 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(-0.16666666666666666 \cdot {x}^{3} + \left(x + 0.075 \cdot {x}^{5}\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) 1)))) x) < -0.200000003Initial program 54.6%
+-commutative54.6%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt14.2%
flip-+12.4%
log-div12.4%
add-sqr-sqrt13.2%
fma-def13.6%
+-commutative13.6%
hypot-1-def13.6%
Applied egg-rr13.6%
fma-udef13.2%
+-commutative13.2%
associate--l+51.4%
+-inverses98.5%
metadata-eval98.5%
metadata-eval98.5%
neg-sub098.5%
Simplified98.5%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.200000003Initial program 21.8%
*-un-lft-identity21.8%
*-commutative21.8%
log-prod21.8%
add-sqr-sqrt7.6%
fabs-sqr7.6%
add-sqr-sqrt22.4%
+-commutative22.4%
hypot-1-def22.5%
metadata-eval22.5%
Applied egg-rr22.5%
+-rgt-identity22.5%
Simplified22.5%
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) 1)))) x) Initial program 69.1%
*-un-lft-identity69.1%
*-commutative69.1%
log-prod69.1%
add-sqr-sqrt69.1%
fabs-sqr69.1%
add-sqr-sqrt69.1%
+-commutative69.1%
hypot-1-def99.8%
metadata-eval99.8%
Applied egg-rr99.8%
+-rgt-identity99.8%
Simplified99.8%
Final simplification99.5%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (- (log (- (* x -2.0) (/ 0.5 x)))) x)
(if (<= x 0.0010000000474974513)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(-logf(((x * -2.0f) - (0.5f / x))), x);
} else if (x <= 0.0010000000474974513f) {
tmp = copysignf((x * (1.0f + ((x * x) * -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(-5.0)) tmp = copysign(Float32(-log(Float32(Float32(x * Float32(-2.0)) - Float32(Float32(0.5) / x)))), x); elseif (x <= Float32(0.0010000000474974513)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * 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(-5.0)) tmp = sign(x) * abs(-log(((x * single(-2.0)) - (single(0.5) / x)))); elseif (x <= single(0.0010000000474974513)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * 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 -5:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2 - \frac{0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.0010000000474974513:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\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 < -5Initial program 54.0%
+-commutative54.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.9%
flip-+11.2%
log-div11.2%
add-sqr-sqrt11.9%
fma-def12.3%
+-commutative12.3%
hypot-1-def12.3%
Applied egg-rr12.3%
fma-udef11.9%
+-commutative11.9%
associate--l+50.8%
+-inverses98.6%
metadata-eval98.6%
metadata-eval98.6%
neg-sub098.6%
Simplified98.6%
Taylor expanded in x around -inf 97.6%
*-commutative97.6%
associate-*r/97.6%
metadata-eval97.6%
Simplified97.6%
if -5 < x < 0.00100000005Initial program 21.3%
*-un-lft-identity21.3%
*-commutative21.3%
log-prod21.3%
add-sqr-sqrt6.2%
fabs-sqr6.2%
add-sqr-sqrt21.9%
+-commutative21.9%
hypot-1-def21.9%
metadata-eval21.9%
Applied egg-rr21.9%
+-rgt-identity21.9%
Simplified21.9%
Taylor expanded in x around 0 99.7%
unpow399.7%
associate-*r*99.7%
fma-def99.7%
Applied egg-rr99.7%
fma-udef99.7%
distribute-lft1-in99.7%
Applied egg-rr99.7%
if 0.00100000005 < x Initial program 69.7%
*-un-lft-identity69.7%
*-commutative69.7%
log-prod69.7%
add-sqr-sqrt69.7%
fabs-sqr69.7%
add-sqr-sqrt69.7%
+-commutative69.7%
hypot-1-def99.6%
metadata-eval99.6%
Applied egg-rr99.6%
+-rgt-identity99.6%
Simplified99.6%
Final simplification99.1%
(FPCore (x)
:precision binary32
(if (<= x -0.20000000298023224)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.0010000000474974513)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) 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.0010000000474974513f) {
tmp = copysignf((x * (1.0f + ((x * x) * -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.20000000298023224)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.0010000000474974513)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * 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.20000000298023224)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (x <= single(0.0010000000474974513)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * 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.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.0010000000474974513:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\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.200000003Initial program 54.6%
+-commutative54.6%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt14.2%
flip-+12.4%
log-div12.4%
add-sqr-sqrt13.2%
fma-def13.6%
+-commutative13.6%
hypot-1-def13.6%
Applied egg-rr13.6%
fma-udef13.2%
+-commutative13.2%
associate--l+51.4%
+-inverses98.5%
metadata-eval98.5%
metadata-eval98.5%
neg-sub098.5%
Simplified98.5%
if -0.200000003 < x < 0.00100000005Initial program 20.6%
*-un-lft-identity20.6%
*-commutative20.6%
log-prod20.6%
add-sqr-sqrt6.3%
fabs-sqr6.3%
add-sqr-sqrt21.3%
+-commutative21.3%
hypot-1-def21.3%
metadata-eval21.3%
Applied egg-rr21.3%
+-rgt-identity21.3%
Simplified21.3%
Taylor expanded in x around 0 100.0%
unpow3100.0%
associate-*r*100.0%
fma-def100.0%
Applied egg-rr100.0%
fma-udef100.0%
distribute-lft1-in100.0%
Applied egg-rr100.0%
if 0.00100000005 < x Initial program 69.7%
*-un-lft-identity69.7%
*-commutative69.7%
log-prod69.7%
add-sqr-sqrt69.7%
fabs-sqr69.7%
add-sqr-sqrt69.7%
+-commutative69.7%
hypot-1-def99.6%
metadata-eval99.6%
Applied egg-rr99.6%
+-rgt-identity99.6%
Simplified99.6%
Final simplification99.5%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (log (+ (/ 0.5 x) (+ x x))) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
} else {
tmp = copysignf(logf(((0.5f / x) + (x + x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), x); else tmp = copysign(log(Float32(Float32(Float32(0.5) / x) + Float32(x + x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-5.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * single(-0.16666666666666666))))); else tmp = sign(x) * abs(log(((single(0.5) / x) + (x + x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(x + x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 54.0%
*-un-lft-identity54.0%
*-commutative54.0%
log-prod54.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.9%
+-commutative12.9%
hypot-1-def12.9%
metadata-eval12.9%
Applied egg-rr12.9%
+-rgt-identity12.9%
Simplified12.9%
Taylor expanded in x around -inf 97.4%
if -5 < x < 1Initial program 24.7%
*-un-lft-identity24.7%
*-commutative24.7%
log-prod24.7%
add-sqr-sqrt10.4%
fabs-sqr10.4%
add-sqr-sqrt25.3%
+-commutative25.3%
hypot-1-def25.4%
metadata-eval25.4%
Applied egg-rr25.4%
+-rgt-identity25.4%
Simplified25.4%
Taylor expanded in x around 0 97.9%
unpow397.9%
associate-*r*97.9%
fma-def97.9%
Applied egg-rr97.9%
fma-udef97.9%
distribute-lft1-in97.9%
Applied egg-rr97.9%
if 1 < x Initial program 67.3%
Taylor expanded in x around inf 98.1%
associate-*r/98.1%
metadata-eval98.1%
rem-square-sqrt98.1%
fabs-sqr98.1%
rem-square-sqrt98.1%
Simplified98.1%
Final simplification97.8%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (- (log (- (* x -2.0) (/ 0.5 x)))) x)
(if (<= x 1.0)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (log (+ (/ 0.5 x) (+ x x))) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(-logf(((x * -2.0f) - (0.5f / x))), x);
} else if (x <= 1.0f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
} else {
tmp = copysignf(logf(((0.5f / x) + (x + x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(Float32(-log(Float32(Float32(x * Float32(-2.0)) - Float32(Float32(0.5) / x)))), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), x); else tmp = copysign(log(Float32(Float32(Float32(0.5) / x) + Float32(x + x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-5.0)) tmp = sign(x) * abs(-log(((x * single(-2.0)) - (single(0.5) / x)))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * single(-0.16666666666666666))))); else tmp = sign(x) * abs(log(((single(0.5) / x) + (x + x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2 - \frac{0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(x + x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 54.0%
+-commutative54.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.9%
flip-+11.2%
log-div11.2%
add-sqr-sqrt11.9%
fma-def12.3%
+-commutative12.3%
hypot-1-def12.3%
Applied egg-rr12.3%
fma-udef11.9%
+-commutative11.9%
associate--l+50.8%
+-inverses98.6%
metadata-eval98.6%
metadata-eval98.6%
neg-sub098.6%
Simplified98.6%
Taylor expanded in x around -inf 97.6%
*-commutative97.6%
associate-*r/97.6%
metadata-eval97.6%
Simplified97.6%
if -5 < x < 1Initial program 24.7%
*-un-lft-identity24.7%
*-commutative24.7%
log-prod24.7%
add-sqr-sqrt10.4%
fabs-sqr10.4%
add-sqr-sqrt25.3%
+-commutative25.3%
hypot-1-def25.4%
metadata-eval25.4%
Applied egg-rr25.4%
+-rgt-identity25.4%
Simplified25.4%
Taylor expanded in x around 0 97.9%
unpow397.9%
associate-*r*97.9%
fma-def97.9%
Applied egg-rr97.9%
fma-udef97.9%
distribute-lft1-in97.9%
Applied egg-rr97.9%
if 1 < x Initial program 67.3%
Taylor expanded in x around inf 98.1%
associate-*r/98.1%
metadata-eval98.1%
rem-square-sqrt98.1%
fabs-sqr98.1%
rem-square-sqrt98.1%
Simplified98.1%
Final simplification97.9%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign 15.333333333333334 x)
(if (<= x 1.0)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(15.333333333333334f, x);
} else if (x <= 1.0f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(Float32(15.333333333333334), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), x); else tmp = copysign(log(Float32(x + x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-5.0)) tmp = sign(x) * abs(single(15.333333333333334)); elseif (x <= single(1.0)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * single(-0.16666666666666666))))); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(15.333333333333334, x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 54.0%
Taylor expanded in x around inf -0.0%
associate-*r/-0.0%
metadata-eval-0.0%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt-0.0%
Simplified-0.0%
Taylor expanded in x around 0 -0.0%
Simplified26.8%
if -5 < x < 1Initial program 24.7%
*-un-lft-identity24.7%
*-commutative24.7%
log-prod24.7%
add-sqr-sqrt10.4%
fabs-sqr10.4%
add-sqr-sqrt25.3%
+-commutative25.3%
hypot-1-def25.4%
metadata-eval25.4%
Applied egg-rr25.4%
+-rgt-identity25.4%
Simplified25.4%
Taylor expanded in x around 0 97.9%
unpow397.9%
associate-*r*97.9%
fma-def97.9%
Applied egg-rr97.9%
fma-udef97.9%
distribute-lft1-in97.9%
Applied egg-rr97.9%
if 1 < x Initial program 67.3%
Taylor expanded in x around inf 96.6%
rem-square-sqrt96.6%
fabs-sqr96.6%
rem-square-sqrt96.6%
Simplified96.6%
Final simplification79.5%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), x); else tmp = copysign(log(Float32(x + x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-5.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * single(-0.16666666666666666))))); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 54.0%
*-un-lft-identity54.0%
*-commutative54.0%
log-prod54.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.9%
+-commutative12.9%
hypot-1-def12.9%
metadata-eval12.9%
Applied egg-rr12.9%
+-rgt-identity12.9%
Simplified12.9%
Taylor expanded in x around -inf 97.4%
if -5 < x < 1Initial program 24.7%
*-un-lft-identity24.7%
*-commutative24.7%
log-prod24.7%
add-sqr-sqrt10.4%
fabs-sqr10.4%
add-sqr-sqrt25.3%
+-commutative25.3%
hypot-1-def25.4%
metadata-eval25.4%
Applied egg-rr25.4%
+-rgt-identity25.4%
Simplified25.4%
Taylor expanded in x around 0 97.9%
unpow397.9%
associate-*r*97.9%
fma-def97.9%
Applied egg-rr97.9%
fma-udef97.9%
distribute-lft1-in97.9%
Applied egg-rr97.9%
if 1 < x Initial program 67.3%
Taylor expanded in x around inf 96.6%
rem-square-sqrt96.6%
fabs-sqr96.6%
rem-square-sqrt96.6%
Simplified96.6%
Final simplification97.4%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign 15.333333333333334 x)
(if (<= x 2.0)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (log x) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(15.333333333333334f, x);
} else if (x <= 2.0f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
} else {
tmp = copysignf(logf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(Float32(15.333333333333334), x); elseif (x <= Float32(2.0)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), x); else tmp = copysign(log(x), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-5.0)) tmp = sign(x) * abs(single(15.333333333333334)); elseif (x <= single(2.0)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * single(-0.16666666666666666))))); else tmp = sign(x) * abs(log(x)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(15.333333333333334, x\right)\\
\mathbf{elif}\;x \leq 2:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\end{array}
if x < -5Initial program 54.0%
Taylor expanded in x around inf -0.0%
associate-*r/-0.0%
metadata-eval-0.0%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt-0.0%
Simplified-0.0%
Taylor expanded in x around 0 -0.0%
Simplified26.8%
if -5 < x < 2Initial program 25.9%
*-un-lft-identity25.9%
*-commutative25.9%
log-prod25.9%
add-sqr-sqrt11.8%
fabs-sqr11.8%
add-sqr-sqrt26.5%
+-commutative26.5%
hypot-1-def26.5%
metadata-eval26.5%
Applied egg-rr26.5%
+-rgt-identity26.5%
Simplified26.5%
Taylor expanded in x around 0 96.9%
unpow396.9%
associate-*r*96.9%
fma-def96.9%
Applied egg-rr96.9%
fma-udef96.9%
distribute-lft1-in96.9%
Applied egg-rr96.9%
if 2 < x Initial program 66.3%
Taylor expanded in x around inf 43.5%
mul-1-neg43.5%
log-rec43.5%
remove-double-neg43.5%
Simplified43.5%
Final simplification66.4%
(FPCore (x) :precision binary32 (if (<= x -5.0) (copysign 15.333333333333334 x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(15.333333333333334f, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(Float32(15.333333333333334), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(15.333333333333334, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 54.0%
Taylor expanded in x around inf -0.0%
associate-*r/-0.0%
metadata-eval-0.0%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt-0.0%
Simplified-0.0%
Taylor expanded in x around 0 -0.0%
Simplified26.8%
if -5 < x Initial program 38.8%
Taylor expanded in x around 0 27.8%
log1p-def76.0%
rem-square-sqrt38.1%
fabs-sqr38.1%
rem-square-sqrt76.0%
Simplified76.0%
Final simplification63.5%
(FPCore (x) :precision binary32 (if (or (<= x -5.0) (not (<= x 2.0))) (copysign 15.333333333333334 x) (copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)))
float code(float x) {
float tmp;
if ((x <= -5.0f) || !(x <= 2.0f)) {
tmp = copysignf(15.333333333333334f, x);
} else {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if ((x <= Float32(-5.0)) || !(x <= Float32(2.0))) tmp = copysign(Float32(15.333333333333334), x); else tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if ((x <= single(-5.0)) || ~((x <= single(2.0)))) tmp = sign(x) * abs(single(15.333333333333334)); else tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * single(-0.16666666666666666))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \lor \neg \left(x \leq 2\right):\\
\;\;\;\;\mathsf{copysign}\left(15.333333333333334, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\
\end{array}
\end{array}
if x < -5 or 2 < x Initial program 59.9%
Taylor expanded in x around inf 48.2%
associate-*r/48.2%
metadata-eval48.2%
rem-square-sqrt48.2%
fabs-sqr48.2%
rem-square-sqrt48.2%
Simplified48.2%
Taylor expanded in x around 0 1.0%
Simplified27.2%
if -5 < x < 2Initial program 25.9%
*-un-lft-identity25.9%
*-commutative25.9%
log-prod25.9%
add-sqr-sqrt11.8%
fabs-sqr11.8%
add-sqr-sqrt26.5%
+-commutative26.5%
hypot-1-def26.5%
metadata-eval26.5%
Applied egg-rr26.5%
+-rgt-identity26.5%
Simplified26.5%
Taylor expanded in x around 0 96.9%
unpow396.9%
associate-*r*96.9%
fma-def96.9%
Applied egg-rr96.9%
fma-udef96.9%
distribute-lft1-in96.9%
Applied egg-rr96.9%
Final simplification62.6%
(FPCore (x) :precision binary32 (if (<= x -100.0) (copysign 15.333333333333334 x) (if (<= x 10.0) (copysign x x) (copysign 15.333333333333334 x))))
float code(float x) {
float tmp;
if (x <= -100.0f) {
tmp = copysignf(15.333333333333334f, x);
} else if (x <= 10.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(15.333333333333334f, x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-100.0)) tmp = copysign(Float32(15.333333333333334), x); elseif (x <= Float32(10.0)) tmp = copysign(x, x); else tmp = copysign(Float32(15.333333333333334), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-100.0)) tmp = sign(x) * abs(single(15.333333333333334)); elseif (x <= single(10.0)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(single(15.333333333333334)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -100:\\
\;\;\;\;\mathsf{copysign}\left(15.333333333333334, x\right)\\
\mathbf{elif}\;x \leq 10:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(15.333333333333334, x\right)\\
\end{array}
\end{array}
if x < -100 or 10 < x Initial program 58.6%
Taylor expanded in x around inf 49.2%
associate-*r/49.2%
metadata-eval49.2%
rem-square-sqrt49.2%
fabs-sqr49.2%
rem-square-sqrt49.2%
Simplified49.2%
Taylor expanded in x around 0 0.9%
Simplified27.3%
if -100 < x < 10Initial program 28.1%
*-un-lft-identity28.1%
*-commutative28.1%
log-prod28.1%
add-sqr-sqrt12.2%
fabs-sqr12.2%
add-sqr-sqrt28.4%
+-commutative28.4%
hypot-1-def28.5%
metadata-eval28.5%
Applied egg-rr28.5%
+-rgt-identity28.5%
Simplified28.5%
Taylor expanded in x around 0 93.2%
Final simplification61.8%
(FPCore (x) :precision binary32 (copysign -6.0 x))
float code(float x) {
return copysignf(-6.0f, x);
}
function code(x) return copysign(Float32(-6.0), x) end
function tmp = code(x) tmp = sign(x) * abs(single(-6.0)); end
\begin{array}{l}
\\
\mathsf{copysign}\left(-6, x\right)
\end{array}
Initial program 42.6%
Taylor expanded in x around inf 26.4%
associate-*r/26.4%
metadata-eval26.4%
rem-square-sqrt26.4%
fabs-sqr26.4%
rem-square-sqrt26.4%
Simplified26.4%
Taylor expanded in x around 0 3.6%
Simplified17.8%
Final simplification17.8%
(FPCore (x) :precision binary32 (copysign 15.333333333333334 x))
float code(float x) {
return copysignf(15.333333333333334f, x);
}
function code(x) return copysign(Float32(15.333333333333334), x) end
function tmp = code(x) tmp = sign(x) * abs(single(15.333333333333334)); end
\begin{array}{l}
\\
\mathsf{copysign}\left(15.333333333333334, x\right)
\end{array}
Initial program 42.6%
Taylor expanded in x around inf 26.4%
associate-*r/26.4%
metadata-eval26.4%
rem-square-sqrt26.4%
fabs-sqr26.4%
rem-square-sqrt26.4%
Simplified26.4%
Taylor expanded in x around 0 2.8%
Simplified18.8%
Final simplification18.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 2023201
(FPCore (x)
:name "Rust f32::asinh"
:precision binary32
:herbie-target
(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))