Average Error: 61.8 → 0.3
Time: 3.2s
Precision: binary64
Cost: 448
\[0.9 \leq t \land t \leq 1.1\]
\[\left(1 + t \cdot 2 \cdot 10^{-16}\right) \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right) + \left(-1 - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)\]
↓
\[2 \cdot 10^{-16} \cdot \left(t \cdot \left(2 \cdot 10^{-16} \cdot t\right)\right)\]
\left(1 + t \cdot 2 \cdot 10^{-16}\right) \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right) + \left(-1 - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)↓
2 \cdot 10^{-16} \cdot \left(t \cdot \left(2 \cdot 10^{-16} \cdot t\right)\right)(FPCore (t)
:precision binary64
(+ (* (+ 1.0 (* t 2e-16)) (+ 1.0 (* t 2e-16))) (- -1.0 (* 2.0 (* t 2e-16)))))
↓
(FPCore (t) :precision binary64 (* 2e-16 (* t (* 2e-16 t))))
double code(double t) {
return ((1.0 + (t * 2e-16)) * (1.0 + (t * 2e-16))) + (-1.0 - (2.0 * (t * 2e-16)));
}
↓
double code(double t) {
return 2e-16 * (t * (2e-16 * t));
}
Try it out
Enter valid numbers for all inputs
Target
| Original | 61.8 |
|---|
| Target | 50.6 |
|---|
| Herbie | 0.3 |
|---|
\[\mathsf{fma}\left(1 + t \cdot 2 \cdot 10^{-16}, 1 + t \cdot 2 \cdot 10^{-16}, -1 - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)\]
Alternatives
| Alternative 1 |
|---|
| Error | 2.0 |
|---|
| Cost | 20032 |
|---|
\[t \cdot \left(\sqrt[3]{t \cdot 3.9999999999999997 \cdot 10^{-32}} \cdot \left(\sqrt[3]{t \cdot 3.9999999999999997 \cdot 10^{-32}} \cdot \sqrt[3]{t \cdot 3.9999999999999997 \cdot 10^{-32}}\right)\right)\]
| Alternative 2 |
|---|
| Error | 1.3 |
|---|
| Cost | 19776 |
|---|
\[\left(\sqrt[3]{t} \cdot \sqrt[3]{t}\right) \cdot \left(t \cdot \left(3.9999999999999997 \cdot 10^{-32} \cdot \sqrt[3]{t}\right)\right)\]
| Alternative 3 |
|---|
| Error | 1.3 |
|---|
| Cost | 19776 |
|---|
\[t \cdot \left(\left(\sqrt[3]{t} \cdot \sqrt[3]{t}\right) \cdot \left(3.9999999999999997 \cdot 10^{-32} \cdot \sqrt[3]{t}\right)\right)\]
| Alternative 4 |
|---|
| Error | 0.6 |
|---|
| Cost | 13632 |
|---|
\[2 \cdot 10^{-16} \cdot \left(\sqrt{t \cdot \left(t \cdot 2 \cdot 10^{-16}\right)} \cdot \sqrt{t \cdot \left(t \cdot 2 \cdot 10^{-16}\right)}\right)\]
| Alternative 5 |
|---|
| Error | 0.6 |
|---|
| Cost | 13504 |
|---|
\[\sqrt{t \cdot \left(t \cdot 3.9999999999999997 \cdot 10^{-32}\right)} \cdot \sqrt{t \cdot \left(t \cdot 3.9999999999999997 \cdot 10^{-32}\right)}\]
| Alternative 6 |
|---|
| Error | 0.7 |
|---|
| Cost | 13376 |
|---|
\[t \cdot \left(\left(\sqrt{t} \cdot 2 \cdot 10^{-16}\right) \cdot \left(\sqrt{t} \cdot 2 \cdot 10^{-16}\right)\right)\]
| Alternative 7 |
|---|
| Error | 0.6 |
|---|
| Cost | 13376 |
|---|
\[t \cdot \left(\sqrt{t \cdot 3.9999999999999997 \cdot 10^{-32}} \cdot \sqrt{t \cdot 3.9999999999999997 \cdot 10^{-32}}\right)\]
| Alternative 8 |
|---|
| Error | 0.4 |
|---|
| Cost | 13376 |
|---|
\[t \cdot \left(\sqrt{2 \cdot 10^{-16}} \cdot \left(\left(t \cdot 2 \cdot 10^{-16}\right) \cdot \sqrt{2 \cdot 10^{-16}}\right)\right)\]
| Alternative 9 |
|---|
| Error | 0.5 |
|---|
| Cost | 13312 |
|---|
\[2 \cdot 10^{-16} \cdot \left(\sqrt{t} \cdot \left({t}^{1.5} \cdot 2 \cdot 10^{-16}\right)\right)\]
| Alternative 10 |
|---|
| Error | 0.6 |
|---|
| Cost | 13248 |
|---|
\[t \cdot \left(\sqrt{t} \cdot \left(\sqrt{t} \cdot 3.9999999999999997 \cdot 10^{-32}\right)\right)\]
| Alternative 11 |
|---|
| Error | 0.5 |
|---|
| Cost | 13184 |
|---|
\[\sqrt{t} \cdot \left(3.9999999999999997 \cdot 10^{-32} \cdot {t}^{1.5}\right)\]
| Alternative 12 |
|---|
| Error | 0.7 |
|---|
| Cost | 13184 |
|---|
\[t \cdot \sqrt[3]{{\left(t \cdot 3.9999999999999997 \cdot 10^{-32}\right)}^{3}}\]
| Alternative 13 |
|---|
| Error | 0.6 |
|---|
| Cost | 13184 |
|---|
\[2 \cdot 10^{-16} \cdot \sqrt[3]{{t}^{6} \cdot 8 \cdot 10^{-48}}\]
| Alternative 14 |
|---|
| Error | 4.3 |
|---|
| Cost | 13120 |
|---|
\[t \cdot e^{\log \left(t \cdot 3.9999999999999997 \cdot 10^{-32}\right)}\]
| Alternative 15 |
|---|
| Error | 0.6 |
|---|
| Cost | 13056 |
|---|
\[\sqrt[3]{6.4 \cdot 10^{-95} \cdot {t}^{6}}\]
| Alternative 16 |
|---|
| Error | 0.7 |
|---|
| Cost | 13056 |
|---|
\[\sqrt[3]{{\left(t \cdot 2 \cdot 10^{-16}\right)}^{6}}\]
| Alternative 17 |
|---|
| Error | 61.8 |
|---|
| Cost | 1216 |
|---|
\[\left(t \cdot 2 \cdot 10^{-16} + 1\right) \cdot \left(t \cdot 2 \cdot 10^{-16} + 1\right) + \left(-1 - \left(t \cdot 2 \cdot 10^{-16}\right) \cdot 2\right)\]
| Alternative 18 |
|---|
| Error | 0.3 |
|---|
| Cost | 448 |
|---|
\[t \cdot \left(2 \cdot 10^{-16} \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)\]
| Alternative 19 |
|---|
| Error | 0.5 |
|---|
| Cost | 448 |
|---|
\[\left(t \cdot 2 \cdot 10^{-16}\right) \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\]
| Alternative 20 |
|---|
| Error | 0.4 |
|---|
| Cost | 448 |
|---|
\[2 \cdot 10^{-16} \cdot \left(2 \cdot 10^{-16} \cdot \left(t \cdot t\right)\right)\]
| Alternative 21 |
|---|
| Error | 0.3 |
|---|
| Cost | 448 |
|---|
\[2 \cdot 10^{-16} \cdot \left(t \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)\]
| Alternative 22 |
|---|
| Error | 0.3 |
|---|
| Cost | 320 |
|---|
\[t \cdot \left(t \cdot 3.9999999999999997 \cdot 10^{-32}\right)\]
| Alternative 23 |
|---|
| Error | 0.3 |
|---|
| Cost | 320 |
|---|
\[3.9999999999999997 \cdot 10^{-32} \cdot \left(t \cdot t\right)\]
| Alternative 24 |
|---|
| Error | 58.7 |
|---|
| Cost | 64 |
|---|
\[1\]
| Alternative 25 |
|---|
| Error | 61.8 |
|---|
| Cost | 64 |
|---|
\[0\]
| Alternative 26 |
|---|
| Error | 62.9 |
|---|
| Cost | 64 |
|---|
\[-1\]
Error

Derivation
Initial program 61.8
\[\left(1 + t \cdot 2 \cdot 10^{-16}\right) \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right) + \left(-1 - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)\]
Simplified0.3
\[\leadsto \color{blue}{t \cdot \left(t \cdot 3.9999999999999997 \cdot 10^{-32}\right)}\]
- Using strategy
rm Applied add-sqr-sqrt_binary64_27570.3
\[\leadsto t \cdot \left(t \cdot \color{blue}{\left(\sqrt{3.9999999999999997 \cdot 10^{-32}} \cdot \sqrt{3.9999999999999997 \cdot 10^{-32}}\right)}\right)\]
Applied associate-*r*_binary64_26750.3
\[\leadsto t \cdot \color{blue}{\left(\left(t \cdot \sqrt{3.9999999999999997 \cdot 10^{-32}}\right) \cdot \sqrt{3.9999999999999997 \cdot 10^{-32}}\right)}\]
Simplified0.3
\[\leadsto t \cdot \left(\color{blue}{\left(t \cdot 2 \cdot 10^{-16}\right)} \cdot \sqrt{3.9999999999999997 \cdot 10^{-32}}\right)\]
- Using strategy
rm Applied associate-*r*_binary64_26750.3
\[\leadsto \color{blue}{\left(t \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right) \cdot \sqrt{3.9999999999999997 \cdot 10^{-32}}}\]
Simplified0.3
\[\leadsto \color{blue}{2 \cdot 10^{-16} \cdot \left(t \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)}\]
Final simplification0.3
\[\leadsto 2 \cdot 10^{-16} \cdot \left(t \cdot \left(2 \cdot 10^{-16} \cdot t\right)\right)\]
Reproduce
herbie shell --seed 2021042
(FPCore (t)
:name "fma_test1"
:precision binary64
:pre (<= 0.9 t 1.1)
:herbie-target
(fma (+ 1.0 (* t 2e-16)) (+ 1.0 (* t 2e-16)) (- -1.0 (* 2.0 (* t 2e-16))))
(+ (* (+ 1.0 (* t 2e-16)) (+ 1.0 (* t 2e-16))) (- -1.0 (* 2.0 (* t 2e-16)))))