
(FPCore (x y z t a b c) :precision binary64 (+ (- (+ (* x y) (/ (* z t) 16.0)) (/ (* a b) 4.0)) c))
double code(double x, double y, double z, double t, double a, double b, double c) {
return (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c;
}
real(8) function code(x, y, z, t, a, b, c)
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), intent (in) :: c
code = (((x * y) + ((z * t) / 16.0d0)) - ((a * b) / 4.0d0)) + c
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
return (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c;
}
def code(x, y, z, t, a, b, c): return (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c
function code(x, y, z, t, a, b, c) return Float64(Float64(Float64(Float64(x * y) + Float64(Float64(z * t) / 16.0)) - Float64(Float64(a * b) / 4.0)) + c) end
function tmp = code(x, y, z, t, a, b, c) tmp = (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c; end
code[x_, y_, z_, t_, a_, b_, c_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision] - N[(N[(a * b), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision] + c), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b c) :precision binary64 (+ (- (+ (* x y) (/ (* z t) 16.0)) (/ (* a b) 4.0)) c))
double code(double x, double y, double z, double t, double a, double b, double c) {
return (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c;
}
real(8) function code(x, y, z, t, a, b, c)
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), intent (in) :: c
code = (((x * y) + ((z * t) / 16.0d0)) - ((a * b) / 4.0d0)) + c
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
return (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c;
}
def code(x, y, z, t, a, b, c): return (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c
function code(x, y, z, t, a, b, c) return Float64(Float64(Float64(Float64(x * y) + Float64(Float64(z * t) / 16.0)) - Float64(Float64(a * b) / 4.0)) + c) end
function tmp = code(x, y, z, t, a, b, c) tmp = (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c; end
code[x_, y_, z_, t_, a_, b_, c_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision] - N[(N[(a * b), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision] + c), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c
\end{array}
(FPCore (x y z t a b c) :precision binary64 (let* ((t_1 (- (+ (* x y) (/ (* z t) 16.0)) (/ (* a b) 4.0)))) (if (<= t_1 INFINITY) (+ t_1 c) (fma a (* b -0.25) c))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = ((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0);
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1 + c;
} else {
tmp = fma(a, (b * -0.25), c);
}
return tmp;
}
function code(x, y, z, t, a, b, c) t_1 = Float64(Float64(Float64(x * y) + Float64(Float64(z * t) / 16.0)) - Float64(Float64(a * b) / 4.0)) tmp = 0.0 if (t_1 <= Inf) tmp = Float64(t_1 + c); else tmp = fma(a, Float64(b * -0.25), c); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(N[(N[(x * y), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision] - N[(N[(a * b), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], N[(t$95$1 + c), $MachinePrecision], N[(a * N[(b * -0.25), $MachinePrecision] + c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1 + c\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b \cdot -0.25, c\right)\\
\end{array}
\end{array}
if (-.f64 (+.f64 (*.f64 x y) (/.f64 (*.f64 z t) #s(literal 16 binary64))) (/.f64 (*.f64 a b) #s(literal 4 binary64))) < +inf.0Initial program 100.0%
if +inf.0 < (-.f64 (+.f64 (*.f64 x y) (/.f64 (*.f64 z t) #s(literal 16 binary64))) (/.f64 (*.f64 a b) #s(literal 4 binary64))) Initial program 0.0%
Taylor expanded in z around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6450.0
Applied rewrites50.0%
Taylor expanded in x around 0
Applied rewrites50.7%
(FPCore (x y z t a b c) :precision binary64 (let* ((t_1 (fma 0.0625 (* z t) (* x y))) (t_2 (+ (* x y) (/ (* z t) 16.0)))) (if (<= t_2 -5e+152) t_1 (if (<= t_2 5e+181) (fma a (* b -0.25) c) t_1))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = fma(0.0625, (z * t), (x * y));
double t_2 = (x * y) + ((z * t) / 16.0);
double tmp;
if (t_2 <= -5e+152) {
tmp = t_1;
} else if (t_2 <= 5e+181) {
tmp = fma(a, (b * -0.25), c);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c) t_1 = fma(0.0625, Float64(z * t), Float64(x * y)) t_2 = Float64(Float64(x * y) + Float64(Float64(z * t) / 16.0)) tmp = 0.0 if (t_2 <= -5e+152) tmp = t_1; elseif (t_2 <= 5e+181) tmp = fma(a, Float64(b * -0.25), c); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(0.0625 * N[(z * t), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+152], t$95$1, If[LessEqual[t$95$2, 5e+181], N[(a * N[(b * -0.25), $MachinePrecision] + c), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(0.0625, z \cdot t, x \cdot y\right)\\
t_2 := x \cdot y + \frac{z \cdot t}{16}\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+152}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+181}:\\
\;\;\;\;\mathsf{fma}\left(a, b \cdot -0.25, c\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 (*.f64 x y) (/.f64 (*.f64 z t) #s(literal 16 binary64))) < -5e152 or 5.0000000000000003e181 < (+.f64 (*.f64 x y) (/.f64 (*.f64 z t) #s(literal 16 binary64))) Initial program 90.5%
Taylor expanded in a around 0
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6484.1
Applied rewrites84.1%
Taylor expanded in x around inf
Applied rewrites76.1%
if -5e152 < (+.f64 (*.f64 x y) (/.f64 (*.f64 z t) #s(literal 16 binary64))) < 5.0000000000000003e181Initial program 100.0%
Taylor expanded in z around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6489.3
Applied rewrites89.3%
Taylor expanded in x around 0
Applied rewrites79.4%
Final simplification77.8%
(FPCore (x y z t a b c)
:precision binary64
(let* ((t_1 (fma a (* b -0.25) c)))
(if (<= (* a b) -0.5)
t_1
(if (<= (* a b) 5e-167)
(fma x y c)
(if (<= (* a b) 2.4e+16) (fma 0.0625 (* z t) c) t_1)))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = fma(a, (b * -0.25), c);
double tmp;
if ((a * b) <= -0.5) {
tmp = t_1;
} else if ((a * b) <= 5e-167) {
tmp = fma(x, y, c);
} else if ((a * b) <= 2.4e+16) {
tmp = fma(0.0625, (z * t), c);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c) t_1 = fma(a, Float64(b * -0.25), c) tmp = 0.0 if (Float64(a * b) <= -0.5) tmp = t_1; elseif (Float64(a * b) <= 5e-167) tmp = fma(x, y, c); elseif (Float64(a * b) <= 2.4e+16) tmp = fma(0.0625, Float64(z * t), c); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(a * N[(b * -0.25), $MachinePrecision] + c), $MachinePrecision]}, If[LessEqual[N[(a * b), $MachinePrecision], -0.5], t$95$1, If[LessEqual[N[(a * b), $MachinePrecision], 5e-167], N[(x * y + c), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 2.4e+16], N[(0.0625 * N[(z * t), $MachinePrecision] + c), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(a, b \cdot -0.25, c\right)\\
\mathbf{if}\;a \cdot b \leq -0.5:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{-167}:\\
\;\;\;\;\mathsf{fma}\left(x, y, c\right)\\
\mathbf{elif}\;a \cdot b \leq 2.4 \cdot 10^{+16}:\\
\;\;\;\;\mathsf{fma}\left(0.0625, z \cdot t, c\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 a b) < -0.5 or 2.4e16 < (*.f64 a b) Initial program 92.2%
Taylor expanded in z around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6484.4
Applied rewrites84.4%
Taylor expanded in x around 0
Applied rewrites74.3%
if -0.5 < (*.f64 a b) < 5.0000000000000002e-167Initial program 99.0%
Taylor expanded in z around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6470.5
Applied rewrites70.5%
Taylor expanded in a around 0
Applied rewrites68.6%
if 5.0000000000000002e-167 < (*.f64 a b) < 2.4e16Initial program 96.3%
Taylor expanded in a around 0
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6489.4
Applied rewrites89.4%
Taylor expanded in x around 0
Applied rewrites75.9%
Final simplification72.3%
(FPCore (x y z t a b c)
:precision binary64
(let* ((t_1 (* a (* b -0.25))))
(if (<= (* a b) -1e+186)
t_1
(if (<= (* a b) 5e-167)
(fma x y c)
(if (<= (* a b) 2e+110) (fma 0.0625 (* z t) c) t_1)))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = a * (b * -0.25);
double tmp;
if ((a * b) <= -1e+186) {
tmp = t_1;
} else if ((a * b) <= 5e-167) {
tmp = fma(x, y, c);
} else if ((a * b) <= 2e+110) {
tmp = fma(0.0625, (z * t), c);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c) t_1 = Float64(a * Float64(b * -0.25)) tmp = 0.0 if (Float64(a * b) <= -1e+186) tmp = t_1; elseif (Float64(a * b) <= 5e-167) tmp = fma(x, y, c); elseif (Float64(a * b) <= 2e+110) tmp = fma(0.0625, Float64(z * t), c); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(a * N[(b * -0.25), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a * b), $MachinePrecision], -1e+186], t$95$1, If[LessEqual[N[(a * b), $MachinePrecision], 5e-167], N[(x * y + c), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 2e+110], N[(0.0625 * N[(z * t), $MachinePrecision] + c), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a \cdot \left(b \cdot -0.25\right)\\
\mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+186}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{-167}:\\
\;\;\;\;\mathsf{fma}\left(x, y, c\right)\\
\mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+110}:\\
\;\;\;\;\mathsf{fma}\left(0.0625, z \cdot t, c\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 a b) < -9.9999999999999998e185 or 2e110 < (*.f64 a b) Initial program 88.3%
Taylor expanded in a around inf
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6484.6
Applied rewrites84.6%
if -9.9999999999999998e185 < (*.f64 a b) < 5.0000000000000002e-167Initial program 98.5%
Taylor expanded in z around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6471.3
Applied rewrites71.3%
Taylor expanded in a around 0
Applied rewrites63.9%
if 5.0000000000000002e-167 < (*.f64 a b) < 2e110Initial program 98.0%
Taylor expanded in a around 0
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6481.5
Applied rewrites81.5%
Taylor expanded in x around 0
Applied rewrites62.1%
Final simplification69.8%
(FPCore (x y z t a b c)
:precision binary64
(let* ((t_1 (fma 0.0625 (* z t) (fma a (* b -0.25) c))))
(if (<= (* z t) -1e+107)
t_1
(if (<= (* z t) 0.02) (fma a (* b -0.25) (fma x y c)) t_1))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = fma(0.0625, (z * t), fma(a, (b * -0.25), c));
double tmp;
if ((z * t) <= -1e+107) {
tmp = t_1;
} else if ((z * t) <= 0.02) {
tmp = fma(a, (b * -0.25), fma(x, y, c));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c) t_1 = fma(0.0625, Float64(z * t), fma(a, Float64(b * -0.25), c)) tmp = 0.0 if (Float64(z * t) <= -1e+107) tmp = t_1; elseif (Float64(z * t) <= 0.02) tmp = fma(a, Float64(b * -0.25), fma(x, y, c)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(0.0625 * N[(z * t), $MachinePrecision] + N[(a * N[(b * -0.25), $MachinePrecision] + c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -1e+107], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 0.02], N[(a * N[(b * -0.25), $MachinePrecision] + N[(x * y + c), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(0.0625, z \cdot t, \mathsf{fma}\left(a, b \cdot -0.25, c\right)\right)\\
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+107}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq 0.02:\\
\;\;\;\;\mathsf{fma}\left(a, b \cdot -0.25, \mathsf{fma}\left(x, y, c\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 z t) < -9.9999999999999997e106 or 0.0200000000000000004 < (*.f64 z t) Initial program 89.6%
Taylor expanded in x around 0
cancel-sign-sub-invN/A
+-commutativeN/A
metadata-evalN/A
associate-+l+N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6482.6
Applied rewrites82.6%
if -9.9999999999999997e106 < (*.f64 z t) < 0.0200000000000000004Initial program 100.0%
Taylor expanded in z around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6497.2
Applied rewrites97.2%
Final simplification90.7%
(FPCore (x y z t a b c)
:precision binary64
(let* ((t_1 (fma a (* b -0.25) (fma x y c))))
(if (<= (* a b) -2e+39)
t_1
(if (<= (* a b) 10000000.0) (fma 0.0625 (* z t) (fma x y c)) t_1))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = fma(a, (b * -0.25), fma(x, y, c));
double tmp;
if ((a * b) <= -2e+39) {
tmp = t_1;
} else if ((a * b) <= 10000000.0) {
tmp = fma(0.0625, (z * t), fma(x, y, c));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c) t_1 = fma(a, Float64(b * -0.25), fma(x, y, c)) tmp = 0.0 if (Float64(a * b) <= -2e+39) tmp = t_1; elseif (Float64(a * b) <= 10000000.0) tmp = fma(0.0625, Float64(z * t), fma(x, y, c)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(a * N[(b * -0.25), $MachinePrecision] + N[(x * y + c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a * b), $MachinePrecision], -2e+39], t$95$1, If[LessEqual[N[(a * b), $MachinePrecision], 10000000.0], N[(0.0625 * N[(z * t), $MachinePrecision] + N[(x * y + c), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(a, b \cdot -0.25, \mathsf{fma}\left(x, y, c\right)\right)\\
\mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+39}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \cdot b \leq 10000000:\\
\;\;\;\;\mathsf{fma}\left(0.0625, z \cdot t, \mathsf{fma}\left(x, y, c\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 a b) < -1.99999999999999988e39 or 1e7 < (*.f64 a b) Initial program 90.8%
Taylor expanded in z around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6485.6
Applied rewrites85.6%
if -1.99999999999999988e39 < (*.f64 a b) < 1e7Initial program 99.3%
Taylor expanded in a around 0
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6494.6
Applied rewrites94.6%
Final simplification90.4%
(FPCore (x y z t a b c)
:precision binary64
(if (<= (* a b) -1e+186)
(fma a (* b -0.25) c)
(if (<= (* a b) 2e+110)
(fma 0.0625 (* z t) (fma x y c))
(fma a (* b -0.25) (* x y)))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if ((a * b) <= -1e+186) {
tmp = fma(a, (b * -0.25), c);
} else if ((a * b) <= 2e+110) {
tmp = fma(0.0625, (z * t), fma(x, y, c));
} else {
tmp = fma(a, (b * -0.25), (x * y));
}
return tmp;
}
function code(x, y, z, t, a, b, c) tmp = 0.0 if (Float64(a * b) <= -1e+186) tmp = fma(a, Float64(b * -0.25), c); elseif (Float64(a * b) <= 2e+110) tmp = fma(0.0625, Float64(z * t), fma(x, y, c)); else tmp = fma(a, Float64(b * -0.25), Float64(x * y)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_] := If[LessEqual[N[(a * b), $MachinePrecision], -1e+186], N[(a * N[(b * -0.25), $MachinePrecision] + c), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 2e+110], N[(0.0625 * N[(z * t), $MachinePrecision] + N[(x * y + c), $MachinePrecision]), $MachinePrecision], N[(a * N[(b * -0.25), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+186}:\\
\;\;\;\;\mathsf{fma}\left(a, b \cdot -0.25, c\right)\\
\mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+110}:\\
\;\;\;\;\mathsf{fma}\left(0.0625, z \cdot t, \mathsf{fma}\left(x, y, c\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b \cdot -0.25, x \cdot y\right)\\
\end{array}
\end{array}
if (*.f64 a b) < -9.9999999999999998e185Initial program 81.8%
Taylor expanded in z around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6485.5
Applied rewrites85.5%
Taylor expanded in x around 0
Applied rewrites85.5%
if -9.9999999999999998e185 < (*.f64 a b) < 2e110Initial program 98.3%
Taylor expanded in a around 0
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6488.1
Applied rewrites88.1%
if 2e110 < (*.f64 a b) Initial program 93.2%
Taylor expanded in z around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6489.4
Applied rewrites89.4%
Taylor expanded in x around inf
Applied rewrites88.3%
Final simplification87.8%
(FPCore (x y z t a b c) :precision binary64 (let* ((t_1 (* a (* b -0.25)))) (if (<= (* a b) -1e+186) t_1 (if (<= (* a b) 2e+110) (fma x y c) t_1))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = a * (b * -0.25);
double tmp;
if ((a * b) <= -1e+186) {
tmp = t_1;
} else if ((a * b) <= 2e+110) {
tmp = fma(x, y, c);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c) t_1 = Float64(a * Float64(b * -0.25)) tmp = 0.0 if (Float64(a * b) <= -1e+186) tmp = t_1; elseif (Float64(a * b) <= 2e+110) tmp = fma(x, y, c); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(a * N[(b * -0.25), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a * b), $MachinePrecision], -1e+186], t$95$1, If[LessEqual[N[(a * b), $MachinePrecision], 2e+110], N[(x * y + c), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a \cdot \left(b \cdot -0.25\right)\\
\mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+186}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+110}:\\
\;\;\;\;\mathsf{fma}\left(x, y, c\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 a b) < -9.9999999999999998e185 or 2e110 < (*.f64 a b) Initial program 88.3%
Taylor expanded in a around inf
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6484.6
Applied rewrites84.6%
if -9.9999999999999998e185 < (*.f64 a b) < 2e110Initial program 98.3%
Taylor expanded in z around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6470.3
Applied rewrites70.3%
Taylor expanded in a around 0
Applied rewrites60.4%
(FPCore (x y z t a b c) :precision binary64 (let* ((t_1 (* 0.0625 (* z t)))) (if (<= (* z t) -1e+107) t_1 (if (<= (* z t) 4e+212) (fma x y c) t_1))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = 0.0625 * (z * t);
double tmp;
if ((z * t) <= -1e+107) {
tmp = t_1;
} else if ((z * t) <= 4e+212) {
tmp = fma(x, y, c);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c) t_1 = Float64(0.0625 * Float64(z * t)) tmp = 0.0 if (Float64(z * t) <= -1e+107) tmp = t_1; elseif (Float64(z * t) <= 4e+212) tmp = fma(x, y, c); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(0.0625 * N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -1e+107], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 4e+212], N[(x * y + c), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 0.0625 \cdot \left(z \cdot t\right)\\
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+107}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq 4 \cdot 10^{+212}:\\
\;\;\;\;\mathsf{fma}\left(x, y, c\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 z t) < -9.9999999999999997e106 or 3.9999999999999996e212 < (*.f64 z t) Initial program 84.8%
Taylor expanded in z around inf
lower-*.f64N/A
lower-*.f6466.4
Applied rewrites66.4%
if -9.9999999999999997e106 < (*.f64 z t) < 3.9999999999999996e212Initial program 100.0%
Taylor expanded in z around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6493.3
Applied rewrites93.3%
Taylor expanded in a around 0
Applied rewrites59.0%
Final simplification61.3%
(FPCore (x y z t a b c) :precision binary64 (fma x y c))
double code(double x, double y, double z, double t, double a, double b, double c) {
return fma(x, y, c);
}
function code(x, y, z, t, a, b, c) return fma(x, y, c) end
code[x_, y_, z_, t_, a_, b_, c_] := N[(x * y + c), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, y, c\right)
\end{array}
Initial program 95.3%
Taylor expanded in z around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6475.5
Applied rewrites75.5%
Taylor expanded in a around 0
Applied rewrites45.8%
(FPCore (x y z t a b c) :precision binary64 (* x y))
double code(double x, double y, double z, double t, double a, double b, double c) {
return x * y;
}
real(8) function code(x, y, z, t, a, b, c)
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), intent (in) :: c
code = x * y
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
return x * y;
}
def code(x, y, z, t, a, b, c): return x * y
function code(x, y, z, t, a, b, c) return Float64(x * y) end
function tmp = code(x, y, z, t, a, b, c) tmp = x * y; end
code[x_, y_, z_, t_, a_, b_, c_] := N[(x * y), $MachinePrecision]
\begin{array}{l}
\\
x \cdot y
\end{array}
Initial program 95.3%
Taylor expanded in x around inf
lower-*.f6426.8
Applied rewrites26.8%
herbie shell --seed 2024232
(FPCore (x y z t a b c)
:name "Diagrams.Solve.Polynomial:quartForm from diagrams-solve-0.1, C"
:precision binary64
(+ (- (+ (* x y) (/ (* z t) 16.0)) (/ (* a b) 4.0)) c))