| Alternative 1 | |
|---|---|
| Error | 3.9 |
| Cost | 1864 |
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* z t)) a))
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* t (- (/ z a)))))
(if (<= (* z t) (- INFINITY))
t_1
(if (<= (* z t) 4e+259) (- (* y (/ x a)) (/ (* t z) a)) t_1))))double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
double code(double x, double y, double z, double t, double a) {
double t_1 = t * -(z / a);
double tmp;
if ((z * t) <= -((double) INFINITY)) {
tmp = t_1;
} else if ((z * t) <= 4e+259) {
tmp = (y * (x / a)) - ((t * z) / a);
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = t * -(z / a);
double tmp;
if ((z * t) <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if ((z * t) <= 4e+259) {
tmp = (y * (x / a)) - ((t * z) / a);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): return ((x * y) - (z * t)) / a
def code(x, y, z, t, a): t_1 = t * -(z / a) tmp = 0 if (z * t) <= -math.inf: tmp = t_1 elif (z * t) <= 4e+259: tmp = (y * (x / a)) - ((t * z) / a) else: tmp = t_1 return tmp
function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) - Float64(z * t)) / a) end
function code(x, y, z, t, a) t_1 = Float64(t * Float64(-Float64(z / a))) tmp = 0.0 if (Float64(z * t) <= Float64(-Inf)) tmp = t_1; elseif (Float64(z * t) <= 4e+259) tmp = Float64(Float64(y * Float64(x / a)) - Float64(Float64(t * z) / a)); else tmp = t_1; end return tmp end
function tmp = code(x, y, z, t, a) tmp = ((x * y) - (z * t)) / a; end
function tmp_2 = code(x, y, z, t, a) t_1 = t * -(z / a); tmp = 0.0; if ((z * t) <= -Inf) tmp = t_1; elseif ((z * t) <= 4e+259) tmp = (y * (x / a)) - ((t * z) / a); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(t * (-N[(z / a), $MachinePrecision])), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], (-Infinity)], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 4e+259], N[(N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision] - N[(N[(t * z), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
t_1 := t \cdot \left(-\frac{z}{a}\right)\\
\mathbf{if}\;z \cdot t \leq -\infty:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \cdot t \leq 4 \cdot 10^{+259}:\\
\;\;\;\;y \cdot \frac{x}{a} - \frac{t \cdot z}{a}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
Results
| Original | 7.3 |
|---|---|
| Target | 5.6 |
| Herbie | 4.5 |
if (*.f64 z t) < -inf.0 or 4e259 < (*.f64 z t) Initial program 51.0
Applied egg-rr64.0
Taylor expanded in x around inf 51.0
Simplified51.0
[Start]51.0 | \[ \left(-2 \cdot \frac{t \cdot z}{a} + \frac{y \cdot x}{a}\right) - -1 \cdot \frac{t \cdot z}{a}
\] |
|---|---|
rational.json-simplify-1 [=>]51.0 | \[ \color{blue}{\left(\frac{y \cdot x}{a} + -2 \cdot \frac{t \cdot z}{a}\right)} - -1 \cdot \frac{t \cdot z}{a}
\] |
rational.json-simplify-2 [=>]51.0 | \[ \left(\frac{y \cdot x}{a} + -2 \cdot \frac{t \cdot z}{a}\right) - \color{blue}{\frac{t \cdot z}{a} \cdot -1}
\] |
rational.json-simplify-9 [=>]51.0 | \[ \left(\frac{y \cdot x}{a} + -2 \cdot \frac{t \cdot z}{a}\right) - \color{blue}{\left(-\frac{t \cdot z}{a}\right)}
\] |
Taylor expanded in t around -inf 4.1
Simplified4.1
[Start]4.1 | \[ -1 \cdot \left(t \cdot \left(2 \cdot \frac{z}{a} + -1 \cdot \frac{z}{a}\right)\right)
\] |
|---|---|
rational.json-simplify-43 [=>]4.1 | \[ \color{blue}{t \cdot \left(\left(2 \cdot \frac{z}{a} + -1 \cdot \frac{z}{a}\right) \cdot -1\right)}
\] |
rational.json-simplify-9 [=>]4.1 | \[ t \cdot \color{blue}{\left(-\left(2 \cdot \frac{z}{a} + -1 \cdot \frac{z}{a}\right)\right)}
\] |
rational.json-simplify-2 [=>]4.1 | \[ t \cdot \left(-\left(\color{blue}{\frac{z}{a} \cdot 2} + -1 \cdot \frac{z}{a}\right)\right)
\] |
rational.json-simplify-47 [=>]4.1 | \[ t \cdot \left(-\color{blue}{\frac{z}{a} \cdot \left(-1 + 2\right)}\right)
\] |
metadata-eval [=>]4.1 | \[ t \cdot \left(-\frac{z}{a} \cdot \color{blue}{1}\right)
\] |
rational.json-simplify-2 [=>]4.1 | \[ t \cdot \left(-\color{blue}{1 \cdot \frac{z}{a}}\right)
\] |
rational.json-simplify-6 [=>]4.1 | \[ t \cdot \left(-\color{blue}{\frac{z}{a}}\right)
\] |
if -inf.0 < (*.f64 z t) < 4e259Initial program 4.0
Applied egg-rr23.2
Taylor expanded in y around 0 4.5
Simplified4.5
[Start]4.5 | \[ -1 \cdot \frac{t \cdot z}{a} + y \cdot \left(2 \cdot \frac{x}{a} - \frac{x}{a}\right)
\] |
|---|---|
rational.json-simplify-2 [=>]4.5 | \[ \color{blue}{\frac{t \cdot z}{a} \cdot -1} + y \cdot \left(2 \cdot \frac{x}{a} - \frac{x}{a}\right)
\] |
rational.json-simplify-9 [=>]4.5 | \[ \color{blue}{\left(-\frac{t \cdot z}{a}\right)} + y \cdot \left(2 \cdot \frac{x}{a} - \frac{x}{a}\right)
\] |
Taylor expanded in t around 0 4.5
Simplified4.5
[Start]4.5 | \[ -1 \cdot \frac{t \cdot z}{a} + y \cdot \left(2 \cdot \frac{x}{a} - \frac{x}{a}\right)
\] |
|---|---|
rational.json-simplify-2 [=>]4.5 | \[ -1 \cdot \frac{t \cdot z}{a} + y \cdot \left(\color{blue}{\frac{x}{a} \cdot 2} - \frac{x}{a}\right)
\] |
rational.json-simplify-6 [<=]4.5 | \[ -1 \cdot \frac{t \cdot z}{a} + y \cdot \left(\frac{x}{a} \cdot 2 - \color{blue}{1 \cdot \frac{x}{a}}\right)
\] |
rational.json-simplify-48 [=>]4.5 | \[ -1 \cdot \frac{t \cdot z}{a} + y \cdot \color{blue}{\left(\frac{x}{a} \cdot \left(2 - 1\right)\right)}
\] |
metadata-eval [=>]4.5 | \[ -1 \cdot \frac{t \cdot z}{a} + y \cdot \left(\frac{x}{a} \cdot \color{blue}{1}\right)
\] |
rational.json-simplify-2 [=>]4.5 | \[ -1 \cdot \frac{t \cdot z}{a} + y \cdot \color{blue}{\left(1 \cdot \frac{x}{a}\right)}
\] |
rational.json-simplify-6 [=>]4.5 | \[ -1 \cdot \frac{t \cdot z}{a} + y \cdot \color{blue}{\frac{x}{a}}
\] |
rational.json-simplify-5 [<=]4.5 | \[ -1 \cdot \frac{t \cdot z}{a} + \color{blue}{\left(y \cdot \frac{x}{a} - 0\right)}
\] |
metadata-eval [<=]4.5 | \[ -1 \cdot \frac{t \cdot z}{a} + \left(y \cdot \frac{x}{a} - \color{blue}{\left(0 - 0\right)}\right)
\] |
rational.json-simplify-44 [<=]4.5 | \[ -1 \cdot \frac{t \cdot z}{a} + \color{blue}{\left(0 - \left(0 - y \cdot \frac{x}{a}\right)\right)}
\] |
rational.json-simplify-12 [<=]4.5 | \[ -1 \cdot \frac{t \cdot z}{a} + \left(0 - \color{blue}{\left(-y \cdot \frac{x}{a}\right)}\right)
\] |
rational.json-simplify-12 [<=]4.5 | \[ -1 \cdot \frac{t \cdot z}{a} + \color{blue}{\left(-\left(-y \cdot \frac{x}{a}\right)\right)}
\] |
rational.json-simplify-8 [=>]4.5 | \[ -1 \cdot \frac{t \cdot z}{a} + \color{blue}{\left(-y \cdot \frac{x}{a}\right) \cdot -1}
\] |
rational.json-simplify-47 [=>]4.5 | \[ \color{blue}{-1 \cdot \left(\left(-y \cdot \frac{x}{a}\right) + \frac{t \cdot z}{a}\right)}
\] |
rational.json-simplify-1 [<=]4.5 | \[ -1 \cdot \color{blue}{\left(\frac{t \cdot z}{a} + \left(-y \cdot \frac{x}{a}\right)\right)}
\] |
rational.json-simplify-2 [<=]4.5 | \[ \color{blue}{\left(\frac{t \cdot z}{a} + \left(-y \cdot \frac{x}{a}\right)\right) \cdot -1}
\] |
rational.json-simplify-8 [<=]4.5 | \[ \color{blue}{-\left(\frac{t \cdot z}{a} + \left(-y \cdot \frac{x}{a}\right)\right)}
\] |
rational.json-simplify-13 [<=]4.5 | \[ \color{blue}{0 - \left(\frac{t \cdot z}{a} + \left(-y \cdot \frac{x}{a}\right)\right)}
\] |
rational.json-simplify-46 [=>]4.5 | \[ \color{blue}{\left(0 - \frac{t \cdot z}{a}\right) - \left(-y \cdot \frac{x}{a}\right)}
\] |
rational.json-simplify-42 [=>]4.5 | \[ \color{blue}{\left(0 - \left(-y \cdot \frac{x}{a}\right)\right) - \frac{t \cdot z}{a}}
\] |
Final simplification4.5
| Alternative 1 | |
|---|---|
| Error | 3.9 |
| Cost | 1864 |
| Alternative 2 | |
|---|---|
| Error | 24.9 |
| Cost | 912 |
| Alternative 3 | |
|---|---|
| Error | 24.9 |
| Cost | 912 |
| Alternative 4 | |
|---|---|
| Error | 30.8 |
| Cost | 584 |
| Alternative 5 | |
|---|---|
| Error | 32.2 |
| Cost | 320 |
herbie shell --seed 2023077
(FPCore (x y z t a)
:name "Data.Colour.Matrix:inverse from colour-2.3.3, B"
:precision binary64
:herbie-target
(if (< z -2.468684968699548e+170) (- (* (/ y a) x) (* (/ t a) z)) (if (< z 6.309831121978371e-71) (/ (- (* x y) (* z t)) a) (- (* (/ y a) x) (* (/ t a) z))))
(/ (- (* x y) (* z t)) a))