| Alternative 1 | |
|---|---|
| Accuracy | 90.6% |
| Cost | 12496 |
(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 (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)))
(t_2 (* a (* t -4.0))))
(if (<= t_1 -2e+302)
(/ (+ t_2 (/ (+ b (* 9.0 (* x y))) z)) c)
(if (<= t_1 -5e+76)
t_1
(if (<= t_1 -1e-176)
(/ (+ (fma t (* z (* a -4.0)) b) (* x (* 9.0 y))) (* z c))
(if (<= t_1 50000000000000.0)
(/ (+ t_2 (/ (fma x (* 9.0 y) b) z)) c)
(if (<= t_1 5e+296)
t_1
(+
(/ (/ b c) z)
(- (/ x (/ (* z c) (* 9.0 y))) (* 4.0 (/ a (/ c t))))))))))))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 = ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
double t_2 = a * (t * -4.0);
double tmp;
if (t_1 <= -2e+302) {
tmp = (t_2 + ((b + (9.0 * (x * y))) / z)) / c;
} else if (t_1 <= -5e+76) {
tmp = t_1;
} else if (t_1 <= -1e-176) {
tmp = (fma(t, (z * (a * -4.0)), b) + (x * (9.0 * y))) / (z * c);
} else if (t_1 <= 50000000000000.0) {
tmp = (t_2 + (fma(x, (9.0 * y), b) / z)) / c;
} else if (t_1 <= 5e+296) {
tmp = t_1;
} else {
tmp = ((b / c) / z) + ((x / ((z * c) / (9.0 * y))) - (4.0 * (a / (c / t))));
}
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(Float64(Float64(x * 9.0) * y) - Float64(Float64(Float64(z * 4.0) * t) * a)) + b) / Float64(z * c)) t_2 = Float64(a * Float64(t * -4.0)) tmp = 0.0 if (t_1 <= -2e+302) tmp = Float64(Float64(t_2 + Float64(Float64(b + Float64(9.0 * Float64(x * y))) / z)) / c); elseif (t_1 <= -5e+76) tmp = t_1; elseif (t_1 <= -1e-176) tmp = Float64(Float64(fma(t, Float64(z * Float64(a * -4.0)), b) + Float64(x * Float64(9.0 * y))) / Float64(z * c)); elseif (t_1 <= 50000000000000.0) tmp = Float64(Float64(t_2 + Float64(fma(x, Float64(9.0 * y), b) / z)) / c); elseif (t_1 <= 5e+296) tmp = t_1; else tmp = Float64(Float64(Float64(b / c) / z) + Float64(Float64(x / Float64(Float64(z * c) / Float64(9.0 * y))) - Float64(4.0 * Float64(a / Float64(c / t))))); end return 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[(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$2 = N[(a * N[(t * -4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+302], N[(N[(t$95$2 + N[(N[(b + N[(9.0 * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[t$95$1, -5e+76], t$95$1, If[LessEqual[t$95$1, -1e-176], N[(N[(N[(t * N[(z * N[(a * -4.0), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] + N[(x * N[(9.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 50000000000000.0], N[(N[(t$95$2 + N[(N[(x * N[(9.0 * y), $MachinePrecision] + b), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[t$95$1, 5e+296], t$95$1, N[(N[(N[(b / c), $MachinePrecision] / z), $MachinePrecision] + N[(N[(x / N[(N[(z * c), $MachinePrecision] / N[(9.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(4.0 * N[(a / N[(c / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\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{\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_2 := a \cdot \left(t \cdot -4\right)\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{+302}:\\
\;\;\;\;\frac{t_2 + \frac{b + 9 \cdot \left(x \cdot y\right)}{z}}{c}\\
\mathbf{elif}\;t_1 \leq -5 \cdot 10^{+76}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_1 \leq -1 \cdot 10^{-176}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t, z \cdot \left(a \cdot -4\right), b\right) + x \cdot \left(9 \cdot y\right)}{z \cdot c}\\
\mathbf{elif}\;t_1 \leq 50000000000000:\\
\;\;\;\;\frac{t_2 + \frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z}}{c}\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+296}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{b}{c}}{z} + \left(\frac{x}{\frac{z \cdot c}{9 \cdot y}} - 4 \cdot \frac{a}{\frac{c}{t}}\right)\\
\end{array}
| Original | 67.7% |
|---|---|
| Target | 77.2% |
| Herbie | 90.4% |
if (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < -2.0000000000000002e302Initial program 4.9%
Simplified57.3%
[Start]4.9 | \[ \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}
\] |
|---|---|
associate-/r* [=>]10.8 | \[ \color{blue}{\frac{\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z}}{c}}
\] |
Taylor expanded in z around 0 57.3%
if -2.0000000000000002e302 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < -4.99999999999999991e76 or 5e13 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < 5.0000000000000001e296Initial program 99.0%
if -4.99999999999999991e76 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < -1e-176Initial program 99.2%
Simplified92.3%
[Start]99.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}
\] |
|---|---|
associate-+l- [=>]99.2 | \[ \frac{\color{blue}{\left(x \cdot 9\right) \cdot y - \left(\left(\left(z \cdot 4\right) \cdot t\right) \cdot a - b\right)}}{z \cdot c}
\] |
associate-*l* [=>]99.1 | \[ \frac{\color{blue}{x \cdot \left(9 \cdot y\right)} - \left(\left(\left(z \cdot 4\right) \cdot t\right) \cdot a - b\right)}{z \cdot c}
\] |
fma-neg [=>]99.1 | \[ \frac{\color{blue}{\mathsf{fma}\left(x, 9 \cdot y, -\left(\left(\left(z \cdot 4\right) \cdot t\right) \cdot a - b\right)\right)}}{z \cdot c}
\] |
neg-sub0 [=>]99.1 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \color{blue}{0 - \left(\left(\left(z \cdot 4\right) \cdot t\right) \cdot a - b\right)}\right)}{z \cdot c}
\] |
associate-+l- [<=]99.1 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \color{blue}{\left(0 - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}\right)}{z \cdot c}
\] |
neg-sub0 [<=]99.1 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \color{blue}{\left(-\left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right)} + b\right)}{z \cdot c}
\] |
distribute-lft-neg-in [=>]99.1 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \color{blue}{\left(-\left(z \cdot 4\right) \cdot t\right) \cdot a} + b\right)}{z \cdot c}
\] |
*-commutative [=>]99.1 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \color{blue}{a \cdot \left(-\left(z \cdot 4\right) \cdot t\right)} + b\right)}{z \cdot c}
\] |
distribute-lft-neg-in [=>]99.1 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, a \cdot \color{blue}{\left(\left(-z \cdot 4\right) \cdot t\right)} + b\right)}{z \cdot c}
\] |
associate-*r* [=>]92.3 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \color{blue}{\left(a \cdot \left(-z \cdot 4\right)\right) \cdot t} + b\right)}{z \cdot c}
\] |
*-commutative [=>]92.3 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \color{blue}{t \cdot \left(a \cdot \left(-z \cdot 4\right)\right)} + b\right)}{z \cdot c}
\] |
fma-def [=>]92.3 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \color{blue}{\mathsf{fma}\left(t, a \cdot \left(-z \cdot 4\right), b\right)}\right)}{z \cdot c}
\] |
distribute-rgt-neg-in [<=]92.3 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \mathsf{fma}\left(t, \color{blue}{-a \cdot \left(z \cdot 4\right)}, b\right)\right)}{z \cdot c}
\] |
associate-*r* [=>]92.3 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \mathsf{fma}\left(t, -\color{blue}{\left(a \cdot z\right) \cdot 4}, b\right)\right)}{z \cdot c}
\] |
distribute-rgt-neg-in [=>]92.3 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \mathsf{fma}\left(t, \color{blue}{\left(a \cdot z\right) \cdot \left(-4\right)}, b\right)\right)}{z \cdot c}
\] |
*-commutative [=>]92.3 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \mathsf{fma}\left(t, \color{blue}{\left(z \cdot a\right)} \cdot \left(-4\right), b\right)\right)}{z \cdot c}
\] |
metadata-eval [=>]92.3 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \mathsf{fma}\left(t, \left(z \cdot a\right) \cdot \color{blue}{-4}, b\right)\right)}{z \cdot c}
\] |
Applied egg-rr92.2%
if -1e-176 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < 5e13Initial program 71.9%
Simplified98.9%
[Start]71.9 | \[ \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}
\] |
|---|---|
associate-/r* [=>]98.3 | \[ \color{blue}{\frac{\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z}}{c}}
\] |
if 5.0000000000000001e296 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) Initial program 4.0%
Simplified16.8%
[Start]4.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}
\] |
|---|---|
associate-*l* [=>]4.3 | \[ \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}
\] |
associate-*l* [=>]16.8 | \[ \frac{\left(x \cdot \left(9 \cdot y\right) - \color{blue}{\left(z \cdot 4\right) \cdot \left(t \cdot a\right)}\right) + b}{z \cdot c}
\] |
Taylor expanded in x around 0 54.3%
Simplified75.3%
[Start]54.3 | \[ \left(\frac{b}{c \cdot z} + 9 \cdot \frac{y \cdot x}{c \cdot z}\right) - 4 \cdot \frac{a \cdot t}{c}
\] |
|---|---|
associate--l+ [=>]54.3 | \[ \color{blue}{\frac{b}{c \cdot z} + \left(9 \cdot \frac{y \cdot x}{c \cdot z} - 4 \cdot \frac{a \cdot t}{c}\right)}
\] |
associate-/r* [=>]53.5 | \[ \color{blue}{\frac{\frac{b}{c}}{z}} + \left(9 \cdot \frac{y \cdot x}{c \cdot z} - 4 \cdot \frac{a \cdot t}{c}\right)
\] |
*-commutative [<=]53.5 | \[ \frac{\frac{b}{c}}{z} + \left(9 \cdot \frac{y \cdot x}{\color{blue}{z \cdot c}} - 4 \cdot \frac{a \cdot t}{c}\right)
\] |
associate-*r/ [=>]53.4 | \[ \frac{\frac{b}{c}}{z} + \left(\color{blue}{\frac{9 \cdot \left(y \cdot x\right)}{z \cdot c}} - 4 \cdot \frac{a \cdot t}{c}\right)
\] |
associate-*r* [=>]53.2 | \[ \frac{\frac{b}{c}}{z} + \left(\frac{\color{blue}{\left(9 \cdot y\right) \cdot x}}{z \cdot c} - 4 \cdot \frac{a \cdot t}{c}\right)
\] |
*-commutative [<=]53.2 | \[ \frac{\frac{b}{c}}{z} + \left(\frac{\color{blue}{x \cdot \left(9 \cdot y\right)}}{z \cdot c} - 4 \cdot \frac{a \cdot t}{c}\right)
\] |
associate-/l* [=>]66.0 | \[ \frac{\frac{b}{c}}{z} + \left(\color{blue}{\frac{x}{\frac{z \cdot c}{9 \cdot y}}} - 4 \cdot \frac{a \cdot t}{c}\right)
\] |
associate-/l* [=>]75.3 | \[ \frac{\frac{b}{c}}{z} + \left(\frac{x}{\frac{z \cdot c}{9 \cdot y}} - 4 \cdot \color{blue}{\frac{a}{\frac{c}{t}}}\right)
\] |
Final simplification90.4%
| Alternative 1 | |
|---|---|
| Accuracy | 90.6% |
| Cost | 12496 |
| Alternative 2 | |
|---|---|
| Accuracy | 90.3% |
| Cost | 7892 |
| Alternative 3 | |
|---|---|
| Accuracy | 90.6% |
| Cost | 7892 |
| Alternative 4 | |
|---|---|
| Accuracy | 89.1% |
| Cost | 6352 |
| Alternative 5 | |
|---|---|
| Accuracy | 40.7% |
| Cost | 2028 |
| Alternative 6 | |
|---|---|
| Accuracy | 39.7% |
| Cost | 1896 |
| Alternative 7 | |
|---|---|
| Accuracy | 39.7% |
| Cost | 1896 |
| Alternative 8 | |
|---|---|
| Accuracy | 69.0% |
| Cost | 1884 |
| Alternative 9 | |
|---|---|
| Accuracy | 69.3% |
| Cost | 1884 |
| Alternative 10 | |
|---|---|
| Accuracy | 66.6% |
| Cost | 1625 |
| Alternative 11 | |
|---|---|
| Accuracy | 85.3% |
| Cost | 1481 |
| Alternative 12 | |
|---|---|
| Accuracy | 68.0% |
| Cost | 1364 |
| Alternative 13 | |
|---|---|
| Accuracy | 68.1% |
| Cost | 1364 |
| Alternative 14 | |
|---|---|
| Accuracy | 67.5% |
| Cost | 1361 |
| Alternative 15 | |
|---|---|
| Accuracy | 79.6% |
| Cost | 1353 |
| Alternative 16 | |
|---|---|
| Accuracy | 46.4% |
| Cost | 1240 |
| Alternative 17 | |
|---|---|
| Accuracy | 57.8% |
| Cost | 977 |
| Alternative 18 | |
|---|---|
| Accuracy | 46.2% |
| Cost | 713 |
| Alternative 19 | |
|---|---|
| Accuracy | 46.6% |
| Cost | 712 |
| Alternative 20 | |
|---|---|
| Accuracy | 32.6% |
| Cost | 320 |
| Alternative 21 | |
|---|---|
| Accuracy | 32.3% |
| Cost | 320 |
herbie shell --seed 2023129
(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)))