| Alternative 1 | |
|---|---|
| Error | 0.62% |
| Cost | 448 |
\[t \cdot \left(2 \cdot 10^{-16} \cdot \left(t \cdot 2 \cdot 10^{-16}\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 (* t (sqrt (* (* t t) 1.6e-63))))
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 * sqrt(((t * t) * 1.6e-63));
}
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 * sqrt(((t * t) * 1.6d-63))
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 * Math.sqrt(((t * t) * 1.6e-63));
}
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 * math.sqrt(((t * t) * 1.6e-63))
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 * sqrt(Float64(Float64(t * t) * 1.6e-63))) 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 * sqrt(((t * t) * 1.6e-63)); 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[Sqrt[N[(N[(t * t), $MachinePrecision] * 1.6e-63), $MachinePrecision]], $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 \sqrt{\left(t \cdot t\right) \cdot 1.6 \cdot 10^{-63}}
Results
| Original | 96.63% |
|---|---|
| Target | 79% |
| Herbie | 0.49% |
Initial program 96.63
Simplified0.64
[Start]96.63 | \[ \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)
\] |
|---|---|
cancel-sign-sub-inv [=>]96.63 | \[ \left(1 + t \cdot 2 \cdot 10^{-16}\right) \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right) + \color{blue}{\left(-1 + \left(-2\right) \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)}
\] |
distribute-rgt-in [=>]96.63 | \[ \color{blue}{\left(1 \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right) + \left(t \cdot 2 \cdot 10^{-16}\right) \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right)\right)} + \left(-1 + \left(-2\right) \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)
\] |
cancel-sign-sub-inv [<=]96.63 | \[ \left(1 \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right) + \left(t \cdot 2 \cdot 10^{-16}\right) \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right)\right) + \color{blue}{\left(-1 - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)}
\] |
associate-+l+ [=>]96.63 | \[ \color{blue}{1 \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right) + \left(\left(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)\right)}
\] |
*-lft-identity [=>]96.63 | \[ \color{blue}{\left(1 + t \cdot 2 \cdot 10^{-16}\right)} + \left(\left(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)\right)
\] |
+-commutative [=>]96.63 | \[ \color{blue}{\left(\left(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)\right) + \left(1 + t \cdot 2 \cdot 10^{-16}\right)}
\] |
associate-+r+ [<=]98.25 | \[ \color{blue}{\left(t \cdot 2 \cdot 10^{-16}\right) \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right) + \left(\left(-1 - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right) + \left(1 + t \cdot 2 \cdot 10^{-16}\right)\right)}
\] |
*-commutative [=>]98.25 | \[ \color{blue}{\left(2 \cdot 10^{-16} \cdot t\right)} \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right) + \left(\left(-1 - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right) + \left(1 + t \cdot 2 \cdot 10^{-16}\right)\right)
\] |
associate-*l* [=>]98.25 | \[ \color{blue}{2 \cdot 10^{-16} \cdot \left(t \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right)\right)} + \left(\left(-1 - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right) + \left(1 + t \cdot 2 \cdot 10^{-16}\right)\right)
\] |
+-commutative [=>]98.25 | \[ 2 \cdot 10^{-16} \cdot \left(t \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right)\right) + \color{blue}{\left(\left(1 + t \cdot 2 \cdot 10^{-16}\right) + \left(-1 - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)\right)}
\] |
associate-+r- [=>]90.02 | \[ 2 \cdot 10^{-16} \cdot \left(t \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right)\right) + \color{blue}{\left(\left(\left(1 + t \cdot 2 \cdot 10^{-16}\right) + -1\right) - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)}
\] |
Applied egg-rr0.49
Final simplification0.49
| Alternative 1 | |
|---|---|
| Error | 0.62% |
| Cost | 448 |
| Alternative 2 | |
|---|---|
| Error | 0.65% |
| Cost | 320 |
| Alternative 3 | |
|---|---|
| Error | 0.64% |
| Cost | 320 |
herbie shell --seed 2023090
(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)))))