
(FPCore (x y z t a b) :precision binary64 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
real(8) function code(x, y, z, t, a, b)
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
code = ((x + (y * z)) + (t * a)) + ((a * z) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
def code(x, y, z, t, a, b): return ((x + (y * z)) + (t * a)) + ((a * z) * b)
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 tmp = code(x, y, z, t, a, b) tmp = ((x + (y * z)) + (t * a)) + ((a * z) * b); 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]
\begin{array}{l}
\\
\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
real(8) function code(x, y, z, t, a, b)
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
code = ((x + (y * z)) + (t * a)) + ((a * z) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
def code(x, y, z, t, a, b): return ((x + (y * z)) + (t * a)) + ((a * z) * b)
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 tmp = code(x, y, z, t, a, b) tmp = ((x + (y * z)) + (t * a)) + ((a * z) * b); 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]
\begin{array}{l}
\\
\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
\end{array}
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (+ (+ (+ x (* y z)) (* t a)) (* (* z a) b)))) (if (<= t_1 5e+274) t_1 (fma z y (fma (fma z b t) a x)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((x + (y * z)) + (t * a)) + ((z * a) * b);
double tmp;
if (t_1 <= 5e+274) {
tmp = t_1;
} else {
tmp = fma(z, y, fma(fma(z, b, t), a, x));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(Float64(z * a) * b)) tmp = 0.0 if (t_1 <= 5e+274) tmp = t_1; else tmp = fma(z, y, fma(fma(z, b, t), a, x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(N[(z * a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e+274], t$95$1, N[(z * y + N[(N[(z * b + t), $MachinePrecision] * a + x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(z \cdot a\right) \cdot b\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{+274}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) < 4.9999999999999998e274Initial program 99.0%
if 4.9999999999999998e274 < (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) Initial program 68.3%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-+l+N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-outN/A
lower-*.f64N/A
lower-fma.f6496.2
Applied rewrites96.2%
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6496.2
Applied rewrites96.2%
Final simplification98.5%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma a (fma b z t) x)))
(if (<= a -8.8e+33)
t_1
(if (<= a 1.1e-200)
(fma z (fma a b y) x)
(if (<= a 5.5e+77) (fma a t (fma z y x)) t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(a, fma(b, z, t), x);
double tmp;
if (a <= -8.8e+33) {
tmp = t_1;
} else if (a <= 1.1e-200) {
tmp = fma(z, fma(a, b, y), x);
} else if (a <= 5.5e+77) {
tmp = fma(a, t, fma(z, y, x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(a, fma(b, z, t), x) tmp = 0.0 if (a <= -8.8e+33) tmp = t_1; elseif (a <= 1.1e-200) tmp = fma(z, fma(a, b, y), x); elseif (a <= 5.5e+77) tmp = fma(a, t, fma(z, y, x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(a * N[(b * z + t), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[a, -8.8e+33], t$95$1, If[LessEqual[a, 1.1e-200], N[(z * N[(a * b + y), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[a, 5.5e+77], N[(a * t + N[(z * y + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(a, \mathsf{fma}\left(b, z, t\right), x\right)\\
\mathbf{if}\;a \leq -8.8 \cdot 10^{+33}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 1.1 \cdot 10^{-200}:\\
\;\;\;\;\mathsf{fma}\left(z, \mathsf{fma}\left(a, b, y\right), x\right)\\
\mathbf{elif}\;a \leq 5.5 \cdot 10^{+77}:\\
\;\;\;\;\mathsf{fma}\left(a, t, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -8.79999999999999975e33 or 5.50000000000000036e77 < a Initial program 85.0%
Taylor expanded in y around 0
distribute-lft-inN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6491.4
Applied rewrites91.4%
if -8.79999999999999975e33 < a < 1.10000000000000007e-200Initial program 99.0%
Taylor expanded in t around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6492.5
Applied rewrites92.5%
if 1.10000000000000007e-200 < a < 5.50000000000000036e77Initial program 98.1%
Taylor expanded in b around 0
Applied rewrites96.7%
(FPCore (x y z t a b)
:precision binary64
(if (<= a -8.8e+33)
(fma a t x)
(if (<= a 5.5e+77)
(fma z y x)
(if (<= a 5.7e+253) (fma a t x) (* (* z a) b)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -8.8e+33) {
tmp = fma(a, t, x);
} else if (a <= 5.5e+77) {
tmp = fma(z, y, x);
} else if (a <= 5.7e+253) {
tmp = fma(a, t, x);
} else {
tmp = (z * a) * b;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -8.8e+33) tmp = fma(a, t, x); elseif (a <= 5.5e+77) tmp = fma(z, y, x); elseif (a <= 5.7e+253) tmp = fma(a, t, x); else tmp = Float64(Float64(z * a) * b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -8.8e+33], N[(a * t + x), $MachinePrecision], If[LessEqual[a, 5.5e+77], N[(z * y + x), $MachinePrecision], If[LessEqual[a, 5.7e+253], N[(a * t + x), $MachinePrecision], N[(N[(z * a), $MachinePrecision] * b), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -8.8 \cdot 10^{+33}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{elif}\;a \leq 5.5 \cdot 10^{+77}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{elif}\;a \leq 5.7 \cdot 10^{+253}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot a\right) \cdot b\\
\end{array}
\end{array}
if a < -8.79999999999999975e33 or 5.50000000000000036e77 < a < 5.70000000000000016e253Initial program 84.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6457.5
Applied rewrites57.5%
if -8.79999999999999975e33 < a < 5.50000000000000036e77Initial program 98.7%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6474.5
Applied rewrites74.5%
if 5.70000000000000016e253 < a Initial program 85.6%
Taylor expanded in b around inf
lower-*.f64N/A
lower-*.f6466.3
Applied rewrites66.3%
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6479.3
Applied rewrites79.3%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma a (fma b z t) x))) (if (<= a -2.8e-97) t_1 (if (<= a 5.5e+77) (fma a t (fma z y x)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(a, fma(b, z, t), x);
double tmp;
if (a <= -2.8e-97) {
tmp = t_1;
} else if (a <= 5.5e+77) {
tmp = fma(a, t, fma(z, y, x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(a, fma(b, z, t), x) tmp = 0.0 if (a <= -2.8e-97) tmp = t_1; elseif (a <= 5.5e+77) tmp = fma(a, t, fma(z, y, x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(a * N[(b * z + t), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[a, -2.8e-97], t$95$1, If[LessEqual[a, 5.5e+77], N[(a * t + N[(z * y + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(a, \mathsf{fma}\left(b, z, t\right), x\right)\\
\mathbf{if}\;a \leq -2.8 \cdot 10^{-97}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 5.5 \cdot 10^{+77}:\\
\;\;\;\;\mathsf{fma}\left(a, t, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -2.8000000000000002e-97 or 5.50000000000000036e77 < a Initial program 88.1%
Taylor expanded in y around 0
distribute-lft-inN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6488.3
Applied rewrites88.3%
if -2.8000000000000002e-97 < a < 5.50000000000000036e77Initial program 98.3%
Taylor expanded in b around 0
Applied rewrites90.1%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma (* z a) b x))) (if (<= b -6e+191) t_1 (if (<= b 1.2e+101) (fma a t (fma z y x)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma((z * a), b, x);
double tmp;
if (b <= -6e+191) {
tmp = t_1;
} else if (b <= 1.2e+101) {
tmp = fma(a, t, fma(z, y, x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(Float64(z * a), b, x) tmp = 0.0 if (b <= -6e+191) tmp = t_1; elseif (b <= 1.2e+101) tmp = fma(a, t, fma(z, y, x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(z * a), $MachinePrecision] * b + x), $MachinePrecision]}, If[LessEqual[b, -6e+191], t$95$1, If[LessEqual[b, 1.2e+101], N[(a * t + N[(z * y + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(z \cdot a, b, x\right)\\
\mathbf{if}\;b \leq -6 \cdot 10^{+191}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 1.2 \cdot 10^{+101}:\\
\;\;\;\;\mathsf{fma}\left(a, t, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -5.9999999999999995e191 or 1.19999999999999994e101 < b Initial program 94.0%
Taylor expanded in t around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6489.8
Applied rewrites89.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f64N/A
lower-*.f6478.4
Applied rewrites78.4%
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lower-fma.f6486.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6486.5
Applied rewrites86.5%
if -5.9999999999999995e191 < b < 1.19999999999999994e101Initial program 92.2%
Taylor expanded in b around 0
Applied rewrites87.5%
Final simplification87.2%
(FPCore (x y z t a b) :precision binary64 (if (<= z 4.6e+223) (fma z y (fma (fma z b t) a x)) (fma z (fma a b y) x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= 4.6e+223) {
tmp = fma(z, y, fma(fma(z, b, t), a, x));
} else {
tmp = fma(z, fma(a, b, y), x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= 4.6e+223) tmp = fma(z, y, fma(fma(z, b, t), a, x)); else tmp = fma(z, fma(a, b, y), x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, 4.6e+223], N[(z * y + N[(N[(z * b + t), $MachinePrecision] * a + x), $MachinePrecision]), $MachinePrecision], N[(z * N[(a * b + y), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 4.6 \cdot 10^{+223}:\\
\;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, \mathsf{fma}\left(a, b, y\right), x\right)\\
\end{array}
\end{array}
if z < 4.60000000000000009e223Initial program 94.5%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-+l+N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-outN/A
lower-*.f64N/A
lower-fma.f6496.3
Applied rewrites96.3%
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6496.3
Applied rewrites96.3%
if 4.60000000000000009e223 < z Initial program 74.1%
Taylor expanded in t around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
(FPCore (x y z t a b) :precision binary64 (if (<= z 1.7e+101) (fma a (fma z b t) (fma y z x)) (fma z (fma a b y) x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= 1.7e+101) {
tmp = fma(a, fma(z, b, t), fma(y, z, x));
} else {
tmp = fma(z, fma(a, b, y), x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= 1.7e+101) tmp = fma(a, fma(z, b, t), fma(y, z, x)); else tmp = fma(z, fma(a, b, y), x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, 1.7e+101], N[(a * N[(z * b + t), $MachinePrecision] + N[(y * z + x), $MachinePrecision]), $MachinePrecision], N[(z * N[(a * b + y), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.7 \cdot 10^{+101}:\\
\;\;\;\;\mathsf{fma}\left(a, \mathsf{fma}\left(z, b, t\right), \mathsf{fma}\left(y, z, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, \mathsf{fma}\left(a, b, y\right), x\right)\\
\end{array}
\end{array}
if z < 1.70000000000000009e101Initial program 94.9%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-+l+N/A
+-commutativeN/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-outN/A
lower-fma.f64N/A
lower-fma.f6496.8
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6496.8
Applied rewrites96.8%
if 1.70000000000000009e101 < z Initial program 82.7%
Taylor expanded in t around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6495.9
Applied rewrites95.9%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* a (fma b z t)))) (if (<= a -2.8e-97) t_1 (if (<= a 8.2e+77) (fma z y x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = a * fma(b, z, t);
double tmp;
if (a <= -2.8e-97) {
tmp = t_1;
} else if (a <= 8.2e+77) {
tmp = fma(z, y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(a * fma(b, z, t)) tmp = 0.0 if (a <= -2.8e-97) tmp = t_1; elseif (a <= 8.2e+77) tmp = fma(z, y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(a * N[(b * z + t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -2.8e-97], t$95$1, If[LessEqual[a, 8.2e+77], N[(z * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a \cdot \mathsf{fma}\left(b, z, t\right)\\
\mathbf{if}\;a \leq -2.8 \cdot 10^{-97}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 8.2 \cdot 10^{+77}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -2.8000000000000002e-97 or 8.2000000000000002e77 < a Initial program 88.1%
Taylor expanded in a around inf
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6475.8
Applied rewrites75.8%
if -2.8000000000000002e-97 < a < 8.2000000000000002e77Initial program 98.3%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6481.4
Applied rewrites81.4%
(FPCore (x y z t a b) :precision binary64 (if (<= y -7.3e-25) (fma z y x) (if (<= y 2.7e-44) (fma a t x) (fma z y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -7.3e-25) {
tmp = fma(z, y, x);
} else if (y <= 2.7e-44) {
tmp = fma(a, t, x);
} else {
tmp = fma(z, y, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -7.3e-25) tmp = fma(z, y, x); elseif (y <= 2.7e-44) tmp = fma(a, t, x); else tmp = fma(z, y, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -7.3e-25], N[(z * y + x), $MachinePrecision], If[LessEqual[y, 2.7e-44], N[(a * t + x), $MachinePrecision], N[(z * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.3 \cdot 10^{-25}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{-44}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\end{array}
\end{array}
if y < -7.30000000000000045e-25 or 2.6999999999999999e-44 < y Initial program 93.0%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6469.8
Applied rewrites69.8%
if -7.30000000000000045e-25 < y < 2.6999999999999999e-44Initial program 92.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6462.1
Applied rewrites62.1%
(FPCore (x y z t a b) :precision binary64 (if (<= y -4.8e+114) (* y z) (if (<= y 6.3e+94) (fma a t x) (* y z))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -4.8e+114) {
tmp = y * z;
} else if (y <= 6.3e+94) {
tmp = fma(a, t, x);
} else {
tmp = y * z;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -4.8e+114) tmp = Float64(y * z); elseif (y <= 6.3e+94) tmp = fma(a, t, x); else tmp = Float64(y * z); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -4.8e+114], N[(y * z), $MachinePrecision], If[LessEqual[y, 6.3e+94], N[(a * t + x), $MachinePrecision], N[(y * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.8 \cdot 10^{+114}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;y \leq 6.3 \cdot 10^{+94}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot z\\
\end{array}
\end{array}
if y < -4.8e114 or 6.3000000000000001e94 < y Initial program 93.2%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6464.2
Applied rewrites64.2%
if -4.8e114 < y < 6.3000000000000001e94Initial program 92.5%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6458.1
Applied rewrites58.1%
Final simplification59.8%
(FPCore (x y z t a b) :precision binary64 (if (<= a -8.2e+30) (* t a) (if (<= a 5.5e+77) (* y z) (* t a))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -8.2e+30) {
tmp = t * a;
} else if (a <= 5.5e+77) {
tmp = y * z;
} else {
tmp = t * a;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
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) :: tmp
if (a <= (-8.2d+30)) then
tmp = t * a
else if (a <= 5.5d+77) then
tmp = y * z
else
tmp = t * a
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -8.2e+30) {
tmp = t * a;
} else if (a <= 5.5e+77) {
tmp = y * z;
} else {
tmp = t * a;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if a <= -8.2e+30: tmp = t * a elif a <= 5.5e+77: tmp = y * z else: tmp = t * a return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -8.2e+30) tmp = Float64(t * a); elseif (a <= 5.5e+77) tmp = Float64(y * z); else tmp = Float64(t * a); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (a <= -8.2e+30) tmp = t * a; elseif (a <= 5.5e+77) tmp = y * z; else tmp = t * a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -8.2e+30], N[(t * a), $MachinePrecision], If[LessEqual[a, 5.5e+77], N[(y * z), $MachinePrecision], N[(t * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -8.2 \cdot 10^{+30}:\\
\;\;\;\;t \cdot a\\
\mathbf{elif}\;a \leq 5.5 \cdot 10^{+77}:\\
\;\;\;\;y \cdot z\\
\mathbf{else}:\\
\;\;\;\;t \cdot a\\
\end{array}
\end{array}
if a < -8.20000000000000011e30 or 5.50000000000000036e77 < a Initial program 85.1%
Taylor expanded in t around inf
lower-*.f6445.0
Applied rewrites45.0%
if -8.20000000000000011e30 < a < 5.50000000000000036e77Initial program 98.7%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6440.9
Applied rewrites40.9%
Final simplification42.7%
(FPCore (x y z t a b) :precision binary64 (* t a))
double code(double x, double y, double z, double t, double a, double b) {
return t * a;
}
real(8) function code(x, y, z, t, a, b)
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
code = t * a
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return t * a;
}
def code(x, y, z, t, a, b): return t * a
function code(x, y, z, t, a, b) return Float64(t * a) end
function tmp = code(x, y, z, t, a, b) tmp = t * a; end
code[x_, y_, z_, t_, a_, b_] := N[(t * a), $MachinePrecision]
\begin{array}{l}
\\
t \cdot a
\end{array}
Initial program 92.7%
Taylor expanded in t around inf
lower-*.f6426.1
Applied rewrites26.1%
Final simplification26.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (* z (+ (* b a) y)) (+ x (* t a)))))
(if (< z -11820553527347888000.0)
t_1
(if (< z 4.7589743188364287e-122)
(+ (* (+ (* b z) t) a) (+ (* z y) x))
t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (z * ((b * a) + y)) + (x + (t * a));
double tmp;
if (z < -11820553527347888000.0) {
tmp = t_1;
} else if (z < 4.7589743188364287e-122) {
tmp = (((b * z) + t) * a) + ((z * y) + x);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
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) :: t_1
real(8) :: tmp
t_1 = (z * ((b * a) + y)) + (x + (t * a))
if (z < (-11820553527347888000.0d0)) then
tmp = t_1
else if (z < 4.7589743188364287d-122) then
tmp = (((b * z) + t) * a) + ((z * y) + x)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (z * ((b * a) + y)) + (x + (t * a));
double tmp;
if (z < -11820553527347888000.0) {
tmp = t_1;
} else if (z < 4.7589743188364287e-122) {
tmp = (((b * z) + t) * a) + ((z * y) + x);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (z * ((b * a) + y)) + (x + (t * a)) tmp = 0 if z < -11820553527347888000.0: tmp = t_1 elif z < 4.7589743188364287e-122: tmp = (((b * z) + t) * a) + ((z * y) + x) else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(z * Float64(Float64(b * a) + y)) + Float64(x + Float64(t * a))) tmp = 0.0 if (z < -11820553527347888000.0) tmp = t_1; elseif (z < 4.7589743188364287e-122) tmp = Float64(Float64(Float64(Float64(b * z) + t) * a) + Float64(Float64(z * y) + x)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (z * ((b * a) + y)) + (x + (t * a)); tmp = 0.0; if (z < -11820553527347888000.0) tmp = t_1; elseif (z < 4.7589743188364287e-122) tmp = (((b * z) + t) * a) + ((z * y) + x); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(z * N[(N[(b * a), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision] + N[(x + N[(t * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[z, -11820553527347888000.0], t$95$1, If[Less[z, 4.7589743188364287e-122], N[(N[(N[(N[(b * z), $MachinePrecision] + t), $MachinePrecision] * a), $MachinePrecision] + N[(N[(z * y), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(b \cdot a + y\right) + \left(x + t \cdot a\right)\\
\mathbf{if}\;z < -11820553527347888000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z < 4.7589743188364287 \cdot 10^{-122}:\\
\;\;\;\;\left(b \cdot z + t\right) \cdot a + \left(z \cdot y + x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2024214
(FPCore (x y z t a b)
:name "Graphics.Rasterific.CubicBezier:cachedBezierAt from Rasterific-0.6.1"
:precision binary64
:alt
(! :herbie-platform default (if (< z -11820553527347888000) (+ (* z (+ (* b a) y)) (+ x (* t a))) (if (< z 47589743188364287/1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (+ (* (+ (* b z) t) a) (+ (* z y) x)) (+ (* z (+ (* b a) y)) (+ x (* t a))))))
(+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))