| Alternative 1 | |
|---|---|
| Accuracy | 97.2% |
| Cost | 580 |
\[\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{+36}:\\
\;\;\;\;y \cdot \left(\left(x - z\right) \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\
\end{array}
\]

(FPCore (x y z t) :precision binary64 (* (- (* x y) (* z y)) t))
(FPCore (x y z t) :precision binary64 (if (<= y -1e+36) (* y (* (- x z) t)) (* t (* y (- x z)))))
double code(double x, double y, double z, double t) {
return ((x * y) - (z * y)) * t;
}
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1e+36) {
tmp = y * ((x - z) * t);
} else {
tmp = t * (y * (x - z));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x * y) - (z * y)) * t
end function
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= (-1d+36)) then
tmp = y * ((x - z) * t)
else
tmp = t * (y * (x - z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
return ((x * y) - (z * y)) * t;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1e+36) {
tmp = y * ((x - z) * t);
} else {
tmp = t * (y * (x - z));
}
return tmp;
}
def code(x, y, z, t): return ((x * y) - (z * y)) * t
def code(x, y, z, t): tmp = 0 if y <= -1e+36: tmp = y * ((x - z) * t) else: tmp = t * (y * (x - z)) return tmp
function code(x, y, z, t) return Float64(Float64(Float64(x * y) - Float64(z * y)) * t) end
function code(x, y, z, t) tmp = 0.0 if (y <= -1e+36) tmp = Float64(y * Float64(Float64(x - z) * t)); else tmp = Float64(t * Float64(y * Float64(x - z))); end return tmp end
function tmp = code(x, y, z, t) tmp = ((x * y) - (z * y)) * t; end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1e+36) tmp = y * ((x - z) * t); else tmp = t * (y * (x - z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
code[x_, y_, z_, t_] := If[LessEqual[y, -1e+36], N[(y * N[(N[(x - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision], N[(t * N[(y * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\left(x \cdot y - z \cdot y\right) \cdot t
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{+36}:\\
\;\;\;\;y \cdot \left(\left(x - z\right) \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\
\end{array}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
| Original | 90.6% |
|---|---|
| Target | 96.4% |
| Herbie | 97.2% |
if y < -1.00000000000000004e36Initial program 81.3%
Simplified99.8%
[Start]81.3% | \[ \left(x \cdot y - z \cdot y\right) \cdot t
\] |
|---|---|
distribute-rgt-out-- [=>]89.8% | \[ \color{blue}{\left(y \cdot \left(x - z\right)\right)} \cdot t
\] |
associate-*l* [=>]99.8% | \[ \color{blue}{y \cdot \left(\left(x - z\right) \cdot t\right)}
\] |
if -1.00000000000000004e36 < y Initial program 93.3%
Simplified94.3%
[Start]93.3% | \[ \left(x \cdot y - z \cdot y\right) \cdot t
\] |
|---|---|
distribute-rgt-out-- [=>]94.3% | \[ \color{blue}{\left(y \cdot \left(x - z\right)\right)} \cdot t
\] |
Final simplification95.3%
| Alternative 1 | |
|---|---|
| Accuracy | 97.2% |
| Cost | 580 |
| Alternative 2 | |
|---|---|
| Accuracy | 73.1% |
| Cost | 912 |
| Alternative 3 | |
|---|---|
| Accuracy | 72.5% |
| Cost | 912 |
| Alternative 4 | |
|---|---|
| Accuracy | 72.6% |
| Cost | 912 |
| Alternative 5 | |
|---|---|
| Accuracy | 97.4% |
| Cost | 580 |
| Alternative 6 | |
|---|---|
| Accuracy | 56.3% |
| Cost | 452 |
| Alternative 7 | |
|---|---|
| Accuracy | 92.5% |
| Cost | 448 |
| Alternative 8 | |
|---|---|
| Accuracy | 54.1% |
| Cost | 320 |
herbie shell --seed 2023171
(FPCore (x y z t)
:name "Linear.Projection:inverseInfinitePerspective from linear-1.19.1.3"
:precision binary64
:herbie-target
(if (< t -9.231879582886777e-80) (* (* y t) (- x z)) (if (< t 2.543067051564877e+83) (* y (* t (- x z))) (* (* y (- x z)) t)))
(* (- (* x y) (* z y)) t))