
(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 14 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 (if (<= (+ (+ (+ x (* y z)) (* t a)) (* b (* z a))) INFINITY) (fma (* z a) b (fma y z (fma t a x))) (fma y (fma (/ a y) (fma b z t) z) x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((((x + (y * z)) + (t * a)) + (b * (z * a))) <= ((double) INFINITY)) {
tmp = fma((z * a), b, fma(y, z, fma(t, a, x)));
} else {
tmp = fma(y, fma((a / y), fma(b, z, t), z), x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(b * Float64(z * a))) <= Inf) tmp = fma(Float64(z * a), b, fma(y, z, fma(t, a, x))); else tmp = fma(y, fma(Float64(a / y), fma(b, z, t), z), x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(N[(N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(b * N[(z * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(z * a), $MachinePrecision] * b + N[(y * z + N[(t * a + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[(a / y), $MachinePrecision] * N[(b * z + t), $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + b \cdot \left(z \cdot a\right) \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(z \cdot a, b, \mathsf{fma}\left(y, z, \mathsf{fma}\left(t, a, x\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \mathsf{fma}\left(\frac{a}{y}, \mathsf{fma}\left(b, z, t\right), z\right), x\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) < +inf.0Initial program 99.5%
+-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
associate-+l+N/A
+-commutativeN/A
associate-+l+N/A
accelerator-lowering-fma.f64N/A
accelerator-lowering-fma.f6499.5
Applied egg-rr99.5%
if +inf.0 < (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) Initial program 0.0%
Taylor expanded in y around inf
+-commutativeN/A
associate-+r+N/A
distribute-lft-inN/A
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
accelerator-lowering-fma.f64N/A
Simplified100.0%
Final simplification99.5%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ (+ (+ x (* y z)) (* t a)) (* b (* z a))) INFINITY) (fma (* z a) b (fma y z (fma t a x))) (fma z (fma a b y) x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((((x + (y * z)) + (t * a)) + (b * (z * a))) <= ((double) INFINITY)) {
tmp = fma((z * a), b, fma(y, z, fma(t, a, x)));
} else {
tmp = fma(z, fma(a, b, y), x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(b * Float64(z * a))) <= Inf) tmp = fma(Float64(z * a), b, fma(y, z, fma(t, a, x))); else tmp = fma(z, fma(a, b, y), x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(N[(N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(b * N[(z * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(z * a), $MachinePrecision] * b + N[(y * z + N[(t * a + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(a * b + y), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + b \cdot \left(z \cdot a\right) \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(z \cdot a, b, \mathsf{fma}\left(y, z, \mathsf{fma}\left(t, a, x\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, \mathsf{fma}\left(a, b, y\right), x\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) < +inf.0Initial program 99.5%
+-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
associate-+l+N/A
+-commutativeN/A
associate-+l+N/A
accelerator-lowering-fma.f64N/A
accelerator-lowering-fma.f6499.5
Applied egg-rr99.5%
if +inf.0 < (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) Initial program 0.0%
Taylor expanded in t around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f6483.5
Simplified83.5%
Final simplification98.4%
(FPCore (x y z t a b)
:precision binary64
(if (<= y -180000000.0)
(fma z y x)
(if (<= y -5e-148)
(fma a t x)
(if (<= y -1.28e-247)
(* b (* z a))
(if (<= y 4.8e+32) (fma a t x) (fma z y x))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -180000000.0) {
tmp = fma(z, y, x);
} else if (y <= -5e-148) {
tmp = fma(a, t, x);
} else if (y <= -1.28e-247) {
tmp = b * (z * a);
} else if (y <= 4.8e+32) {
tmp = fma(a, t, x);
} else {
tmp = fma(z, y, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -180000000.0) tmp = fma(z, y, x); elseif (y <= -5e-148) tmp = fma(a, t, x); elseif (y <= -1.28e-247) tmp = Float64(b * Float64(z * a)); elseif (y <= 4.8e+32) tmp = fma(a, t, x); else tmp = fma(z, y, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -180000000.0], N[(z * y + x), $MachinePrecision], If[LessEqual[y, -5e-148], N[(a * t + x), $MachinePrecision], If[LessEqual[y, -1.28e-247], N[(b * N[(z * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.8e+32], N[(a * t + x), $MachinePrecision], N[(z * y + x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -180000000:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{elif}\;y \leq -5 \cdot 10^{-148}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{elif}\;y \leq -1.28 \cdot 10^{-247}:\\
\;\;\;\;b \cdot \left(z \cdot a\right)\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{+32}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\end{array}
\end{array}
if y < -1.8e8 or 4.79999999999999983e32 < y Initial program 91.9%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f6472.2
Simplified72.2%
if -1.8e8 < y < -4.9999999999999999e-148 or -1.28000000000000007e-247 < y < 4.79999999999999983e32Initial program 92.3%
Taylor expanded in z around 0
+-commutativeN/A
accelerator-lowering-fma.f6465.8
Simplified65.8%
if -4.9999999999999999e-148 < y < -1.28000000000000007e-247Initial program 99.7%
Taylor expanded in t around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f6478.0
Simplified78.0%
flip-+N/A
clear-numN/A
/-lowering-/.f64N/A
clear-numN/A
flip-+N/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f6478.0
Applied egg-rr78.0%
Taylor expanded in a around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f6476.5
Simplified76.5%
Final simplification70.0%
(FPCore (x y z t a b)
:precision binary64
(if (<= y -3100000.0)
(fma z y x)
(if (<= y -8.6e-146)
(fma a t x)
(if (<= y -5e-248)
(* a (* z b))
(if (<= y 6e+32) (fma a t x) (fma z y x))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -3100000.0) {
tmp = fma(z, y, x);
} else if (y <= -8.6e-146) {
tmp = fma(a, t, x);
} else if (y <= -5e-248) {
tmp = a * (z * b);
} else if (y <= 6e+32) {
tmp = fma(a, t, x);
} else {
tmp = fma(z, y, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -3100000.0) tmp = fma(z, y, x); elseif (y <= -8.6e-146) tmp = fma(a, t, x); elseif (y <= -5e-248) tmp = Float64(a * Float64(z * b)); elseif (y <= 6e+32) tmp = fma(a, t, x); else tmp = fma(z, y, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -3100000.0], N[(z * y + x), $MachinePrecision], If[LessEqual[y, -8.6e-146], N[(a * t + x), $MachinePrecision], If[LessEqual[y, -5e-248], N[(a * N[(z * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6e+32], N[(a * t + x), $MachinePrecision], N[(z * y + x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3100000:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{elif}\;y \leq -8.6 \cdot 10^{-146}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{elif}\;y \leq -5 \cdot 10^{-248}:\\
\;\;\;\;a \cdot \left(z \cdot b\right)\\
\mathbf{elif}\;y \leq 6 \cdot 10^{+32}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\end{array}
\end{array}
if y < -3.1e6 or 6e32 < y Initial program 91.9%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f6472.2
Simplified72.2%
if -3.1e6 < y < -8.5999999999999998e-146 or -5.0000000000000001e-248 < y < 6e32Initial program 92.3%
Taylor expanded in z around 0
+-commutativeN/A
accelerator-lowering-fma.f6465.8
Simplified65.8%
if -8.5999999999999998e-146 < y < -5.0000000000000001e-248Initial program 99.7%
Taylor expanded in b around inf
*-lowering-*.f64N/A
*-lowering-*.f6464.0
Simplified64.0%
Final simplification68.7%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma z (fma a b y) x)))
(if (<= b -2400000000.0)
t_1
(if (<= b 7.8e+50) (fma a t (fma z y x)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(z, fma(a, b, y), x);
double tmp;
if (b <= -2400000000.0) {
tmp = t_1;
} else if (b <= 7.8e+50) {
tmp = fma(a, t, fma(z, y, x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(z, fma(a, b, y), x) tmp = 0.0 if (b <= -2400000000.0) tmp = t_1; elseif (b <= 7.8e+50) tmp = fma(a, t, fma(z, y, x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(z * N[(a * b + y), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[b, -2400000000.0], t$95$1, If[LessEqual[b, 7.8e+50], N[(a * t + N[(z * y + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(z, \mathsf{fma}\left(a, b, y\right), x\right)\\
\mathbf{if}\;b \leq -2400000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 7.8 \cdot 10^{+50}:\\
\;\;\;\;\mathsf{fma}\left(a, t, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -2.4e9 or 7.79999999999999935e50 < b Initial program 90.7%
Taylor expanded in t around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f6487.2
Simplified87.2%
if -2.4e9 < b < 7.79999999999999935e50Initial program 94.8%
Taylor expanded in b around 0
Simplified92.0%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* z (fma a b y)))) (if (<= b -4e+178) t_1 (if (<= b 9.8e+58) (fma a t (fma z y x)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = z * fma(a, b, y);
double tmp;
if (b <= -4e+178) {
tmp = t_1;
} else if (b <= 9.8e+58) {
tmp = fma(a, t, fma(z, y, x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(z * fma(a, b, y)) tmp = 0.0 if (b <= -4e+178) tmp = t_1; elseif (b <= 9.8e+58) tmp = fma(a, t, fma(z, y, x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(z * N[(a * b + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -4e+178], t$95$1, If[LessEqual[b, 9.8e+58], N[(a * t + N[(z * y + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \mathsf{fma}\left(a, b, y\right)\\
\mathbf{if}\;b \leq -4 \cdot 10^{+178}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 9.8 \cdot 10^{+58}:\\
\;\;\;\;\mathsf{fma}\left(a, t, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -4.0000000000000002e178 or 9.80000000000000037e58 < b Initial program 91.0%
Taylor expanded in z around inf
*-lowering-*.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f6482.8
Simplified82.8%
if -4.0000000000000002e178 < b < 9.80000000000000037e58Initial program 93.7%
Taylor expanded in b around 0
Simplified87.2%
(FPCore (x y z t a b) :precision binary64 (if (<= y -1.95e+64) (* y z) (if (<= y 1.05e-243) x (if (<= y 3.6e+80) (* t a) (* y z)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -1.95e+64) {
tmp = y * z;
} else if (y <= 1.05e-243) {
tmp = x;
} else if (y <= 3.6e+80) {
tmp = t * a;
} else {
tmp = y * z;
}
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 (y <= (-1.95d+64)) then
tmp = y * z
else if (y <= 1.05d-243) then
tmp = x
else if (y <= 3.6d+80) then
tmp = t * a
else
tmp = y * z
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 (y <= -1.95e+64) {
tmp = y * z;
} else if (y <= 1.05e-243) {
tmp = x;
} else if (y <= 3.6e+80) {
tmp = t * a;
} else {
tmp = y * z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if y <= -1.95e+64: tmp = y * z elif y <= 1.05e-243: tmp = x elif y <= 3.6e+80: tmp = t * a else: tmp = y * z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -1.95e+64) tmp = Float64(y * z); elseif (y <= 1.05e-243) tmp = x; elseif (y <= 3.6e+80) tmp = Float64(t * a); else tmp = Float64(y * z); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (y <= -1.95e+64) tmp = y * z; elseif (y <= 1.05e-243) tmp = x; elseif (y <= 3.6e+80) tmp = t * a; else tmp = y * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -1.95e+64], N[(y * z), $MachinePrecision], If[LessEqual[y, 1.05e-243], x, If[LessEqual[y, 3.6e+80], N[(t * a), $MachinePrecision], N[(y * z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.95 \cdot 10^{+64}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{-243}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{+80}:\\
\;\;\;\;t \cdot a\\
\mathbf{else}:\\
\;\;\;\;y \cdot z\\
\end{array}
\end{array}
if y < -1.9499999999999999e64 or 3.59999999999999995e80 < y Initial program 90.2%
Taylor expanded in y around inf
*-commutativeN/A
*-lowering-*.f6460.5
Simplified60.5%
if -1.9499999999999999e64 < y < 1.05e-243Initial program 95.0%
Taylor expanded in x around inf
Simplified35.4%
if 1.05e-243 < y < 3.59999999999999995e80Initial program 94.1%
Taylor expanded in t around inf
*-lowering-*.f6437.6
Simplified37.6%
Final simplification46.1%
(FPCore (x y z t a b) :precision binary64 (if (<= y -2.3e+129) (fma z y x) (if (<= y 1.75e+18) (fma (* z a) b x) (fma a t (* y z)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -2.3e+129) {
tmp = fma(z, y, x);
} else if (y <= 1.75e+18) {
tmp = fma((z * a), b, x);
} else {
tmp = fma(a, t, (y * z));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -2.3e+129) tmp = fma(z, y, x); elseif (y <= 1.75e+18) tmp = fma(Float64(z * a), b, x); else tmp = fma(a, t, Float64(y * z)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -2.3e+129], N[(z * y + x), $MachinePrecision], If[LessEqual[y, 1.75e+18], N[(N[(z * a), $MachinePrecision] * b + x), $MachinePrecision], N[(a * t + N[(y * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.3 \cdot 10^{+129}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{elif}\;y \leq 1.75 \cdot 10^{+18}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot a, b, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, t, y \cdot z\right)\\
\end{array}
\end{array}
if y < -2.2999999999999999e129Initial program 94.3%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f6486.7
Simplified86.7%
if -2.2999999999999999e129 < y < 1.75e18Initial program 92.8%
+-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
associate-+l+N/A
+-commutativeN/A
associate-+l+N/A
accelerator-lowering-fma.f64N/A
accelerator-lowering-fma.f6493.4
Applied egg-rr93.4%
Taylor expanded in x around inf
Simplified71.1%
if 1.75e18 < y Initial program 92.4%
Taylor expanded in b around 0
Simplified86.2%
Taylor expanded in z around inf
*-lowering-*.f6472.9
Simplified72.9%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* z (fma a b y)))) (if (<= z -2.6e-146) t_1 (if (<= z 7.4e+66) (fma a t x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = z * fma(a, b, y);
double tmp;
if (z <= -2.6e-146) {
tmp = t_1;
} else if (z <= 7.4e+66) {
tmp = fma(a, t, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(z * fma(a, b, y)) tmp = 0.0 if (z <= -2.6e-146) tmp = t_1; elseif (z <= 7.4e+66) tmp = fma(a, t, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(z * N[(a * b + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.6e-146], t$95$1, If[LessEqual[z, 7.4e+66], N[(a * t + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \mathsf{fma}\left(a, b, y\right)\\
\mathbf{if}\;z \leq -2.6 \cdot 10^{-146}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 7.4 \cdot 10^{+66}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -2.59999999999999987e-146 or 7.4000000000000001e66 < z Initial program 88.6%
Taylor expanded in z around inf
*-lowering-*.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f6475.3
Simplified75.3%
if -2.59999999999999987e-146 < z < 7.4000000000000001e66Initial program 99.0%
Taylor expanded in z around 0
+-commutativeN/A
accelerator-lowering-fma.f6469.0
Simplified69.0%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* a (fma b z t)))) (if (<= a -5.5e+51) t_1 (if (<= a 3.2e-10) (fma z y x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = a * fma(b, z, t);
double tmp;
if (a <= -5.5e+51) {
tmp = t_1;
} else if (a <= 3.2e-10) {
tmp = fma(z, y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(a * fma(b, z, t)) tmp = 0.0 if (a <= -5.5e+51) tmp = t_1; elseif (a <= 3.2e-10) tmp = fma(z, y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(a * N[(b * z + t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -5.5e+51], t$95$1, If[LessEqual[a, 3.2e-10], N[(z * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a \cdot \mathsf{fma}\left(b, z, t\right)\\
\mathbf{if}\;a \leq -5.5 \cdot 10^{+51}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 3.2 \cdot 10^{-10}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -5.5e51 or 3.19999999999999981e-10 < a Initial program 85.6%
Taylor expanded in a around inf
*-lowering-*.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f6475.6
Simplified75.6%
if -5.5e51 < a < 3.19999999999999981e-10Initial program 98.5%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f6470.1
Simplified70.1%
(FPCore (x y z t a b) :precision binary64 (if (<= y -19000.0) (fma z y x) (if (<= y 7e+31) (fma a t x) (fma z y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -19000.0) {
tmp = fma(z, y, x);
} else if (y <= 7e+31) {
tmp = fma(a, t, x);
} else {
tmp = fma(z, y, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -19000.0) tmp = fma(z, y, x); elseif (y <= 7e+31) tmp = fma(a, t, x); else tmp = fma(z, y, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -19000.0], N[(z * y + x), $MachinePrecision], If[LessEqual[y, 7e+31], N[(a * t + x), $MachinePrecision], N[(z * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -19000:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{elif}\;y \leq 7 \cdot 10^{+31}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\end{array}
\end{array}
if y < -19000 or 7e31 < y Initial program 91.9%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f6472.2
Simplified72.2%
if -19000 < y < 7e31Initial program 93.8%
Taylor expanded in z around 0
+-commutativeN/A
accelerator-lowering-fma.f6458.1
Simplified58.1%
(FPCore (x y z t a b) :precision binary64 (if (<= y -5.6e+94) (* y z) (if (<= y 1e+126) (fma a t x) (* y z))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -5.6e+94) {
tmp = y * z;
} else if (y <= 1e+126) {
tmp = fma(a, t, x);
} else {
tmp = y * z;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -5.6e+94) tmp = Float64(y * z); elseif (y <= 1e+126) tmp = fma(a, t, x); else tmp = Float64(y * z); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -5.6e+94], N[(y * z), $MachinePrecision], If[LessEqual[y, 1e+126], N[(a * t + x), $MachinePrecision], N[(y * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.6 \cdot 10^{+94}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;y \leq 10^{+126}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot z\\
\end{array}
\end{array}
if y < -5.59999999999999997e94 or 9.99999999999999925e125 < y Initial program 89.4%
Taylor expanded in y around inf
*-commutativeN/A
*-lowering-*.f6465.4
Simplified65.4%
if -5.59999999999999997e94 < y < 9.99999999999999925e125Initial program 94.6%
Taylor expanded in z around 0
+-commutativeN/A
accelerator-lowering-fma.f6455.7
Simplified55.7%
Final simplification58.9%
(FPCore (x y z t a b) :precision binary64 (if (<= t -1.4e+68) (* t a) (if (<= t 6e+20) x (* t a))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -1.4e+68) {
tmp = t * a;
} else if (t <= 6e+20) {
tmp = x;
} else {
tmp = t * a;
}
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 (t <= (-1.4d+68)) then
tmp = t * a
else if (t <= 6d+20) then
tmp = x
else
tmp = t * a
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 (t <= -1.4e+68) {
tmp = t * a;
} else if (t <= 6e+20) {
tmp = x;
} else {
tmp = t * a;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if t <= -1.4e+68: tmp = t * a elif t <= 6e+20: tmp = x else: tmp = t * a return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -1.4e+68) tmp = Float64(t * a); elseif (t <= 6e+20) tmp = x; else tmp = Float64(t * a); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (t <= -1.4e+68) tmp = t * a; elseif (t <= 6e+20) tmp = x; else tmp = t * a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -1.4e+68], N[(t * a), $MachinePrecision], If[LessEqual[t, 6e+20], x, N[(t * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.4 \cdot 10^{+68}:\\
\;\;\;\;t \cdot a\\
\mathbf{elif}\;t \leq 6 \cdot 10^{+20}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t \cdot a\\
\end{array}
\end{array}
if t < -1.4e68 or 6e20 < t Initial program 87.8%
Taylor expanded in t around inf
*-lowering-*.f6445.2
Simplified45.2%
if -1.4e68 < t < 6e20Initial program 96.1%
Taylor expanded in x around inf
Simplified31.5%
Final simplification36.8%
(FPCore (x y z t a b) :precision binary64 x)
double code(double x, double y, double z, double t, double a, double b) {
return x;
}
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
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return x;
}
def code(x, y, z, t, a, b): return x
function code(x, y, z, t, a, b) return x end
function tmp = code(x, y, z, t, a, b) tmp = x; end
code[x_, y_, z_, t_, a_, b_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 92.9%
Taylor expanded in x around inf
Simplified24.7%
(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 2024198
(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)))