| Alternative 1 | |
|---|---|
| Accuracy | 99.1% |
| Cost | 2512 |
(FPCore (x y z t) :precision binary64 (* (- (* x y) (* z y)) t))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* x y) (* y z))) (t_2 (* t (* y (- x z)))))
(if (<= t_1 -2e+194)
(/ y (/ (/ 1.0 t) (- x z)))
(if (<= t_1 -2e-148)
t_2
(if (<= t_1 5e-137)
(* (- x z) (* y t))
(if (<= t_1 5e+256) t_2 (* y (* t (- 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 t_1 = (x * y) - (y * z);
double t_2 = t * (y * (x - z));
double tmp;
if (t_1 <= -2e+194) {
tmp = y / ((1.0 / t) / (x - z));
} else if (t_1 <= -2e-148) {
tmp = t_2;
} else if (t_1 <= 5e-137) {
tmp = (x - z) * (y * t);
} else if (t_1 <= 5e+256) {
tmp = t_2;
} else {
tmp = y * (t * (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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (x * y) - (y * z)
t_2 = t * (y * (x - z))
if (t_1 <= (-2d+194)) then
tmp = y / ((1.0d0 / t) / (x - z))
else if (t_1 <= (-2d-148)) then
tmp = t_2
else if (t_1 <= 5d-137) then
tmp = (x - z) * (y * t)
else if (t_1 <= 5d+256) then
tmp = t_2
else
tmp = y * (t * (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 t_1 = (x * y) - (y * z);
double t_2 = t * (y * (x - z));
double tmp;
if (t_1 <= -2e+194) {
tmp = y / ((1.0 / t) / (x - z));
} else if (t_1 <= -2e-148) {
tmp = t_2;
} else if (t_1 <= 5e-137) {
tmp = (x - z) * (y * t);
} else if (t_1 <= 5e+256) {
tmp = t_2;
} else {
tmp = y * (t * (x - z));
}
return tmp;
}
def code(x, y, z, t): return ((x * y) - (z * y)) * t
def code(x, y, z, t): t_1 = (x * y) - (y * z) t_2 = t * (y * (x - z)) tmp = 0 if t_1 <= -2e+194: tmp = y / ((1.0 / t) / (x - z)) elif t_1 <= -2e-148: tmp = t_2 elif t_1 <= 5e-137: tmp = (x - z) * (y * t) elif t_1 <= 5e+256: tmp = t_2 else: tmp = y * (t * (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) t_1 = Float64(Float64(x * y) - Float64(y * z)) t_2 = Float64(t * Float64(y * Float64(x - z))) tmp = 0.0 if (t_1 <= -2e+194) tmp = Float64(y / Float64(Float64(1.0 / t) / Float64(x - z))); elseif (t_1 <= -2e-148) tmp = t_2; elseif (t_1 <= 5e-137) tmp = Float64(Float64(x - z) * Float64(y * t)); elseif (t_1 <= 5e+256) tmp = t_2; else tmp = Float64(y * Float64(t * 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) t_1 = (x * y) - (y * z); t_2 = t * (y * (x - z)); tmp = 0.0; if (t_1 <= -2e+194) tmp = y / ((1.0 / t) / (x - z)); elseif (t_1 <= -2e-148) tmp = t_2; elseif (t_1 <= 5e-137) tmp = (x - z) * (y * t); elseif (t_1 <= 5e+256) tmp = t_2; else tmp = y * (t * (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_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t * N[(y * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+194], N[(y / N[(N[(1.0 / t), $MachinePrecision] / N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -2e-148], t$95$2, If[LessEqual[t$95$1, 5e-137], N[(N[(x - z), $MachinePrecision] * N[(y * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+256], t$95$2, N[(y * N[(t * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\left(x \cdot y - z \cdot y\right) \cdot t
\begin{array}{l}
t_1 := x \cdot y - y \cdot z\\
t_2 := t \cdot \left(y \cdot \left(x - z\right)\right)\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{+194}:\\
\;\;\;\;\frac{y}{\frac{\frac{1}{t}}{x - z}}\\
\mathbf{elif}\;t_1 \leq -2 \cdot 10^{-148}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{-137}:\\
\;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+256}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(t \cdot \left(x - z\right)\right)\\
\end{array}
Results
| Original | 88.9% |
|---|---|
| Target | 95.1% |
| Herbie | 98.9% |
if (-.f64 (*.f64 x y) (*.f64 z y)) < -1.99999999999999989e194Initial program 59.3%
Simplified97.5%
[Start]59.3 | \[ \left(x \cdot y - z \cdot y\right) \cdot t
\] |
|---|---|
distribute-rgt-out-- [=>]59.3 | \[ \color{blue}{\left(y \cdot \left(x - z\right)\right)} \cdot t
\] |
associate-*l* [=>]97.5 | \[ \color{blue}{y \cdot \left(\left(x - z\right) \cdot t\right)}
\] |
*-commutative [=>]97.5 | \[ y \cdot \color{blue}{\left(t \cdot \left(x - z\right)\right)}
\] |
Applied egg-rr99.0%
[Start]97.5 | \[ y \cdot \left(t \cdot \left(x - z\right)\right)
\] |
|---|---|
associate-*r* [=>]99.1 | \[ \color{blue}{\left(y \cdot t\right) \cdot \left(x - z\right)}
\] |
flip3-- [=>]24.0 | \[ \left(y \cdot t\right) \cdot \color{blue}{\frac{{x}^{3} - {z}^{3}}{x \cdot x + \left(z \cdot z + x \cdot z\right)}}
\] |
associate-*r/ [=>]17.0 | \[ \color{blue}{\frac{\left(y \cdot t\right) \cdot \left({x}^{3} - {z}^{3}\right)}{x \cdot x + \left(z \cdot z + x \cdot z\right)}}
\] |
associate-/l* [=>]24.0 | \[ \color{blue}{\frac{y \cdot t}{\frac{x \cdot x + \left(z \cdot z + x \cdot z\right)}{{x}^{3} - {z}^{3}}}}
\] |
*-un-lft-identity [=>]24.0 | \[ \frac{y \cdot t}{\frac{\color{blue}{1 \cdot \left(x \cdot x + \left(z \cdot z + x \cdot z\right)\right)}}{{x}^{3} - {z}^{3}}}
\] |
associate-/l* [=>]24.0 | \[ \frac{y \cdot t}{\color{blue}{\frac{1}{\frac{{x}^{3} - {z}^{3}}{x \cdot x + \left(z \cdot z + x \cdot z\right)}}}}
\] |
flip3-- [<=]99.0 | \[ \frac{y \cdot t}{\frac{1}{\color{blue}{x - z}}}
\] |
Applied egg-rr98.9%
[Start]99.0 | \[ \frac{y \cdot t}{\frac{1}{x - z}}
\] |
|---|---|
frac-2neg [=>]99.0 | \[ \frac{y \cdot t}{\color{blue}{\frac{-1}{-\left(x - z\right)}}}
\] |
associate-/r/ [=>]99.1 | \[ \color{blue}{\frac{y \cdot t}{-1} \cdot \left(-\left(x - z\right)\right)}
\] |
associate-/l* [=>]98.9 | \[ \color{blue}{\frac{y}{\frac{-1}{t}}} \cdot \left(-\left(x - z\right)\right)
\] |
metadata-eval [=>]98.9 | \[ \frac{y}{\frac{\color{blue}{-1}}{t}} \cdot \left(-\left(x - z\right)\right)
\] |
Applied egg-rr97.6%
[Start]98.9 | \[ \frac{y}{\frac{-1}{t}} \cdot \left(-\left(x - z\right)\right)
\] |
|---|---|
associate-*l/ [=>]59.2 | \[ \color{blue}{\frac{y \cdot \left(-\left(x - z\right)\right)}{\frac{-1}{t}}}
\] |
associate-/l* [=>]97.6 | \[ \color{blue}{\frac{y}{\frac{\frac{-1}{t}}{-\left(x - z\right)}}}
\] |
neg-mul-1 [=>]97.6 | \[ \frac{y}{\frac{\frac{-1}{t}}{\color{blue}{-1 \cdot \left(x - z\right)}}}
\] |
associate-/r* [=>]97.6 | \[ \frac{y}{\color{blue}{\frac{\frac{\frac{-1}{t}}{-1}}{x - z}}}
\] |
associate-/r* [<=]97.6 | \[ \frac{y}{\frac{\color{blue}{\frac{-1}{t \cdot -1}}}{x - z}}
\] |
metadata-eval [<=]97.6 | \[ \frac{y}{\frac{\frac{-1}{t \cdot \color{blue}{\frac{1}{-1}}}}{x - z}}
\] |
div-inv [<=]97.6 | \[ \frac{y}{\frac{\frac{-1}{\color{blue}{\frac{t}{-1}}}}{x - z}}
\] |
clear-num [=>]97.6 | \[ \frac{y}{\frac{\frac{-1}{\color{blue}{\frac{1}{\frac{-1}{t}}}}}{x - z}}
\] |
associate-/r/ [=>]97.6 | \[ \frac{y}{\frac{\frac{-1}{\color{blue}{\frac{1}{-1} \cdot t}}}{x - z}}
\] |
metadata-eval [=>]97.6 | \[ \frac{y}{\frac{\frac{-1}{\color{blue}{-1} \cdot t}}{x - z}}
\] |
associate-/r* [=>]97.6 | \[ \frac{y}{\frac{\color{blue}{\frac{\frac{-1}{-1}}{t}}}{x - z}}
\] |
metadata-eval [=>]97.6 | \[ \frac{y}{\frac{\frac{\color{blue}{1}}{t}}{x - z}}
\] |
if -1.99999999999999989e194 < (-.f64 (*.f64 x y) (*.f64 z y)) < -1.99999999999999987e-148 or 5.00000000000000001e-137 < (-.f64 (*.f64 x y) (*.f64 z y)) < 5.00000000000000015e256Initial program 99.6%
Simplified99.6%
[Start]99.6 | \[ \left(x \cdot y - z \cdot y\right) \cdot t
\] |
|---|---|
distribute-rgt-out-- [=>]99.6 | \[ \color{blue}{\left(y \cdot \left(x - z\right)\right)} \cdot t
\] |
if -1.99999999999999987e-148 < (-.f64 (*.f64 x y) (*.f64 z y)) < 5.00000000000000001e-137Initial program 91.8%
Simplified97.1%
[Start]91.8 | \[ \left(x \cdot y - z \cdot y\right) \cdot t
\] |
|---|---|
distribute-rgt-out-- [=>]91.8 | \[ \color{blue}{\left(y \cdot \left(x - z\right)\right)} \cdot t
\] |
associate-*l* [=>]97.1 | \[ \color{blue}{y \cdot \left(\left(x - z\right) \cdot t\right)}
\] |
*-commutative [=>]97.1 | \[ y \cdot \color{blue}{\left(t \cdot \left(x - z\right)\right)}
\] |
Taylor expanded in x around 0 97.1%
Simplified97.0%
[Start]97.1 | \[ y \cdot \left(t \cdot x\right) + -1 \cdot \left(y \cdot \left(t \cdot z\right)\right)
\] |
|---|---|
mul-1-neg [=>]97.1 | \[ y \cdot \left(t \cdot x\right) + \color{blue}{\left(-y \cdot \left(t \cdot z\right)\right)}
\] |
associate-*r* [=>]96.5 | \[ \color{blue}{\left(y \cdot t\right) \cdot x} + \left(-y \cdot \left(t \cdot z\right)\right)
\] |
associate-*r* [=>]97.0 | \[ \left(y \cdot t\right) \cdot x + \left(-\color{blue}{\left(y \cdot t\right) \cdot z}\right)
\] |
distribute-rgt-neg-out [<=]97.0 | \[ \left(y \cdot t\right) \cdot x + \color{blue}{\left(y \cdot t\right) \cdot \left(-z\right)}
\] |
distribute-lft-in [<=]97.0 | \[ \color{blue}{\left(y \cdot t\right) \cdot \left(x + \left(-z\right)\right)}
\] |
sub-neg [<=]97.0 | \[ \left(y \cdot t\right) \cdot \color{blue}{\left(x - z\right)}
\] |
*-commutative [=>]97.0 | \[ \color{blue}{\left(x - z\right) \cdot \left(y \cdot t\right)}
\] |
if 5.00000000000000015e256 < (-.f64 (*.f64 x y) (*.f64 z y)) Initial program 31.7%
Simplified99.4%
[Start]31.7 | \[ \left(x \cdot y - z \cdot y\right) \cdot t
\] |
|---|---|
distribute-rgt-out-- [=>]31.7 | \[ \color{blue}{\left(y \cdot \left(x - z\right)\right)} \cdot t
\] |
associate-*l* [=>]99.4 | \[ \color{blue}{y \cdot \left(\left(x - z\right) \cdot t\right)}
\] |
*-commutative [=>]99.4 | \[ y \cdot \color{blue}{\left(t \cdot \left(x - z\right)\right)}
\] |
Final simplification98.9%
| Alternative 1 | |
|---|---|
| Accuracy | 99.1% |
| Cost | 2512 |
| Alternative 2 | |
|---|---|
| Accuracy | 69.7% |
| Cost | 780 |
| Alternative 3 | |
|---|---|
| Accuracy | 69.4% |
| Cost | 649 |
| Alternative 4 | |
|---|---|
| Accuracy | 69.6% |
| Cost | 649 |
| Alternative 5 | |
|---|---|
| Accuracy | 87.0% |
| Cost | 580 |
| Alternative 6 | |
|---|---|
| Accuracy | 96.2% |
| Cost | 580 |
| Alternative 7 | |
|---|---|
| Accuracy | 54.4% |
| Cost | 452 |
| Alternative 8 | |
|---|---|
| Accuracy | 51.4% |
| Cost | 320 |
herbie shell --seed 2023137
(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))