
(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 10 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 (- INFINITY))
(fma (fma b z t) a (* z y))
(if (<= t_1 INFINITY) t_1 (fma (fma b z t) a x)))))
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 <= -((double) INFINITY)) {
tmp = fma(fma(b, z, t), a, (z * y));
} else if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = fma(fma(b, z, t), a, x);
}
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 <= Float64(-Inf)) tmp = fma(fma(b, z, t), a, Float64(z * y)); elseif (t_1 <= Inf) tmp = t_1; else tmp = fma(fma(b, z, t), a, x); 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, (-Infinity)], N[(N[(b * z + t), $MachinePrecision] * a + N[(z * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], t$95$1, N[(N[(b * z + t), $MachinePrecision] * a + x), $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 -\infty:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, z \cdot y\right)\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, 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 80.5%
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-*.f6495.2
Applied rewrites95.2%
if -inf.0 < (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) < +inf.0Initial program 98.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 0
distribute-lft-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6484.6
Applied rewrites84.6%
(FPCore (x y z t a b) :precision binary64 (if (<= b -1.9e+67) (fma (fma b a y) z x) (if (<= b 2.95e+23) (fma a t (fma z y x)) (+ (fma a t x) (* (* a z) b)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (b <= -1.9e+67) {
tmp = fma(fma(b, a, y), z, x);
} else if (b <= 2.95e+23) {
tmp = fma(a, t, fma(z, y, x));
} else {
tmp = fma(a, t, x) + ((a * z) * b);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (b <= -1.9e+67) tmp = fma(fma(b, a, y), z, x); elseif (b <= 2.95e+23) tmp = fma(a, t, fma(z, y, x)); else tmp = Float64(fma(a, t, x) + Float64(Float64(a * z) * b)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[b, -1.9e+67], N[(N[(b * a + y), $MachinePrecision] * z + x), $MachinePrecision], If[LessEqual[b, 2.95e+23], N[(a * t + N[(z * y + x), $MachinePrecision]), $MachinePrecision], N[(N[(a * t + x), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.9 \cdot 10^{+67}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)\\
\mathbf{elif}\;b \leq 2.95 \cdot 10^{+23}:\\
\;\;\;\;\mathsf{fma}\left(a, t, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right) + \left(a \cdot z\right) \cdot b\\
\end{array}
\end{array}
if b < -1.9000000000000001e67Initial 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.f6483.7
Applied rewrites83.7%
if -1.9000000000000001e67 < b < 2.94999999999999994e23Initial program 91.3%
Taylor expanded in y around 0
distribute-lft-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6468.9
Applied rewrites68.9%
Taylor expanded in b around 0
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6493.8
Applied rewrites93.8%
if 2.94999999999999994e23 < b Initial program 91.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f6488.7
Applied rewrites88.7%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -5.4e-69) (not (<= z 370000000.0))) (fma (fma b a y) z x) (fma a t (fma z y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -5.4e-69) || !(z <= 370000000.0)) {
tmp = fma(fma(b, a, y), z, x);
} else {
tmp = fma(a, t, fma(z, y, x));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -5.4e-69) || !(z <= 370000000.0)) tmp = fma(fma(b, a, y), z, x); else tmp = fma(a, t, fma(z, y, x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -5.4e-69], N[Not[LessEqual[z, 370000000.0]], $MachinePrecision]], N[(N[(b * a + y), $MachinePrecision] * z + x), $MachinePrecision], N[(a * t + N[(z * y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.4 \cdot 10^{-69} \lor \neg \left(z \leq 370000000\right):\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, t, \mathsf{fma}\left(z, y, x\right)\right)\\
\end{array}
\end{array}
if z < -5.3999999999999995e-69 or 3.7e8 < z Initial program 83.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.f6487.7
Applied rewrites87.7%
if -5.3999999999999995e-69 < z < 3.7e8Initial program 99.1%
Taylor expanded in y around 0
distribute-lft-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6488.2
Applied rewrites88.2%
Taylor expanded in b around 0
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6490.5
Applied rewrites90.5%
Final simplification89.1%
(FPCore (x y z t a b) :precision binary64 (if (<= b -1.9e+67) (fma (fma b a y) z x) (if (<= b 2.45e+23) (fma a t (fma z y 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 (b <= -1.9e+67) {
tmp = fma(fma(b, a, y), z, x);
} else if (b <= 2.45e+23) {
tmp = fma(a, t, fma(z, y, x));
} else {
tmp = fma(fma(b, z, t), a, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (b <= -1.9e+67) tmp = fma(fma(b, a, y), z, x); elseif (b <= 2.45e+23) tmp = fma(a, t, fma(z, y, x)); else tmp = fma(fma(b, z, t), a, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[b, -1.9e+67], N[(N[(b * a + y), $MachinePrecision] * z + x), $MachinePrecision], If[LessEqual[b, 2.45e+23], N[(a * t + N[(z * y + x), $MachinePrecision]), $MachinePrecision], N[(N[(b * z + t), $MachinePrecision] * a + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.9 \cdot 10^{+67}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)\\
\mathbf{elif}\;b \leq 2.45 \cdot 10^{+23}:\\
\;\;\;\;\mathsf{fma}\left(a, t, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, x\right)\\
\end{array}
\end{array}
if b < -1.9000000000000001e67Initial 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.f6483.7
Applied rewrites83.7%
if -1.9000000000000001e67 < b < 2.4500000000000001e23Initial program 91.3%
Taylor expanded in y around 0
distribute-lft-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6468.9
Applied rewrites68.9%
Taylor expanded in b around 0
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6493.8
Applied rewrites93.8%
if 2.4500000000000001e23 < b Initial program 91.0%
Taylor expanded in y around 0
distribute-lft-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6488.6
Applied rewrites88.6%
(FPCore (x y z t a b) :precision binary64 (if (<= b -4.4e+71) (fma (* b z) a x) (if (<= b 9e+34) (fma a t (fma z y x)) (* (fma b z t) a))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (b <= -4.4e+71) {
tmp = fma((b * z), a, x);
} else if (b <= 9e+34) {
tmp = fma(a, t, fma(z, y, x));
} else {
tmp = fma(b, z, t) * a;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (b <= -4.4e+71) tmp = fma(Float64(b * z), a, x); elseif (b <= 9e+34) tmp = fma(a, t, fma(z, y, x)); else tmp = Float64(fma(b, z, t) * a); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[b, -4.4e+71], N[(N[(b * z), $MachinePrecision] * a + x), $MachinePrecision], If[LessEqual[b, 9e+34], N[(a * t + N[(z * y + x), $MachinePrecision]), $MachinePrecision], N[(N[(b * z + t), $MachinePrecision] * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.4 \cdot 10^{+71}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot z, a, x\right)\\
\mathbf{elif}\;b \leq 9 \cdot 10^{+34}:\\
\;\;\;\;\mathsf{fma}\left(a, t, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, z, t\right) \cdot a\\
\end{array}
\end{array}
if b < -4.39999999999999989e71Initial program 88.8%
Taylor expanded in y around 0
distribute-lft-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6481.1
Applied rewrites81.1%
Taylor expanded in z around inf
Applied rewrites72.5%
if -4.39999999999999989e71 < b < 9.0000000000000001e34Initial program 91.5%
Taylor expanded in y around 0
distribute-lft-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6469.3
Applied rewrites69.3%
Taylor expanded in b around 0
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6493.4
Applied rewrites93.4%
if 9.0000000000000001e34 < b Initial program 90.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6471.1
Applied rewrites71.1%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -2.5e-31) (not (<= z 5200000000.0))) (* (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 <= -2.5e-31) || !(z <= 5200000000.0)) {
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 <= -2.5e-31) || !(z <= 5200000000.0)) 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, -2.5e-31], N[Not[LessEqual[z, 5200000000.0]], $MachinePrecision]], N[(N[(b * a + y), $MachinePrecision] * z), $MachinePrecision], N[(a * t + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.5 \cdot 10^{-31} \lor \neg \left(z \leq 5200000000\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 < -2.5e-31 or 5.2e9 < z Initial program 82.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6477.1
Applied rewrites77.1%
if -2.5e-31 < z < 5.2e9Initial program 99.2%
Taylor expanded in y around 0
distribute-lft-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6488.9
Applied rewrites88.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6477.2
Applied rewrites77.2%
Final simplification77.1%
(FPCore (x y z t a b) :precision binary64 (if (or (<= a -0.00033) (not (<= a 3e-82))) (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 ((a <= -0.00033) || !(a <= 3e-82)) {
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 ((a <= -0.00033) || !(a <= 3e-82)) tmp = fma(a, t, x); else tmp = fma(z, y, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[a, -0.00033], N[Not[LessEqual[a, 3e-82]], $MachinePrecision]], N[(a * t + x), $MachinePrecision], N[(z * y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.00033 \lor \neg \left(a \leq 3 \cdot 10^{-82}\right):\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\end{array}
\end{array}
if a < -3.3e-4 or 2.9999999999999999e-82 < a Initial program 83.6%
Taylor expanded in y around 0
distribute-lft-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6490.4
Applied rewrites90.4%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6459.5
Applied rewrites59.5%
if -3.3e-4 < a < 2.9999999999999999e-82Initial 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.f6456.4
Applied rewrites56.4%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6479.0
Applied rewrites79.0%
Final simplification68.2%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -1.4e+227) (not (<= z 1.05e+58))) (* z y) (fma a t x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -1.4e+227) || !(z <= 1.05e+58)) {
tmp = z * y;
} else {
tmp = fma(a, t, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -1.4e+227) || !(z <= 1.05e+58)) tmp = Float64(z * y); else tmp = fma(a, t, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -1.4e+227], N[Not[LessEqual[z, 1.05e+58]], $MachinePrecision]], N[(z * y), $MachinePrecision], N[(a * t + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.4 \cdot 10^{+227} \lor \neg \left(z \leq 1.05 \cdot 10^{+58}\right):\\
\;\;\;\;z \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\end{array}
\end{array}
if z < -1.39999999999999992e227 or 1.05000000000000006e58 < z Initial program 75.1%
Taylor expanded in y around 0
distribute-lft-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6449.8
Applied rewrites49.8%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6456.5
Applied rewrites56.5%
if -1.39999999999999992e227 < z < 1.05000000000000006e58Initial program 96.3%
Taylor expanded in y around 0
distribute-lft-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6484.1
Applied rewrites84.1%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6467.1
Applied rewrites67.1%
Final simplification64.4%
(FPCore (x y z t a b) :precision binary64 (if (or (<= a -1e-9) (not (<= a 3e-82))) (* a t) (* z y)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a <= -1e-9) || !(a <= 3e-82)) {
tmp = a * t;
} else {
tmp = z * y;
}
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 ((a <= (-1d-9)) .or. (.not. (a <= 3d-82))) then
tmp = a * t
else
tmp = z * y
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 ((a <= -1e-9) || !(a <= 3e-82)) {
tmp = a * t;
} else {
tmp = z * y;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a <= -1e-9) or not (a <= 3e-82): tmp = a * t else: tmp = z * y return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((a <= -1e-9) || !(a <= 3e-82)) tmp = Float64(a * t); else tmp = Float64(z * y); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((a <= -1e-9) || ~((a <= 3e-82))) tmp = a * t; else tmp = z * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[a, -1e-9], N[Not[LessEqual[a, 3e-82]], $MachinePrecision]], N[(a * t), $MachinePrecision], N[(z * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1 \cdot 10^{-9} \lor \neg \left(a \leq 3 \cdot 10^{-82}\right):\\
\;\;\;\;a \cdot t\\
\mathbf{else}:\\
\;\;\;\;z \cdot y\\
\end{array}
\end{array}
if a < -1.00000000000000006e-9 or 2.9999999999999999e-82 < a Initial program 83.7%
Taylor expanded in t around inf
lower-*.f6443.1
Applied rewrites43.1%
if -1.00000000000000006e-9 < a < 2.9999999999999999e-82Initial 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.f6456.0
Applied rewrites56.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6441.3
Applied rewrites41.3%
Final simplification42.3%
(FPCore (x y z t a b) :precision binary64 (* a t))
double code(double x, double y, double z, double t, double a, double b) {
return a * t;
}
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 = a * t
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return a * t;
}
def code(x, y, z, t, a, b): return a * t
function code(x, y, z, t, a, b) return Float64(a * t) end
function tmp = code(x, y, z, t, a, b) tmp = a * t; end
code[x_, y_, z_, t_, a_, b_] := N[(a * t), $MachinePrecision]
\begin{array}{l}
\\
a \cdot t
\end{array}
Initial program 90.8%
Taylor expanded in t around inf
lower-*.f6429.6
Applied rewrites29.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 2024332
(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)))