
(FPCore (x y z t a b c i) :precision binary64 (* 2.0 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i));
}
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: i
code = 2.0d0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i))
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i));
}
def code(x, y, z, t, a, b, c, i): return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i))
function code(x, y, z, t, a, b, c, i) return Float64(2.0 * Float64(Float64(Float64(x * y) + Float64(z * t)) - Float64(Float64(Float64(a + Float64(b * c)) * c) * i))) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i)); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(2.0 * N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b c i) :precision binary64 (* 2.0 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i));
}
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: i
code = 2.0d0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i))
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i));
}
def code(x, y, z, t, a, b, c, i): return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i))
function code(x, y, z, t, a, b, c, i) return Float64(2.0 * Float64(Float64(Float64(x * y) + Float64(z * t)) - Float64(Float64(Float64(a + Float64(b * c)) * c) * i))) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i)); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(2.0 * N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)
\end{array}
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (+ a (* b c))))
(if (<= (- (+ (* x y) (* z t)) (* (* c t_1) i)) INFINITY)
(* 2.0 (- (fma x y (* z t)) (* t_1 (* c i))))
(* 2.0 (* x (- y (* a (/ (* c i) x))))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = a + (b * c);
double tmp;
if ((((x * y) + (z * t)) - ((c * t_1) * i)) <= ((double) INFINITY)) {
tmp = 2.0 * (fma(x, y, (z * t)) - (t_1 * (c * i)));
} else {
tmp = 2.0 * (x * (y - (a * ((c * i) / x))));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(a + Float64(b * c)) tmp = 0.0 if (Float64(Float64(Float64(x * y) + Float64(z * t)) - Float64(Float64(c * t_1) * i)) <= Inf) tmp = Float64(2.0 * Float64(fma(x, y, Float64(z * t)) - Float64(t_1 * Float64(c * i)))); else tmp = Float64(2.0 * Float64(x * Float64(y - Float64(a * Float64(Float64(c * i) / x))))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(N[(c * t$95$1), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision], Infinity], N[(2.0 * N[(N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * N[(c * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(x * N[(y - N[(a * N[(N[(c * i), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a + b \cdot c\\
\mathbf{if}\;\left(x \cdot y + z \cdot t\right) - \left(c \cdot t\_1\right) \cdot i \leq \infty:\\
\;\;\;\;2 \cdot \left(\mathsf{fma}\left(x, y, z \cdot t\right) - t\_1 \cdot \left(c \cdot i\right)\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(x \cdot \left(y - a \cdot \frac{c \cdot i}{x}\right)\right)\\
\end{array}
\end{array}
if (-.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i)) < +inf.0Initial program 95.3%
fma-define95.3%
associate-*l*98.7%
Simplified98.7%
if +inf.0 < (-.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i)) Initial program 0.0%
Taylor expanded in a around inf 20.0%
Taylor expanded in z around 0 40.1%
associate-*r*33.4%
*-commutative33.4%
associate-*r*40.1%
*-commutative40.1%
Simplified40.1%
Taylor expanded in x around inf 53.4%
mul-1-neg53.4%
unsub-neg53.4%
associate-/l*53.4%
Simplified53.4%
Final simplification96.1%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (+ a (* b c))) (t_2 (* c t_1)))
(if (or (<= t_2 -1e+296) (not (<= t_2 1e+243)))
(* -2.0 (* c (* t_1 i)))
(* (- (+ (* x y) (* z t)) (* t_2 i)) 2.0))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = a + (b * c);
double t_2 = c * t_1;
double tmp;
if ((t_2 <= -1e+296) || !(t_2 <= 1e+243)) {
tmp = -2.0 * (c * (t_1 * i));
} else {
tmp = (((x * y) + (z * t)) - (t_2 * i)) * 2.0;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: i
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = a + (b * c)
t_2 = c * t_1
if ((t_2 <= (-1d+296)) .or. (.not. (t_2 <= 1d+243))) then
tmp = (-2.0d0) * (c * (t_1 * i))
else
tmp = (((x * y) + (z * t)) - (t_2 * i)) * 2.0d0
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 i) {
double t_1 = a + (b * c);
double t_2 = c * t_1;
double tmp;
if ((t_2 <= -1e+296) || !(t_2 <= 1e+243)) {
tmp = -2.0 * (c * (t_1 * i));
} else {
tmp = (((x * y) + (z * t)) - (t_2 * i)) * 2.0;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): t_1 = a + (b * c) t_2 = c * t_1 tmp = 0 if (t_2 <= -1e+296) or not (t_2 <= 1e+243): tmp = -2.0 * (c * (t_1 * i)) else: tmp = (((x * y) + (z * t)) - (t_2 * i)) * 2.0 return tmp
function code(x, y, z, t, a, b, c, i) t_1 = Float64(a + Float64(b * c)) t_2 = Float64(c * t_1) tmp = 0.0 if ((t_2 <= -1e+296) || !(t_2 <= 1e+243)) tmp = Float64(-2.0 * Float64(c * Float64(t_1 * i))); else tmp = Float64(Float64(Float64(Float64(x * y) + Float64(z * t)) - Float64(t_2 * i)) * 2.0); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) t_1 = a + (b * c); t_2 = c * t_1; tmp = 0.0; if ((t_2 <= -1e+296) || ~((t_2 <= 1e+243))) tmp = -2.0 * (c * (t_1 * i)); else tmp = (((x * y) + (z * t)) - (t_2 * i)) * 2.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(c * t$95$1), $MachinePrecision]}, If[Or[LessEqual[t$95$2, -1e+296], N[Not[LessEqual[t$95$2, 1e+243]], $MachinePrecision]], N[(-2.0 * N[(c * N[(t$95$1 * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(t$95$2 * i), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a + b \cdot c\\
t_2 := c \cdot t\_1\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{+296} \lor \neg \left(t\_2 \leq 10^{+243}\right):\\
\;\;\;\;-2 \cdot \left(c \cdot \left(t\_1 \cdot i\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(x \cdot y + z \cdot t\right) - t\_2 \cdot i\right) \cdot 2\\
\end{array}
\end{array}
if (*.f64 (+.f64 a (*.f64 b c)) c) < -9.99999999999999981e295 or 1.0000000000000001e243 < (*.f64 (+.f64 a (*.f64 b c)) c) Initial program 77.3%
fma-define77.3%
associate-*l*88.8%
Simplified88.8%
Taylor expanded in i around inf 92.4%
if -9.99999999999999981e295 < (*.f64 (+.f64 a (*.f64 b c)) c) < 1.0000000000000001e243Initial program 96.3%
Final simplification95.0%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= c -1.18e+171) (not (<= c 2.7e+109))) (* -2.0 (* c (* (+ a (* b c)) i))) (* 2.0 (- (+ (* x y) (* z t)) (* a (* c i))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((c <= -1.18e+171) || !(c <= 2.7e+109)) {
tmp = -2.0 * (c * ((a + (b * c)) * i));
} else {
tmp = 2.0 * (((x * y) + (z * t)) - (a * (c * i)));
}
return tmp;
}
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: i
real(8) :: tmp
if ((c <= (-1.18d+171)) .or. (.not. (c <= 2.7d+109))) then
tmp = (-2.0d0) * (c * ((a + (b * c)) * i))
else
tmp = 2.0d0 * (((x * y) + (z * t)) - (a * (c * i)))
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 i) {
double tmp;
if ((c <= -1.18e+171) || !(c <= 2.7e+109)) {
tmp = -2.0 * (c * ((a + (b * c)) * i));
} else {
tmp = 2.0 * (((x * y) + (z * t)) - (a * (c * i)));
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (c <= -1.18e+171) or not (c <= 2.7e+109): tmp = -2.0 * (c * ((a + (b * c)) * i)) else: tmp = 2.0 * (((x * y) + (z * t)) - (a * (c * i))) return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((c <= -1.18e+171) || !(c <= 2.7e+109)) tmp = Float64(-2.0 * Float64(c * Float64(Float64(a + Float64(b * c)) * i))); else tmp = Float64(2.0 * Float64(Float64(Float64(x * y) + Float64(z * t)) - Float64(a * Float64(c * i)))); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((c <= -1.18e+171) || ~((c <= 2.7e+109))) tmp = -2.0 * (c * ((a + (b * c)) * i)); else tmp = 2.0 * (((x * y) + (z * t)) - (a * (c * i))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[c, -1.18e+171], N[Not[LessEqual[c, 2.7e+109]], $MachinePrecision]], N[(-2.0 * N[(c * N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(a * N[(c * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.18 \cdot 10^{+171} \lor \neg \left(c \leq 2.7 \cdot 10^{+109}\right):\\
\;\;\;\;-2 \cdot \left(c \cdot \left(\left(a + b \cdot c\right) \cdot i\right)\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\left(x \cdot y + z \cdot t\right) - a \cdot \left(c \cdot i\right)\right)\\
\end{array}
\end{array}
if c < -1.1799999999999999e171 or 2.70000000000000001e109 < c Initial program 82.6%
fma-define82.6%
associate-*l*88.2%
Simplified88.2%
Taylor expanded in i around inf 92.9%
if -1.1799999999999999e171 < c < 2.70000000000000001e109Initial program 92.2%
Taylor expanded in a around inf 87.5%
Final simplification88.9%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* (* c c) (* i (* b -2.0)))))
(if (<= c -5e+88)
t_1
(if (<= c -1.1e-43)
(* c (* i (* a -2.0)))
(if (<= c 1.2e+106) (* (+ (* x y) (* z t)) 2.0) t_1)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (c * c) * (i * (b * -2.0));
double tmp;
if (c <= -5e+88) {
tmp = t_1;
} else if (c <= -1.1e-43) {
tmp = c * (i * (a * -2.0));
} else if (c <= 1.2e+106) {
tmp = ((x * y) + (z * t)) * 2.0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: i
real(8) :: t_1
real(8) :: tmp
t_1 = (c * c) * (i * (b * (-2.0d0)))
if (c <= (-5d+88)) then
tmp = t_1
else if (c <= (-1.1d-43)) then
tmp = c * (i * (a * (-2.0d0)))
else if (c <= 1.2d+106) then
tmp = ((x * y) + (z * t)) * 2.0d0
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 i) {
double t_1 = (c * c) * (i * (b * -2.0));
double tmp;
if (c <= -5e+88) {
tmp = t_1;
} else if (c <= -1.1e-43) {
tmp = c * (i * (a * -2.0));
} else if (c <= 1.2e+106) {
tmp = ((x * y) + (z * t)) * 2.0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): t_1 = (c * c) * (i * (b * -2.0)) tmp = 0 if c <= -5e+88: tmp = t_1 elif c <= -1.1e-43: tmp = c * (i * (a * -2.0)) elif c <= 1.2e+106: tmp = ((x * y) + (z * t)) * 2.0 else: tmp = t_1 return tmp
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(c * c) * Float64(i * Float64(b * -2.0))) tmp = 0.0 if (c <= -5e+88) tmp = t_1; elseif (c <= -1.1e-43) tmp = Float64(c * Float64(i * Float64(a * -2.0))); elseif (c <= 1.2e+106) tmp = Float64(Float64(Float64(x * y) + Float64(z * t)) * 2.0); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) t_1 = (c * c) * (i * (b * -2.0)); tmp = 0.0; if (c <= -5e+88) tmp = t_1; elseif (c <= -1.1e-43) tmp = c * (i * (a * -2.0)); elseif (c <= 1.2e+106) tmp = ((x * y) + (z * t)) * 2.0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(c * c), $MachinePrecision] * N[(i * N[(b * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -5e+88], t$95$1, If[LessEqual[c, -1.1e-43], N[(c * N[(i * N[(a * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.2e+106], N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(c \cdot c\right) \cdot \left(i \cdot \left(b \cdot -2\right)\right)\\
\mathbf{if}\;c \leq -5 \cdot 10^{+88}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq -1.1 \cdot 10^{-43}:\\
\;\;\;\;c \cdot \left(i \cdot \left(a \cdot -2\right)\right)\\
\mathbf{elif}\;c \leq 1.2 \cdot 10^{+106}:\\
\;\;\;\;\left(x \cdot y + z \cdot t\right) \cdot 2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if c < -4.99999999999999997e88 or 1.2e106 < c Initial program 82.1%
fma-define82.1%
associate-*l*86.7%
Simplified86.7%
Taylor expanded in b around inf 72.7%
*-commutative72.7%
associate-*r*73.9%
*-commutative73.9%
associate-*r*73.7%
associate-*r*73.7%
*-commutative73.7%
associate-*l*73.7%
Simplified73.7%
unpow273.7%
Applied egg-rr73.7%
if -4.99999999999999997e88 < c < -1.09999999999999999e-43Initial program 93.1%
fma-define93.1%
associate-*l*96.3%
Simplified96.3%
Taylor expanded in a around inf 52.9%
*-commutative52.9%
*-commutative52.9%
associate-*l*53.1%
*-commutative53.1%
associate-*r*53.1%
*-commutative53.1%
associate-*l*53.1%
Simplified53.1%
if -1.09999999999999999e-43 < c < 1.2e106Initial program 93.3%
Taylor expanded in c around 0 73.3%
Final simplification71.1%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= c -1.65e-124) (not (<= c 4000.0))) (* -2.0 (* c (* (+ a (* b c)) i))) (* (+ (* x y) (* z t)) 2.0)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((c <= -1.65e-124) || !(c <= 4000.0)) {
tmp = -2.0 * (c * ((a + (b * c)) * i));
} else {
tmp = ((x * y) + (z * t)) * 2.0;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: i
real(8) :: tmp
if ((c <= (-1.65d-124)) .or. (.not. (c <= 4000.0d0))) then
tmp = (-2.0d0) * (c * ((a + (b * c)) * i))
else
tmp = ((x * y) + (z * t)) * 2.0d0
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 i) {
double tmp;
if ((c <= -1.65e-124) || !(c <= 4000.0)) {
tmp = -2.0 * (c * ((a + (b * c)) * i));
} else {
tmp = ((x * y) + (z * t)) * 2.0;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (c <= -1.65e-124) or not (c <= 4000.0): tmp = -2.0 * (c * ((a + (b * c)) * i)) else: tmp = ((x * y) + (z * t)) * 2.0 return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((c <= -1.65e-124) || !(c <= 4000.0)) tmp = Float64(-2.0 * Float64(c * Float64(Float64(a + Float64(b * c)) * i))); else tmp = Float64(Float64(Float64(x * y) + Float64(z * t)) * 2.0); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((c <= -1.65e-124) || ~((c <= 4000.0))) tmp = -2.0 * (c * ((a + (b * c)) * i)); else tmp = ((x * y) + (z * t)) * 2.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[c, -1.65e-124], N[Not[LessEqual[c, 4000.0]], $MachinePrecision]], N[(-2.0 * N[(c * N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.65 \cdot 10^{-124} \lor \neg \left(c \leq 4000\right):\\
\;\;\;\;-2 \cdot \left(c \cdot \left(\left(a + b \cdot c\right) \cdot i\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot y + z \cdot t\right) \cdot 2\\
\end{array}
\end{array}
if c < -1.64999999999999992e-124 or 4e3 < c Initial program 84.7%
fma-define84.7%
associate-*l*90.7%
Simplified90.7%
Taylor expanded in i around inf 73.5%
if -1.64999999999999992e-124 < c < 4e3Initial program 97.0%
Taylor expanded in c around 0 82.2%
Final simplification77.1%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* 2.0 (* z t))))
(if (<= z -4.3e+102)
t_1
(if (<= z -1.9e-308)
(* -2.0 (* i (* a c)))
(if (<= z 2.55e-16) (* y (* x 2.0)) t_1)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = 2.0 * (z * t);
double tmp;
if (z <= -4.3e+102) {
tmp = t_1;
} else if (z <= -1.9e-308) {
tmp = -2.0 * (i * (a * c));
} else if (z <= 2.55e-16) {
tmp = y * (x * 2.0);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: i
real(8) :: t_1
real(8) :: tmp
t_1 = 2.0d0 * (z * t)
if (z <= (-4.3d+102)) then
tmp = t_1
else if (z <= (-1.9d-308)) then
tmp = (-2.0d0) * (i * (a * c))
else if (z <= 2.55d-16) then
tmp = y * (x * 2.0d0)
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 i) {
double t_1 = 2.0 * (z * t);
double tmp;
if (z <= -4.3e+102) {
tmp = t_1;
} else if (z <= -1.9e-308) {
tmp = -2.0 * (i * (a * c));
} else if (z <= 2.55e-16) {
tmp = y * (x * 2.0);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): t_1 = 2.0 * (z * t) tmp = 0 if z <= -4.3e+102: tmp = t_1 elif z <= -1.9e-308: tmp = -2.0 * (i * (a * c)) elif z <= 2.55e-16: tmp = y * (x * 2.0) else: tmp = t_1 return tmp
function code(x, y, z, t, a, b, c, i) t_1 = Float64(2.0 * Float64(z * t)) tmp = 0.0 if (z <= -4.3e+102) tmp = t_1; elseif (z <= -1.9e-308) tmp = Float64(-2.0 * Float64(i * Float64(a * c))); elseif (z <= 2.55e-16) tmp = Float64(y * Float64(x * 2.0)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) t_1 = 2.0 * (z * t); tmp = 0.0; if (z <= -4.3e+102) tmp = t_1; elseif (z <= -1.9e-308) tmp = -2.0 * (i * (a * c)); elseif (z <= 2.55e-16) tmp = y * (x * 2.0); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(2.0 * N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.3e+102], t$95$1, If[LessEqual[z, -1.9e-308], N[(-2.0 * N[(i * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.55e-16], N[(y * N[(x * 2.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 2 \cdot \left(z \cdot t\right)\\
\mathbf{if}\;z \leq -4.3 \cdot 10^{+102}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -1.9 \cdot 10^{-308}:\\
\;\;\;\;-2 \cdot \left(i \cdot \left(a \cdot c\right)\right)\\
\mathbf{elif}\;z \leq 2.55 \cdot 10^{-16}:\\
\;\;\;\;y \cdot \left(x \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -4.3000000000000001e102 or 2.55e-16 < z Initial program 87.3%
Taylor expanded in z around inf 53.5%
if -4.3000000000000001e102 < z < -1.9000000000000001e-308Initial program 89.4%
Taylor expanded in a around inf 68.9%
Taylor expanded in z around 0 52.4%
associate-*r*52.6%
*-commutative52.6%
associate-*r*50.1%
*-commutative50.1%
Simplified50.1%
Taylor expanded in x around 0 35.4%
associate-*r*36.8%
*-commutative36.8%
Simplified36.8%
if -1.9000000000000001e-308 < z < 2.55e-16Initial program 93.3%
fma-define93.3%
associate-*l*96.0%
Simplified96.0%
Taylor expanded in x around inf 46.2%
*-commutative46.2%
associate-*r*46.2%
*-commutative46.2%
associate-*r*46.2%
Simplified46.2%
Final simplification46.1%
(FPCore (x y z t a b c i) :precision binary64 (if (<= a -2.1e+209) (* -2.0 (* a (* c i))) (if (<= a 3.3e+176) (* (+ (* x y) (* z t)) 2.0) (* c (* i (* a -2.0))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (a <= -2.1e+209) {
tmp = -2.0 * (a * (c * i));
} else if (a <= 3.3e+176) {
tmp = ((x * y) + (z * t)) * 2.0;
} else {
tmp = c * (i * (a * -2.0));
}
return tmp;
}
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: i
real(8) :: tmp
if (a <= (-2.1d+209)) then
tmp = (-2.0d0) * (a * (c * i))
else if (a <= 3.3d+176) then
tmp = ((x * y) + (z * t)) * 2.0d0
else
tmp = c * (i * (a * (-2.0d0)))
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 i) {
double tmp;
if (a <= -2.1e+209) {
tmp = -2.0 * (a * (c * i));
} else if (a <= 3.3e+176) {
tmp = ((x * y) + (z * t)) * 2.0;
} else {
tmp = c * (i * (a * -2.0));
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if a <= -2.1e+209: tmp = -2.0 * (a * (c * i)) elif a <= 3.3e+176: tmp = ((x * y) + (z * t)) * 2.0 else: tmp = c * (i * (a * -2.0)) return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (a <= -2.1e+209) tmp = Float64(-2.0 * Float64(a * Float64(c * i))); elseif (a <= 3.3e+176) tmp = Float64(Float64(Float64(x * y) + Float64(z * t)) * 2.0); else tmp = Float64(c * Float64(i * Float64(a * -2.0))); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if (a <= -2.1e+209) tmp = -2.0 * (a * (c * i)); elseif (a <= 3.3e+176) tmp = ((x * y) + (z * t)) * 2.0; else tmp = c * (i * (a * -2.0)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[a, -2.1e+209], N[(-2.0 * N[(a * N[(c * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 3.3e+176], N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision], N[(c * N[(i * N[(a * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.1 \cdot 10^{+209}:\\
\;\;\;\;-2 \cdot \left(a \cdot \left(c \cdot i\right)\right)\\
\mathbf{elif}\;a \leq 3.3 \cdot 10^{+176}:\\
\;\;\;\;\left(x \cdot y + z \cdot t\right) \cdot 2\\
\mathbf{else}:\\
\;\;\;\;c \cdot \left(i \cdot \left(a \cdot -2\right)\right)\\
\end{array}
\end{array}
if a < -2.1e209Initial program 83.2%
fma-define83.2%
associate-*l*95.5%
Simplified95.5%
Taylor expanded in a around inf 61.0%
*-commutative61.0%
Simplified61.0%
if -2.1e209 < a < 3.30000000000000025e176Initial program 91.0%
Taylor expanded in c around 0 58.3%
if 3.30000000000000025e176 < a Initial program 86.5%
fma-define86.5%
associate-*l*94.2%
Simplified94.2%
Taylor expanded in a around inf 63.4%
*-commutative63.4%
*-commutative63.4%
associate-*l*66.1%
*-commutative66.1%
associate-*r*66.1%
*-commutative66.1%
associate-*l*66.1%
Simplified66.1%
Final simplification59.6%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= z -5.2e+50) (not (<= z 6.8e-19))) (* 2.0 (* z t)) (* y (* x 2.0))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((z <= -5.2e+50) || !(z <= 6.8e-19)) {
tmp = 2.0 * (z * t);
} else {
tmp = y * (x * 2.0);
}
return tmp;
}
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: i
real(8) :: tmp
if ((z <= (-5.2d+50)) .or. (.not. (z <= 6.8d-19))) then
tmp = 2.0d0 * (z * t)
else
tmp = y * (x * 2.0d0)
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 i) {
double tmp;
if ((z <= -5.2e+50) || !(z <= 6.8e-19)) {
tmp = 2.0 * (z * t);
} else {
tmp = y * (x * 2.0);
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (z <= -5.2e+50) or not (z <= 6.8e-19): tmp = 2.0 * (z * t) else: tmp = y * (x * 2.0) return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((z <= -5.2e+50) || !(z <= 6.8e-19)) tmp = Float64(2.0 * Float64(z * t)); else tmp = Float64(y * Float64(x * 2.0)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((z <= -5.2e+50) || ~((z <= 6.8e-19))) tmp = 2.0 * (z * t); else tmp = y * (x * 2.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[z, -5.2e+50], N[Not[LessEqual[z, 6.8e-19]], $MachinePrecision]], N[(2.0 * N[(z * t), $MachinePrecision]), $MachinePrecision], N[(y * N[(x * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.2 \cdot 10^{+50} \lor \neg \left(z \leq 6.8 \cdot 10^{-19}\right):\\
\;\;\;\;2 \cdot \left(z \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot 2\right)\\
\end{array}
\end{array}
if z < -5.2000000000000004e50 or 6.8000000000000004e-19 < z Initial program 87.7%
Taylor expanded in z around inf 51.2%
if -5.2000000000000004e50 < z < 6.8000000000000004e-19Initial program 91.2%
fma-define91.2%
associate-*l*95.1%
Simplified95.1%
Taylor expanded in x around inf 33.8%
*-commutative33.8%
associate-*r*34.4%
*-commutative34.4%
associate-*r*33.8%
Simplified33.8%
Final simplification41.4%
(FPCore (x y z t a b c i) :precision binary64 (* 2.0 (* z t)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (z * t);
}
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: i
code = 2.0d0 * (z * t)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (z * t);
}
def code(x, y, z, t, a, b, c, i): return 2.0 * (z * t)
function code(x, y, z, t, a, b, c, i) return Float64(2.0 * Float64(z * t)) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = 2.0 * (z * t); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(2.0 * N[(z * t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(z \cdot t\right)
\end{array}
Initial program 89.7%
Taylor expanded in z around inf 28.5%
Final simplification28.5%
(FPCore (x y z t a b c i) :precision binary64 (* 2.0 (- (+ (* x y) (* z t)) (* (+ a (* b c)) (* c i)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (((x * y) + (z * t)) - ((a + (b * c)) * (c * i)));
}
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: i
code = 2.0d0 * (((x * y) + (z * t)) - ((a + (b * c)) * (c * i)))
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (((x * y) + (z * t)) - ((a + (b * c)) * (c * i)));
}
def code(x, y, z, t, a, b, c, i): return 2.0 * (((x * y) + (z * t)) - ((a + (b * c)) * (c * i)))
function code(x, y, z, t, a, b, c, i) return Float64(2.0 * Float64(Float64(Float64(x * y) + Float64(z * t)) - Float64(Float64(a + Float64(b * c)) * Float64(c * i)))) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = 2.0 * (((x * y) + (z * t)) - ((a + (b * c)) * (c * i))); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(2.0 * N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * N[(c * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(a + b \cdot c\right) \cdot \left(c \cdot i\right)\right)
\end{array}
herbie shell --seed 2024114
(FPCore (x y z t a b c i)
:name "Diagrams.ThreeD.Shapes:frustum from diagrams-lib-1.3.0.3, A"
:precision binary64
:alt
(! :herbie-platform default (* 2 (- (+ (* x y) (* z t)) (* (+ a (* b c)) (* c i)))))
(* 2.0 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))))