| Alternative 1 | |
|---|---|
| Accuracy | 90.4% |
| Cost | 18896 |
(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 (fma x (* 9.0 y) b))
(t_2 (* t (* a -4.0)))
(t_3 (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)))
(t_4 (/ (fma x (* 9.0 y) (fma a (* t (* z -4.0)) b)) (* z c))))
(if (<= t_3 (- INFINITY))
(/ (+ (pow (/ z t_1) -1.0) t_2) c)
(if (<= t_3 -2e-38)
t_4
(if (<= t_3 5e+14)
(/ (+ t_2 (* t_1 (/ 1.0 z))) c)
(if (<= t_3 1e+300) t_4 (/ (+ t_2 (* (* 9.0 y) (/ x z))) c)))))))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 = fma(x, (9.0 * y), b);
double t_2 = t * (a * -4.0);
double t_3 = ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
double t_4 = fma(x, (9.0 * y), fma(a, (t * (z * -4.0)), b)) / (z * c);
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = (pow((z / t_1), -1.0) + t_2) / c;
} else if (t_3 <= -2e-38) {
tmp = t_4;
} else if (t_3 <= 5e+14) {
tmp = (t_2 + (t_1 * (1.0 / z))) / c;
} else if (t_3 <= 1e+300) {
tmp = t_4;
} else {
tmp = (t_2 + ((9.0 * y) * (x / z))) / c;
}
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 = fma(x, Float64(9.0 * y), b) t_2 = Float64(t * Float64(a * -4.0)) t_3 = Float64(Float64(Float64(Float64(Float64(x * 9.0) * y) - Float64(Float64(Float64(z * 4.0) * t) * a)) + b) / Float64(z * c)) t_4 = Float64(fma(x, Float64(9.0 * y), fma(a, Float64(t * Float64(z * -4.0)), b)) / Float64(z * c)) tmp = 0.0 if (t_3 <= Float64(-Inf)) tmp = Float64(Float64((Float64(z / t_1) ^ -1.0) + t_2) / c); elseif (t_3 <= -2e-38) tmp = t_4; elseif (t_3 <= 5e+14) tmp = Float64(Float64(t_2 + Float64(t_1 * Float64(1.0 / z))) / c); elseif (t_3 <= 1e+300) tmp = t_4; else tmp = Float64(Float64(t_2 + Float64(Float64(9.0 * y) * Float64(x / z))) / c); 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[(x * N[(9.0 * y), $MachinePrecision] + b), $MachinePrecision]}, Block[{t$95$2 = N[(t * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = 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$4 = N[(N[(x * N[(9.0 * y), $MachinePrecision] + N[(a * N[(t * N[(z * -4.0), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, (-Infinity)], N[(N[(N[Power[N[(z / t$95$1), $MachinePrecision], -1.0], $MachinePrecision] + t$95$2), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[t$95$3, -2e-38], t$95$4, If[LessEqual[t$95$3, 5e+14], N[(N[(t$95$2 + N[(t$95$1 * N[(1.0 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[t$95$3, 1e+300], t$95$4, N[(N[(t$95$2 + N[(N[(9.0 * y), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $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 := \mathsf{fma}\left(x, 9 \cdot y, b\right)\\
t_2 := t \cdot \left(a \cdot -4\right)\\
t_3 := \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_4 := \frac{\mathsf{fma}\left(x, 9 \cdot y, \mathsf{fma}\left(a, t \cdot \left(z \cdot -4\right), b\right)\right)}{z \cdot c}\\
\mathbf{if}\;t_3 \leq -\infty:\\
\;\;\;\;\frac{{\left(\frac{z}{t_1}\right)}^{-1} + t_2}{c}\\
\mathbf{elif}\;t_3 \leq -2 \cdot 10^{-38}:\\
\;\;\;\;t_4\\
\mathbf{elif}\;t_3 \leq 5 \cdot 10^{+14}:\\
\;\;\;\;\frac{t_2 + t_1 \cdot \frac{1}{z}}{c}\\
\mathbf{elif}\;t_3 \leq 10^{+300}:\\
\;\;\;\;t_4\\
\mathbf{else}:\\
\;\;\;\;\frac{t_2 + \left(9 \cdot y\right) \cdot \frac{x}{z}}{c}\\
\end{array}
| Original | 67.9% |
|---|---|
| Target | 77.3% |
| Herbie | 90.4% |
if (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < -inf.0Initial program 0.0%
Simplified60.7%
[Start]0.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-/r* [=>]8.9 | \[ \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}}
\] |
Applied egg-rr60.7%
[Start]60.7 | \[ \frac{\frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z} + t \cdot \left(a \cdot -4\right)}{c}
\] |
|---|---|
clear-num [=>]60.7 | \[ \frac{\color{blue}{\frac{1}{\frac{z}{\mathsf{fma}\left(x, 9 \cdot y, b\right)}}} + t \cdot \left(a \cdot -4\right)}{c}
\] |
inv-pow [=>]60.7 | \[ \frac{\color{blue}{{\left(\frac{z}{\mathsf{fma}\left(x, 9 \cdot y, b\right)}\right)}^{-1}} + t \cdot \left(a \cdot -4\right)}{c}
\] |
if -inf.0 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < -1.9999999999999999e-38 or 5e14 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < 1.0000000000000001e300Initial program 99.1%
Simplified99.0%
[Start]99.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}
\] |
|---|---|
associate-+l- [=>]99.1 | \[ \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.0 | \[ \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.0 | \[ \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}
\] |
sub-neg [=>]99.0 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, -\color{blue}{\left(\left(\left(z \cdot 4\right) \cdot t\right) \cdot a + \left(-b\right)\right)}\right)}{z \cdot c}
\] |
distribute-neg-in [=>]99.0 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \color{blue}{\left(-\left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + \left(-\left(-b\right)\right)}\right)}{z \cdot c}
\] |
*-commutative [=>]99.0 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \left(-\color{blue}{a \cdot \left(\left(z \cdot 4\right) \cdot t\right)}\right) + \left(-\left(-b\right)\right)\right)}{z \cdot c}
\] |
distribute-rgt-neg-in [=>]99.0 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \color{blue}{a \cdot \left(-\left(z \cdot 4\right) \cdot t\right)} + \left(-\left(-b\right)\right)\right)}{z \cdot c}
\] |
fma-def [=>]99.0 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \color{blue}{\mathsf{fma}\left(a, -\left(z \cdot 4\right) \cdot t, -\left(-b\right)\right)}\right)}{z \cdot c}
\] |
*-commutative [=>]99.0 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \mathsf{fma}\left(a, -\color{blue}{t \cdot \left(z \cdot 4\right)}, -\left(-b\right)\right)\right)}{z \cdot c}
\] |
distribute-rgt-neg-in [=>]99.0 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \mathsf{fma}\left(a, \color{blue}{t \cdot \left(-z \cdot 4\right)}, -\left(-b\right)\right)\right)}{z \cdot c}
\] |
distribute-rgt-neg-in [=>]99.0 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \mathsf{fma}\left(a, t \cdot \color{blue}{\left(z \cdot \left(-4\right)\right)}, -\left(-b\right)\right)\right)}{z \cdot c}
\] |
metadata-eval [=>]99.0 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \mathsf{fma}\left(a, t \cdot \left(z \cdot \color{blue}{-4}\right), -\left(-b\right)\right)\right)}{z \cdot c}
\] |
remove-double-neg [=>]99.0 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \mathsf{fma}\left(a, t \cdot \left(z \cdot -4\right), \color{blue}{b}\right)\right)}{z \cdot c}
\] |
if -1.9999999999999999e-38 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < 5e14Initial program 77.5%
Simplified98.4%
[Start]77.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}
\] |
|---|---|
associate-/r* [=>]98.2 | \[ \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}}
\] |
Applied egg-rr98.3%
[Start]98.4 | \[ \frac{\frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z} + t \cdot \left(a \cdot -4\right)}{c}
\] |
|---|---|
div-inv [=>]98.3 | \[ \frac{\color{blue}{\mathsf{fma}\left(x, 9 \cdot y, b\right) \cdot \frac{1}{z}} + t \cdot \left(a \cdot -4\right)}{c}
\] |
if 1.0000000000000001e300 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) Initial program 2.9%
Simplified58.7%
[Start]2.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* [=>]6.0 | \[ \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 x around inf 53.0%
Simplified68.8%
[Start]53.0 | \[ \frac{9 \cdot \frac{y \cdot x}{z} + t \cdot \left(a \cdot -4\right)}{c}
\] |
|---|---|
associate-/l* [=>]69.0 | \[ \frac{9 \cdot \color{blue}{\frac{y}{\frac{z}{x}}} + t \cdot \left(a \cdot -4\right)}{c}
\] |
associate-*r/ [=>]68.8 | \[ \frac{\color{blue}{\frac{9 \cdot y}{\frac{z}{x}}} + t \cdot \left(a \cdot -4\right)}{c}
\] |
Applied egg-rr68.8%
[Start]68.8 | \[ \frac{\frac{9 \cdot y}{\frac{z}{x}} + t \cdot \left(a \cdot -4\right)}{c}
\] |
|---|---|
clear-num [=>]68.8 | \[ \frac{\color{blue}{\frac{1}{\frac{\frac{z}{x}}{9 \cdot y}}} + t \cdot \left(a \cdot -4\right)}{c}
\] |
associate-/r/ [=>]68.8 | \[ \frac{\color{blue}{\frac{1}{\frac{z}{x}} \cdot \left(9 \cdot y\right)} + t \cdot \left(a \cdot -4\right)}{c}
\] |
clear-num [<=]68.8 | \[ \frac{\color{blue}{\frac{x}{z}} \cdot \left(9 \cdot y\right) + t \cdot \left(a \cdot -4\right)}{c}
\] |
Final simplification90.4%
| Alternative 1 | |
|---|---|
| Accuracy | 90.4% |
| Cost | 18896 |
| Alternative 2 | |
|---|---|
| Accuracy | 90.4% |
| Cost | 11340 |
| Alternative 3 | |
|---|---|
| Accuracy | 88.9% |
| Cost | 6352 |
| Alternative 4 | |
|---|---|
| Accuracy | 82.3% |
| Cost | 2380 |
| Alternative 5 | |
|---|---|
| Accuracy | 57.0% |
| Cost | 2024 |
| Alternative 6 | |
|---|---|
| Accuracy | 42.4% |
| Cost | 1900 |
| Alternative 7 | |
|---|---|
| Accuracy | 68.7% |
| Cost | 1624 |
| Alternative 8 | |
|---|---|
| Accuracy | 68.6% |
| Cost | 1624 |
| Alternative 9 | |
|---|---|
| Accuracy | 43.6% |
| Cost | 1505 |
| Alternative 10 | |
|---|---|
| Accuracy | 43.6% |
| Cost | 1505 |
| Alternative 11 | |
|---|---|
| Accuracy | 43.6% |
| Cost | 1504 |
| Alternative 12 | |
|---|---|
| Accuracy | 43.9% |
| Cost | 1504 |
| Alternative 13 | |
|---|---|
| Accuracy | 44.0% |
| Cost | 1504 |
| Alternative 14 | |
|---|---|
| Accuracy | 44.0% |
| Cost | 1504 |
| Alternative 15 | |
|---|---|
| Accuracy | 83.0% |
| Cost | 1353 |
| Alternative 16 | |
|---|---|
| Accuracy | 43.4% |
| Cost | 1242 |
| Alternative 17 | |
|---|---|
| Accuracy | 69.9% |
| Cost | 969 |
| Alternative 18 | |
|---|---|
| Accuracy | 32.8% |
| Cost | 585 |
| Alternative 19 | |
|---|---|
| Accuracy | 31.2% |
| Cost | 452 |
| Alternative 20 | |
|---|---|
| Accuracy | 31.6% |
| Cost | 320 |
herbie shell --seed 2023147
(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)))