
(FPCore (x y z t a b) :precision binary64 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
real(8) function code(x, y, z, t, a, b)
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
code = ((x + (y * z)) + (t * a)) + ((a * z) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
def code(x, y, z, t, a, b): return ((x + (y * z)) + (t * a)) + ((a * z) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(Float64(a * z) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x + (y * z)) + (t * a)) + ((a * z) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
real(8) function code(x, y, z, t, a, b)
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
code = ((x + (y * z)) + (t * a)) + ((a * z) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
def code(x, y, z, t, a, b): return ((x + (y * z)) + (t * a)) + ((a * z) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(Float64(a * z) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x + (y * z)) + (t * a)) + ((a * z) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
\end{array}
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))) (if (<= t_1 2e+306) t_1 (fma z y (* (fma z b t) a)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((x + (y * z)) + (t * a)) + ((a * z) * b);
double tmp;
if (t_1 <= 2e+306) {
tmp = t_1;
} else {
tmp = fma(z, y, (fma(z, b, t) * a));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(Float64(a * z) * b)) tmp = 0.0 if (t_1 <= 2e+306) tmp = t_1; else tmp = fma(z, y, Float64(fma(z, b, t) * a)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 2e+306], t$95$1, N[(z * y + N[(N[(z * b + t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{+306}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(z, b, t\right) \cdot a\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) < 2.00000000000000003e306Initial program 99.5%
if 2.00000000000000003e306 < (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) Initial program 71.7%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6491.3
Applied rewrites91.3%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6491.3
Applied rewrites91.3%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (* a b) z)))
(if (<= z -2.8e+211)
t_1
(if (<= z -3.1e-55)
(fma y z x)
(if (<= z 4.4e+41)
(fma a t x)
(if (<= z 1.05e+261) (fma y z x) t_1))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * b) * z;
double tmp;
if (z <= -2.8e+211) {
tmp = t_1;
} else if (z <= -3.1e-55) {
tmp = fma(y, z, x);
} else if (z <= 4.4e+41) {
tmp = fma(a, t, x);
} else if (z <= 1.05e+261) {
tmp = fma(y, z, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a * b) * z) tmp = 0.0 if (z <= -2.8e+211) tmp = t_1; elseif (z <= -3.1e-55) tmp = fma(y, z, x); elseif (z <= 4.4e+41) tmp = fma(a, t, x); elseif (z <= 1.05e+261) tmp = fma(y, z, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * b), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -2.8e+211], t$95$1, If[LessEqual[z, -3.1e-55], N[(y * z + x), $MachinePrecision], If[LessEqual[z, 4.4e+41], N[(a * t + x), $MachinePrecision], If[LessEqual[z, 1.05e+261], N[(y * z + x), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a \cdot b\right) \cdot z\\
\mathbf{if}\;z \leq -2.8 \cdot 10^{+211}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -3.1 \cdot 10^{-55}:\\
\;\;\;\;\mathsf{fma}\left(y, z, x\right)\\
\mathbf{elif}\;z \leq 4.4 \cdot 10^{+41}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{elif}\;z \leq 1.05 \cdot 10^{+261}:\\
\;\;\;\;\mathsf{fma}\left(y, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -2.8e211 or 1.05e261 < z Initial program 87.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6496.0
Applied rewrites96.0%
Taylor expanded in y around 0
Applied rewrites80.7%
if -2.8e211 < z < -3.09999999999999997e-55 or 4.3999999999999998e41 < z < 1.05e261Initial program 89.7%
Taylor expanded in t around inf
lower-*.f6416.4
Applied rewrites16.4%
Taylor expanded in y around inf
*-commutativeN/A
associate-+r+N/A
div-add-revN/A
distribute-lft-inN/A
associate-+r+N/A
lower-*.f64N/A
Applied rewrites80.5%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f6465.0
Applied rewrites65.0%
if -3.09999999999999997e-55 < z < 4.3999999999999998e41Initial program 99.9%
Taylor expanded in t around inf
lower-*.f6437.6
Applied rewrites37.6%
Taylor expanded in y around inf
*-commutativeN/A
associate-+r+N/A
div-add-revN/A
distribute-lft-inN/A
associate-+r+N/A
lower-*.f64N/A
Applied rewrites86.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6477.6
Applied rewrites77.6%
Final simplification72.6%
(FPCore (x y z t a b) :precision binary64 (if (<= x -2.65e+54) (fma (* z a) b (fma t a x)) (if (<= x 0.0022) (fma (fma b z t) a (* z y)) (fma (fma b a y) z x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= -2.65e+54) {
tmp = fma((z * a), b, fma(t, a, x));
} else if (x <= 0.0022) {
tmp = fma(fma(b, z, t), a, (z * y));
} else {
tmp = fma(fma(b, a, y), z, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= -2.65e+54) tmp = fma(Float64(z * a), b, fma(t, a, x)); elseif (x <= 0.0022) tmp = fma(fma(b, z, t), a, Float64(z * y)); else tmp = fma(fma(b, a, y), z, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, -2.65e+54], N[(N[(z * a), $MachinePrecision] * b + N[(t * a + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.0022], N[(N[(b * z + t), $MachinePrecision] * a + N[(z * y), $MachinePrecision]), $MachinePrecision], N[(N[(b * a + y), $MachinePrecision] * z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.65 \cdot 10^{+54}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot a, b, \mathsf{fma}\left(t, a, x\right)\right)\\
\mathbf{elif}\;x \leq 0.0022:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)\\
\end{array}
\end{array}
if x < -2.65000000000000009e54Initial program 96.2%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f6491.2
Applied rewrites91.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6491.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6491.2
Applied rewrites91.2%
if -2.65000000000000009e54 < x < 0.00220000000000000013Initial program 92.6%
Taylor expanded in x around 0
associate-+r+N/A
distribute-lft-inN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6489.9
Applied rewrites89.9%
if 0.00220000000000000013 < x Initial program 97.0%
Taylor expanded in t around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6490.5
Applied rewrites90.5%
Final simplification90.3%
(FPCore (x y z t a b) :precision binary64 (if (<= z -3.7e+158) (fma (fma b a y) z x) (fma z y (+ x (* a (fma b z t))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -3.7e+158) {
tmp = fma(fma(b, a, y), z, x);
} else {
tmp = fma(z, y, (x + (a * fma(b, z, t))));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -3.7e+158) tmp = fma(fma(b, a, y), z, x); else tmp = fma(z, y, Float64(x + Float64(a * fma(b, z, t)))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -3.7e+158], N[(N[(b * a + y), $MachinePrecision] * z + x), $MachinePrecision], N[(z * y + N[(x + N[(a * N[(b * z + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.7 \cdot 10^{+158}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x + a \cdot \mathsf{fma}\left(b, z, t\right)\right)\\
\end{array}
\end{array}
if z < -3.70000000000000011e158Initial program 93.1%
Taylor expanded in t around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6499.9
Applied rewrites99.9%
if -3.70000000000000011e158 < z Initial program 94.7%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6497.0
Applied rewrites97.0%
Final simplification97.3%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -3.1e-55) (not (<= z 4.5e+41))) (fma (fma b a y) z x) (fma (fma b z t) a x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -3.1e-55) || !(z <= 4.5e+41)) {
tmp = fma(fma(b, a, y), z, x);
} else {
tmp = fma(fma(b, z, t), a, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -3.1e-55) || !(z <= 4.5e+41)) tmp = fma(fma(b, a, y), z, x); else tmp = fma(fma(b, z, t), a, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -3.1e-55], N[Not[LessEqual[z, 4.5e+41]], $MachinePrecision]], N[(N[(b * a + y), $MachinePrecision] * z + x), $MachinePrecision], N[(N[(b * z + t), $MachinePrecision] * a + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.1 \cdot 10^{-55} \lor \neg \left(z \leq 4.5 \cdot 10^{+41}\right):\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, x\right)\\
\end{array}
\end{array}
if z < -3.09999999999999997e-55 or 4.5000000000000001e41 < z Initial program 89.3%
Taylor expanded in t around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6490.4
Applied rewrites90.4%
if -3.09999999999999997e-55 < z < 4.5000000000000001e41Initial program 99.9%
Taylor expanded in y around 0
distribute-lft-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6489.8
Applied rewrites89.8%
Final simplification90.1%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -2.8e-58) (not (<= z 8.5e-169))) (fma (fma b a y) z x) (fma a t x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -2.8e-58) || !(z <= 8.5e-169)) {
tmp = fma(fma(b, a, y), z, x);
} else {
tmp = fma(a, t, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -2.8e-58) || !(z <= 8.5e-169)) tmp = fma(fma(b, a, y), z, x); else tmp = fma(a, t, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -2.8e-58], N[Not[LessEqual[z, 8.5e-169]], $MachinePrecision]], N[(N[(b * a + y), $MachinePrecision] * z + x), $MachinePrecision], N[(a * t + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.8 \cdot 10^{-58} \lor \neg \left(z \leq 8.5 \cdot 10^{-169}\right):\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\end{array}
\end{array}
if z < -2.8000000000000001e-58 or 8.50000000000000054e-169 < z Initial program 92.2%
Taylor expanded in t around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6485.4
Applied rewrites85.4%
if -2.8000000000000001e-58 < z < 8.50000000000000054e-169Initial program 99.9%
Taylor expanded in t around inf
lower-*.f6443.3
Applied rewrites43.3%
Taylor expanded in y around inf
*-commutativeN/A
associate-+r+N/A
div-add-revN/A
distribute-lft-inN/A
associate-+r+N/A
lower-*.f64N/A
Applied rewrites86.1%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6486.1
Applied rewrites86.1%
Final simplification85.6%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -4.8e-51) (not (<= z 1.55e+106))) (* (fma b a y) z) (fma a t x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -4.8e-51) || !(z <= 1.55e+106)) {
tmp = fma(b, a, y) * z;
} else {
tmp = fma(a, t, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -4.8e-51) || !(z <= 1.55e+106)) tmp = Float64(fma(b, a, y) * z); else tmp = fma(a, t, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -4.8e-51], N[Not[LessEqual[z, 1.55e+106]], $MachinePrecision]], N[(N[(b * a + y), $MachinePrecision] * z), $MachinePrecision], N[(a * t + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.8 \cdot 10^{-51} \lor \neg \left(z \leq 1.55 \cdot 10^{+106}\right):\\
\;\;\;\;\mathsf{fma}\left(b, a, y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\end{array}
\end{array}
if z < -4.8e-51 or 1.55e106 < z Initial program 88.1%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6480.1
Applied rewrites80.1%
if -4.8e-51 < z < 1.55e106Initial program 99.9%
Taylor expanded in t around inf
lower-*.f6434.7
Applied rewrites34.7%
Taylor expanded in y around inf
*-commutativeN/A
associate-+r+N/A
div-add-revN/A
distribute-lft-inN/A
associate-+r+N/A
lower-*.f64N/A
Applied rewrites84.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6475.9
Applied rewrites75.9%
Final simplification77.8%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -3.1e-55) (not (<= z 4.4e+41))) (fma y z x) (fma a t x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -3.1e-55) || !(z <= 4.4e+41)) {
tmp = fma(y, z, x);
} else {
tmp = fma(a, t, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -3.1e-55) || !(z <= 4.4e+41)) tmp = fma(y, z, x); else tmp = fma(a, t, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -3.1e-55], N[Not[LessEqual[z, 4.4e+41]], $MachinePrecision]], N[(y * z + x), $MachinePrecision], N[(a * t + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.1 \cdot 10^{-55} \lor \neg \left(z \leq 4.4 \cdot 10^{+41}\right):\\
\;\;\;\;\mathsf{fma}\left(y, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\end{array}
\end{array}
if z < -3.09999999999999997e-55 or 4.3999999999999998e41 < z Initial program 89.3%
Taylor expanded in t around inf
lower-*.f6415.9
Applied rewrites15.9%
Taylor expanded in y around inf
*-commutativeN/A
associate-+r+N/A
div-add-revN/A
distribute-lft-inN/A
associate-+r+N/A
lower-*.f64N/A
Applied rewrites81.3%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f6459.1
Applied rewrites59.1%
if -3.09999999999999997e-55 < z < 4.3999999999999998e41Initial program 99.9%
Taylor expanded in t around inf
lower-*.f6437.6
Applied rewrites37.6%
Taylor expanded in y around inf
*-commutativeN/A
associate-+r+N/A
div-add-revN/A
distribute-lft-inN/A
associate-+r+N/A
lower-*.f64N/A
Applied rewrites86.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6477.6
Applied rewrites77.6%
Final simplification68.1%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -1.62e+63) (not (<= z 4.2e+121))) (* y z) (fma a t x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -1.62e+63) || !(z <= 4.2e+121)) {
tmp = y * z;
} else {
tmp = fma(a, t, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -1.62e+63) || !(z <= 4.2e+121)) tmp = Float64(y * z); else tmp = fma(a, t, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -1.62e+63], N[Not[LessEqual[z, 4.2e+121]], $MachinePrecision]], N[(y * z), $MachinePrecision], N[(a * t + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.62 \cdot 10^{+63} \lor \neg \left(z \leq 4.2 \cdot 10^{+121}\right):\\
\;\;\;\;y \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\end{array}
\end{array}
if z < -1.62e63 or 4.2000000000000003e121 < z Initial program 85.4%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6489.0
Applied rewrites89.0%
Taylor expanded in y around inf
lower-*.f6451.3
Applied rewrites51.3%
if -1.62e63 < z < 4.2000000000000003e121Initial program 99.3%
Taylor expanded in t around inf
lower-*.f6432.1
Applied rewrites32.1%
Taylor expanded in y around inf
*-commutativeN/A
associate-+r+N/A
div-add-revN/A
distribute-lft-inN/A
associate-+r+N/A
lower-*.f64N/A
Applied rewrites83.1%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6469.0
Applied rewrites69.0%
Final simplification62.9%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -9e-68) (not (<= z 1.18e+42))) (* y z) (* a t)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -9e-68) || !(z <= 1.18e+42)) {
tmp = y * z;
} else {
tmp = a * t;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
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) :: tmp
if ((z <= (-9d-68)) .or. (.not. (z <= 1.18d+42))) then
tmp = y * z
else
tmp = a * t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -9e-68) || !(z <= 1.18e+42)) {
tmp = y * z;
} else {
tmp = a * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (z <= -9e-68) or not (z <= 1.18e+42): tmp = y * z else: tmp = a * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -9e-68) || !(z <= 1.18e+42)) tmp = Float64(y * z); else tmp = Float64(a * t); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((z <= -9e-68) || ~((z <= 1.18e+42))) tmp = y * z; else tmp = a * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -9e-68], N[Not[LessEqual[z, 1.18e+42]], $MachinePrecision]], N[(y * z), $MachinePrecision], N[(a * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9 \cdot 10^{-68} \lor \neg \left(z \leq 1.18 \cdot 10^{+42}\right):\\
\;\;\;\;y \cdot z\\
\mathbf{else}:\\
\;\;\;\;a \cdot t\\
\end{array}
\end{array}
if z < -8.99999999999999998e-68 or 1.18e42 < z Initial program 89.5%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6490.6
Applied rewrites90.6%
Taylor expanded in y around inf
lower-*.f6443.5
Applied rewrites43.5%
if -8.99999999999999998e-68 < z < 1.18e42Initial program 99.9%
Taylor expanded in t around inf
lower-*.f6438.2
Applied rewrites38.2%
Final simplification41.0%
(FPCore (x y z t a b) :precision binary64 (* y z))
double code(double x, double y, double z, double t, double a, double b) {
return y * z;
}
real(8) function code(x, y, z, t, a, b)
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
code = y * z
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return y * z;
}
def code(x, y, z, t, a, b): return y * z
function code(x, y, z, t, a, b) return Float64(y * z) end
function tmp = code(x, y, z, t, a, b) tmp = y * z; end
code[x_, y_, z_, t_, a_, b_] := N[(y * z), $MachinePrecision]
\begin{array}{l}
\\
y \cdot z
\end{array}
Initial program 94.5%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6495.1
Applied rewrites95.1%
Taylor expanded in y around inf
lower-*.f6428.6
Applied rewrites28.6%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (* z (+ (* b a) y)) (+ x (* t a)))))
(if (< z -11820553527347888000.0)
t_1
(if (< z 4.7589743188364287e-122)
(+ (* (+ (* b z) t) a) (+ (* z y) x))
t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (z * ((b * a) + y)) + (x + (t * a));
double tmp;
if (z < -11820553527347888000.0) {
tmp = t_1;
} else if (z < 4.7589743188364287e-122) {
tmp = (((b * z) + t) * a) + ((z * y) + x);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
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) :: t_1
real(8) :: tmp
t_1 = (z * ((b * a) + y)) + (x + (t * a))
if (z < (-11820553527347888000.0d0)) then
tmp = t_1
else if (z < 4.7589743188364287d-122) then
tmp = (((b * z) + t) * a) + ((z * y) + x)
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 t_1 = (z * ((b * a) + y)) + (x + (t * a));
double tmp;
if (z < -11820553527347888000.0) {
tmp = t_1;
} else if (z < 4.7589743188364287e-122) {
tmp = (((b * z) + t) * a) + ((z * y) + x);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (z * ((b * a) + y)) + (x + (t * a)) tmp = 0 if z < -11820553527347888000.0: tmp = t_1 elif z < 4.7589743188364287e-122: tmp = (((b * z) + t) * a) + ((z * y) + x) else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(z * Float64(Float64(b * a) + y)) + Float64(x + Float64(t * a))) tmp = 0.0 if (z < -11820553527347888000.0) tmp = t_1; elseif (z < 4.7589743188364287e-122) tmp = Float64(Float64(Float64(Float64(b * z) + t) * a) + Float64(Float64(z * y) + x)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (z * ((b * a) + y)) + (x + (t * a)); tmp = 0.0; if (z < -11820553527347888000.0) tmp = t_1; elseif (z < 4.7589743188364287e-122) tmp = (((b * z) + t) * a) + ((z * y) + x); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(z * N[(N[(b * a), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision] + N[(x + N[(t * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[z, -11820553527347888000.0], t$95$1, If[Less[z, 4.7589743188364287e-122], N[(N[(N[(N[(b * z), $MachinePrecision] + t), $MachinePrecision] * a), $MachinePrecision] + N[(N[(z * y), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(b \cdot a + y\right) + \left(x + t \cdot a\right)\\
\mathbf{if}\;z < -11820553527347888000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z < 4.7589743188364287 \cdot 10^{-122}:\\
\;\;\;\;\left(b \cdot z + t\right) \cdot a + \left(z \cdot y + x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2024337
(FPCore (x y z t a b)
:name "Graphics.Rasterific.CubicBezier:cachedBezierAt from Rasterific-0.6.1"
:precision binary64
:alt
(! :herbie-platform default (if (< z -11820553527347888000) (+ (* z (+ (* b a) y)) (+ x (* t a))) (if (< z 47589743188364287/1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (+ (* (+ (* b z) t) a) (+ (* z y) x)) (+ (* z (+ (* b a) y)) (+ x (* t a))))))
(+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))