| Alternative 1 | |
|---|---|
| Accuracy | 99.1% |
| Cost | 9896 |
(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.05000000074505806)
(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) {
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.05000000074505806f) {
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) 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.05000000074505806)) 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 = code(x) tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); 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.05000000074505806)) 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
\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.05000000074505806:\\
\;\;\;\;\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}
| Original | 36.7% |
|---|---|
| Target | 99.7% |
| Herbie | 99.6% |
if (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < -0.200000003Initial program 49.3%
Simplified99.2%
[Start]49.3 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\] |
|---|---|
+-commutative [=>]49.3 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right), x\right)
\] |
hypot-1-def [=>]99.2 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
Applied egg-rr7.7%
[Start]99.2 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)
\] |
|---|---|
flip-+ [=>]7.6 | \[ \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 [=>]7.5 | \[ \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)
\] |
sqr-abs [=>]7.5 | \[ \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 [<=]2.7 | \[ \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 [=>]2.7 | \[ \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 [=>]2.7 | \[ \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 [<=]2.7 | \[ \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 [=>]2.7 | \[ \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 [<=]7.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.2%
[Start]7.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)
\] |
|---|---|
div-sub [<=]9.7 | \[ \mathsf{copysign}\left(\log \color{blue}{\left(\frac{x \cdot x - \left(1 + x \cdot x\right)}{x - \mathsf{hypot}\left(1, x\right)}\right)}, x\right)
\] |
+-commutative [=>]9.7 | \[ \mathsf{copysign}\left(\log \left(\frac{x \cdot x - \color{blue}{\left(x \cdot x + 1\right)}}{x - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
associate--r+ [=>]49.3 | \[ \mathsf{copysign}\left(\log \left(\frac{\color{blue}{\left(x \cdot x - x \cdot x\right) - 1}}{x - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
+-inverses [=>]99.2 | \[ \mathsf{copysign}\left(\log \left(\frac{\color{blue}{0} - 1}{x - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
metadata-eval [=>]99.2 | \[ \mathsf{copysign}\left(\log \left(\frac{\color{blue}{-1}}{x - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
metadata-eval [<=]99.2 | \[ \mathsf{copysign}\left(\log \left(\frac{\color{blue}{\frac{1}{-1}}}{x - \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
associate-/r* [<=]99.2 | \[ \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.2 | \[ \mathsf{copysign}\left(\log \left(\frac{1}{\color{blue}{-\left(x - \mathsf{hypot}\left(1, x\right)\right)}}\right), x\right)
\] |
neg-sub0 [=>]99.2 | \[ \mathsf{copysign}\left(\log \left(\frac{1}{\color{blue}{0 - \left(x - \mathsf{hypot}\left(1, x\right)\right)}}\right), x\right)
\] |
associate--r- [=>]99.2 | \[ \mathsf{copysign}\left(\log \left(\frac{1}{\color{blue}{\left(0 - x\right) + \mathsf{hypot}\left(1, x\right)}}\right), x\right)
\] |
neg-sub0 [<=]99.2 | \[ \mathsf{copysign}\left(\log \left(\frac{1}{\color{blue}{\left(-x\right)} + \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
mul-1-neg [<=]99.2 | \[ \mathsf{copysign}\left(\log \left(\frac{1}{\color{blue}{-1 \cdot x} + \mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
+-commutative [<=]99.2 | \[ \mathsf{copysign}\left(\log \left(\frac{1}{\color{blue}{\mathsf{hypot}\left(1, x\right) + -1 \cdot x}}\right), x\right)
\] |
mul-1-neg [=>]99.2 | \[ \mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) + \color{blue}{\left(-x\right)}}\right), x\right)
\] |
sub-neg [<=]99.2 | \[ \mathsf{copysign}\left(\log \left(\frac{1}{\color{blue}{\mathsf{hypot}\left(1, x\right) - x}}\right), x\right)
\] |
Applied egg-rr99.2%
[Start]99.2 | \[ \mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)
\] |
|---|---|
log-div [=>]99.2 | \[ \mathsf{copysign}\left(\color{blue}{\log 1 - \log \left(\mathsf{hypot}\left(1, x\right) - x\right)}, x\right)
\] |
sub-neg [=>]99.2 | \[ \mathsf{copysign}\left(\color{blue}{\log 1 + \left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right)\right)}, x\right)
\] |
metadata-eval [=>]99.2 | \[ \mathsf{copysign}\left(\color{blue}{0} + \left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right)\right), x\right)
\] |
Simplified99.2%
[Start]99.2 | \[ \mathsf{copysign}\left(0 + \left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right)\right), x\right)
\] |
|---|---|
+-lft-identity [=>]99.2 | \[ \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.0500000007Initial program 21.1%
Simplified21.1%
[Start]21.1 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\] |
|---|---|
+-commutative [=>]21.1 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right), x\right)
\] |
hypot-1-def [=>]21.1 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
Applied egg-rr21.4%
[Start]21.1 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)
\] |
|---|---|
*-un-lft-identity [=>]21.1 | \[ \mathsf{copysign}\left(\log \color{blue}{\left(1 \cdot \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)}, x\right)
\] |
log-prod [=>]21.1 | \[ \mathsf{copysign}\left(\color{blue}{\log 1 + \log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)}, x\right)
\] |
metadata-eval [=>]21.1 | \[ \mathsf{copysign}\left(\color{blue}{0} + \log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)
\] |
add-sqr-sqrt [=>]10.2 | \[ \mathsf{copysign}\left(0 + \log \left(\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)
\] |
fabs-sqr [=>]10.2 | \[ \mathsf{copysign}\left(0 + \log \left(\color{blue}{\sqrt{x} \cdot \sqrt{x}} + \mathsf{hypot}\left(1, x\right)\right), x\right)
\] |
add-sqr-sqrt [<=]21.4 | \[ \mathsf{copysign}\left(0 + \log \left(\color{blue}{x} + \mathsf{hypot}\left(1, x\right)\right), x\right)
\] |
Simplified21.4%
[Start]21.4 | \[ \mathsf{copysign}\left(0 + \log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)
\] |
|---|---|
+-lft-identity [=>]21.4 | \[ \mathsf{copysign}\left(\color{blue}{\log \left(x + \mathsf{hypot}\left(1, x\right)\right)}, x\right)
\] |
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) 1)))) x) Initial program 52.5%
Simplified99.4%
[Start]52.5 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\] |
|---|---|
+-commutative [=>]52.5 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right), x\right)
\] |
hypot-1-def [=>]99.4 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right), x\right)
\] |
Applied egg-rr99.4%
[Start]99.4 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)
\] |
|---|---|
*-un-lft-identity [=>]99.4 | \[ \mathsf{copysign}\left(\log \color{blue}{\left(1 \cdot \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)}, x\right)
\] |
log-prod [=>]99.4 | \[ \mathsf{copysign}\left(\color{blue}{\log 1 + \log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)}, x\right)
\] |
metadata-eval [=>]99.4 | \[ \mathsf{copysign}\left(\color{blue}{0} + \log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)
\] |
add-sqr-sqrt [=>]99.4 | \[ \mathsf{copysign}\left(0 + \log \left(\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)
\] |
fabs-sqr [=>]99.4 | \[ \mathsf{copysign}\left(0 + \log \left(\color{blue}{\sqrt{x} \cdot \sqrt{x}} + \mathsf{hypot}\left(1, x\right)\right), x\right)
\] |
add-sqr-sqrt [<=]99.4 | \[ \mathsf{copysign}\left(0 + \log \left(\color{blue}{x} + \mathsf{hypot}\left(1, x\right)\right), x\right)
\] |
Simplified99.4%
[Start]99.4 | \[ \mathsf{copysign}\left(0 + \log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)
\] |
|---|---|
+-lft-identity [=>]99.4 | \[ \mathsf{copysign}\left(\color{blue}{\log \left(x + \mathsf{hypot}\left(1, x\right)\right)}, x\right)
\] |
Final simplification99.6%
| Alternative 1 | |
|---|---|
| Accuracy | 99.1% |
| Cost | 9896 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.6% |
| Cost | 9896 |
| Alternative 3 | |
|---|---|
| Accuracy | 98.2% |
| Cost | 6792 |
| Alternative 4 | |
|---|---|
| Accuracy | 98.3% |
| Cost | 6792 |
| Alternative 5 | |
|---|---|
| Accuracy | 84.4% |
| Cost | 6664 |
| Alternative 6 | |
|---|---|
| Accuracy | 97.8% |
| Cost | 6664 |
| Alternative 7 | |
|---|---|
| Accuracy | 68.3% |
| Cost | 6564 |
| Alternative 8 | |
|---|---|
| Accuracy | 63.9% |
| Cost | 6532 |
| Alternative 9 | |
|---|---|
| Accuracy | 62.3% |
| Cost | 3656 |
| Alternative 10 | |
|---|---|
| Accuracy | 61.5% |
| Cost | 3400 |
| Alternative 11 | |
|---|---|
| Accuracy | 17.5% |
| Cost | 3264 |
| Alternative 12 | |
|---|---|
| Accuracy | 18.9% |
| Cost | 3264 |
herbie shell --seed 2023137
(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))