
(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 12 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 (+ (fma x y (fma 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 fma(x, y, fma(z, (t / 16.0), ((a * b) / -4.0))) + c;
}
function code(x, y, z, t, a, b, c) return Float64(fma(x, y, fma(z, Float64(t / 16.0), Float64(Float64(a * b) / -4.0))) + c) end
code[x_, y_, z_, t_, a_, b_, c_] := N[(N[(x * y + N[(z * N[(t / 16.0), $MachinePrecision] + N[(N[(a * b), $MachinePrecision] / -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + c), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, y, \mathsf{fma}\left(z, \frac{t}{16}, \frac{a \cdot b}{-4}\right)\right) + c
\end{array}
Initial program 98.5%
associate--l+98.5%
fma-define98.9%
associate-/l*98.9%
fma-neg99.3%
distribute-neg-frac299.3%
metadata-eval99.3%
Simplified99.3%
(FPCore (x y z t a b c) :precision binary64 (+ c (- (fma x y (* z (/ t 16.0))) (* a (/ b 4.0)))))
double code(double x, double y, double z, double t, double a, double b, double c) {
return c + (fma(x, y, (z * (t / 16.0))) - (a * (b / 4.0)));
}
function code(x, y, z, t, a, b, c) return Float64(c + Float64(fma(x, y, Float64(z * Float64(t / 16.0))) - Float64(a * Float64(b / 4.0)))) end
code[x_, y_, z_, t_, a_, b_, c_] := N[(c + N[(N[(x * y + N[(z * N[(t / 16.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a * N[(b / 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c + \left(\mathsf{fma}\left(x, y, z \cdot \frac{t}{16}\right) - a \cdot \frac{b}{4}\right)
\end{array}
Initial program 98.5%
associate-+l-98.5%
*-commutative98.5%
associate-+l-98.5%
fma-define98.9%
*-commutative98.9%
associate-/l*98.9%
associate-/l*99.2%
Simplified99.2%
Final simplification99.2%
(FPCore (x y z t a b c)
:precision binary64
(let* ((t_1 (+ c (* x y))))
(if (<= (* x y) -8.8e+58)
t_1
(if (<= (* x y) -1e-79)
(* b (* a -0.25))
(if (<= (* x y) 2.5e+16) (+ c (* 0.0625 (* z t))) t_1)))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = c + (x * y);
double tmp;
if ((x * y) <= -8.8e+58) {
tmp = t_1;
} else if ((x * y) <= -1e-79) {
tmp = b * (a * -0.25);
} else if ((x * y) <= 2.5e+16) {
tmp = c + (0.0625 * (z * t));
} else {
tmp = t_1;
}
return tmp;
}
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
real(8) :: t_1
real(8) :: tmp
t_1 = c + (x * y)
if ((x * y) <= (-8.8d+58)) then
tmp = t_1
else if ((x * y) <= (-1d-79)) then
tmp = b * (a * (-0.25d0))
else if ((x * y) <= 2.5d+16) then
tmp = c + (0.0625d0 * (z * t))
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 c) {
double t_1 = c + (x * y);
double tmp;
if ((x * y) <= -8.8e+58) {
tmp = t_1;
} else if ((x * y) <= -1e-79) {
tmp = b * (a * -0.25);
} else if ((x * y) <= 2.5e+16) {
tmp = c + (0.0625 * (z * t));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b, c): t_1 = c + (x * y) tmp = 0 if (x * y) <= -8.8e+58: tmp = t_1 elif (x * y) <= -1e-79: tmp = b * (a * -0.25) elif (x * y) <= 2.5e+16: tmp = c + (0.0625 * (z * t)) else: tmp = t_1 return tmp
function code(x, y, z, t, a, b, c) t_1 = Float64(c + Float64(x * y)) tmp = 0.0 if (Float64(x * y) <= -8.8e+58) tmp = t_1; elseif (Float64(x * y) <= -1e-79) tmp = Float64(b * Float64(a * -0.25)); elseif (Float64(x * y) <= 2.5e+16) tmp = Float64(c + Float64(0.0625 * Float64(z * t))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c) t_1 = c + (x * y); tmp = 0.0; if ((x * y) <= -8.8e+58) tmp = t_1; elseif ((x * y) <= -1e-79) tmp = b * (a * -0.25); elseif ((x * y) <= 2.5e+16) tmp = c + (0.0625 * (z * t)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(c + N[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -8.8e+58], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], -1e-79], N[(b * N[(a * -0.25), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2.5e+16], N[(c + N[(0.0625 * N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := c + x \cdot y\\
\mathbf{if}\;x \cdot y \leq -8.8 \cdot 10^{+58}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \cdot y \leq -1 \cdot 10^{-79}:\\
\;\;\;\;b \cdot \left(a \cdot -0.25\right)\\
\mathbf{elif}\;x \cdot y \leq 2.5 \cdot 10^{+16}:\\
\;\;\;\;c + 0.0625 \cdot \left(z \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 x y) < -8.8000000000000003e58 or 2.5e16 < (*.f64 x y) Initial program 99.0%
Taylor expanded in a around 0 83.3%
Taylor expanded in t around 0 71.0%
if -8.8000000000000003e58 < (*.f64 x y) < -1e-79Initial program 96.8%
associate--l+96.8%
fma-define96.8%
associate-/l*96.8%
fma-neg100.0%
distribute-neg-frac2100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in a around inf 72.8%
*-commutative72.8%
associate-*r*72.8%
Simplified72.8%
Taylor expanded in c around inf 66.8%
Taylor expanded in c around 0 57.2%
associate-*r*57.2%
*-commutative57.2%
*-commutative57.2%
Simplified57.2%
if -1e-79 < (*.f64 x y) < 2.5e16Initial program 98.5%
Taylor expanded in a around 0 70.2%
Taylor expanded in t around inf 66.0%
Final simplification66.9%
(FPCore (x y z t a b c)
:precision binary64
(let* ((t_1 (* b (* a -0.25))))
(if (<= a -6.8e+108)
t_1
(if (<= a -5.8e+15)
c
(if (<= a -2.5e-246) (* t (* z 0.0625)) (if (<= a 9e-43) c t_1))))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = b * (a * -0.25);
double tmp;
if (a <= -6.8e+108) {
tmp = t_1;
} else if (a <= -5.8e+15) {
tmp = c;
} else if (a <= -2.5e-246) {
tmp = t * (z * 0.0625);
} else if (a <= 9e-43) {
tmp = c;
} else {
tmp = t_1;
}
return tmp;
}
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
real(8) :: t_1
real(8) :: tmp
t_1 = b * (a * (-0.25d0))
if (a <= (-6.8d+108)) then
tmp = t_1
else if (a <= (-5.8d+15)) then
tmp = c
else if (a <= (-2.5d-246)) then
tmp = t * (z * 0.0625d0)
else if (a <= 9d-43) then
tmp = c
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 c) {
double t_1 = b * (a * -0.25);
double tmp;
if (a <= -6.8e+108) {
tmp = t_1;
} else if (a <= -5.8e+15) {
tmp = c;
} else if (a <= -2.5e-246) {
tmp = t * (z * 0.0625);
} else if (a <= 9e-43) {
tmp = c;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b, c): t_1 = b * (a * -0.25) tmp = 0 if a <= -6.8e+108: tmp = t_1 elif a <= -5.8e+15: tmp = c elif a <= -2.5e-246: tmp = t * (z * 0.0625) elif a <= 9e-43: tmp = c else: tmp = t_1 return tmp
function code(x, y, z, t, a, b, c) t_1 = Float64(b * Float64(a * -0.25)) tmp = 0.0 if (a <= -6.8e+108) tmp = t_1; elseif (a <= -5.8e+15) tmp = c; elseif (a <= -2.5e-246) tmp = Float64(t * Float64(z * 0.0625)); elseif (a <= 9e-43) tmp = c; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c) t_1 = b * (a * -0.25); tmp = 0.0; if (a <= -6.8e+108) tmp = t_1; elseif (a <= -5.8e+15) tmp = c; elseif (a <= -2.5e-246) tmp = t * (z * 0.0625); elseif (a <= 9e-43) tmp = c; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(b * N[(a * -0.25), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -6.8e+108], t$95$1, If[LessEqual[a, -5.8e+15], c, If[LessEqual[a, -2.5e-246], N[(t * N[(z * 0.0625), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 9e-43], c, t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := b \cdot \left(a \cdot -0.25\right)\\
\mathbf{if}\;a \leq -6.8 \cdot 10^{+108}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq -5.8 \cdot 10^{+15}:\\
\;\;\;\;c\\
\mathbf{elif}\;a \leq -2.5 \cdot 10^{-246}:\\
\;\;\;\;t \cdot \left(z \cdot 0.0625\right)\\
\mathbf{elif}\;a \leq 9 \cdot 10^{-43}:\\
\;\;\;\;c\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -6.79999999999999992e108 or 9.0000000000000005e-43 < a Initial program 97.4%
associate--l+97.4%
fma-define98.3%
associate-/l*98.3%
fma-neg99.1%
distribute-neg-frac299.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in a around inf 64.2%
*-commutative64.2%
associate-*r*64.2%
Simplified64.2%
Taylor expanded in c around inf 54.0%
Taylor expanded in c around 0 51.5%
associate-*r*51.5%
*-commutative51.5%
*-commutative51.5%
Simplified51.5%
if -6.79999999999999992e108 < a < -5.8e15 or -2.4999999999999998e-246 < a < 9.0000000000000005e-43Initial program 100.0%
Taylor expanded in c around inf 30.5%
if -5.8e15 < a < -2.4999999999999998e-246Initial program 98.3%
Taylor expanded in a around 0 82.5%
Taylor expanded in t around inf 53.2%
Taylor expanded in c around 0 34.2%
associate-*r*50.2%
*-commutative50.2%
associate-*r*50.2%
Simplified34.2%
Final simplification40.9%
(FPCore (x y z t a b c) :precision binary64 (if (or (<= (* a b) -5e-43) (not (<= (* a b) 2e-32))) (- (+ c (* x y)) (* (* a b) 0.25)) (+ c (+ (* x y) (* 0.0625 (* z t))))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if (((a * b) <= -5e-43) || !((a * b) <= 2e-32)) {
tmp = (c + (x * y)) - ((a * b) * 0.25);
} else {
tmp = c + ((x * y) + (0.0625 * (z * t)));
}
return tmp;
}
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
real(8) :: tmp
if (((a * b) <= (-5d-43)) .or. (.not. ((a * b) <= 2d-32))) then
tmp = (c + (x * y)) - ((a * b) * 0.25d0)
else
tmp = c + ((x * y) + (0.0625d0 * (z * t)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if (((a * b) <= -5e-43) || !((a * b) <= 2e-32)) {
tmp = (c + (x * y)) - ((a * b) * 0.25);
} else {
tmp = c + ((x * y) + (0.0625 * (z * t)));
}
return tmp;
}
def code(x, y, z, t, a, b, c): tmp = 0 if ((a * b) <= -5e-43) or not ((a * b) <= 2e-32): tmp = (c + (x * y)) - ((a * b) * 0.25) else: tmp = c + ((x * y) + (0.0625 * (z * t))) return tmp
function code(x, y, z, t, a, b, c) tmp = 0.0 if ((Float64(a * b) <= -5e-43) || !(Float64(a * b) <= 2e-32)) tmp = Float64(Float64(c + Float64(x * y)) - Float64(Float64(a * b) * 0.25)); else tmp = Float64(c + Float64(Float64(x * y) + Float64(0.0625 * Float64(z * t)))); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c) tmp = 0.0; if (((a * b) <= -5e-43) || ~(((a * b) <= 2e-32))) tmp = (c + (x * y)) - ((a * b) * 0.25); else tmp = c + ((x * y) + (0.0625 * (z * t))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -5e-43], N[Not[LessEqual[N[(a * b), $MachinePrecision], 2e-32]], $MachinePrecision]], N[(N[(c + N[(x * y), $MachinePrecision]), $MachinePrecision] - N[(N[(a * b), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision], N[(c + N[(N[(x * y), $MachinePrecision] + N[(0.0625 * N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -5 \cdot 10^{-43} \lor \neg \left(a \cdot b \leq 2 \cdot 10^{-32}\right):\\
\;\;\;\;\left(c + x \cdot y\right) - \left(a \cdot b\right) \cdot 0.25\\
\mathbf{else}:\\
\;\;\;\;c + \left(x \cdot y + 0.0625 \cdot \left(z \cdot t\right)\right)\\
\end{array}
\end{array}
if (*.f64 a b) < -5.00000000000000019e-43 or 2.00000000000000011e-32 < (*.f64 a b) Initial program 97.4%
Taylor expanded in z around 0 87.6%
if -5.00000000000000019e-43 < (*.f64 a b) < 2.00000000000000011e-32Initial program 100.0%
Taylor expanded in a around 0 100.0%
Final simplification92.8%
(FPCore (x y z t a b c) :precision binary64 (if (or (<= (* a b) -5e+223) (not (<= (* a b) 1e+141))) (+ c (* a (* b -0.25))) (+ c (+ (* x y) (* 0.0625 (* z t))))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if (((a * b) <= -5e+223) || !((a * b) <= 1e+141)) {
tmp = c + (a * (b * -0.25));
} else {
tmp = c + ((x * y) + (0.0625 * (z * t)));
}
return tmp;
}
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
real(8) :: tmp
if (((a * b) <= (-5d+223)) .or. (.not. ((a * b) <= 1d+141))) then
tmp = c + (a * (b * (-0.25d0)))
else
tmp = c + ((x * y) + (0.0625d0 * (z * t)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if (((a * b) <= -5e+223) || !((a * b) <= 1e+141)) {
tmp = c + (a * (b * -0.25));
} else {
tmp = c + ((x * y) + (0.0625 * (z * t)));
}
return tmp;
}
def code(x, y, z, t, a, b, c): tmp = 0 if ((a * b) <= -5e+223) or not ((a * b) <= 1e+141): tmp = c + (a * (b * -0.25)) else: tmp = c + ((x * y) + (0.0625 * (z * t))) return tmp
function code(x, y, z, t, a, b, c) tmp = 0.0 if ((Float64(a * b) <= -5e+223) || !(Float64(a * b) <= 1e+141)) tmp = Float64(c + Float64(a * Float64(b * -0.25))); else tmp = Float64(c + Float64(Float64(x * y) + Float64(0.0625 * Float64(z * t)))); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c) tmp = 0.0; if (((a * b) <= -5e+223) || ~(((a * b) <= 1e+141))) tmp = c + (a * (b * -0.25)); else tmp = c + ((x * y) + (0.0625 * (z * t))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -5e+223], N[Not[LessEqual[N[(a * b), $MachinePrecision], 1e+141]], $MachinePrecision]], N[(c + N[(a * N[(b * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c + N[(N[(x * y), $MachinePrecision] + N[(0.0625 * N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+223} \lor \neg \left(a \cdot b \leq 10^{+141}\right):\\
\;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\
\mathbf{else}:\\
\;\;\;\;c + \left(x \cdot y + 0.0625 \cdot \left(z \cdot t\right)\right)\\
\end{array}
\end{array}
if (*.f64 a b) < -4.99999999999999985e223 or 1.00000000000000002e141 < (*.f64 a b) Initial program 93.9%
associate--l+93.9%
fma-define95.5%
associate-/l*95.5%
fma-neg97.1%
distribute-neg-frac297.1%
metadata-eval97.1%
Simplified97.1%
Taylor expanded in a around inf 86.2%
*-commutative86.2%
associate-*r*87.5%
Simplified87.5%
if -4.99999999999999985e223 < (*.f64 a b) < 1.00000000000000002e141Initial program 100.0%
Taylor expanded in a around 0 87.1%
Final simplification87.2%
(FPCore (x y z t a b c)
:precision binary64
(if (<= (* a b) -5e+223)
(+ c (* a (* b -0.25)))
(if (<= (* a b) 1e+132)
(+ c (+ (* x y) (* 0.0625 (* z t))))
(- (* t (* z 0.0625)) (* (* a b) 0.25)))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if ((a * b) <= -5e+223) {
tmp = c + (a * (b * -0.25));
} else if ((a * b) <= 1e+132) {
tmp = c + ((x * y) + (0.0625 * (z * t)));
} else {
tmp = (t * (z * 0.0625)) - ((a * b) * 0.25);
}
return tmp;
}
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
real(8) :: tmp
if ((a * b) <= (-5d+223)) then
tmp = c + (a * (b * (-0.25d0)))
else if ((a * b) <= 1d+132) then
tmp = c + ((x * y) + (0.0625d0 * (z * t)))
else
tmp = (t * (z * 0.0625d0)) - ((a * b) * 0.25d0)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if ((a * b) <= -5e+223) {
tmp = c + (a * (b * -0.25));
} else if ((a * b) <= 1e+132) {
tmp = c + ((x * y) + (0.0625 * (z * t)));
} else {
tmp = (t * (z * 0.0625)) - ((a * b) * 0.25);
}
return tmp;
}
def code(x, y, z, t, a, b, c): tmp = 0 if (a * b) <= -5e+223: tmp = c + (a * (b * -0.25)) elif (a * b) <= 1e+132: tmp = c + ((x * y) + (0.0625 * (z * t))) else: tmp = (t * (z * 0.0625)) - ((a * b) * 0.25) return tmp
function code(x, y, z, t, a, b, c) tmp = 0.0 if (Float64(a * b) <= -5e+223) tmp = Float64(c + Float64(a * Float64(b * -0.25))); elseif (Float64(a * b) <= 1e+132) tmp = Float64(c + Float64(Float64(x * y) + Float64(0.0625 * Float64(z * t)))); else tmp = Float64(Float64(t * Float64(z * 0.0625)) - Float64(Float64(a * b) * 0.25)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c) tmp = 0.0; if ((a * b) <= -5e+223) tmp = c + (a * (b * -0.25)); elseif ((a * b) <= 1e+132) tmp = c + ((x * y) + (0.0625 * (z * t))); else tmp = (t * (z * 0.0625)) - ((a * b) * 0.25); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_] := If[LessEqual[N[(a * b), $MachinePrecision], -5e+223], N[(c + N[(a * N[(b * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 1e+132], N[(c + N[(N[(x * y), $MachinePrecision] + N[(0.0625 * N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t * N[(z * 0.0625), $MachinePrecision]), $MachinePrecision] - N[(N[(a * b), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+223}:\\
\;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\
\mathbf{elif}\;a \cdot b \leq 10^{+132}:\\
\;\;\;\;c + \left(x \cdot y + 0.0625 \cdot \left(z \cdot t\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot \left(z \cdot 0.0625\right) - \left(a \cdot b\right) \cdot 0.25\\
\end{array}
\end{array}
if (*.f64 a b) < -4.99999999999999985e223Initial program 90.9%
associate--l+90.9%
fma-define90.9%
associate-/l*90.9%
fma-neg95.5%
distribute-neg-frac295.5%
metadata-eval95.5%
Simplified95.5%
Taylor expanded in a around inf 91.2%
*-commutative91.2%
associate-*r*91.2%
Simplified91.2%
if -4.99999999999999985e223 < (*.f64 a b) < 9.99999999999999991e131Initial program 100.0%
Taylor expanded in a around 0 87.0%
if 9.99999999999999991e131 < (*.f64 a b) Initial program 95.6%
Taylor expanded in x around 0 90.8%
Taylor expanded in c around 0 88.5%
associate-*r*88.5%
*-commutative88.5%
associate-*r*88.5%
Simplified88.5%
Final simplification87.6%
(FPCore (x y z t a b c) :precision binary64 (if (or (<= (* a b) -5e-43) (not (<= (* a b) 2e-32))) (+ c (* a (* b -0.25))) (+ c (* 0.0625 (* z t)))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if (((a * b) <= -5e-43) || !((a * b) <= 2e-32)) {
tmp = c + (a * (b * -0.25));
} else {
tmp = c + (0.0625 * (z * t));
}
return tmp;
}
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
real(8) :: tmp
if (((a * b) <= (-5d-43)) .or. (.not. ((a * b) <= 2d-32))) then
tmp = c + (a * (b * (-0.25d0)))
else
tmp = c + (0.0625d0 * (z * t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if (((a * b) <= -5e-43) || !((a * b) <= 2e-32)) {
tmp = c + (a * (b * -0.25));
} else {
tmp = c + (0.0625 * (z * t));
}
return tmp;
}
def code(x, y, z, t, a, b, c): tmp = 0 if ((a * b) <= -5e-43) or not ((a * b) <= 2e-32): tmp = c + (a * (b * -0.25)) else: tmp = c + (0.0625 * (z * t)) return tmp
function code(x, y, z, t, a, b, c) tmp = 0.0 if ((Float64(a * b) <= -5e-43) || !(Float64(a * b) <= 2e-32)) tmp = Float64(c + Float64(a * Float64(b * -0.25))); else tmp = Float64(c + Float64(0.0625 * Float64(z * t))); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c) tmp = 0.0; if (((a * b) <= -5e-43) || ~(((a * b) <= 2e-32))) tmp = c + (a * (b * -0.25)); else tmp = c + (0.0625 * (z * t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -5e-43], N[Not[LessEqual[N[(a * b), $MachinePrecision], 2e-32]], $MachinePrecision]], N[(c + N[(a * N[(b * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c + N[(0.0625 * N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -5 \cdot 10^{-43} \lor \neg \left(a \cdot b \leq 2 \cdot 10^{-32}\right):\\
\;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\
\mathbf{else}:\\
\;\;\;\;c + 0.0625 \cdot \left(z \cdot t\right)\\
\end{array}
\end{array}
if (*.f64 a b) < -5.00000000000000019e-43 or 2.00000000000000011e-32 < (*.f64 a b) Initial program 97.4%
associate--l+97.4%
fma-define98.1%
associate-/l*98.1%
fma-neg98.8%
distribute-neg-frac298.8%
metadata-eval98.8%
Simplified98.8%
Taylor expanded in a around inf 68.9%
*-commutative68.9%
associate-*r*69.5%
Simplified69.5%
if -5.00000000000000019e-43 < (*.f64 a b) < 2.00000000000000011e-32Initial program 100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in t around inf 67.1%
Final simplification68.5%
(FPCore (x y z t a b c) :precision binary64 (+ c (+ (* x y) (- (* 0.0625 (* z t)) (/ a (/ 4.0 b))))))
double code(double x, double y, double z, double t, double a, double b, double c) {
return c + ((x * y) + ((0.0625 * (z * t)) - (a / (4.0 / b))));
}
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 = c + ((x * y) + ((0.0625d0 * (z * t)) - (a / (4.0d0 / b))))
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
return c + ((x * y) + ((0.0625 * (z * t)) - (a / (4.0 / b))));
}
def code(x, y, z, t, a, b, c): return c + ((x * y) + ((0.0625 * (z * t)) - (a / (4.0 / b))))
function code(x, y, z, t, a, b, c) return Float64(c + Float64(Float64(x * y) + Float64(Float64(0.0625 * Float64(z * t)) - Float64(a / Float64(4.0 / b))))) end
function tmp = code(x, y, z, t, a, b, c) tmp = c + ((x * y) + ((0.0625 * (z * t)) - (a / (4.0 / b)))); end
code[x_, y_, z_, t_, a_, b_, c_] := N[(c + N[(N[(x * y), $MachinePrecision] + N[(N[(0.0625 * N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(a / N[(4.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c + \left(x \cdot y + \left(0.0625 \cdot \left(z \cdot t\right) - \frac{a}{\frac{4}{b}}\right)\right)
\end{array}
Initial program 98.5%
clear-num98.4%
inv-pow98.4%
*-commutative98.4%
associate-/r*98.7%
Applied egg-rr98.7%
unpow-198.7%
Simplified98.7%
associate--l+98.7%
div-inv98.7%
metadata-eval98.7%
*-commutative98.7%
*-commutative98.7%
clear-num98.8%
Applied egg-rr98.8%
Final simplification98.8%
(FPCore (x y z t a b c) :precision binary64 (if (or (<= a -2.4e+111) (not (<= a 4e+65))) (* b (* a -0.25)) (+ c (* x y))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if ((a <= -2.4e+111) || !(a <= 4e+65)) {
tmp = b * (a * -0.25);
} else {
tmp = c + (x * y);
}
return tmp;
}
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
real(8) :: tmp
if ((a <= (-2.4d+111)) .or. (.not. (a <= 4d+65))) then
tmp = b * (a * (-0.25d0))
else
tmp = c + (x * y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if ((a <= -2.4e+111) || !(a <= 4e+65)) {
tmp = b * (a * -0.25);
} else {
tmp = c + (x * y);
}
return tmp;
}
def code(x, y, z, t, a, b, c): tmp = 0 if (a <= -2.4e+111) or not (a <= 4e+65): tmp = b * (a * -0.25) else: tmp = c + (x * y) return tmp
function code(x, y, z, t, a, b, c) tmp = 0.0 if ((a <= -2.4e+111) || !(a <= 4e+65)) tmp = Float64(b * Float64(a * -0.25)); else tmp = Float64(c + Float64(x * y)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c) tmp = 0.0; if ((a <= -2.4e+111) || ~((a <= 4e+65))) tmp = b * (a * -0.25); else tmp = c + (x * y); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_] := If[Or[LessEqual[a, -2.4e+111], N[Not[LessEqual[a, 4e+65]], $MachinePrecision]], N[(b * N[(a * -0.25), $MachinePrecision]), $MachinePrecision], N[(c + N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.4 \cdot 10^{+111} \lor \neg \left(a \leq 4 \cdot 10^{+65}\right):\\
\;\;\;\;b \cdot \left(a \cdot -0.25\right)\\
\mathbf{else}:\\
\;\;\;\;c + x \cdot y\\
\end{array}
\end{array}
if a < -2.40000000000000006e111 or 4e65 < a Initial program 96.6%
associate--l+96.6%
fma-define97.8%
associate-/l*97.8%
fma-neg98.9%
distribute-neg-frac298.9%
metadata-eval98.9%
Simplified98.9%
Taylor expanded in a around inf 71.3%
*-commutative71.3%
associate-*r*71.3%
Simplified71.3%
Taylor expanded in c around inf 61.0%
Taylor expanded in c around 0 58.3%
associate-*r*58.3%
*-commutative58.3%
*-commutative58.3%
Simplified58.3%
if -2.40000000000000006e111 < a < 4e65Initial program 99.5%
Taylor expanded in a around 0 84.4%
Taylor expanded in t around 0 55.9%
Final simplification56.7%
(FPCore (x y z t a b c) :precision binary64 (if (<= c -1.55e-13) c (if (<= c 6.2e+85) (* b (* a -0.25)) c)))
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if (c <= -1.55e-13) {
tmp = c;
} else if (c <= 6.2e+85) {
tmp = b * (a * -0.25);
} else {
tmp = c;
}
return tmp;
}
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
real(8) :: tmp
if (c <= (-1.55d-13)) then
tmp = c
else if (c <= 6.2d+85) then
tmp = b * (a * (-0.25d0))
else
tmp = c
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if (c <= -1.55e-13) {
tmp = c;
} else if (c <= 6.2e+85) {
tmp = b * (a * -0.25);
} else {
tmp = c;
}
return tmp;
}
def code(x, y, z, t, a, b, c): tmp = 0 if c <= -1.55e-13: tmp = c elif c <= 6.2e+85: tmp = b * (a * -0.25) else: tmp = c return tmp
function code(x, y, z, t, a, b, c) tmp = 0.0 if (c <= -1.55e-13) tmp = c; elseif (c <= 6.2e+85) tmp = Float64(b * Float64(a * -0.25)); else tmp = c; end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c) tmp = 0.0; if (c <= -1.55e-13) tmp = c; elseif (c <= 6.2e+85) tmp = b * (a * -0.25); else tmp = c; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_] := If[LessEqual[c, -1.55e-13], c, If[LessEqual[c, 6.2e+85], N[(b * N[(a * -0.25), $MachinePrecision]), $MachinePrecision], c]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.55 \cdot 10^{-13}:\\
\;\;\;\;c\\
\mathbf{elif}\;c \leq 6.2 \cdot 10^{+85}:\\
\;\;\;\;b \cdot \left(a \cdot -0.25\right)\\
\mathbf{else}:\\
\;\;\;\;c\\
\end{array}
\end{array}
if c < -1.55e-13 or 6.20000000000000023e85 < c Initial program 99.0%
Taylor expanded in c around inf 44.0%
if -1.55e-13 < c < 6.20000000000000023e85Initial program 98.1%
associate--l+98.1%
fma-define98.1%
associate-/l*98.1%
fma-neg98.8%
distribute-neg-frac298.8%
metadata-eval98.8%
Simplified98.8%
Taylor expanded in a around inf 44.6%
*-commutative44.6%
associate-*r*45.2%
Simplified45.2%
Taylor expanded in c around inf 34.7%
Taylor expanded in c around 0 41.3%
associate-*r*41.8%
*-commutative41.8%
*-commutative41.8%
Simplified41.8%
(FPCore (x y z t a b c) :precision binary64 c)
double code(double x, double y, double z, double t, double a, double b, double c) {
return 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 = c
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
return c;
}
def code(x, y, z, t, a, b, c): return c
function code(x, y, z, t, a, b, c) return c end
function tmp = code(x, y, z, t, a, b, c) tmp = c; end
code[x_, y_, z_, t_, a_, b_, c_] := c
\begin{array}{l}
\\
c
\end{array}
Initial program 98.5%
Taylor expanded in c around inf 21.5%
herbie shell --seed 2024145
(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))