| Alternative 1 | |
|---|---|
| Error | 8.1 |
| 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) (* (* (* z 4.0) t) a)) b) (* z c))))
(if (<= t_1 -5e+300)
(+ (* -4.0 (/ (* a t) c)) (/ (/ b c) z))
(if (<= t_1 -5e-313)
t_1
(if (<= t_1 0.0)
(/ (/ (+ (- (* x (* 9.0 y)) (* t (* z (* 4.0 a)))) b) z) c)
(if (<= t_1 1e+305) t_1 (/ a (* c (/ -0.25 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 tmp;
if (t_1 <= -5e+300) {
tmp = (-4.0 * ((a * t) / c)) + ((b / c) / z);
} else if (t_1 <= -5e-313) {
tmp = t_1;
} else if (t_1 <= 0.0) {
tmp = ((((x * (9.0 * y)) - (t * (z * (4.0 * a)))) + b) / z) / c;
} else if (t_1 <= 1e+305) {
tmp = t_1;
} else {
tmp = a / (c * (-0.25 / t));
}
return tmp;
}
real(8) function code(x, y, z, t, a, b, c)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = ((((x * 9.0d0) * y) - (((z * 4.0d0) * t) * a)) + b) / (z * c)
end function
real(8) function code(x, y, z, t, a, b, c)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_1
real(8) :: tmp
t_1 = ((((x * 9.0d0) * y) - (((z * 4.0d0) * t) * a)) + b) / (z * c)
if (t_1 <= (-5d+300)) then
tmp = ((-4.0d0) * ((a * t) / c)) + ((b / c) / z)
else if (t_1 <= (-5d-313)) then
tmp = t_1
else if (t_1 <= 0.0d0) then
tmp = ((((x * (9.0d0 * y)) - (t * (z * (4.0d0 * a)))) + b) / z) / c
else if (t_1 <= 1d+305) then
tmp = t_1
else
tmp = a / (c * ((-0.25d0) / t))
end if
code = tmp
end function
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 = ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
double tmp;
if (t_1 <= -5e+300) {
tmp = (-4.0 * ((a * t) / c)) + ((b / c) / z);
} else if (t_1 <= -5e-313) {
tmp = t_1;
} else if (t_1 <= 0.0) {
tmp = ((((x * (9.0 * y)) - (t * (z * (4.0 * a)))) + b) / z) / c;
} else if (t_1 <= 1e+305) {
tmp = t_1;
} else {
tmp = a / (c * (-0.25 / t));
}
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 = ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c) tmp = 0 if t_1 <= -5e+300: tmp = (-4.0 * ((a * t) / c)) + ((b / c) / z) elif t_1 <= -5e-313: tmp = t_1 elif t_1 <= 0.0: tmp = ((((x * (9.0 * y)) - (t * (z * (4.0 * a)))) + b) / z) / c elif t_1 <= 1e+305: tmp = t_1 else: tmp = a / (c * (-0.25 / 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)) tmp = 0.0 if (t_1 <= -5e+300) tmp = Float64(Float64(-4.0 * Float64(Float64(a * t) / c)) + Float64(Float64(b / c) / z)); elseif (t_1 <= -5e-313) tmp = t_1; elseif (t_1 <= 0.0) tmp = Float64(Float64(Float64(Float64(Float64(x * Float64(9.0 * y)) - Float64(t * Float64(z * Float64(4.0 * a)))) + b) / z) / c); elseif (t_1 <= 1e+305) tmp = t_1; else tmp = Float64(a / Float64(c * Float64(-0.25 / t))); 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 = ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c); tmp = 0.0; if (t_1 <= -5e+300) tmp = (-4.0 * ((a * t) / c)) + ((b / c) / z); elseif (t_1 <= -5e-313) tmp = t_1; elseif (t_1 <= 0.0) tmp = ((((x * (9.0 * y)) - (t * (z * (4.0 * a)))) + b) / z) / c; elseif (t_1 <= 1e+305) tmp = t_1; else tmp = a / (c * (-0.25 / t)); 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[(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]}, If[LessEqual[t$95$1, -5e+300], N[(N[(-4.0 * N[(N[(a * t), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] + N[(N[(b / c), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -5e-313], t$95$1, If[LessEqual[t$95$1, 0.0], N[(N[(N[(N[(N[(x * N[(9.0 * y), $MachinePrecision]), $MachinePrecision] - N[(t * N[(z * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / z), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[t$95$1, 1e+305], t$95$1, N[(a / N[(c * N[(-0.25 / 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 - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{+300}:\\
\;\;\;\;-4 \cdot \frac{a \cdot t}{c} + \frac{\frac{b}{c}}{z}\\
\mathbf{elif}\;t_1 \leq -5 \cdot 10^{-313}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;\frac{\frac{\left(x \cdot \left(9 \cdot y\right) - t \cdot \left(z \cdot \left(4 \cdot a\right)\right)\right) + b}{z}}{c}\\
\mathbf{elif}\;t_1 \leq 10^{+305}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c \cdot \frac{-0.25}{t}}\\
\end{array}
Results
| Original | 20.4 |
|---|---|
| Target | 14.6 |
| Herbie | 8.2 |
if (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < -5.00000000000000026e300Initial program 59.8
Simplified45.7
[Start]59.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}
\] |
|---|---|
rational.json-simplify-2 [=>]59.8 | \[ \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 [=>]59.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 [=>]59.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 [=>]59.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 [=>]59.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 [=>]45.7 | \[ \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 60.2
Simplified60.2
[Start]60.2 | \[ \frac{b - 4 \cdot \left(a \cdot \left(t \cdot z\right)\right)}{c \cdot z}
\] |
|---|---|
rational.json-simplify-2 [<=]60.2 | \[ \frac{b - 4 \cdot \left(a \cdot \left(t \cdot z\right)\right)}{\color{blue}{z \cdot c}}
\] |
Taylor expanded in b around 0 32.2
Simplified32.3
[Start]32.2 | \[ \frac{b}{c \cdot z} + -4 \cdot \frac{a \cdot t}{c}
\] |
|---|---|
rational.json-simplify-1 [=>]32.2 | \[ \color{blue}{-4 \cdot \frac{a \cdot t}{c} + \frac{b}{c \cdot z}}
\] |
rational.json-simplify-46 [=>]32.3 | \[ -4 \cdot \frac{a \cdot t}{c} + \color{blue}{\frac{\frac{b}{c}}{z}}
\] |
if -5.00000000000000026e300 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < -5.00000000002e-313 or 0.0 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < 9.9999999999999994e304Initial program 0.7
if -5.00000000002e-313 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < 0.0Initial program 36.8
Applied egg-rr10.6
Applied egg-rr10.6
if 9.9999999999999994e304 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) Initial program 63.3
Simplified56.3
[Start]63.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}
\] |
|---|---|
rational.json-simplify-2 [=>]63.3 | \[ \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.1 | \[ \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.1 | \[ \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.1 | \[ \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.0 | \[ \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 [=>]56.3 | \[ \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 31.9
Simplified22.3
[Start]31.9 | \[ -4 \cdot \frac{a \cdot t}{c}
\] |
|---|---|
rational.json-simplify-2 [=>]31.9 | \[ -4 \cdot \frac{\color{blue}{t \cdot a}}{c}
\] |
rational.json-simplify-49 [=>]22.3 | \[ -4 \cdot \color{blue}{\left(a \cdot \frac{t}{c}\right)}
\] |
rational.json-simplify-43 [=>]22.3 | \[ \color{blue}{a \cdot \left(\frac{t}{c} \cdot -4\right)}
\] |
Applied egg-rr24.4
Applied egg-rr32.0
Applied egg-rr22.3
Final simplification8.2
| Alternative 1 | |
|---|---|
| Error | 8.1 |
| Cost | 6352 |
| Alternative 2 | |
|---|---|
| Error | 36.3 |
| Cost | 2656 |
| Alternative 3 | |
|---|---|
| Error | 23.7 |
| Cost | 2404 |
| Alternative 4 | |
|---|---|
| Error | 27.6 |
| Cost | 2156 |
| Alternative 5 | |
|---|---|
| Error | 28.9 |
| Cost | 2024 |
| Alternative 6 | |
|---|---|
| Error | 35.5 |
| Cost | 1504 |
| Alternative 7 | |
|---|---|
| Error | 35.5 |
| Cost | 1504 |
| Alternative 8 | |
|---|---|
| Error | 35.5 |
| Cost | 1504 |
| Alternative 9 | |
|---|---|
| Error | 35.5 |
| Cost | 1504 |
| Alternative 10 | |
|---|---|
| Error | 35.6 |
| Cost | 1504 |
| Alternative 11 | |
|---|---|
| Error | 35.5 |
| Cost | 1504 |
| Alternative 12 | |
|---|---|
| Error | 38.1 |
| Cost | 1500 |
| Alternative 13 | |
|---|---|
| Error | 38.0 |
| Cost | 1500 |
| Alternative 14 | |
|---|---|
| Error | 35.4 |
| Cost | 976 |
| Alternative 15 | |
|---|---|
| Error | 35.2 |
| Cost | 976 |
| Alternative 16 | |
|---|---|
| Error | 34.9 |
| Cost | 976 |
| Alternative 17 | |
|---|---|
| Error | 34.8 |
| Cost | 976 |
| Alternative 18 | |
|---|---|
| Error | 34.7 |
| Cost | 976 |
| Alternative 19 | |
|---|---|
| Error | 18.7 |
| Cost | 968 |
| Alternative 20 | |
|---|---|
| Error | 43.3 |
| Cost | 584 |
| Alternative 21 | |
|---|---|
| Error | 42.6 |
| Cost | 584 |
| Alternative 22 | |
|---|---|
| Error | 43.4 |
| Cost | 320 |
herbie shell --seed 2023068
(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)))