
(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 (if (<= b -5e+138) (+ (* (* a z) b) (+ (* a t) (+ (* z y) x))) (fma a (fma b z t) (fma z y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (b <= -5e+138) {
tmp = ((a * z) * b) + ((a * t) + ((z * y) + x));
} else {
tmp = fma(a, fma(b, z, t), fma(z, y, x));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (b <= -5e+138) tmp = Float64(Float64(Float64(a * z) * b) + Float64(Float64(a * t) + Float64(Float64(z * y) + x))); else tmp = fma(a, fma(b, z, t), fma(z, y, x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[b, -5e+138], N[(N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision] + N[(N[(a * t), $MachinePrecision] + N[(N[(z * y), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a * N[(b * z + t), $MachinePrecision] + N[(z * y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+138}:\\
\;\;\;\;\left(a \cdot z\right) \cdot b + \left(a \cdot t + \left(z \cdot y + x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, \mathsf{fma}\left(b, z, t\right), \mathsf{fma}\left(z, y, x\right)\right)\\
\end{array}
\end{array}
if b < -5.00000000000000016e138Initial program 100.0%
if -5.00000000000000016e138 < b Initial program 90.3%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-outN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f6496.9
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6496.9
Applied rewrites96.9%
Final simplification97.3%
(FPCore (x y z t a b) :precision binary64 (if (<= y -1.4e-37) (fma t a (fma z y x)) (if (<= y 7.5e+83) (fma (fma b z t) a x) (fma z y (fma t a x)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -1.4e-37) {
tmp = fma(t, a, fma(z, y, x));
} else if (y <= 7.5e+83) {
tmp = fma(fma(b, z, t), a, x);
} else {
tmp = fma(z, y, fma(t, a, x));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -1.4e-37) tmp = fma(t, a, fma(z, y, x)); elseif (y <= 7.5e+83) tmp = fma(fma(b, z, t), a, x); else tmp = fma(z, y, fma(t, a, x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -1.4e-37], N[(t * a + N[(z * y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.5e+83], N[(N[(b * z + t), $MachinePrecision] * a + x), $MachinePrecision], N[(z * y + N[(t * a + x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{-37}:\\
\;\;\;\;\mathsf{fma}\left(t, a, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{+83}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(t, a, x\right)\right)\\
\end{array}
\end{array}
if y < -1.4000000000000001e-37Initial program 91.3%
Taylor expanded in b around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6488.3
Applied rewrites88.3%
Applied rewrites89.8%
if -1.4000000000000001e-37 < y < 7.49999999999999989e83Initial program 91.5%
Taylor expanded in y around 0
distribute-lft-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6491.2
Applied rewrites91.2%
if 7.49999999999999989e83 < y Initial program 91.9%
Taylor expanded in b around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6486.9
Applied rewrites86.9%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (fma b z t) a))) (if (<= a -5.8e+77) t_1 (if (<= a 7e-31) (fma z y x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(b, z, t) * a;
double tmp;
if (a <= -5.8e+77) {
tmp = t_1;
} else if (a <= 7e-31) {
tmp = fma(z, y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(fma(b, z, t) * a) tmp = 0.0 if (a <= -5.8e+77) tmp = t_1; elseif (a <= 7e-31) 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[(N[(b * z + t), $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[a, -5.8e+77], t$95$1, If[LessEqual[a, 7e-31], N[(z * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, z, t\right) \cdot a\\
\mathbf{if}\;a \leq -5.8 \cdot 10^{+77}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 7 \cdot 10^{-31}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -5.8000000000000003e77 or 6.99999999999999971e-31 < a Initial program 85.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6479.4
Applied rewrites79.4%
if -5.8000000000000003e77 < a < 6.99999999999999971e-31Initial program 96.9%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6478.9
Applied rewrites78.9%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (fma b a y) z))) (if (<= z -1.95e-22) t_1 (if (<= z 2.8e+18) (fma t a x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(b, a, y) * z;
double tmp;
if (z <= -1.95e-22) {
tmp = t_1;
} else if (z <= 2.8e+18) {
tmp = fma(t, a, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(fma(b, a, y) * z) tmp = 0.0 if (z <= -1.95e-22) tmp = t_1; elseif (z <= 2.8e+18) tmp = fma(t, a, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(b * a + y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -1.95e-22], t$95$1, If[LessEqual[z, 2.8e+18], N[(t * a + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, a, y\right) \cdot z\\
\mathbf{if}\;z \leq -1.95 \cdot 10^{-22}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{+18}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.94999999999999999e-22 or 2.8e18 < z Initial program 86.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6471.8
Applied rewrites71.8%
if -1.94999999999999999e-22 < z < 2.8e18Initial program 97.4%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6479.3
Applied rewrites79.3%
(FPCore (x y z t a b) :precision binary64 (if (<= a -4e+81) (* (* z b) a) (if (<= a 1.6e-57) (fma z y x) (fma t a x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -4e+81) {
tmp = (z * b) * a;
} else if (a <= 1.6e-57) {
tmp = fma(z, y, x);
} else {
tmp = fma(t, a, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -4e+81) tmp = Float64(Float64(z * b) * a); elseif (a <= 1.6e-57) tmp = fma(z, y, x); else tmp = fma(t, a, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -4e+81], N[(N[(z * b), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[a, 1.6e-57], N[(z * y + x), $MachinePrecision], N[(t * a + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4 \cdot 10^{+81}:\\
\;\;\;\;\left(z \cdot b\right) \cdot a\\
\mathbf{elif}\;a \leq 1.6 \cdot 10^{-57}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\end{array}
\end{array}
if a < -3.99999999999999969e81Initial program 80.2%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6456.2
Applied rewrites56.2%
if -3.99999999999999969e81 < a < 1.6e-57Initial program 96.9%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6479.7
Applied rewrites79.7%
if 1.6e-57 < a Initial program 89.6%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6458.5
Applied rewrites58.5%
Final simplification68.8%
(FPCore (x y z t a b) :precision binary64 (if (<= a -3.65e+81) (* (* a b) z) (if (<= a 1.6e-57) (fma z y x) (fma t a x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -3.65e+81) {
tmp = (a * b) * z;
} else if (a <= 1.6e-57) {
tmp = fma(z, y, x);
} else {
tmp = fma(t, a, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -3.65e+81) tmp = Float64(Float64(a * b) * z); elseif (a <= 1.6e-57) tmp = fma(z, y, x); else tmp = fma(t, a, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -3.65e+81], N[(N[(a * b), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[a, 1.6e-57], N[(z * y + x), $MachinePrecision], N[(t * a + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.65 \cdot 10^{+81}:\\
\;\;\;\;\left(a \cdot b\right) \cdot z\\
\mathbf{elif}\;a \leq 1.6 \cdot 10^{-57}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\end{array}
\end{array}
if a < -3.6499999999999998e81Initial program 80.2%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6456.2
Applied rewrites56.2%
Applied rewrites52.4%
if -3.6499999999999998e81 < a < 1.6e-57Initial program 96.9%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6479.7
Applied rewrites79.7%
if 1.6e-57 < a Initial program 89.6%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6458.5
Applied rewrites58.5%
Final simplification68.1%
(FPCore (x y z t a b) :precision binary64 (if (<= y -2.9e+24) (fma z y x) (if (<= y 2.2e+82) (fma t a x) (fma z y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -2.9e+24) {
tmp = fma(z, y, x);
} else if (y <= 2.2e+82) {
tmp = fma(t, a, x);
} else {
tmp = fma(z, y, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -2.9e+24) tmp = fma(z, y, x); elseif (y <= 2.2e+82) tmp = fma(t, a, x); else tmp = fma(z, y, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -2.9e+24], N[(z * y + x), $MachinePrecision], If[LessEqual[y, 2.2e+82], N[(t * a + x), $MachinePrecision], N[(z * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.9 \cdot 10^{+24}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{+82}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\end{array}
\end{array}
if y < -2.89999999999999979e24 or 2.2000000000000001e82 < y Initial program 89.3%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6472.6
Applied rewrites72.6%
if -2.89999999999999979e24 < y < 2.2000000000000001e82Initial program 92.7%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6464.0
Applied rewrites64.0%
(FPCore (x y z t a b) :precision binary64 (if (<= a -4e+81) (* (fma b z t) a) (fma t a (fma z y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -4e+81) {
tmp = fma(b, z, t) * a;
} else {
tmp = fma(t, a, fma(z, y, x));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -4e+81) tmp = Float64(fma(b, z, t) * a); else tmp = fma(t, a, fma(z, y, x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -4e+81], N[(N[(b * z + t), $MachinePrecision] * a), $MachinePrecision], N[(t * a + N[(z * y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4 \cdot 10^{+81}:\\
\;\;\;\;\mathsf{fma}\left(b, z, t\right) \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, a, \mathsf{fma}\left(z, y, x\right)\right)\\
\end{array}
\end{array}
if a < -3.99999999999999969e81Initial program 80.2%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6486.3
Applied rewrites86.3%
if -3.99999999999999969e81 < a Initial program 94.1%
Taylor expanded in b around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6482.4
Applied rewrites82.4%
Applied rewrites82.9%
(FPCore (x y z t a b) :precision binary64 (fma a (fma b z t) (fma z y x)))
double code(double x, double y, double z, double t, double a, double b) {
return fma(a, fma(b, z, t), fma(z, y, x));
}
function code(x, y, z, t, a, b) return fma(a, fma(b, z, t), fma(z, y, x)) end
code[x_, y_, z_, t_, a_, b_] := N[(a * N[(b * z + t), $MachinePrecision] + N[(z * y + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a, \mathsf{fma}\left(b, z, t\right), \mathsf{fma}\left(z, y, x\right)\right)
\end{array}
Initial program 91.5%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-outN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f6495.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6495.0
Applied rewrites95.0%
(FPCore (x y z t a b) :precision binary64 (if (<= y -1.25e+29) (* z y) (if (<= y 2.3e+82) (* a t) (* z y))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -1.25e+29) {
tmp = z * y;
} else if (y <= 2.3e+82) {
tmp = a * t;
} else {
tmp = z * y;
}
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 (y <= (-1.25d+29)) then
tmp = z * y
else if (y <= 2.3d+82) then
tmp = a * t
else
tmp = z * y
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 (y <= -1.25e+29) {
tmp = z * y;
} else if (y <= 2.3e+82) {
tmp = a * t;
} else {
tmp = z * y;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if y <= -1.25e+29: tmp = z * y elif y <= 2.3e+82: tmp = a * t else: tmp = z * y return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -1.25e+29) tmp = Float64(z * y); elseif (y <= 2.3e+82) tmp = Float64(a * t); else tmp = Float64(z * y); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (y <= -1.25e+29) tmp = z * y; elseif (y <= 2.3e+82) tmp = a * t; else tmp = z * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -1.25e+29], N[(z * y), $MachinePrecision], If[LessEqual[y, 2.3e+82], N[(a * t), $MachinePrecision], N[(z * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.25 \cdot 10^{+29}:\\
\;\;\;\;z \cdot y\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{+82}:\\
\;\;\;\;a \cdot t\\
\mathbf{else}:\\
\;\;\;\;z \cdot y\\
\end{array}
\end{array}
if y < -1.25e29 or 2.29999999999999988e82 < y Initial program 89.3%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6450.5
Applied rewrites50.5%
if -1.25e29 < y < 2.29999999999999988e82Initial program 92.7%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f6432.7
Applied rewrites32.7%
Final simplification39.1%
(FPCore (x y z t a b) :precision binary64 (if (<= y -1.1e+123) (* z y) (fma t a x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -1.1e+123) {
tmp = z * y;
} else {
tmp = fma(t, a, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -1.1e+123) tmp = Float64(z * y); else tmp = fma(t, a, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -1.1e+123], N[(z * y), $MachinePrecision], N[(t * a + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.1 \cdot 10^{+123}:\\
\;\;\;\;z \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\end{array}
\end{array}
if y < -1.09999999999999996e123Initial program 86.8%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6460.3
Applied rewrites60.3%
if -1.09999999999999996e123 < y Initial program 92.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6458.8
Applied rewrites58.8%
(FPCore (x y z t a b) :precision binary64 (* a t))
double code(double x, double y, double z, double t, double a, double b) {
return a * t;
}
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 = a * t
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return a * t;
}
def code(x, y, z, t, a, b): return a * t
function code(x, y, z, t, a, b) return Float64(a * t) end
function tmp = code(x, y, z, t, a, b) tmp = a * t; end
code[x_, y_, z_, t_, a_, b_] := N[(a * t), $MachinePrecision]
\begin{array}{l}
\\
a \cdot t
\end{array}
Initial program 91.5%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f6427.1
Applied rewrites27.1%
Final simplification27.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 2024249
(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)))