| Alternative 1 | |
|---|---|
| Error | 0.4 |
| Cost | 320 |
\[4 \cdot 10^{-32} \cdot \left(t \cdot t\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 (* t (/ t 2.5e+31)))
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 t * (t / 2.5e+31);
}
real(8) function code(t)
real(8), intent (in) :: t
code = ((1.0d0 + (t * 2d-16)) * (1.0d0 + (t * 2d-16))) + ((-1.0d0) - (2.0d0 * (t * 2d-16)))
end function
real(8) function code(t)
real(8), intent (in) :: t
code = t * (t / 2.5d+31)
end function
public static double code(double t) {
return ((1.0 + (t * 2e-16)) * (1.0 + (t * 2e-16))) + (-1.0 - (2.0 * (t * 2e-16)));
}
public static double code(double t) {
return t * (t / 2.5e+31);
}
def code(t): return ((1.0 + (t * 2e-16)) * (1.0 + (t * 2e-16))) + (-1.0 - (2.0 * (t * 2e-16)))
def code(t): return t * (t / 2.5e+31)
function code(t) return Float64(Float64(Float64(1.0 + Float64(t * 2e-16)) * Float64(1.0 + Float64(t * 2e-16))) + Float64(-1.0 - Float64(2.0 * Float64(t * 2e-16)))) end
function code(t) return Float64(t * Float64(t / 2.5e+31)) end
function tmp = code(t) tmp = ((1.0 + (t * 2e-16)) * (1.0 + (t * 2e-16))) + (-1.0 - (2.0 * (t * 2e-16))); end
function tmp = code(t) tmp = t * (t / 2.5e+31); end
code[t_] := N[(N[(N[(1.0 + N[(t * 2e-16), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(t * 2e-16), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 - N[(2.0 * N[(t * 2e-16), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[t_] := N[(t * N[(t / 2.5e+31), $MachinePrecision]), $MachinePrecision]
\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)
t \cdot \frac{t}{2.5 \cdot 10^{+31}}
Results
| Original | 61.8 |
|---|---|
| Target | 50.6 |
| Herbie | 0.4 |
Initial program 61.8
Simplified0.4
[Start]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)
\] |
|---|---|
rational.json-simplify-14 [=>]57.6 | \[ \color{blue}{\left(\left(1 + t \cdot 2 \cdot 10^{-16}\right) \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right) + -1\right) - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)}
\] |
rational.json-simplify-76 [=>]57.6 | \[ \color{blue}{\left(\left(1 + t \cdot 2 \cdot 10^{-16}\right) \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right) - 1\right)} - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)
\] |
rational.json-simplify-9 [=>]61.8 | \[ \color{blue}{\left(\left(1 + t \cdot 2 \cdot 10^{-16}\right) \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right) - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right) - 1}
\] |
rational.json-simplify-36 [=>]61.8 | \[ \left(\color{blue}{\left(1 \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right) + \left(1 + t \cdot 2 \cdot 10^{-16}\right) \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)} - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right) - 1
\] |
rational.json-simplify-13 [=>]61.8 | \[ \color{blue}{\left(1 \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right) + \left(\left(1 + t \cdot 2 \cdot 10^{-16}\right) \cdot \left(t \cdot 2 \cdot 10^{-16}\right) - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)\right)} - 1
\] |
rational.json-simplify-41 [=>]61.8 | \[ \color{blue}{\left(\left(\left(1 + t \cdot 2 \cdot 10^{-16}\right) \cdot \left(t \cdot 2 \cdot 10^{-16}\right) - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right) + 1 \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right)\right)} - 1
\] |
rational.json-simplify-13 [=>]57.6 | \[ \color{blue}{\left(\left(1 + t \cdot 2 \cdot 10^{-16}\right) \cdot \left(t \cdot 2 \cdot 10^{-16}\right) - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right) + \left(1 \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right) - 1\right)}
\] |
Applied egg-rr0.4
Final simplification0.4
| Alternative 1 | |
|---|---|
| Error | 0.4 |
| Cost | 320 |
herbie shell --seed 2023066
(FPCore (t)
:name "fma_test1"
:precision binary64
:pre (and (<= 0.9 t) (<= 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)))))