| Alternative 1 | |
|---|---|
| Error | 12.93% |
| 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 (/ (+ (+ (* (* x 9.0) y) (* a (* t (* z -4.0)))) b) (* z c))))
(if (<= t_1 (- INFINITY))
(+ (* 9.0 (* (/ y c) (/ x z))) (/ (+ b (* (* z a) (* t -4.0))) (* z c)))
(if (<= t_1 -5000.0)
(/ (fma x (* 9.0 y) (fma a (* z (* t -4.0)) b)) (* z c))
(if (<= t_1 2e-5)
(/ (+ (* a (* t -4.0)) (/ (+ b (* x (* 9.0 y))) z)) c)
(if (<= t_1 1e+304) t_1 (* -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) + (a * (t * (z * -4.0)))) + b) / (z * c);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = (9.0 * ((y / c) * (x / z))) + ((b + ((z * a) * (t * -4.0))) / (z * c));
} else if (t_1 <= -5000.0) {
tmp = fma(x, (9.0 * y), fma(a, (z * (t * -4.0)), b)) / (z * c);
} else if (t_1 <= 2e-5) {
tmp = ((a * (t * -4.0)) + ((b + (x * (9.0 * y))) / z)) / c;
} else if (t_1 <= 1e+304) {
tmp = t_1;
} else {
tmp = -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(a * Float64(t * Float64(z * -4.0)))) + b) / Float64(z * c)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(Float64(9.0 * Float64(Float64(y / c) * Float64(x / z))) + Float64(Float64(b + Float64(Float64(z * a) * Float64(t * -4.0))) / Float64(z * c))); elseif (t_1 <= -5000.0) tmp = Float64(fma(x, Float64(9.0 * y), fma(a, Float64(z * Float64(t * -4.0)), b)) / Float64(z * c)); elseif (t_1 <= 2e-5) tmp = Float64(Float64(Float64(a * Float64(t * -4.0)) + Float64(Float64(b + Float64(x * Float64(9.0 * y))) / z)) / c); elseif (t_1 <= 1e+304) tmp = t_1; else tmp = 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[(a * N[(t * N[(z * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(9.0 * N[(N[(y / c), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(b + N[(N[(z * a), $MachinePrecision] * N[(t * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -5000.0], N[(N[(x * N[(9.0 * y), $MachinePrecision] + N[(a * N[(z * N[(t * -4.0), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e-5], N[(N[(N[(a * N[(t * -4.0), $MachinePrecision]), $MachinePrecision] + N[(N[(b + N[(x * N[(9.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[t$95$1, 1e+304], t$95$1, N[(-4.0 * N[(a / N[(c / t), $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 + a \cdot \left(t \cdot \left(z \cdot -4\right)\right)\right) + b}{z \cdot c}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;9 \cdot \left(\frac{y}{c} \cdot \frac{x}{z}\right) + \frac{b + \left(z \cdot a\right) \cdot \left(t \cdot -4\right)}{z \cdot c}\\
\mathbf{elif}\;t_1 \leq -5000:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, 9 \cdot y, \mathsf{fma}\left(a, z \cdot \left(t \cdot -4\right), b\right)\right)}{z \cdot c}\\
\mathbf{elif}\;t_1 \leq 2 \cdot 10^{-5}:\\
\;\;\;\;\frac{a \cdot \left(t \cdot -4\right) + \frac{b + x \cdot \left(9 \cdot y\right)}{z}}{c}\\
\mathbf{elif}\;t_1 \leq 10^{+304}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \frac{a}{\frac{c}{t}}\\
\end{array}
| Original | 31.78% |
|---|---|
| Target | 22.91% |
| Herbie | 12.35% |
if (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < -inf.0Initial program 100
Applied egg-rr76.72
Applied egg-rr76.53
Simplified68.56
[Start]76.53 | \[ \frac{9 \cdot \left(y \cdot x\right)}{z \cdot c} - \frac{\mathsf{fma}\left(z, 4 \cdot \left(t \cdot a\right), -b\right)}{z \cdot c}
\] |
|---|---|
associate-*r/ [<=]76.53 | \[ \color{blue}{9 \cdot \frac{y \cdot x}{z \cdot c}} - \frac{\mathsf{fma}\left(z, 4 \cdot \left(t \cdot a\right), -b\right)}{z \cdot c}
\] |
*-commutative [=>]76.53 | \[ 9 \cdot \frac{y \cdot x}{\color{blue}{c \cdot z}} - \frac{\mathsf{fma}\left(z, 4 \cdot \left(t \cdot a\right), -b\right)}{z \cdot c}
\] |
times-frac [=>]66.8 | \[ 9 \cdot \color{blue}{\left(\frac{y}{c} \cdot \frac{x}{z}\right)} - \frac{\mathsf{fma}\left(z, 4 \cdot \left(t \cdot a\right), -b\right)}{z \cdot c}
\] |
fma-udef [=>]66.8 | \[ 9 \cdot \left(\frac{y}{c} \cdot \frac{x}{z}\right) - \frac{\color{blue}{z \cdot \left(4 \cdot \left(t \cdot a\right)\right) + \left(-b\right)}}{z \cdot c}
\] |
unsub-neg [=>]66.8 | \[ 9 \cdot \left(\frac{y}{c} \cdot \frac{x}{z}\right) - \frac{\color{blue}{z \cdot \left(4 \cdot \left(t \cdot a\right)\right) - b}}{z \cdot c}
\] |
*-commutative [=>]66.8 | \[ 9 \cdot \left(\frac{y}{c} \cdot \frac{x}{z}\right) - \frac{\color{blue}{\left(4 \cdot \left(t \cdot a\right)\right) \cdot z} - b}{z \cdot c}
\] |
associate-*r* [=>]66.98 | \[ 9 \cdot \left(\frac{y}{c} \cdot \frac{x}{z}\right) - \frac{\color{blue}{\left(\left(4 \cdot t\right) \cdot a\right)} \cdot z - b}{z \cdot c}
\] |
associate-*l* [=>]68.56 | \[ 9 \cdot \left(\frac{y}{c} \cdot \frac{x}{z}\right) - \frac{\color{blue}{\left(4 \cdot t\right) \cdot \left(a \cdot z\right)} - b}{z \cdot c}
\] |
*-commutative [=>]68.56 | \[ 9 \cdot \left(\frac{y}{c} \cdot \frac{x}{z}\right) - \frac{\color{blue}{\left(t \cdot 4\right)} \cdot \left(a \cdot z\right) - b}{z \cdot c}
\] |
*-commutative [=>]68.56 | \[ 9 \cdot \left(\frac{y}{c} \cdot \frac{x}{z}\right) - \frac{\left(t \cdot 4\right) \cdot \left(a \cdot z\right) - b}{\color{blue}{c \cdot z}}
\] |
if -inf.0 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < -5e3Initial program 0.9
Simplified0.89
[Start]0.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-+l- [=>]0.9 | \[ \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* [=>]0.89 | \[ \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 [=>]0.89 | \[ \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 [=>]0.89 | \[ \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- [<=]0.89 | \[ \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 [<=]0.89 | \[ \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 [=>]0.89 | \[ \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 [=>]0.89 | \[ \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}
\] |
fma-def [=>]0.89 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \color{blue}{\mathsf{fma}\left(a, -\left(z \cdot 4\right) \cdot t, b\right)}\right)}{z \cdot c}
\] |
associate-*l* [=>]0.89 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \mathsf{fma}\left(a, -\color{blue}{z \cdot \left(4 \cdot t\right)}, b\right)\right)}{z \cdot c}
\] |
distribute-rgt-neg-in [=>]0.89 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \mathsf{fma}\left(a, \color{blue}{z \cdot \left(-4 \cdot t\right)}, b\right)\right)}{z \cdot c}
\] |
*-commutative [=>]0.89 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \mathsf{fma}\left(a, z \cdot \left(-\color{blue}{t \cdot 4}\right), b\right)\right)}{z \cdot c}
\] |
distribute-rgt-neg-in [=>]0.89 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \mathsf{fma}\left(a, z \cdot \color{blue}{\left(t \cdot \left(-4\right)\right)}, b\right)\right)}{z \cdot c}
\] |
metadata-eval [=>]0.89 | \[ \frac{\mathsf{fma}\left(x, 9 \cdot y, \mathsf{fma}\left(a, z \cdot \left(t \cdot \color{blue}{-4}\right), b\right)\right)}{z \cdot c}
\] |
if -5e3 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < 2.00000000000000016e-5Initial program 21.8
Simplified1.42
[Start]21.8 | \[ \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* [=>]1.93 | \[ \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-rr1.42
if 2.00000000000000016e-5 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < 9.9999999999999994e303Initial program 0.95
if 9.9999999999999994e303 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) Initial program 98.57
Simplified42.63
[Start]98.57 | \[ \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* [=>]95.52 | \[ \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 a around inf 48.87
Simplified37.12
[Start]48.87 | \[ -4 \cdot \frac{a \cdot t}{c}
\] |
|---|---|
associate-/l* [=>]37.12 | \[ -4 \cdot \color{blue}{\frac{a}{\frac{c}{t}}}
\] |
Final simplification12.35
| Alternative 1 | |
|---|---|
| Error | 12.93% |
| Cost | 6352 |
| Alternative 2 | |
|---|---|
| Error | 13.45% |
| Cost | 6352 |
| Alternative 3 | |
|---|---|
| Error | 54.73% |
| Cost | 2032 |
| Alternative 4 | |
|---|---|
| Error | 54.53% |
| Cost | 2032 |
| Alternative 5 | |
|---|---|
| Error | 54.6% |
| Cost | 2032 |
| Alternative 6 | |
|---|---|
| Error | 54.57% |
| Cost | 2032 |
| Alternative 7 | |
|---|---|
| Error | 54.32% |
| Cost | 1768 |
| Alternative 8 | |
|---|---|
| Error | 41.95% |
| Cost | 1760 |
| Alternative 9 | |
|---|---|
| Error | 53.07% |
| Cost | 1505 |
| Alternative 10 | |
|---|---|
| Error | 31.19% |
| Cost | 1488 |
| Alternative 11 | |
|---|---|
| Error | 14.35% |
| Cost | 1481 |
| Alternative 12 | |
|---|---|
| Error | 19.52% |
| Cost | 1353 |
| Alternative 13 | |
|---|---|
| Error | 55.14% |
| Cost | 1241 |
| Alternative 14 | |
|---|---|
| Error | 55.17% |
| Cost | 1240 |
| Alternative 15 | |
|---|---|
| Error | 56.14% |
| Cost | 1240 |
| Alternative 16 | |
|---|---|
| Error | 56.1% |
| Cost | 1240 |
| Alternative 17 | |
|---|---|
| Error | 30.01% |
| Cost | 969 |
| Alternative 18 | |
|---|---|
| Error | 65.63% |
| Cost | 585 |
| Alternative 19 | |
|---|---|
| Error | 67.78% |
| Cost | 320 |
| Alternative 20 | |
|---|---|
| Error | 67.83% |
| Cost | 320 |
herbie shell --seed 2023090
(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)))