
(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 11 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 (* (fma z t (fma y x (* (- c) (* (fma c b a) i)))) 2.0))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return fma(z, t, fma(y, x, (-c * (fma(c, b, a) * i)))) * 2.0;
}
function code(x, y, z, t, a, b, c, i) return Float64(fma(z, t, fma(y, x, Float64(Float64(-c) * Float64(fma(c, b, a) * i)))) * 2.0) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(z * t + N[(y * x + N[((-c) * N[(N[(c * b + a), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, t, \mathsf{fma}\left(y, x, \left(-c\right) \cdot \left(\mathsf{fma}\left(c, b, a\right) \cdot i\right)\right)\right) \cdot 2
\end{array}
Initial program 89.9%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
sub-negN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites94.6%
Final simplification94.6%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* (* (+ (* b c) a) c) i)))
(if (<= t_1 -1e+264)
(* -2.0 (* (* (fma c b a) i) c))
(if (<= t_1 1e+157)
(* (fma (* (- a) c) i (fma y x (* t z))) 2.0)
(* (fma (- i) (* (fma c b a) c) (* x y)) 2.0)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (((b * c) + a) * c) * i;
double tmp;
if (t_1 <= -1e+264) {
tmp = -2.0 * ((fma(c, b, a) * i) * c);
} else if (t_1 <= 1e+157) {
tmp = fma((-a * c), i, fma(y, x, (t * z))) * 2.0;
} else {
tmp = fma(-i, (fma(c, b, a) * c), (x * y)) * 2.0;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(Float64(Float64(b * c) + a) * c) * i) tmp = 0.0 if (t_1 <= -1e+264) tmp = Float64(-2.0 * Float64(Float64(fma(c, b, a) * i) * c)); elseif (t_1 <= 1e+157) tmp = Float64(fma(Float64(Float64(-a) * c), i, fma(y, x, Float64(t * z))) * 2.0); else tmp = Float64(fma(Float64(-i), Float64(fma(c, b, a) * c), Float64(x * y)) * 2.0); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(N[(b * c), $MachinePrecision] + a), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+264], N[(-2.0 * N[(N[(N[(c * b + a), $MachinePrecision] * i), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+157], N[(N[(N[((-a) * c), $MachinePrecision] * i + N[(y * x + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision], N[(N[((-i) * N[(N[(c * b + a), $MachinePrecision] * c), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\left(b \cdot c + a\right) \cdot c\right) \cdot i\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+264}:\\
\;\;\;\;-2 \cdot \left(\left(\mathsf{fma}\left(c, b, a\right) \cdot i\right) \cdot c\right)\\
\mathbf{elif}\;t\_1 \leq 10^{+157}:\\
\;\;\;\;\mathsf{fma}\left(\left(-a\right) \cdot c, i, \mathsf{fma}\left(y, x, t \cdot z\right)\right) \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-i, \mathsf{fma}\left(c, b, a\right) \cdot c, x \cdot y\right) \cdot 2\\
\end{array}
\end{array}
if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -1.00000000000000004e264Initial program 74.1%
Taylor expanded in i around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6489.3
Applied rewrites89.3%
if -1.00000000000000004e264 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 9.99999999999999983e156Initial program 98.5%
Taylor expanded in c around 0
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
associate-*r*N/A
lower-*.f64N/A
neg-mul-1N/A
lower-neg.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6493.5
Applied rewrites93.5%
if 9.99999999999999983e156 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) Initial program 81.3%
Taylor expanded in t around 0
sub-negN/A
+-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6486.1
Applied rewrites86.1%
Final simplification90.9%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* (fma c b a) c)) (t_2 (* (* (+ (* b c) a) c) i)))
(if (<= t_2 -1e+61)
(* (fma (- i) t_1 (* x y)) 2.0)
(if (<= t_2 1e-169)
(* (fma y x (* t z)) 2.0)
(* (fma (- i) t_1 (* t z)) 2.0)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(c, b, a) * c;
double t_2 = (((b * c) + a) * c) * i;
double tmp;
if (t_2 <= -1e+61) {
tmp = fma(-i, t_1, (x * y)) * 2.0;
} else if (t_2 <= 1e-169) {
tmp = fma(y, x, (t * z)) * 2.0;
} else {
tmp = fma(-i, t_1, (t * z)) * 2.0;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(fma(c, b, a) * c) t_2 = Float64(Float64(Float64(Float64(b * c) + a) * c) * i) tmp = 0.0 if (t_2 <= -1e+61) tmp = Float64(fma(Float64(-i), t_1, Float64(x * y)) * 2.0); elseif (t_2 <= 1e-169) tmp = Float64(fma(y, x, Float64(t * z)) * 2.0); else tmp = Float64(fma(Float64(-i), t_1, Float64(t * z)) * 2.0); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(c * b + a), $MachinePrecision] * c), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(b * c), $MachinePrecision] + a), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]}, If[LessEqual[t$95$2, -1e+61], N[(N[((-i) * t$95$1 + N[(x * y), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision], If[LessEqual[t$95$2, 1e-169], N[(N[(y * x + N[(t * z), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision], N[(N[((-i) * t$95$1 + N[(t * z), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(c, b, a\right) \cdot c\\
t_2 := \left(\left(b \cdot c + a\right) \cdot c\right) \cdot i\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{+61}:\\
\;\;\;\;\mathsf{fma}\left(-i, t\_1, x \cdot y\right) \cdot 2\\
\mathbf{elif}\;t\_2 \leq 10^{-169}:\\
\;\;\;\;\mathsf{fma}\left(y, x, t \cdot z\right) \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-i, t\_1, t \cdot z\right) \cdot 2\\
\end{array}
\end{array}
if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -9.99999999999999949e60Initial program 82.7%
Taylor expanded in t around 0
sub-negN/A
+-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6482.9
Applied rewrites82.9%
if -9.99999999999999949e60 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 1.00000000000000002e-169Initial program 97.7%
Taylor expanded in c around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6495.6
Applied rewrites95.6%
if 1.00000000000000002e-169 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) Initial program 87.8%
Taylor expanded in x around 0
sub-negN/A
+-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6481.2
Applied rewrites81.2%
Final simplification86.7%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* (fma (- i) (* (fma c b a) c) (* x y)) 2.0))
(t_2 (* (* (+ (* b c) a) c) i)))
(if (<= t_2 -1e+61) t_1 (if (<= t_2 5e-72) (* (fma y x (* t z)) 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 = fma(-i, (fma(c, b, a) * c), (x * y)) * 2.0;
double t_2 = (((b * c) + a) * c) * i;
double tmp;
if (t_2 <= -1e+61) {
tmp = t_1;
} else if (t_2 <= 5e-72) {
tmp = fma(y, x, (t * z)) * 2.0;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(fma(Float64(-i), Float64(fma(c, b, a) * c), Float64(x * y)) * 2.0) t_2 = Float64(Float64(Float64(Float64(b * c) + a) * c) * i) tmp = 0.0 if (t_2 <= -1e+61) tmp = t_1; elseif (t_2 <= 5e-72) tmp = Float64(fma(y, x, Float64(t * z)) * 2.0); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[((-i) * N[(N[(c * b + a), $MachinePrecision] * c), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(b * c), $MachinePrecision] + a), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]}, If[LessEqual[t$95$2, -1e+61], t$95$1, If[LessEqual[t$95$2, 5e-72], N[(N[(y * x + N[(t * z), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(-i, \mathsf{fma}\left(c, b, a\right) \cdot c, x \cdot y\right) \cdot 2\\
t_2 := \left(\left(b \cdot c + a\right) \cdot c\right) \cdot i\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{+61}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-72}:\\
\;\;\;\;\mathsf{fma}\left(y, x, t \cdot z\right) \cdot 2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -9.99999999999999949e60 or 4.9999999999999996e-72 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) Initial program 85.1%
Taylor expanded in t around 0
sub-negN/A
+-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6481.2
Applied rewrites81.2%
if -9.99999999999999949e60 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 4.9999999999999996e-72Initial program 97.9%
Taylor expanded in c around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6495.8
Applied rewrites95.8%
Final simplification86.7%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* (* (* (fma c b a) c) (- i)) 2.0))
(t_2 (* (* (+ (* b c) a) c) i)))
(if (<= t_2 -2e+126)
t_1
(if (<= t_2 1e+157) (* (fma y x (* t z)) 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 = ((fma(c, b, a) * c) * -i) * 2.0;
double t_2 = (((b * c) + a) * c) * i;
double tmp;
if (t_2 <= -2e+126) {
tmp = t_1;
} else if (t_2 <= 1e+157) {
tmp = fma(y, x, (t * z)) * 2.0;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(Float64(fma(c, b, a) * c) * Float64(-i)) * 2.0) t_2 = Float64(Float64(Float64(Float64(b * c) + a) * c) * i) tmp = 0.0 if (t_2 <= -2e+126) tmp = t_1; elseif (t_2 <= 1e+157) tmp = Float64(fma(y, x, Float64(t * z)) * 2.0); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(N[(c * b + a), $MachinePrecision] * c), $MachinePrecision] * (-i)), $MachinePrecision] * 2.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(b * c), $MachinePrecision] + a), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+126], t$95$1, If[LessEqual[t$95$2, 1e+157], N[(N[(y * x + N[(t * z), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\left(\mathsf{fma}\left(c, b, a\right) \cdot c\right) \cdot \left(-i\right)\right) \cdot 2\\
t_2 := \left(\left(b \cdot c + a\right) \cdot c\right) \cdot i\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+126}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 10^{+157}:\\
\;\;\;\;\mathsf{fma}\left(y, x, t \cdot z\right) \cdot 2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -1.99999999999999985e126 or 9.99999999999999983e156 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) Initial program 80.7%
Taylor expanded in i around inf
mul-1-negN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6481.8
Applied rewrites81.8%
if -1.99999999999999985e126 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 9.99999999999999983e156Initial program 98.4%
Taylor expanded in c around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6485.9
Applied rewrites85.9%
Final simplification83.9%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* -2.0 (* (* (fma c b a) i) c))) (t_2 (* (* (+ (* b c) a) c) i)))
(if (<= t_2 -2e+126)
t_1
(if (<= t_2 1e+157) (* (fma y x (* t z)) 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 * ((fma(c, b, a) * i) * c);
double t_2 = (((b * c) + a) * c) * i;
double tmp;
if (t_2 <= -2e+126) {
tmp = t_1;
} else if (t_2 <= 1e+157) {
tmp = fma(y, x, (t * z)) * 2.0;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(-2.0 * Float64(Float64(fma(c, b, a) * i) * c)) t_2 = Float64(Float64(Float64(Float64(b * c) + a) * c) * i) tmp = 0.0 if (t_2 <= -2e+126) tmp = t_1; elseif (t_2 <= 1e+157) tmp = Float64(fma(y, x, Float64(t * z)) * 2.0); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(-2.0 * N[(N[(N[(c * b + a), $MachinePrecision] * i), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(b * c), $MachinePrecision] + a), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+126], t$95$1, If[LessEqual[t$95$2, 1e+157], N[(N[(y * x + N[(t * z), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := -2 \cdot \left(\left(\mathsf{fma}\left(c, b, a\right) \cdot i\right) \cdot c\right)\\
t_2 := \left(\left(b \cdot c + a\right) \cdot c\right) \cdot i\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+126}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 10^{+157}:\\
\;\;\;\;\mathsf{fma}\left(y, x, t \cdot z\right) \cdot 2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -1.99999999999999985e126 or 9.99999999999999983e156 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) Initial program 80.7%
Taylor expanded in i around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6481.7
Applied rewrites81.7%
if -1.99999999999999985e126 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 9.99999999999999983e156Initial program 98.4%
Taylor expanded in c around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6485.9
Applied rewrites85.9%
Final simplification83.9%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* (* (+ (* b c) a) c) i)))
(if (<= t_1 -1e+264)
(* (* (* (* b c) c) i) -2.0)
(if (<= t_1 5e+253)
(* (fma y x (* t z)) 2.0)
(* (* (* (* b i) c) c) -2.0)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (((b * c) + a) * c) * i;
double tmp;
if (t_1 <= -1e+264) {
tmp = (((b * c) * c) * i) * -2.0;
} else if (t_1 <= 5e+253) {
tmp = fma(y, x, (t * z)) * 2.0;
} else {
tmp = (((b * i) * c) * c) * -2.0;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(Float64(Float64(b * c) + a) * c) * i) tmp = 0.0 if (t_1 <= -1e+264) tmp = Float64(Float64(Float64(Float64(b * c) * c) * i) * -2.0); elseif (t_1 <= 5e+253) tmp = Float64(fma(y, x, Float64(t * z)) * 2.0); else tmp = Float64(Float64(Float64(Float64(b * i) * c) * c) * -2.0); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(N[(b * c), $MachinePrecision] + a), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+264], N[(N[(N[(N[(b * c), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision] * -2.0), $MachinePrecision], If[LessEqual[t$95$1, 5e+253], N[(N[(y * x + N[(t * z), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision], N[(N[(N[(N[(b * i), $MachinePrecision] * c), $MachinePrecision] * c), $MachinePrecision] * -2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\left(b \cdot c + a\right) \cdot c\right) \cdot i\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+264}:\\
\;\;\;\;\left(\left(\left(b \cdot c\right) \cdot c\right) \cdot i\right) \cdot -2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+253}:\\
\;\;\;\;\mathsf{fma}\left(y, x, t \cdot z\right) \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(b \cdot i\right) \cdot c\right) \cdot c\right) \cdot -2\\
\end{array}
\end{array}
if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -1.00000000000000004e264Initial program 74.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6412.1
Applied rewrites12.1%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6474.9
Applied rewrites74.9%
Applied rewrites74.6%
Applied rewrites76.5%
if -1.00000000000000004e264 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 4.9999999999999997e253Initial program 98.6%
Taylor expanded in c around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6480.2
Applied rewrites80.2%
if 4.9999999999999997e253 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) Initial program 80.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6413.8
Applied rewrites13.8%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6466.6
Applied rewrites66.6%
Applied rewrites71.6%
Final simplification77.5%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* (* (* (* b i) c) c) -2.0)) (t_2 (* (* (+ (* b c) a) c) i)))
(if (<= t_2 -1e+264)
t_1
(if (<= t_2 5e+253) (* (fma y x (* t z)) 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 = (((b * i) * c) * c) * -2.0;
double t_2 = (((b * c) + a) * c) * i;
double tmp;
if (t_2 <= -1e+264) {
tmp = t_1;
} else if (t_2 <= 5e+253) {
tmp = fma(y, x, (t * z)) * 2.0;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(Float64(Float64(b * i) * c) * c) * -2.0) t_2 = Float64(Float64(Float64(Float64(b * c) + a) * c) * i) tmp = 0.0 if (t_2 <= -1e+264) tmp = t_1; elseif (t_2 <= 5e+253) tmp = Float64(fma(y, x, Float64(t * z)) * 2.0); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(N[(b * i), $MachinePrecision] * c), $MachinePrecision] * c), $MachinePrecision] * -2.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(b * c), $MachinePrecision] + a), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]}, If[LessEqual[t$95$2, -1e+264], t$95$1, If[LessEqual[t$95$2, 5e+253], N[(N[(y * x + N[(t * z), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\left(\left(b \cdot i\right) \cdot c\right) \cdot c\right) \cdot -2\\
t_2 := \left(\left(b \cdot c + a\right) \cdot c\right) \cdot i\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{+264}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+253}:\\
\;\;\;\;\mathsf{fma}\left(y, x, t \cdot z\right) \cdot 2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -1.00000000000000004e264 or 4.9999999999999997e253 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) Initial program 77.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6413.1
Applied rewrites13.1%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6470.2
Applied rewrites70.2%
Applied rewrites73.7%
if -1.00000000000000004e264 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 4.9999999999999997e253Initial program 98.6%
Taylor expanded in c around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6480.2
Applied rewrites80.2%
Final simplification77.5%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* (* (* c i) a) -2.0)) (t_2 (* (* (+ (* b c) a) c) i)))
(if (<= t_2 -1e+292)
t_1
(if (<= t_2 1e+157) (* (fma y x (* t z)) 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 * i) * a) * -2.0;
double t_2 = (((b * c) + a) * c) * i;
double tmp;
if (t_2 <= -1e+292) {
tmp = t_1;
} else if (t_2 <= 1e+157) {
tmp = fma(y, x, (t * z)) * 2.0;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(Float64(c * i) * a) * -2.0) t_2 = Float64(Float64(Float64(Float64(b * c) + a) * c) * i) tmp = 0.0 if (t_2 <= -1e+292) tmp = t_1; elseif (t_2 <= 1e+157) tmp = Float64(fma(y, x, Float64(t * z)) * 2.0); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(c * i), $MachinePrecision] * a), $MachinePrecision] * -2.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(b * c), $MachinePrecision] + a), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]}, If[LessEqual[t$95$2, -1e+292], t$95$1, If[LessEqual[t$95$2, 1e+157], N[(N[(y * x + N[(t * z), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\left(c \cdot i\right) \cdot a\right) \cdot -2\\
t_2 := \left(\left(b \cdot c + a\right) \cdot c\right) \cdot i\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{+292}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 10^{+157}:\\
\;\;\;\;\mathsf{fma}\left(y, x, t \cdot z\right) \cdot 2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -1e292 or 9.99999999999999983e156 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) Initial program 78.1%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6441.5
Applied rewrites41.5%
if -1e292 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 9.99999999999999983e156Initial program 98.5%
Taylor expanded in c around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6481.1
Applied rewrites81.1%
Final simplification64.4%
(FPCore (x y z t a b c i) :precision binary64 (let* ((t_1 (* (* x y) 2.0))) (if (<= (* x y) -1e+52) t_1 (if (<= (* x y) 1e+44) (* (* t z) 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 = (x * y) * 2.0;
double tmp;
if ((x * y) <= -1e+52) {
tmp = t_1;
} else if ((x * y) <= 1e+44) {
tmp = (t * z) * 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 = (x * y) * 2.0d0
if ((x * y) <= (-1d+52)) then
tmp = t_1
else if ((x * y) <= 1d+44) then
tmp = (t * z) * 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 = (x * y) * 2.0;
double tmp;
if ((x * y) <= -1e+52) {
tmp = t_1;
} else if ((x * y) <= 1e+44) {
tmp = (t * z) * 2.0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): t_1 = (x * y) * 2.0 tmp = 0 if (x * y) <= -1e+52: tmp = t_1 elif (x * y) <= 1e+44: tmp = (t * z) * 2.0 else: tmp = t_1 return tmp
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(x * y) * 2.0) tmp = 0.0 if (Float64(x * y) <= -1e+52) tmp = t_1; elseif (Float64(x * y) <= 1e+44) tmp = Float64(Float64(t * z) * 2.0); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) t_1 = (x * y) * 2.0; tmp = 0.0; if ((x * y) <= -1e+52) tmp = t_1; elseif ((x * y) <= 1e+44) tmp = (t * z) * 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[(x * y), $MachinePrecision] * 2.0), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -1e+52], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 1e+44], N[(N[(t * z), $MachinePrecision] * 2.0), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x \cdot y\right) \cdot 2\\
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+52}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \cdot y \leq 10^{+44}:\\
\;\;\;\;\left(t \cdot z\right) \cdot 2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 x y) < -9.9999999999999999e51 or 1.0000000000000001e44 < (*.f64 x y) Initial program 83.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6452.7
Applied rewrites52.7%
if -9.9999999999999999e51 < (*.f64 x y) < 1.0000000000000001e44Initial program 95.6%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f6440.3
Applied rewrites40.3%
Final simplification46.0%
(FPCore (x y z t a b c i) :precision binary64 (* (* x y) 2.0))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (x * y) * 2.0;
}
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 = (x * y) * 2.0d0
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (x * y) * 2.0;
}
def code(x, y, z, t, a, b, c, i): return (x * y) * 2.0
function code(x, y, z, t, a, b, c, i) return Float64(Float64(x * y) * 2.0) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = (x * y) * 2.0; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(x * y), $MachinePrecision] * 2.0), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot y\right) \cdot 2
\end{array}
Initial program 89.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6428.2
Applied rewrites28.2%
Final simplification28.2%
(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 2024273
(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))))