| Alternative 1 | |
|---|---|
| Error | 0.4 |
| Cost | 448 |
(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 | 61.8 |
|---|---|
| Target | 50.6 |
| Herbie | 0.3 |
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)
\] |
|---|---|
cancel-sign-sub-inv [=>]61.8 | \[ \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 [=>]61.8 | \[ \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 [<=]61.8 | \[ \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+ [=>]61.8 | \[ \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 [=>]61.8 | \[ \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 [=>]61.8 | \[ \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+ [<=]62.9 | \[ \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 [=>]62.9 | \[ \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* [=>]62.9 | \[ \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 [=>]62.9 | \[ 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- [=>]57.6 | \[ 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)}
\] |
*-lft-identity [<=]57.6 | \[ 2 \cdot 10^{-16} \cdot \left(t \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right)\right) + \left(\left(\color{blue}{1 \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right)} + -1\right) - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)
\] |
+-commutative [=>]57.6 | \[ 2 \cdot 10^{-16} \cdot \left(t \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right)\right) + \left(\left(1 \cdot \color{blue}{\left(t \cdot 2 \cdot 10^{-16} + 1\right)} + -1\right) - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)
\] |
distribute-rgt-in [=>]57.6 | \[ 2 \cdot 10^{-16} \cdot \left(t \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right)\right) + \left(\left(\color{blue}{\left(\left(t \cdot 2 \cdot 10^{-16}\right) \cdot 1 + 1 \cdot 1\right)} + -1\right) - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)
\] |
metadata-eval [=>]57.6 | \[ 2 \cdot 10^{-16} \cdot \left(t \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right)\right) + \left(\left(\left(\left(t \cdot 2 \cdot 10^{-16}\right) \cdot 1 + \color{blue}{1}\right) + -1\right) - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)
\] |
associate-+l+ [=>]50.7 | \[ 2 \cdot 10^{-16} \cdot \left(t \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right)\right) + \left(\color{blue}{\left(\left(t \cdot 2 \cdot 10^{-16}\right) \cdot 1 + \left(1 + -1\right)\right)} - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)
\] |
metadata-eval [=>]50.7 | \[ 2 \cdot 10^{-16} \cdot \left(t \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right)\right) + \left(\left(\left(t \cdot 2 \cdot 10^{-16}\right) \cdot 1 + \color{blue}{0}\right) - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)
\] |
+-rgt-identity [=>]50.7 | \[ 2 \cdot 10^{-16} \cdot \left(t \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right)\right) + \left(\color{blue}{\left(t \cdot 2 \cdot 10^{-16}\right) \cdot 1} - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)
\] |
associate-*l* [=>]50.7 | \[ 2 \cdot 10^{-16} \cdot \left(t \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right)\right) + \left(\color{blue}{t \cdot \left(2 \cdot 10^{-16} \cdot 1\right)} - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)
\] |
metadata-eval [=>]50.7 | \[ 2 \cdot 10^{-16} \cdot \left(t \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right)\right) + \left(t \cdot \color{blue}{2 \cdot 10^{-16}} - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)
\] |
*-commutative [=>]50.7 | \[ 2 \cdot 10^{-16} \cdot \left(t \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right)\right) + \left(\color{blue}{2 \cdot 10^{-16} \cdot t} - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)
\] |
associate-*r* [=>]50.7 | \[ 2 \cdot 10^{-16} \cdot \left(t \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right)\right) + \left(2 \cdot 10^{-16} \cdot t - \color{blue}{\left(2 \cdot t\right) \cdot 2 \cdot 10^{-16}}\right)
\] |
*-commutative [=>]50.7 | \[ 2 \cdot 10^{-16} \cdot \left(t \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right)\right) + \left(2 \cdot 10^{-16} \cdot t - \color{blue}{2 \cdot 10^{-16} \cdot \left(2 \cdot t\right)}\right)
\] |
distribute-lft-out-- [=>]50.7 | \[ 2 \cdot 10^{-16} \cdot \left(t \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right)\right) + \color{blue}{2 \cdot 10^{-16} \cdot \left(t - 2 \cdot t\right)}
\] |
distribute-lft-out [=>]49.6 | \[ \color{blue}{2 \cdot 10^{-16} \cdot \left(t \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right) + \left(t - 2 \cdot t\right)\right)}
\] |
*-lft-identity [<=]49.6 | \[ 2 \cdot 10^{-16} \cdot \left(t \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right) + \left(\color{blue}{1 \cdot t} - 2 \cdot t\right)\right)
\] |
distribute-rgt-out-- [=>]49.6 | \[ 2 \cdot 10^{-16} \cdot \left(t \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right) + \color{blue}{t \cdot \left(1 - 2\right)}\right)
\] |
metadata-eval [=>]49.6 | \[ 2 \cdot 10^{-16} \cdot \left(t \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right) + t \cdot \color{blue}{-1}\right)
\] |
distribute-lft-in [<=]49.5 | \[ 2 \cdot 10^{-16} \cdot \color{blue}{\left(t \cdot \left(\left(1 + t \cdot 2 \cdot 10^{-16}\right) + -1\right)\right)}
\] |
*-rgt-identity [<=]49.5 | \[ 2 \cdot 10^{-16} \cdot \left(\color{blue}{\left(t \cdot 1\right)} \cdot \left(\left(1 + t \cdot 2 \cdot 10^{-16}\right) + -1\right)\right)
\] |
*-lft-identity [<=]49.5 | \[ 2 \cdot 10^{-16} \cdot \left(\left(t \cdot 1\right) \cdot \left(\color{blue}{1 \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right)} + -1\right)\right)
\] |
+-commutative [=>]49.5 | \[ 2 \cdot 10^{-16} \cdot \left(\left(t \cdot 1\right) \cdot \left(1 \cdot \color{blue}{\left(t \cdot 2 \cdot 10^{-16} + 1\right)} + -1\right)\right)
\] |
distribute-rgt-in [=>]49.5 | \[ 2 \cdot 10^{-16} \cdot \left(\left(t \cdot 1\right) \cdot \left(\color{blue}{\left(\left(t \cdot 2 \cdot 10^{-16}\right) \cdot 1 + 1 \cdot 1\right)} + -1\right)\right)
\] |
metadata-eval [=>]49.5 | \[ 2 \cdot 10^{-16} \cdot \left(\left(t \cdot 1\right) \cdot \left(\left(\left(t \cdot 2 \cdot 10^{-16}\right) \cdot 1 + \color{blue}{1}\right) + -1\right)\right)
\] |
associate-+l+ [=>]0.4 | \[ 2 \cdot 10^{-16} \cdot \left(\left(t \cdot 1\right) \cdot \color{blue}{\left(\left(t \cdot 2 \cdot 10^{-16}\right) \cdot 1 + \left(1 + -1\right)\right)}\right)
\] |
metadata-eval [=>]0.4 | \[ 2 \cdot 10^{-16} \cdot \left(\left(t \cdot 1\right) \cdot \left(\left(t \cdot 2 \cdot 10^{-16}\right) \cdot 1 + \color{blue}{0}\right)\right)
\] |
+-rgt-identity [=>]0.4 | \[ 2 \cdot 10^{-16} \cdot \left(\left(t \cdot 1\right) \cdot \color{blue}{\left(\left(t \cdot 2 \cdot 10^{-16}\right) \cdot 1\right)}\right)
\] |
associate-*l* [<=]0.5 | \[ \color{blue}{\left(2 \cdot 10^{-16} \cdot \left(t \cdot 1\right)\right) \cdot \left(\left(t \cdot 2 \cdot 10^{-16}\right) \cdot 1\right)}
\] |
*-commutative [=>]0.5 | \[ \color{blue}{\left(\left(t \cdot 1\right) \cdot 2 \cdot 10^{-16}\right)} \cdot \left(\left(t \cdot 2 \cdot 10^{-16}\right) \cdot 1\right)
\] |
associate-*l* [=>]0.4 | \[ \color{blue}{\left(t \cdot 1\right) \cdot \left(2 \cdot 10^{-16} \cdot \left(\left(t \cdot 2 \cdot 10^{-16}\right) \cdot 1\right)\right)}
\] |
associate-*r* [<=]0.4 | \[ \color{blue}{t \cdot \left(1 \cdot \left(2 \cdot 10^{-16} \cdot \left(\left(t \cdot 2 \cdot 10^{-16}\right) \cdot 1\right)\right)\right)}
\] |
*-lft-identity [=>]0.4 | \[ t \cdot \color{blue}{\left(2 \cdot 10^{-16} \cdot \left(\left(t \cdot 2 \cdot 10^{-16}\right) \cdot 1\right)\right)}
\] |
associate-*l* [=>]0.4 | \[ t \cdot \left(2 \cdot 10^{-16} \cdot \color{blue}{\left(t \cdot \left(2 \cdot 10^{-16} \cdot 1\right)\right)}\right)
\] |
metadata-eval [=>]0.4 | \[ t \cdot \left(2 \cdot 10^{-16} \cdot \left(t \cdot \color{blue}{2 \cdot 10^{-16}}\right)\right)
\] |
*-commutative [=>]0.4 | \[ t \cdot \left(2 \cdot 10^{-16} \cdot \color{blue}{\left(2 \cdot 10^{-16} \cdot t\right)}\right)
\] |
associate-*r* [=>]0.6 | \[ t \cdot \color{blue}{\left(\left(2 \cdot 10^{-16} \cdot 2 \cdot 10^{-16}\right) \cdot t\right)}
\] |
*-commutative [<=]0.6 | \[ t \cdot \color{blue}{\left(t \cdot \left(2 \cdot 10^{-16} \cdot 2 \cdot 10^{-16}\right)\right)}
\] |
metadata-eval [=>]0.4 | \[ t \cdot \left(t \cdot \color{blue}{4 \cdot 10^{-32}}\right)
\] |
Applied egg-rr0.3
Final simplification0.3
| Alternative 1 | |
|---|---|
| Error | 0.4 |
| Cost | 448 |
| Alternative 2 | |
|---|---|
| Error | 0.4 |
| Cost | 320 |
herbie shell --seed 2022349
(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)))))