(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 (- INFINITY))
(fma 9.0 (/ y (/ (* z c) x)) (fma -4.0 (* t (/ a c)) (/ b (* z c))))
(if (<= t_1 -2e-272)
t_1
(if (<= t_1 5e-125)
(/ (fma t (* a -4.0) (/ (fma x (* 9.0 y) b) z)) c)
(if (<= t_1 INFINITY)
t_1
(+
(* b (/ -1.0 (* c (- z))))
(+ (* -4.0 (* a (/ t c))) (* 9.0 (* (/ x z) (/ y 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 = ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = fma(9.0, (y / ((z * c) / x)), fma(-4.0, (t * (a / c)), (b / (z * c))));
} else if (t_1 <= -2e-272) {
tmp = t_1;
} else if (t_1 <= 5e-125) {
tmp = fma(t, (a * -4.0), (fma(x, (9.0 * y), b) / z)) / c;
} else if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = (b * (-1.0 / (c * -z))) + ((-4.0 * (a * (t / c))) + (9.0 * ((x / z) * (y / 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 = 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 <= Float64(-Inf)) tmp = fma(9.0, Float64(y / Float64(Float64(z * c) / x)), fma(-4.0, Float64(t * Float64(a / c)), Float64(b / Float64(z * c)))); elseif (t_1 <= -2e-272) tmp = t_1; elseif (t_1 <= 5e-125) tmp = Float64(fma(t, Float64(a * -4.0), Float64(fma(x, Float64(9.0 * y), b) / z)) / c); elseif (t_1 <= Inf) tmp = t_1; else tmp = Float64(Float64(b * Float64(-1.0 / Float64(c * Float64(-z)))) + Float64(Float64(-4.0 * Float64(a * Float64(t / c))) + Float64(9.0 * Float64(Float64(x / z) * Float64(y / 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[(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, (-Infinity)], N[(9.0 * N[(y / N[(N[(z * c), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] + N[(-4.0 * N[(t * N[(a / c), $MachinePrecision]), $MachinePrecision] + N[(b / N[(z * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -2e-272], t$95$1, If[LessEqual[t$95$1, 5e-125], N[(N[(t * N[(a * -4.0), $MachinePrecision] + N[(N[(x * N[(9.0 * y), $MachinePrecision] + b), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[t$95$1, Infinity], t$95$1, N[(N[(b * N[(-1.0 / N[(c * (-z)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(-4.0 * N[(a * N[(t / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(9.0 * N[(N[(x / z), $MachinePrecision] * N[(y / c), $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}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(9, \frac{y}{\frac{z \cdot c}{x}}, \mathsf{fma}\left(-4, t \cdot \frac{a}{c}, \frac{b}{z \cdot c}\right)\right)\\
\mathbf{elif}\;t_1 \leq -2 \cdot 10^{-272}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{-125}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t, a \cdot -4, \frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z}\right)}{c}\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{-1}{c \cdot \left(-z\right)} + \left(-4 \cdot \left(a \cdot \frac{t}{c}\right) + 9 \cdot \left(\frac{x}{z} \cdot \frac{y}{c}\right)\right)\\
\end{array}
| Original | 20.3 |
|---|---|
| Target | 14.3 |
| Herbie | 6.4 |
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
Simplified23.5
Taylor expanded in t around 0 28.9
Simplified8.4
if -inf.0 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < -1.99999999999999986e-272 or 4.99999999999999967e-125 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < +inf.0Initial program 7.6
if -1.99999999999999986e-272 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) < 4.99999999999999967e-125Initial program 26.7
Simplified0.7
if +inf.0 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x 9) y) (*.f64 (*.f64 (*.f64 z 4) t) a)) b) (*.f64 z c)) Initial program 64.0
Simplified29.1
Taylor expanded in t around 0 31.9
Applied egg-rr31.9
Applied egg-rr23.3
Applied egg-rr5.1
Final simplification6.4
herbie shell --seed 2022209
(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)))