
(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.4%
associate--l+98.4%
fma-define99.2%
associate-/l*99.2%
fma-neg99.6%
distribute-neg-frac299.6%
metadata-eval99.6%
Simplified99.6%
Final simplification99.6%
(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.4%
associate-+l-98.4%
*-commutative98.4%
associate-+l-98.4%
fma-define99.2%
*-commutative99.2%
associate-/l*99.2%
associate-/l*99.2%
Simplified99.2%
Final simplification99.2%
(FPCore (x y z t a b c)
:precision binary64
(let* ((t_1 (+ c (* 0.0625 (* z t))))
(t_2 (+ c (* b (* a -0.25))))
(t_3 (+ c (* x y))))
(if (<= (* a b) -5e+95)
t_2
(if (<= (* a b) -3e-123)
t_1
(if (<= (* a b) -4e-166)
t_3
(if (<= (* a b) 5e-83) t_1 (if (<= (* a b) 5e+131) t_3 t_2)))))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = c + (0.0625 * (z * t));
double t_2 = c + (b * (a * -0.25));
double t_3 = c + (x * y);
double tmp;
if ((a * b) <= -5e+95) {
tmp = t_2;
} else if ((a * b) <= -3e-123) {
tmp = t_1;
} else if ((a * b) <= -4e-166) {
tmp = t_3;
} else if ((a * b) <= 5e-83) {
tmp = t_1;
} else if ((a * b) <= 5e+131) {
tmp = t_3;
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: t_3
real(8) :: tmp
t_1 = c + (0.0625d0 * (z * t))
t_2 = c + (b * (a * (-0.25d0)))
t_3 = c + (x * y)
if ((a * b) <= (-5d+95)) then
tmp = t_2
else if ((a * b) <= (-3d-123)) then
tmp = t_1
else if ((a * b) <= (-4d-166)) then
tmp = t_3
else if ((a * b) <= 5d-83) then
tmp = t_1
else if ((a * b) <= 5d+131) then
tmp = t_3
else
tmp = t_2
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 + (0.0625 * (z * t));
double t_2 = c + (b * (a * -0.25));
double t_3 = c + (x * y);
double tmp;
if ((a * b) <= -5e+95) {
tmp = t_2;
} else if ((a * b) <= -3e-123) {
tmp = t_1;
} else if ((a * b) <= -4e-166) {
tmp = t_3;
} else if ((a * b) <= 5e-83) {
tmp = t_1;
} else if ((a * b) <= 5e+131) {
tmp = t_3;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a, b, c): t_1 = c + (0.0625 * (z * t)) t_2 = c + (b * (a * -0.25)) t_3 = c + (x * y) tmp = 0 if (a * b) <= -5e+95: tmp = t_2 elif (a * b) <= -3e-123: tmp = t_1 elif (a * b) <= -4e-166: tmp = t_3 elif (a * b) <= 5e-83: tmp = t_1 elif (a * b) <= 5e+131: tmp = t_3 else: tmp = t_2 return tmp
function code(x, y, z, t, a, b, c) t_1 = Float64(c + Float64(0.0625 * Float64(z * t))) t_2 = Float64(c + Float64(b * Float64(a * -0.25))) t_3 = Float64(c + Float64(x * y)) tmp = 0.0 if (Float64(a * b) <= -5e+95) tmp = t_2; elseif (Float64(a * b) <= -3e-123) tmp = t_1; elseif (Float64(a * b) <= -4e-166) tmp = t_3; elseif (Float64(a * b) <= 5e-83) tmp = t_1; elseif (Float64(a * b) <= 5e+131) tmp = t_3; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c) t_1 = c + (0.0625 * (z * t)); t_2 = c + (b * (a * -0.25)); t_3 = c + (x * y); tmp = 0.0; if ((a * b) <= -5e+95) tmp = t_2; elseif ((a * b) <= -3e-123) tmp = t_1; elseif ((a * b) <= -4e-166) tmp = t_3; elseif ((a * b) <= 5e-83) tmp = t_1; elseif ((a * b) <= 5e+131) tmp = t_3; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(c + N[(0.0625 * N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(c + N[(b * N[(a * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(c + N[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a * b), $MachinePrecision], -5e+95], t$95$2, If[LessEqual[N[(a * b), $MachinePrecision], -3e-123], t$95$1, If[LessEqual[N[(a * b), $MachinePrecision], -4e-166], t$95$3, If[LessEqual[N[(a * b), $MachinePrecision], 5e-83], t$95$1, If[LessEqual[N[(a * b), $MachinePrecision], 5e+131], t$95$3, t$95$2]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := c + 0.0625 \cdot \left(z \cdot t\right)\\
t_2 := c + b \cdot \left(a \cdot -0.25\right)\\
t_3 := c + x \cdot y\\
\mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+95}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;a \cdot b \leq -3 \cdot 10^{-123}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \cdot b \leq -4 \cdot 10^{-166}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{-83}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{+131}:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 a b) < -5.00000000000000025e95 or 4.99999999999999995e131 < (*.f64 a b) Initial program 97.9%
Taylor expanded in a around inf 73.6%
associate-*r*73.6%
Simplified73.6%
if -5.00000000000000025e95 < (*.f64 a b) < -2.99999999999999984e-123 or -4.00000000000000016e-166 < (*.f64 a b) < 5e-83Initial program 99.1%
Taylor expanded in a around 0 95.6%
Taylor expanded in x around 0 69.7%
if -2.99999999999999984e-123 < (*.f64 a b) < -4.00000000000000016e-166 or 5e-83 < (*.f64 a b) < 4.99999999999999995e131Initial program 98.1%
Taylor expanded in a around 0 93.7%
Taylor expanded in t around 0 73.5%
+-commutative73.5%
Simplified73.5%
Final simplification71.9%
(FPCore (x y z t a b c)
:precision binary64
(if (or (<= (* a b) -4e+188)
(not
(or (<= (* a b) 5e+131)
(and (not (<= (* a b) 2e+190)) (<= (* a b) 1e+220)))))
(+ c (* b (* a -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) <= -4e+188) || !(((a * b) <= 5e+131) || (!((a * b) <= 2e+190) && ((a * b) <= 1e+220)))) {
tmp = c + (b * (a * -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) <= (-4d+188)) .or. (.not. ((a * b) <= 5d+131) .or. (.not. ((a * b) <= 2d+190)) .and. ((a * b) <= 1d+220))) then
tmp = c + (b * (a * (-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) <= -4e+188) || !(((a * b) <= 5e+131) || (!((a * b) <= 2e+190) && ((a * b) <= 1e+220)))) {
tmp = c + (b * (a * -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) <= -4e+188) or not (((a * b) <= 5e+131) or (not ((a * b) <= 2e+190) and ((a * b) <= 1e+220))): tmp = c + (b * (a * -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) <= -4e+188) || !((Float64(a * b) <= 5e+131) || (!(Float64(a * b) <= 2e+190) && (Float64(a * b) <= 1e+220)))) tmp = Float64(c + Float64(b * Float64(a * -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) <= -4e+188) || ~((((a * b) <= 5e+131) || (~(((a * b) <= 2e+190)) && ((a * b) <= 1e+220))))) tmp = c + (b * (a * -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], -4e+188], N[Not[Or[LessEqual[N[(a * b), $MachinePrecision], 5e+131], And[N[Not[LessEqual[N[(a * b), $MachinePrecision], 2e+190]], $MachinePrecision], LessEqual[N[(a * b), $MachinePrecision], 1e+220]]]], $MachinePrecision]], N[(c + N[(b * N[(a * -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 -4 \cdot 10^{+188} \lor \neg \left(a \cdot b \leq 5 \cdot 10^{+131} \lor \neg \left(a \cdot b \leq 2 \cdot 10^{+190}\right) \land a \cdot b \leq 10^{+220}\right):\\
\;\;\;\;c + b \cdot \left(a \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.0000000000000001e188 or 4.99999999999999995e131 < (*.f64 a b) < 2.0000000000000001e190 or 1e220 < (*.f64 a b) Initial program 97.0%
Taylor expanded in a around inf 88.4%
associate-*r*88.4%
Simplified88.4%
if -4.0000000000000001e188 < (*.f64 a b) < 4.99999999999999995e131 or 2.0000000000000001e190 < (*.f64 a b) < 1e220Initial program 98.9%
Taylor expanded in a around 0 90.5%
Final simplification90.0%
(FPCore (x y z t a b c)
:precision binary64
(let* ((t_1 (* z (* t 0.0625))))
(if (<= (* x y) -7.6e+146)
(* x y)
(if (<= (* x y) 1.55e-54)
t_1
(if (<= (* x y) 4.1e+127) c (if (<= (* x y) 4.1e+157) t_1 (* x y)))))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = z * (t * 0.0625);
double tmp;
if ((x * y) <= -7.6e+146) {
tmp = x * y;
} else if ((x * y) <= 1.55e-54) {
tmp = t_1;
} else if ((x * y) <= 4.1e+127) {
tmp = c;
} else if ((x * y) <= 4.1e+157) {
tmp = t_1;
} else {
tmp = 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) :: t_1
real(8) :: tmp
t_1 = z * (t * 0.0625d0)
if ((x * y) <= (-7.6d+146)) then
tmp = x * y
else if ((x * y) <= 1.55d-54) then
tmp = t_1
else if ((x * y) <= 4.1d+127) then
tmp = c
else if ((x * y) <= 4.1d+157) then
tmp = t_1
else
tmp = 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 t_1 = z * (t * 0.0625);
double tmp;
if ((x * y) <= -7.6e+146) {
tmp = x * y;
} else if ((x * y) <= 1.55e-54) {
tmp = t_1;
} else if ((x * y) <= 4.1e+127) {
tmp = c;
} else if ((x * y) <= 4.1e+157) {
tmp = t_1;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z, t, a, b, c): t_1 = z * (t * 0.0625) tmp = 0 if (x * y) <= -7.6e+146: tmp = x * y elif (x * y) <= 1.55e-54: tmp = t_1 elif (x * y) <= 4.1e+127: tmp = c elif (x * y) <= 4.1e+157: tmp = t_1 else: tmp = x * y return tmp
function code(x, y, z, t, a, b, c) t_1 = Float64(z * Float64(t * 0.0625)) tmp = 0.0 if (Float64(x * y) <= -7.6e+146) tmp = Float64(x * y); elseif (Float64(x * y) <= 1.55e-54) tmp = t_1; elseif (Float64(x * y) <= 4.1e+127) tmp = c; elseif (Float64(x * y) <= 4.1e+157) tmp = t_1; else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c) t_1 = z * (t * 0.0625); tmp = 0.0; if ((x * y) <= -7.6e+146) tmp = x * y; elseif ((x * y) <= 1.55e-54) tmp = t_1; elseif ((x * y) <= 4.1e+127) tmp = c; elseif ((x * y) <= 4.1e+157) tmp = t_1; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(z * N[(t * 0.0625), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -7.6e+146], N[(x * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1.55e-54], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 4.1e+127], c, If[LessEqual[N[(x * y), $MachinePrecision], 4.1e+157], t$95$1, N[(x * y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(t \cdot 0.0625\right)\\
\mathbf{if}\;x \cdot y \leq -7.6 \cdot 10^{+146}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \cdot y \leq 1.55 \cdot 10^{-54}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \cdot y \leq 4.1 \cdot 10^{+127}:\\
\;\;\;\;c\\
\mathbf{elif}\;x \cdot y \leq 4.1 \cdot 10^{+157}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < -7.59999999999999958e146 or 4.10000000000000016e157 < (*.f64 x y) Initial program 96.2%
Taylor expanded in a around 0 86.1%
Taylor expanded in t around 0 72.5%
+-commutative72.5%
Simplified72.5%
Taylor expanded in x around inf 69.4%
if -7.59999999999999958e146 < (*.f64 x y) < 1.55000000000000002e-54 or 4.09999999999999983e127 < (*.f64 x y) < 4.10000000000000016e157Initial program 99.3%
+-commutative99.3%
associate-*r/99.3%
*-commutative99.3%
fma-define99.3%
div-inv99.3%
metadata-eval99.3%
Applied egg-rr99.3%
Taylor expanded in a around 0 62.9%
+-commutative62.9%
+-commutative62.9%
fma-define62.9%
associate-*r*62.9%
Simplified62.9%
Taylor expanded in x around 0 57.8%
+-commutative57.8%
associate-*r*57.8%
Simplified57.8%
Taylor expanded in t around inf 36.8%
associate-*r*36.8%
Simplified36.8%
if 1.55000000000000002e-54 < (*.f64 x y) < 4.09999999999999983e127Initial program 100.0%
Taylor expanded in c around inf 40.7%
Final simplification47.6%
(FPCore (x y z t a b c) :precision binary64 (if (or (<= (* a b) -5e+105) (not (<= (* a b) 1e+123))) (- (+ 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+105) || !((a * b) <= 1e+123)) {
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+105)) .or. (.not. ((a * b) <= 1d+123))) 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+105) || !((a * b) <= 1e+123)) {
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+105) or not ((a * b) <= 1e+123): 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+105) || !(Float64(a * b) <= 1e+123)) 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+105) || ~(((a * b) <= 1e+123))) 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+105], N[Not[LessEqual[N[(a * b), $MachinePrecision], 1e+123]], $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^{+105} \lor \neg \left(a \cdot b \leq 10^{+123}\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.00000000000000046e105 or 9.99999999999999978e122 < (*.f64 a b) Initial program 97.9%
Taylor expanded in z around 0 85.7%
if -5.00000000000000046e105 < (*.f64 a b) < 9.99999999999999978e122Initial program 98.7%
Taylor expanded in a around 0 95.0%
Final simplification91.5%
(FPCore (x y z t a b c)
:precision binary64
(let* ((t_1 (* 0.0625 (* z t))) (t_2 (* (* a b) 0.25)))
(if (<= (* a b) -5e+105)
(- (+ c t_1) t_2)
(if (<= (* a b) 1e+123) (+ c (+ (* x y) t_1)) (- (+ c (* x y)) t_2)))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = 0.0625 * (z * t);
double t_2 = (a * b) * 0.25;
double tmp;
if ((a * b) <= -5e+105) {
tmp = (c + t_1) - t_2;
} else if ((a * b) <= 1e+123) {
tmp = c + ((x * y) + t_1);
} else {
tmp = (c + (x * y)) - t_2;
}
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) :: t_2
real(8) :: tmp
t_1 = 0.0625d0 * (z * t)
t_2 = (a * b) * 0.25d0
if ((a * b) <= (-5d+105)) then
tmp = (c + t_1) - t_2
else if ((a * b) <= 1d+123) then
tmp = c + ((x * y) + t_1)
else
tmp = (c + (x * y)) - t_2
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 = 0.0625 * (z * t);
double t_2 = (a * b) * 0.25;
double tmp;
if ((a * b) <= -5e+105) {
tmp = (c + t_1) - t_2;
} else if ((a * b) <= 1e+123) {
tmp = c + ((x * y) + t_1);
} else {
tmp = (c + (x * y)) - t_2;
}
return tmp;
}
def code(x, y, z, t, a, b, c): t_1 = 0.0625 * (z * t) t_2 = (a * b) * 0.25 tmp = 0 if (a * b) <= -5e+105: tmp = (c + t_1) - t_2 elif (a * b) <= 1e+123: tmp = c + ((x * y) + t_1) else: tmp = (c + (x * y)) - t_2 return tmp
function code(x, y, z, t, a, b, c) t_1 = Float64(0.0625 * Float64(z * t)) t_2 = Float64(Float64(a * b) * 0.25) tmp = 0.0 if (Float64(a * b) <= -5e+105) tmp = Float64(Float64(c + t_1) - t_2); elseif (Float64(a * b) <= 1e+123) tmp = Float64(c + Float64(Float64(x * y) + t_1)); else tmp = Float64(Float64(c + Float64(x * y)) - t_2); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c) t_1 = 0.0625 * (z * t); t_2 = (a * b) * 0.25; tmp = 0.0; if ((a * b) <= -5e+105) tmp = (c + t_1) - t_2; elseif ((a * b) <= 1e+123) tmp = c + ((x * y) + t_1); else tmp = (c + (x * y)) - t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(0.0625 * N[(z * t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(a * b), $MachinePrecision] * 0.25), $MachinePrecision]}, If[LessEqual[N[(a * b), $MachinePrecision], -5e+105], N[(N[(c + t$95$1), $MachinePrecision] - t$95$2), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 1e+123], N[(c + N[(N[(x * y), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(c + N[(x * y), $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 0.0625 \cdot \left(z \cdot t\right)\\
t_2 := \left(a \cdot b\right) \cdot 0.25\\
\mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+105}:\\
\;\;\;\;\left(c + t\_1\right) - t\_2\\
\mathbf{elif}\;a \cdot b \leq 10^{+123}:\\
\;\;\;\;c + \left(x \cdot y + t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(c + x \cdot y\right) - t\_2\\
\end{array}
\end{array}
if (*.f64 a b) < -5.00000000000000046e105Initial program 97.1%
Taylor expanded in x around 0 91.9%
if -5.00000000000000046e105 < (*.f64 a b) < 9.99999999999999978e122Initial program 98.7%
Taylor expanded in a around 0 95.0%
if 9.99999999999999978e122 < (*.f64 a b) Initial program 98.3%
Taylor expanded in z around 0 88.6%
Final simplification93.1%
(FPCore (x y z t a b c) :precision binary64 (if (or (<= (* x y) -2.7e+103) (not (<= (* x y) 1.5e+157))) (+ c (* x y)) (+ c (* 0.0625 (* z t)))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if (((x * y) <= -2.7e+103) || !((x * y) <= 1.5e+157)) {
tmp = c + (x * y);
} 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 (((x * y) <= (-2.7d+103)) .or. (.not. ((x * y) <= 1.5d+157))) then
tmp = c + (x * y)
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 (((x * y) <= -2.7e+103) || !((x * y) <= 1.5e+157)) {
tmp = c + (x * y);
} else {
tmp = c + (0.0625 * (z * t));
}
return tmp;
}
def code(x, y, z, t, a, b, c): tmp = 0 if ((x * y) <= -2.7e+103) or not ((x * y) <= 1.5e+157): tmp = c + (x * y) else: tmp = c + (0.0625 * (z * t)) return tmp
function code(x, y, z, t, a, b, c) tmp = 0.0 if ((Float64(x * y) <= -2.7e+103) || !(Float64(x * y) <= 1.5e+157)) tmp = Float64(c + Float64(x * y)); 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 (((x * y) <= -2.7e+103) || ~(((x * y) <= 1.5e+157))) tmp = c + (x * y); else tmp = c + (0.0625 * (z * t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -2.7e+103], N[Not[LessEqual[N[(x * y), $MachinePrecision], 1.5e+157]], $MachinePrecision]], N[(c + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(c + N[(0.0625 * N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2.7 \cdot 10^{+103} \lor \neg \left(x \cdot y \leq 1.5 \cdot 10^{+157}\right):\\
\;\;\;\;c + x \cdot y\\
\mathbf{else}:\\
\;\;\;\;c + 0.0625 \cdot \left(z \cdot t\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -2.69999999999999993e103 or 1.50000000000000005e157 < (*.f64 x y) Initial program 96.3%
Taylor expanded in a around 0 85.4%
Taylor expanded in t around 0 71.2%
+-commutative71.2%
Simplified71.2%
if -2.69999999999999993e103 < (*.f64 x y) < 1.50000000000000005e157Initial program 99.4%
Taylor expanded in a around 0 66.6%
Taylor expanded in x around 0 59.3%
Final simplification63.2%
(FPCore (x y z t a b c) :precision binary64 (if (or (<= (* x y) -2.7e+26) (not (<= (* x y) 1.7e+125))) (* x y) c))
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if (((x * y) <= -2.7e+26) || !((x * y) <= 1.7e+125)) {
tmp = x * y;
} 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 (((x * y) <= (-2.7d+26)) .or. (.not. ((x * y) <= 1.7d+125))) then
tmp = x * y
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 (((x * y) <= -2.7e+26) || !((x * y) <= 1.7e+125)) {
tmp = x * y;
} else {
tmp = c;
}
return tmp;
}
def code(x, y, z, t, a, b, c): tmp = 0 if ((x * y) <= -2.7e+26) or not ((x * y) <= 1.7e+125): tmp = x * y else: tmp = c return tmp
function code(x, y, z, t, a, b, c) tmp = 0.0 if ((Float64(x * y) <= -2.7e+26) || !(Float64(x * y) <= 1.7e+125)) tmp = Float64(x * y); else tmp = c; end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c) tmp = 0.0; if (((x * y) <= -2.7e+26) || ~(((x * y) <= 1.7e+125))) tmp = x * y; else tmp = c; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -2.7e+26], N[Not[LessEqual[N[(x * y), $MachinePrecision], 1.7e+125]], $MachinePrecision]], N[(x * y), $MachinePrecision], c]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2.7 \cdot 10^{+26} \lor \neg \left(x \cdot y \leq 1.7 \cdot 10^{+125}\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;c\\
\end{array}
\end{array}
if (*.f64 x y) < -2.7e26 or 1.6999999999999999e125 < (*.f64 x y) Initial program 96.8%
Taylor expanded in a around 0 82.0%
Taylor expanded in t around 0 65.5%
+-commutative65.5%
Simplified65.5%
Taylor expanded in x around inf 61.9%
if -2.7e26 < (*.f64 x y) < 1.6999999999999999e125Initial program 99.4%
Taylor expanded in c around inf 28.7%
Final simplification41.0%
(FPCore (x y z t a b c) :precision binary64 (+ c (- (+ (* 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 + (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0));
}
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) + ((z * t) / 16.0d0)) - ((a * b) / 4.0d0))
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
return c + (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0));
}
def code(x, y, z, t, a, b, c): return c + (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0))
function code(x, y, z, t, a, b, c) return Float64(c + Float64(Float64(Float64(x * y) + Float64(Float64(z * t) / 16.0)) - Float64(Float64(a * b) / 4.0))) end
function tmp = code(x, y, z, t, a, b, c) tmp = c + (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)); end
code[x_, y_, z_, t_, a_, b_, c_] := N[(c + N[(N[(N[(x * y), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision] - N[(N[(a * b), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c + \left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right)
\end{array}
Initial program 98.4%
Final simplification98.4%
(FPCore (x y z t a b c) :precision binary64 (if (or (<= t -3.6e-10) (not (<= t 6.2e+89))) (* z (* t 0.0625)) (+ c (* x y))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if ((t <= -3.6e-10) || !(t <= 6.2e+89)) {
tmp = z * (t * 0.0625);
} 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 ((t <= (-3.6d-10)) .or. (.not. (t <= 6.2d+89))) then
tmp = z * (t * 0.0625d0)
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 ((t <= -3.6e-10) || !(t <= 6.2e+89)) {
tmp = z * (t * 0.0625);
} else {
tmp = c + (x * y);
}
return tmp;
}
def code(x, y, z, t, a, b, c): tmp = 0 if (t <= -3.6e-10) or not (t <= 6.2e+89): tmp = z * (t * 0.0625) else: tmp = c + (x * y) return tmp
function code(x, y, z, t, a, b, c) tmp = 0.0 if ((t <= -3.6e-10) || !(t <= 6.2e+89)) tmp = Float64(z * Float64(t * 0.0625)); 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 ((t <= -3.6e-10) || ~((t <= 6.2e+89))) tmp = z * (t * 0.0625); else tmp = c + (x * y); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_] := If[Or[LessEqual[t, -3.6e-10], N[Not[LessEqual[t, 6.2e+89]], $MachinePrecision]], N[(z * N[(t * 0.0625), $MachinePrecision]), $MachinePrecision], N[(c + N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.6 \cdot 10^{-10} \lor \neg \left(t \leq 6.2 \cdot 10^{+89}\right):\\
\;\;\;\;z \cdot \left(t \cdot 0.0625\right)\\
\mathbf{else}:\\
\;\;\;\;c + x \cdot y\\
\end{array}
\end{array}
if t < -3.6e-10 or 6.2e89 < t Initial program 96.4%
+-commutative96.4%
associate-*r/96.4%
*-commutative96.4%
fma-define97.3%
div-inv97.3%
metadata-eval97.3%
Applied egg-rr97.3%
Taylor expanded in a around 0 82.3%
+-commutative82.3%
+-commutative82.3%
fma-define84.0%
associate-*r*84.0%
Simplified84.0%
Taylor expanded in x around 0 65.8%
+-commutative65.8%
associate-*r*65.8%
Simplified65.8%
Taylor expanded in t around inf 55.1%
associate-*r*55.1%
Simplified55.1%
if -3.6e-10 < t < 6.2e89Initial program 100.0%
Taylor expanded in a around 0 65.1%
Taylor expanded in t around 0 56.7%
+-commutative56.7%
Simplified56.7%
Final simplification56.0%
(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.4%
Taylor expanded in c around inf 20.2%
Final simplification20.2%
herbie shell --seed 2024044
(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))