(FPCore (x y z t a b c i) :precision binary64 (* 2.0 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))))
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* (* c (+ a (* b c))) i)))
(if (<= t_1 (- INFINITY))
(* 2.0 (fma y x (fma (+ (* c (* b i)) (* a i)) (- c) (* t z))))
(if (<= t_1 5e+302)
(* 2.0 (fma y x (fma i (* c (- (fma c b a))) (* t z))))
(* 2.0 (fma y x (fma (fma (* c i) b (* a i)) (- c) (* t z))))))))double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i));
}
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (c * (a + (b * c))) * i;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = 2.0 * fma(y, x, fma(((c * (b * i)) + (a * i)), -c, (t * z)));
} else if (t_1 <= 5e+302) {
tmp = 2.0 * fma(y, x, fma(i, (c * -fma(c, b, a)), (t * z)));
} else {
tmp = 2.0 * fma(y, x, fma(fma((c * i), b, (a * i)), -c, (t * z)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) return Float64(2.0 * Float64(Float64(Float64(x * y) + Float64(z * t)) - Float64(Float64(Float64(a + Float64(b * c)) * c) * i))) end
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(c * Float64(a + Float64(b * c))) * i) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(2.0 * fma(y, x, fma(Float64(Float64(c * Float64(b * i)) + Float64(a * i)), Float64(-c), Float64(t * z)))); elseif (t_1 <= 5e+302) tmp = Float64(2.0 * fma(y, x, fma(i, Float64(c * Float64(-fma(c, b, a))), Float64(t * z)))); else tmp = Float64(2.0 * fma(y, x, fma(fma(Float64(c * i), b, Float64(a * i)), Float64(-c), Float64(t * z)))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(2.0 * N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(c * N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * i), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(2.0 * N[(y * x + N[(N[(N[(c * N[(b * i), $MachinePrecision]), $MachinePrecision] + N[(a * i), $MachinePrecision]), $MachinePrecision] * (-c) + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+302], N[(2.0 * N[(y * x + N[(i * N[(c * (-N[(c * b + a), $MachinePrecision])), $MachinePrecision] + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(y * x + N[(N[(N[(c * i), $MachinePrecision] * b + N[(a * i), $MachinePrecision]), $MachinePrecision] * (-c) + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)
\begin{array}{l}
t_1 := \left(c \cdot \left(a + b \cdot c\right)\right) \cdot i\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(y, x, \mathsf{fma}\left(c \cdot \left(b \cdot i\right) + a \cdot i, -c, t \cdot z\right)\right)\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+302}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(y, x, \mathsf{fma}\left(i, c \cdot \left(-\mathsf{fma}\left(c, b, a\right)\right), t \cdot z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(y, x, \mathsf{fma}\left(\mathsf{fma}\left(c \cdot i, b, a \cdot i\right), -c, t \cdot z\right)\right)\\
\end{array}
| Original | 6.4 |
|---|---|
| Target | 1.7 |
| Herbie | 0.7 |
if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -inf.0Initial program 64.0
Simplified9.4
Taylor expanded in z around 0 9.4
Simplified9.4
Taylor expanded in c around 0 5.2
if -inf.0 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 5e302Initial program 0.4
Simplified0.9
Taylor expanded in z around 0 4.7
Simplified4.7
Taylor expanded in i around 0 4.7
Simplified0.4
if 5e302 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) Initial program 61.3
Simplified8.7
Taylor expanded in z around 0 9.6
Simplified9.5
Taylor expanded in c around 0 6.2
Applied egg-rr2.0
Final simplification0.7
herbie shell --seed 2022211
(FPCore (x y z t a b c i)
:name "Diagrams.ThreeD.Shapes:frustum from diagrams-lib-1.3.0.3, A"
:precision binary64
:herbie-target
(* 2.0 (- (+ (* x y) (* z t)) (* (+ a (* b c)) (* c i))))
(* 2.0 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))))