| Alternative 1 | |
|---|---|
| Accuracy | 99.5% |
| Cost | 9960 |

(FPCore (x) :precision binary32 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
(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.10000000149011612)
(copysign
(+ (* -0.16666666666666666 (pow x 3.0)) (+ x (* 0.075 (pow x 5.0))))
x)
(copysign (log1p (+ (+ x (hypot 1.0 x)) -1.0)) x)))))float code(float x) {
return copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), 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.10000000149011612f) {
tmp = copysignf(((-0.16666666666666666f * powf(x, 3.0f)) + (x + (0.075f * powf(x, 5.0f)))), x);
} else {
tmp = copysignf(log1pf(((x + hypotf(1.0f, x)) + -1.0f)), x);
}
return tmp;
}
function code(x) return copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) end
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.10000000149011612)) 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(log1p(Float32(Float32(x + hypot(Float32(1.0), x)) + Float32(-1.0))), x); end return tmp end
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\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.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot {x}^{3} + \left(x + 0.075 \cdot {x}^{5}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left(x + \mathsf{hypot}\left(1, x\right)\right) + -1\right), x\right)\\
\end{array}
| Original | 36.8% |
|---|---|
| Target | 99.6% |
| Herbie | 99.6% |
if (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < -0.200000003Initial program 61.3%
Simplified100.0%
[Start]61.3 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\] |
|---|---|
+-commutative [=>]61.3 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right), x\right)
\] |
hypot-1-def [=>]100.0 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
Applied egg-rr15.7%
[Start]100.0 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)
\] |
|---|---|
flip-+ [=>]12.7 | \[ \mathsf{copysign}\left(\log \color{blue}{\left(\frac{\left|x\right| \cdot \left|x\right| - \mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right)}, x\right)
\] |
div-sub [=>]13.1 | \[ \mathsf{copysign}\left(\log \color{blue}{\left(\frac{\left|x\right| \cdot \left|x\right|}{\left|x\right| - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right)}, x\right)
\] |
pow2 [=>]13.1 | \[ \mathsf{copysign}\left(\log \left(\frac{\color{blue}{{\left(\left|x\right|\right)}^{2}}}{\left|x\right| - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
add-sqr-sqrt [=>]-0.0 | \[ \mathsf{copysign}\left(\log \left(\frac{{\left(\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right|\right)}^{2}}{\left|x\right| - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
fabs-sqr [=>]-0.0 | \[ \mathsf{copysign}\left(\log \left(\frac{{\color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right)}}^{2}}{\left|x\right| - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
add-sqr-sqrt [<=]13.1 | \[ \mathsf{copysign}\left(\log \left(\frac{{\color{blue}{x}}^{2}}{\left|x\right| - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
pow2 [<=]13.1 | \[ \mathsf{copysign}\left(\log \left(\frac{\color{blue}{x \cdot x}}{\left|x\right| - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
add-sqr-sqrt [=>]-0.0 | \[ \mathsf{copysign}\left(\log \left(\frac{x \cdot x}{\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
fabs-sqr [=>]-0.0 | \[ \mathsf{copysign}\left(\log \left(\frac{x \cdot x}{\color{blue}{\sqrt{x} \cdot \sqrt{x}} - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
add-sqr-sqrt [<=]4.6 | \[ \mathsf{copysign}\left(\log \left(\frac{x \cdot x}{\color{blue}{x} - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
hypot-udef [=>]4.6 | \[ \mathsf{copysign}\left(\log \left(\frac{x \cdot x}{x - \mathsf{hypot}\left(1, x\right)} - \frac{\color{blue}{\sqrt{1 \cdot 1 + x \cdot x}} \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
hypot-udef [=>]4.6 | \[ \mathsf{copysign}\left(\log \left(\frac{x \cdot x}{x - \mathsf{hypot}\left(1, x\right)} - \frac{\sqrt{1 \cdot 1 + x \cdot x} \cdot \color{blue}{\sqrt{1 \cdot 1 + x \cdot x}}}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
add-sqr-sqrt [<=]4.6 | \[ \mathsf{copysign}\left(\log \left(\frac{x \cdot x}{x - \mathsf{hypot}\left(1, x\right)} - \frac{\color{blue}{1 \cdot 1 + x \cdot x}}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
metadata-eval [=>]4.6 | \[ \mathsf{copysign}\left(\log \left(\frac{x \cdot x}{x - \mathsf{hypot}\left(1, x\right)} - \frac{\color{blue}{1} + x \cdot x}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
add-sqr-sqrt [=>]-0.0 | \[ \mathsf{copysign}\left(\log \left(\frac{x \cdot x}{x - \mathsf{hypot}\left(1, x\right)} - \frac{1 + x \cdot x}{\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
fabs-sqr [=>]-0.0 | \[ \mathsf{copysign}\left(\log \left(\frac{x \cdot x}{x - \mathsf{hypot}\left(1, x\right)} - \frac{1 + x \cdot x}{\color{blue}{\sqrt{x} \cdot \sqrt{x}} - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
add-sqr-sqrt [<=]15.7 | \[ \mathsf{copysign}\left(\log \left(\frac{x \cdot x}{x - \mathsf{hypot}\left(1, x\right)} - \frac{1 + x \cdot x}{\color{blue}{x} - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
Simplified99.9%
[Start]15.7 | \[ \mathsf{copysign}\left(\log \left(\frac{x \cdot x}{x - \mathsf{hypot}\left(1, x\right)} - \frac{1 + x \cdot x}{x - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
|---|---|
unpow2 [<=]15.7 | \[ \mathsf{copysign}\left(\log \left(\frac{\color{blue}{{x}^{2}}}{x - \mathsf{hypot}\left(1, x\right)} - \frac{1 + x \cdot x}{x - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
div-sub [<=]18.5 | \[ \mathsf{copysign}\left(\log \color{blue}{\left(\frac{{x}^{2} - \left(1 + x \cdot x\right)}{x - \mathsf{hypot}\left(1, x\right)}\right)}, x\right)
\] |
unpow2 [=>]18.5 | \[ \mathsf{copysign}\left(\log \left(\frac{\color{blue}{x \cdot x} - \left(1 + x \cdot x\right)}{x - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
unpow2 [<=]18.5 | \[ \mathsf{copysign}\left(\log \left(\frac{\color{blue}{{x}^{2}} - \left(1 + x \cdot x\right)}{x - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
unpow2 [<=]18.5 | \[ \mathsf{copysign}\left(\log \left(\frac{{x}^{2} - \left(1 + \color{blue}{{x}^{2}}\right)}{x - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
+-commutative [=>]18.5 | \[ \mathsf{copysign}\left(\log \left(\frac{{x}^{2} - \color{blue}{\left({x}^{2} + 1\right)}}{x - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
associate--r+ [=>]58.6 | \[ \mathsf{copysign}\left(\log \left(\frac{\color{blue}{\left({x}^{2} - {x}^{2}\right) - 1}}{x - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
+-inverses [=>]99.9 | \[ \mathsf{copysign}\left(\log \left(\frac{\color{blue}{0} - 1}{x - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
metadata-eval [=>]99.9 | \[ \mathsf{copysign}\left(\log \left(\frac{\color{blue}{-1}}{x - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
metadata-eval [<=]99.9 | \[ \mathsf{copysign}\left(\log \left(\frac{\color{blue}{\frac{1}{-1}}}{x - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
associate-/r* [<=]99.9 | \[ \mathsf{copysign}\left(\log \color{blue}{\left(\frac{1}{-1 \cdot \left(x - \mathsf{hypot}\left(1, x\right)\right)}\right)}, x\right)
\] |
neg-mul-1 [<=]99.9 | \[ \mathsf{copysign}\left(\log \left(\frac{1}{\color{blue}{-\left(x - \mathsf{hypot}\left(1, x\right)\right)}}\right), x\right)
\] |
sub-neg [=>]99.9 | \[ \mathsf{copysign}\left(\log \left(\frac{1}{-\color{blue}{\left(x + \left(-\mathsf{hypot}\left(1, x\right)\right)\right)}}\right), x\right)
\] |
+-commutative [=>]99.9 | \[ \mathsf{copysign}\left(\log \left(\frac{1}{-\color{blue}{\left(\left(-\mathsf{hypot}\left(1, x\right)\right) + x\right)}}\right), x\right)
\] |
distribute-neg-in [=>]99.9 | \[ \mathsf{copysign}\left(\log \left(\frac{1}{\color{blue}{\left(-\left(-\mathsf{hypot}\left(1, x\right)\right)\right) + \left(-x\right)}}\right), x\right)
\] |
remove-double-neg [=>]99.9 | \[ \mathsf{copysign}\left(\log \left(\frac{1}{\color{blue}{\mathsf{hypot}\left(1, x\right)} + \left(-x\right)}\right), x\right)
\] |
sub-neg [<=]99.9 | \[ \mathsf{copysign}\left(\log \left(\frac{1}{\color{blue}{\mathsf{hypot}\left(1, x\right) - x}}\right), x\right)
\] |
Applied egg-rr100.0%
[Start]99.9 | \[ \mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)
\] |
|---|---|
log-div [=>]100.0 | \[ \mathsf{copysign}\left(\color{blue}{\log 1 - \log \left(\mathsf{hypot}\left(1, x\right) - x\right)}, x\right)
\] |
sub-neg [=>]100.0 | \[ \mathsf{copysign}\left(\color{blue}{\log 1 + \left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right)\right)}, x\right)
\] |
metadata-eval [=>]100.0 | \[ \mathsf{copysign}\left(\color{blue}{0} + \left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right)\right), x\right)
\] |
Simplified100.0%
[Start]100.0 | \[ \mathsf{copysign}\left(0 + \left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right)\right), x\right)
\] |
|---|---|
+-lft-identity [=>]100.0 | \[ \mathsf{copysign}\left(\color{blue}{-\log \left(\mathsf{hypot}\left(1, x\right) - x\right)}, x\right)
\] |
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.100000001Initial program 22.2%
Simplified22.2%
[Start]22.2 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\] |
|---|---|
+-commutative [=>]22.2 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right), x\right)
\] |
hypot-1-def [=>]22.2 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
Applied egg-rr22.5%
[Start]22.2 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)
\] |
|---|---|
log1p-expm1-u [=>]22.2 | \[ \mathsf{copysign}\left(\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)\right)}, x\right)
\] |
expm1-udef [=>]22.2 | \[ \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{e^{\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)} - 1}\right), x\right)
\] |
add-exp-log [<=]22.2 | \[ \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)} - 1\right), x\right)
\] |
add-sqr-sqrt [=>]11.6 | \[ \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| + \mathsf{hypot}\left(1, x\right)\right) - 1\right), x\right)
\] |
fabs-sqr [=>]11.6 | \[ \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\color{blue}{\sqrt{x} \cdot \sqrt{x}} + \mathsf{hypot}\left(1, x\right)\right) - 1\right), x\right)
\] |
add-sqr-sqrt [<=]22.5 | \[ \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\color{blue}{x} + \mathsf{hypot}\left(1, x\right)\right) - 1\right), x\right)
\] |
Taylor expanded in x around 0 100.0%
if 0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 56.4%
Simplified99.9%
[Start]56.4 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\] |
|---|---|
+-commutative [=>]56.4 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right), x\right)
\] |
hypot-1-def [=>]99.9 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
Applied egg-rr100.0%
[Start]99.9 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)
\] |
|---|---|
log1p-expm1-u [=>]99.9 | \[ \mathsf{copysign}\left(\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)\right)}, x\right)
\] |
expm1-udef [=>]99.9 | \[ \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{e^{\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)} - 1}\right), x\right)
\] |
add-exp-log [<=]100.0 | \[ \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)} - 1\right), x\right)
\] |
add-sqr-sqrt [=>]99.8 | \[ \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| + \mathsf{hypot}\left(1, x\right)\right) - 1\right), x\right)
\] |
fabs-sqr [=>]99.8 | \[ \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\color{blue}{\sqrt{x} \cdot \sqrt{x}} + \mathsf{hypot}\left(1, x\right)\right) - 1\right), x\right)
\] |
add-sqr-sqrt [<=]100.0 | \[ \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\color{blue}{x} + \mathsf{hypot}\left(1, x\right)\right) - 1\right), x\right)
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 99.5% |
| Cost | 9960 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.0% |
| Cost | 9896 |
| Alternative 3 | |
|---|---|
| Accuracy | 99.5% |
| Cost | 9896 |
| Alternative 4 | |
|---|---|
| Accuracy | 98.3% |
| Cost | 6792 |
| Alternative 5 | |
|---|---|
| Accuracy | 98.5% |
| Cost | 6792 |
| Alternative 6 | |
|---|---|
| Accuracy | 97.9% |
| Cost | 6760 |
| Alternative 7 | |
|---|---|
| Accuracy | 97.2% |
| Cost | 6664 |
| Alternative 8 | |
|---|---|
| Accuracy | 82.5% |
| Cost | 6596 |
| Alternative 9 | |
|---|---|
| Accuracy | 69.2% |
| Cost | 6564 |
| Alternative 10 | |
|---|---|
| Accuracy | 62.7% |
| Cost | 6532 |
| Alternative 11 | |
|---|---|
| Accuracy | 54.6% |
| Cost | 3264 |
herbie shell --seed 2023160
(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))