(FPCore (x y z t a b) :precision binary64 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))
(FPCore (x y z t a b) :precision binary64 (if (<= a 1e+32) (fma z (fma b a y) (fma t a x)) (fma z y (fma a (fma z b t) x))))
double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= 1e+32) {
tmp = fma(z, fma(b, a, y), fma(t, a, x));
} else {
tmp = fma(z, y, fma(a, fma(z, b, t), x));
}
return tmp;
}
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(Float64(a * z) * b)) end
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= 1e+32) tmp = fma(z, fma(b, a, y), fma(t, a, x)); else tmp = fma(z, y, fma(a, fma(z, b, t), x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, 1e+32], N[(z * N[(b * a + y), $MachinePrecision] + N[(t * a + x), $MachinePrecision]), $MachinePrecision], N[(z * y + N[(a * N[(z * b + t), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]]
\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
\begin{array}{l}
\mathbf{if}\;a \leq 10^{+32}:\\
\;\;\;\;\mathsf{fma}\left(z, \mathsf{fma}\left(b, a, y\right), \mathsf{fma}\left(t, a, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(a, \mathsf{fma}\left(z, b, t\right), x\right)\right)\\
\end{array}
| Original | 2.3 |
|---|---|
| Target | 0.3 |
| Herbie | 1.4 |
if a < 1.00000000000000005e32Initial program 1.6
Applied egg-rr1.6
Taylor expanded in a around 0 3.2
Simplified1.6
if 1.00000000000000005e32 < a Initial program 6.2
Applied egg-rr6.2
Taylor expanded in a around 0 0.1
Simplified6.9
Taylor expanded in z around 0 7.0
Simplified0.1
Final simplification1.4
herbie shell --seed 2022206
(FPCore (x y z t a b)
:name "Graphics.Rasterific.CubicBezier:cachedBezierAt from Rasterific-0.6.1"
:precision binary64
:herbie-target
(if (< z -11820553527347888000.0) (+ (* z (+ (* b a) y)) (+ x (* t a))) (if (< z 4.7589743188364287e-122) (+ (* (+ (* b z) t) a) (+ (* z y) x)) (+ (* z (+ (* b a) y)) (+ x (* t a)))))
(+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))