| Alternative 1 | |
|---|---|
| Error | 8.4 |
| Cost | 3532 |
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y z) (- t x)) (- a z))))
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ x (/ (* (- y z) (- t x)) (- a z)))))
(if (<= t_1 (- INFINITY))
(+ t (- (* (/ (- t x) z) (- y a))))
(if (<= t_1 -5e-304)
(+ x (* (- t x) (/ (- y z) (- a z))))
(if (<= t_1 0.0)
(+ t (- (/ (* (- t x) (- y a)) z)))
(+ x (/ (- z y) (/ (- z a) (- t x)))))))))double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * (t - x)) / (a - z));
}
double code(double x, double y, double z, double t, double a) {
double t_1 = x + (((y - z) * (t - x)) / (a - z));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t + -(((t - x) / z) * (y - a));
} else if (t_1 <= -5e-304) {
tmp = x + ((t - x) * ((y - z) / (a - z)));
} else if (t_1 <= 0.0) {
tmp = t + -(((t - x) * (y - a)) / z);
} else {
tmp = x + ((z - y) / ((z - a) / (t - x)));
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * (t - x)) / (a - z));
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = x + (((y - z) * (t - x)) / (a - z));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = t + -(((t - x) / z) * (y - a));
} else if (t_1 <= -5e-304) {
tmp = x + ((t - x) * ((y - z) / (a - z)));
} else if (t_1 <= 0.0) {
tmp = t + -(((t - x) * (y - a)) / z);
} else {
tmp = x + ((z - y) / ((z - a) / (t - x)));
}
return tmp;
}
def code(x, y, z, t, a): return x + (((y - z) * (t - x)) / (a - z))
def code(x, y, z, t, a): t_1 = x + (((y - z) * (t - x)) / (a - z)) tmp = 0 if t_1 <= -math.inf: tmp = t + -(((t - x) / z) * (y - a)) elif t_1 <= -5e-304: tmp = x + ((t - x) * ((y - z) / (a - z))) elif t_1 <= 0.0: tmp = t + -(((t - x) * (y - a)) / z) else: tmp = x + ((z - y) / ((z - a) / (t - x))) return tmp
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - z) * Float64(t - x)) / Float64(a - z))) end
function code(x, y, z, t, a) t_1 = Float64(x + Float64(Float64(Float64(y - z) * Float64(t - x)) / Float64(a - z))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(t + Float64(-Float64(Float64(Float64(t - x) / z) * Float64(y - a)))); elseif (t_1 <= -5e-304) tmp = Float64(x + Float64(Float64(t - x) * Float64(Float64(y - z) / Float64(a - z)))); elseif (t_1 <= 0.0) tmp = Float64(t + Float64(-Float64(Float64(Float64(t - x) * Float64(y - a)) / z))); else tmp = Float64(x + Float64(Float64(z - y) / Float64(Float64(z - a) / Float64(t - x)))); end return tmp end
function tmp = code(x, y, z, t, a) tmp = x + (((y - z) * (t - x)) / (a - z)); end
function tmp_2 = code(x, y, z, t, a) t_1 = x + (((y - z) * (t - x)) / (a - z)); tmp = 0.0; if (t_1 <= -Inf) tmp = t + -(((t - x) / z) * (y - a)); elseif (t_1 <= -5e-304) tmp = x + ((t - x) * ((y - z) / (a - z))); elseif (t_1 <= 0.0) tmp = t + -(((t - x) * (y - a)) / z); else tmp = x + ((z - y) / ((z - a) / (t - x))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x + N[(N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(t + (-N[(N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision] * N[(y - a), $MachinePrecision]), $MachinePrecision])), $MachinePrecision], If[LessEqual[t$95$1, -5e-304], N[(x + N[(N[(t - x), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(t + (-N[(N[(N[(t - x), $MachinePrecision] * N[(y - a), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision])), $MachinePrecision], N[(x + N[(N[(z - y), $MachinePrecision] / N[(N[(z - a), $MachinePrecision] / N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
t_1 := x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;t + \left(-\frac{t - x}{z} \cdot \left(y - a\right)\right)\\
\mathbf{elif}\;t_1 \leq -5 \cdot 10^{-304}:\\
\;\;\;\;x + \left(t - x\right) \cdot \frac{y - z}{a - z}\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;t + \left(-\frac{\left(t - x\right) \cdot \left(y - a\right)}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{z - y}{\frac{z - a}{t - x}}\\
\end{array}
Results
| Original | 24.2 |
|---|---|
| Target | 11.6 |
| Herbie | 8.4 |
if (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < -inf.0Initial program 64.0
Taylor expanded in z around inf 38.8
Simplified20.2
[Start]38.8 | \[ \left(-1 \cdot \frac{y \cdot \left(t - x\right)}{z} + t\right) - -1 \cdot \frac{a \cdot \left(t - x\right)}{z}
\] |
|---|---|
rational.json-simplify-48 [=>]38.8 | \[ \color{blue}{t + \left(-1 \cdot \frac{y \cdot \left(t - x\right)}{z} - -1 \cdot \frac{a \cdot \left(t - x\right)}{z}\right)}
\] |
rational.json-simplify-2 [=>]38.8 | \[ t + \left(-1 \cdot \frac{y \cdot \left(t - x\right)}{z} - \color{blue}{\frac{a \cdot \left(t - x\right)}{z} \cdot -1}\right)
\] |
rational.json-simplify-52 [=>]38.8 | \[ t + \color{blue}{-1 \cdot \left(\frac{y \cdot \left(t - x\right)}{z} - \frac{a \cdot \left(t - x\right)}{z}\right)}
\] |
rational.json-simplify-2 [=>]38.8 | \[ t + \color{blue}{\left(\frac{y \cdot \left(t - x\right)}{z} - \frac{a \cdot \left(t - x\right)}{z}\right) \cdot -1}
\] |
rational.json-simplify-9 [=>]38.8 | \[ t + \color{blue}{\left(-\left(\frac{y \cdot \left(t - x\right)}{z} - \frac{a \cdot \left(t - x\right)}{z}\right)\right)}
\] |
rational.json-simplify-2 [=>]38.8 | \[ t + \left(-\left(\frac{\color{blue}{\left(t - x\right) \cdot y}}{z} - \frac{a \cdot \left(t - x\right)}{z}\right)\right)
\] |
rational.json-simplify-49 [=>]28.8 | \[ t + \left(-\left(\color{blue}{y \cdot \frac{t - x}{z}} - \frac{a \cdot \left(t - x\right)}{z}\right)\right)
\] |
rational.json-simplify-2 [=>]28.8 | \[ t + \left(-\left(\color{blue}{\frac{t - x}{z} \cdot y} - \frac{a \cdot \left(t - x\right)}{z}\right)\right)
\] |
rational.json-simplify-2 [=>]28.8 | \[ t + \left(-\left(\frac{t - x}{z} \cdot y - \frac{\color{blue}{\left(t - x\right) \cdot a}}{z}\right)\right)
\] |
rational.json-simplify-49 [=>]20.2 | \[ t + \left(-\left(\frac{t - x}{z} \cdot y - \color{blue}{a \cdot \frac{t - x}{z}}\right)\right)
\] |
rational.json-simplify-52 [=>]20.2 | \[ t + \left(-\color{blue}{\frac{t - x}{z} \cdot \left(y - a\right)}\right)
\] |
if -inf.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < -4.99999999999999965e-304Initial program 1.8
Simplified2.6
[Start]1.8 | \[ x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\] |
|---|---|
rational.json-simplify-49 [=>]2.6 | \[ x + \color{blue}{\left(t - x\right) \cdot \frac{y - z}{a - z}}
\] |
if -4.99999999999999965e-304 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < 0.0Initial program 60.9
Simplified60.9
[Start]60.9 | \[ x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\] |
|---|---|
rational.json-simplify-49 [=>]60.9 | \[ x + \color{blue}{\left(t - x\right) \cdot \frac{y - z}{a - z}}
\] |
Taylor expanded in z around -inf 0.9
Simplified0.9
[Start]0.9 | \[ -1 \cdot \frac{y \cdot \left(t - x\right) - a \cdot \left(t - x\right)}{z} + t
\] |
|---|---|
rational.json-simplify-1 [=>]0.9 | \[ \color{blue}{t + -1 \cdot \frac{y \cdot \left(t - x\right) - a \cdot \left(t - x\right)}{z}}
\] |
rational.json-simplify-2 [=>]0.9 | \[ t + \color{blue}{\frac{y \cdot \left(t - x\right) - a \cdot \left(t - x\right)}{z} \cdot -1}
\] |
rational.json-simplify-9 [=>]0.9 | \[ t + \color{blue}{\left(-\frac{y \cdot \left(t - x\right) - a \cdot \left(t - x\right)}{z}\right)}
\] |
rational.json-simplify-2 [=>]0.9 | \[ t + \left(-\frac{\color{blue}{\left(t - x\right) \cdot y} - a \cdot \left(t - x\right)}{z}\right)
\] |
rational.json-simplify-52 [=>]0.9 | \[ t + \left(-\frac{\color{blue}{\left(t - x\right) \cdot \left(y - a\right)}}{z}\right)
\] |
if 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) Initial program 21.0
Simplified7.0
[Start]21.0 | \[ x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\] |
|---|---|
rational.json-simplify-49 [=>]7.0 | \[ x + \color{blue}{\left(t - x\right) \cdot \frac{y - z}{a - z}}
\] |
Applied egg-rr10.3
Final simplification8.4
| Alternative 1 | |
|---|---|
| Error | 8.4 |
| Cost | 3532 |
| Alternative 2 | |
|---|---|
| Error | 26.5 |
| Cost | 1496 |
| Alternative 3 | |
|---|---|
| Error | 35.2 |
| Cost | 1372 |
| Alternative 4 | |
|---|---|
| Error | 34.9 |
| Cost | 1372 |
| Alternative 5 | |
|---|---|
| Error | 28.9 |
| Cost | 1368 |
| Alternative 6 | |
|---|---|
| Error | 31.4 |
| Cost | 1304 |
| Alternative 7 | |
|---|---|
| Error | 18.8 |
| Cost | 1296 |
| Alternative 8 | |
|---|---|
| Error | 39.8 |
| Cost | 1240 |
| Alternative 9 | |
|---|---|
| Error | 31.1 |
| Cost | 1240 |
| Alternative 10 | |
|---|---|
| Error | 29.9 |
| Cost | 1236 |
| Alternative 11 | |
|---|---|
| Error | 29.4 |
| Cost | 1236 |
| Alternative 12 | |
|---|---|
| Error | 26.3 |
| Cost | 1236 |
| Alternative 13 | |
|---|---|
| Error | 42.6 |
| Cost | 1112 |
| Alternative 14 | |
|---|---|
| Error | 8.0 |
| Cost | 1096 |
| Alternative 15 | |
|---|---|
| Error | 17.5 |
| Cost | 1032 |
| Alternative 16 | |
|---|---|
| Error | 36.1 |
| Cost | 976 |
| Alternative 17 | |
|---|---|
| Error | 26.3 |
| Cost | 972 |
| Alternative 18 | |
|---|---|
| Error | 26.3 |
| Cost | 972 |
| Alternative 19 | |
|---|---|
| Error | 36.6 |
| Cost | 716 |
| Alternative 20 | |
|---|---|
| Error | 38.2 |
| Cost | 716 |
| Alternative 21 | |
|---|---|
| Error | 36.2 |
| Cost | 328 |
| Alternative 22 | |
|---|---|
| Error | 62.1 |
| Cost | 64 |
| Alternative 23 | |
|---|---|
| Error | 45.5 |
| Cost | 64 |
herbie shell --seed 2023069
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.Axis.Types:invLinMap from Chart-1.5.3"
:precision binary64
:herbie-target
(if (< z -1.2536131056095036e+188) (- t (* (/ y z) (- t x))) (if (< z 4.446702369113811e+64) (+ x (/ (- y z) (/ (- a z) (- t x)))) (- t (* (/ y z) (- t x)))))
(+ x (/ (* (- y z) (- t x)) (- a z))))