| Alternative 1 | |
|---|---|
| Error | 11.4 |
| Cost | 6352 |
(FPCore (x y z t a b c) :precision binary64 (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)))
(FPCore (x y z t a b c)
:precision binary64
(let* ((t_1 (/ (+ (* 9.0 (/ (* y x) z)) (* -4.0 (* a t))) c))
(t_2 (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)))
(t_3 (/ (* a t) c)))
(if (<= t_2 (- INFINITY))
(* t_3 -4.0)
(if (<= t_2 -2e+59)
t_2
(if (<= t_2 -5e-195)
(- (+ (/ b (* z c)) (* 9.0 (/ (* y x) (* z c)))) (* 4.0 t_3))
(if (<= t_2 5e-282) t_1 (if (<= t_2 1e+273) t_2 t_1)))))))double code(double x, double y, double z, double t, double a, double b, double c) {
return ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
}
double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = ((9.0 * ((y * x) / z)) + (-4.0 * (a * t))) / c;
double t_2 = ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
double t_3 = (a * t) / c;
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_3 * -4.0;
} else if (t_2 <= -2e+59) {
tmp = t_2;
} else if (t_2 <= -5e-195) {
tmp = ((b / (z * c)) + (9.0 * ((y * x) / (z * c)))) - (4.0 * t_3);
} else if (t_2 <= 5e-282) {
tmp = t_1;
} else if (t_2 <= 1e+273) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a, double b, double c) {
return ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
}
public static double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = ((9.0 * ((y * x) / z)) + (-4.0 * (a * t))) / c;
double t_2 = ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
double t_3 = (a * t) / c;
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = t_3 * -4.0;
} else if (t_2 <= -2e+59) {
tmp = t_2;
} else if (t_2 <= -5e-195) {
tmp = ((b / (z * c)) + (9.0 * ((y * x) / (z * c)))) - (4.0 * t_3);
} else if (t_2 <= 5e-282) {
tmp = t_1;
} else if (t_2 <= 1e+273) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b, c): return ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c)
def code(x, y, z, t, a, b, c): t_1 = ((9.0 * ((y * x) / z)) + (-4.0 * (a * t))) / c t_2 = ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c) t_3 = (a * t) / c tmp = 0 if t_2 <= -math.inf: tmp = t_3 * -4.0 elif t_2 <= -2e+59: tmp = t_2 elif t_2 <= -5e-195: tmp = ((b / (z * c)) + (9.0 * ((y * x) / (z * c)))) - (4.0 * t_3) elif t_2 <= 5e-282: tmp = t_1 elif t_2 <= 1e+273: tmp = t_2 else: tmp = t_1 return tmp
function code(x, y, z, t, a, b, c) return Float64(Float64(Float64(Float64(Float64(x * 9.0) * y) - Float64(Float64(Float64(z * 4.0) * t) * a)) + b) / Float64(z * c)) end
function code(x, y, z, t, a, b, c) t_1 = Float64(Float64(Float64(9.0 * Float64(Float64(y * x) / z)) + Float64(-4.0 * Float64(a * t))) / c) t_2 = Float64(Float64(Float64(Float64(Float64(x * 9.0) * y) - Float64(Float64(Float64(z * 4.0) * t) * a)) + b) / Float64(z * c)) t_3 = Float64(Float64(a * t) / c) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(t_3 * -4.0); elseif (t_2 <= -2e+59) tmp = t_2; elseif (t_2 <= -5e-195) tmp = Float64(Float64(Float64(b / Float64(z * c)) + Float64(9.0 * Float64(Float64(y * x) / Float64(z * c)))) - Float64(4.0 * t_3)); elseif (t_2 <= 5e-282) tmp = t_1; elseif (t_2 <= 1e+273) tmp = t_2; else tmp = t_1; end return tmp end
function tmp = code(x, y, z, t, a, b, c) tmp = ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c); end
function tmp_2 = code(x, y, z, t, a, b, c) t_1 = ((9.0 * ((y * x) / z)) + (-4.0 * (a * t))) / c; t_2 = ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c); t_3 = (a * t) / c; tmp = 0.0; if (t_2 <= -Inf) tmp = t_3 * -4.0; elseif (t_2 <= -2e+59) tmp = t_2; elseif (t_2 <= -5e-195) tmp = ((b / (z * c)) + (9.0 * ((y * x) / (z * c)))) - (4.0 * t_3); elseif (t_2 <= 5e-282) tmp = t_1; elseif (t_2 <= 1e+273) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_] := N[(N[(N[(N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision] - N[(N[(N[(z * 4.0), $MachinePrecision] * t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(N[(N[(9.0 * N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] + N[(-4.0 * N[(a * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision] - N[(N[(N[(z * 4.0), $MachinePrecision] * t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(a * t), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(t$95$3 * -4.0), $MachinePrecision], If[LessEqual[t$95$2, -2e+59], t$95$2, If[LessEqual[t$95$2, -5e-195], N[(N[(N[(b / N[(z * c), $MachinePrecision]), $MachinePrecision] + N[(9.0 * N[(N[(y * x), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(4.0 * t$95$3), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e-282], t$95$1, If[LessEqual[t$95$2, 1e+273], t$95$2, t$95$1]]]]]]]]
\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}
\begin{array}{l}
t_1 := \frac{9 \cdot \frac{y \cdot x}{z} + -4 \cdot \left(a \cdot t\right)}{c}\\
t_2 := \frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\\
t_3 := \frac{a \cdot t}{c}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_3 \cdot -4\\
\mathbf{elif}\;t_2 \leq -2 \cdot 10^{+59}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_2 \leq -5 \cdot 10^{-195}:\\
\;\;\;\;\left(\frac{b}{z \cdot c} + 9 \cdot \frac{y \cdot x}{z \cdot c}\right) - 4 \cdot t_3\\
\mathbf{elif}\;t_2 \leq 5 \cdot 10^{-282}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_2 \leq 10^{+273}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
Results
| Original | 20.1 |
|---|---|
| Target | 14.3 |
| Herbie | 10.9 |
if (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < -inf.0Initial program 64.0
Simplified48.5
[Start]64.0 | \[ \frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}
\] |
|---|---|
rational.json-simplify-2 [=>]64.0 | \[ \frac{\left(\color{blue}{y \cdot \left(x \cdot 9\right)} - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}
\] |
rational.json-simplify-43 [=>]63.9 | \[ \frac{\left(\color{blue}{x \cdot \left(9 \cdot y\right)} - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}
\] |
rational.json-simplify-2 [=>]63.9 | \[ \frac{\left(x \cdot \left(9 \cdot y\right) - \color{blue}{a \cdot \left(\left(z \cdot 4\right) \cdot t\right)}\right) + b}{z \cdot c}
\] |
rational.json-simplify-2 [=>]63.9 | \[ \frac{\left(x \cdot \left(9 \cdot y\right) - a \cdot \color{blue}{\left(t \cdot \left(z \cdot 4\right)\right)}\right) + b}{z \cdot c}
\] |
rational.json-simplify-43 [=>]63.9 | \[ \frac{\left(x \cdot \left(9 \cdot y\right) - a \cdot \color{blue}{\left(z \cdot \left(4 \cdot t\right)\right)}\right) + b}{z \cdot c}
\] |
rational.json-simplify-43 [=>]48.5 | \[ \frac{\left(x \cdot \left(9 \cdot y\right) - \color{blue}{z \cdot \left(\left(4 \cdot t\right) \cdot a\right)}\right) + b}{z \cdot c}
\] |
Taylor expanded in z around inf 33.7
Simplified33.7
[Start]33.7 | \[ -4 \cdot \frac{a \cdot t}{c}
\] |
|---|---|
rational.json-simplify-2 [=>]33.7 | \[ \color{blue}{\frac{a \cdot t}{c} \cdot -4}
\] |
if -inf.0 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < -1.99999999999999994e59 or 5.0000000000000001e-282 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < 9.99999999999999945e272Initial program 0.7
if -1.99999999999999994e59 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < -5.00000000000000009e-195Initial program 0.5
Simplified0.6
[Start]0.5 | \[ \frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}
\] |
|---|---|
rational.json-simplify-2 [=>]0.5 | \[ \frac{\left(\color{blue}{y \cdot \left(x \cdot 9\right)} - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}
\] |
rational.json-simplify-43 [=>]0.6 | \[ \frac{\left(\color{blue}{x \cdot \left(9 \cdot y\right)} - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}
\] |
rational.json-simplify-2 [=>]0.6 | \[ \frac{\left(x \cdot \left(9 \cdot y\right) - \color{blue}{a \cdot \left(\left(z \cdot 4\right) \cdot t\right)}\right) + b}{z \cdot c}
\] |
rational.json-simplify-2 [=>]0.6 | \[ \frac{\left(x \cdot \left(9 \cdot y\right) - a \cdot \color{blue}{\left(t \cdot \left(z \cdot 4\right)\right)}\right) + b}{z \cdot c}
\] |
rational.json-simplify-43 [=>]0.6 | \[ \frac{\left(x \cdot \left(9 \cdot y\right) - a \cdot \color{blue}{\left(z \cdot \left(4 \cdot t\right)\right)}\right) + b}{z \cdot c}
\] |
rational.json-simplify-43 [=>]0.6 | \[ \frac{\left(x \cdot \left(9 \cdot y\right) - \color{blue}{z \cdot \left(\left(4 \cdot t\right) \cdot a\right)}\right) + b}{z \cdot c}
\] |
Taylor expanded in x around 0 0.6
Simplified0.6
[Start]0.6 | \[ \left(\frac{b}{c \cdot z} + 9 \cdot \frac{y \cdot x}{c \cdot z}\right) - 4 \cdot \frac{a \cdot t}{c}
\] |
|---|---|
rational.json-simplify-2 [<=]0.6 | \[ \left(\frac{b}{\color{blue}{z \cdot c}} + 9 \cdot \frac{y \cdot x}{c \cdot z}\right) - 4 \cdot \frac{a \cdot t}{c}
\] |
rational.json-simplify-2 [<=]0.6 | \[ \left(\frac{b}{z \cdot c} + 9 \cdot \frac{y \cdot x}{\color{blue}{z \cdot c}}\right) - 4 \cdot \frac{a \cdot t}{c}
\] |
if -5.00000000000000009e-195 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < 5.0000000000000001e-282 or 9.99999999999999945e272 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) Initial program 47.4
Simplified43.5
[Start]47.4 | \[ \frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}
\] |
|---|---|
rational.json-simplify-2 [=>]47.4 | \[ \frac{\left(\color{blue}{y \cdot \left(x \cdot 9\right)} - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}
\] |
rational.json-simplify-43 [=>]47.4 | \[ \frac{\left(\color{blue}{x \cdot \left(9 \cdot y\right)} - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}
\] |
rational.json-simplify-2 [=>]47.4 | \[ \frac{\left(x \cdot \left(9 \cdot y\right) - \color{blue}{a \cdot \left(\left(z \cdot 4\right) \cdot t\right)}\right) + b}{z \cdot c}
\] |
rational.json-simplify-2 [=>]47.4 | \[ \frac{\left(x \cdot \left(9 \cdot y\right) - a \cdot \color{blue}{\left(t \cdot \left(z \cdot 4\right)\right)}\right) + b}{z \cdot c}
\] |
rational.json-simplify-43 [=>]47.3 | \[ \frac{\left(x \cdot \left(9 \cdot y\right) - a \cdot \color{blue}{\left(z \cdot \left(4 \cdot t\right)\right)}\right) + b}{z \cdot c}
\] |
rational.json-simplify-43 [=>]43.5 | \[ \frac{\left(x \cdot \left(9 \cdot y\right) - \color{blue}{z \cdot \left(\left(4 \cdot t\right) \cdot a\right)}\right) + b}{z \cdot c}
\] |
Taylor expanded in b around 0 50.6
Simplified48.1
[Start]50.6 | \[ \frac{9 \cdot \left(y \cdot x\right) - 4 \cdot \left(a \cdot \left(t \cdot z\right)\right)}{c \cdot z}
\] |
|---|---|
rational.json-simplify-43 [=>]48.0 | \[ \frac{9 \cdot \left(y \cdot x\right) - 4 \cdot \color{blue}{\left(t \cdot \left(z \cdot a\right)\right)}}{c \cdot z}
\] |
rational.json-simplify-43 [=>]48.1 | \[ \frac{9 \cdot \left(y \cdot x\right) - \color{blue}{t \cdot \left(\left(z \cdot a\right) \cdot 4\right)}}{c \cdot z}
\] |
rational.json-simplify-2 [=>]48.1 | \[ \frac{9 \cdot \left(y \cdot x\right) - t \cdot \left(\color{blue}{\left(a \cdot z\right)} \cdot 4\right)}{c \cdot z}
\] |
rational.json-simplify-2 [<=]48.1 | \[ \frac{9 \cdot \left(y \cdot x\right) - t \cdot \left(\left(a \cdot z\right) \cdot 4\right)}{\color{blue}{z \cdot c}}
\] |
Taylor expanded in y around 0 28.8
Taylor expanded in c around 0 25.2
Final simplification10.9
| Alternative 1 | |
|---|---|
| Error | 11.4 |
| Cost | 6352 |
| Alternative 2 | |
|---|---|
| Error | 38.0 |
| Cost | 1500 |
| Alternative 3 | |
|---|---|
| Error | 38.0 |
| Cost | 1500 |
| Alternative 4 | |
|---|---|
| Error | 21.8 |
| Cost | 1488 |
| Alternative 5 | |
|---|---|
| Error | 14.2 |
| Cost | 1480 |
| Alternative 6 | |
|---|---|
| Error | 16.8 |
| Cost | 1348 |
| Alternative 7 | |
|---|---|
| Error | 37.7 |
| Cost | 1236 |
| Alternative 8 | |
|---|---|
| Error | 37.7 |
| Cost | 1236 |
| Alternative 9 | |
|---|---|
| Error | 28.1 |
| Cost | 1232 |
| Alternative 10 | |
|---|---|
| Error | 27.1 |
| Cost | 1100 |
| Alternative 11 | |
|---|---|
| Error | 36.0 |
| Cost | 712 |
| Alternative 12 | |
|---|---|
| Error | 36.0 |
| Cost | 712 |
| Alternative 13 | |
|---|---|
| Error | 43.3 |
| Cost | 320 |
herbie shell --seed 2023077
(FPCore (x y z t a b c)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, J"
:precision binary64
:herbie-target
(if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) -1.100156740804105e-171) (/ (+ (- (* (* x 9.0) y) (* (* z 4.0) (* t a))) b) (* z c)) (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) 0.0) (/ (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) z) c) (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) 1.1708877911747488e-53) (/ (+ (- (* (* x 9.0) y) (* (* z 4.0) (* t a))) b) (* z c)) (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) 2.876823679546137e+130) (- (+ (* (* 9.0 (/ y c)) (/ x z)) (/ b (* c z))) (* 4.0 (/ (* a t) c))) (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) 1.3838515042456319e+158) (/ (+ (- (* (* x 9.0) y) (* (* z 4.0) (* t a))) b) (* z c)) (- (+ (* 9.0 (* (/ y (* c z)) x)) (/ b (* c z))) (* 4.0 (/ (* a t) c))))))))
(/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)))