
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0)))
double code(double x, double y, double z, double t, double a) {
return ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
}
real(8) function code(x, y, z, t, a)
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
code = ((x * y) - ((z * 9.0d0) * t)) / (a * 2.0d0)
end function
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
}
def code(x, y, z, t, a): return ((x * y) - ((z * 9.0) * t)) / (a * 2.0)
function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) - Float64(Float64(z * 9.0) * t)) / Float64(a * 2.0)) end
function tmp = code(x, y, z, t, a) tmp = ((x * y) - ((z * 9.0) * t)) / (a * 2.0); end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(N[(z * 9.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0)))
double code(double x, double y, double z, double t, double a) {
return ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
}
real(8) function code(x, y, z, t, a)
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
code = ((x * y) - ((z * 9.0d0) * t)) / (a * 2.0d0)
end function
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
}
def code(x, y, z, t, a): return ((x * y) - ((z * 9.0) * t)) / (a * 2.0)
function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) - Float64(Float64(z * 9.0) * t)) / Float64(a * 2.0)) end
function tmp = code(x, y, z, t, a) tmp = ((x * y) - ((z * 9.0) * t)) / (a * 2.0); end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(N[(z * 9.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\end{array}
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
:precision binary64
(if (<= (* x y) -1e+219)
(* y (* x (/ 0.5 a)))
(if (<= (* x y) 2e+282)
(* (/ 0.5 a) (+ (* x y) (* -9.0 (* t z))))
(* y (/ (* x 0.5) a)))))assert(x < y);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -1e+219) {
tmp = y * (x * (0.5 / a));
} else if ((x * y) <= 2e+282) {
tmp = (0.5 / a) * ((x * y) + (-9.0 * (t * z)));
} else {
tmp = y * ((x * 0.5) / a);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a)
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) :: tmp
if ((x * y) <= (-1d+219)) then
tmp = y * (x * (0.5d0 / a))
else if ((x * y) <= 2d+282) then
tmp = (0.5d0 / a) * ((x * y) + ((-9.0d0) * (t * z)))
else
tmp = y * ((x * 0.5d0) / a)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -1e+219) {
tmp = y * (x * (0.5 / a));
} else if ((x * y) <= 2e+282) {
tmp = (0.5 / a) * ((x * y) + (-9.0 * (t * z)));
} else {
tmp = y * ((x * 0.5) / a);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): tmp = 0 if (x * y) <= -1e+219: tmp = y * (x * (0.5 / a)) elif (x * y) <= 2e+282: tmp = (0.5 / a) * ((x * y) + (-9.0 * (t * z))) else: tmp = y * ((x * 0.5) / a) return tmp
x, y = sort([x, y]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= -1e+219) tmp = Float64(y * Float64(x * Float64(0.5 / a))); elseif (Float64(x * y) <= 2e+282) tmp = Float64(Float64(0.5 / a) * Float64(Float64(x * y) + Float64(-9.0 * Float64(t * z)))); else tmp = Float64(y * Float64(Float64(x * 0.5) / a)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((x * y) <= -1e+219)
tmp = y * (x * (0.5 / a));
elseif ((x * y) <= 2e+282)
tmp = (0.5 / a) * ((x * y) + (-9.0 * (t * z)));
else
tmp = y * ((x * 0.5) / a);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], -1e+219], N[(y * N[(x * N[(0.5 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2e+282], N[(N[(0.5 / a), $MachinePrecision] * N[(N[(x * y), $MachinePrecision] + N[(-9.0 * N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[(x * 0.5), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+219}:\\
\;\;\;\;y \cdot \left(x \cdot \frac{0.5}{a}\right)\\
\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+282}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(x \cdot y + -9 \cdot \left(t \cdot z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x \cdot 0.5}{a}\\
\end{array}
\end{array}
if (*.f64 x y) < -9.99999999999999965e218Initial program 77.3%
sub-neg77.3%
+-commutative77.3%
neg-sub077.3%
associate-+l-77.3%
sub0-neg77.3%
neg-mul-177.3%
associate-/l*77.4%
associate-/r/77.3%
*-commutative77.3%
sub-neg77.3%
+-commutative77.3%
neg-sub077.3%
associate-+l-77.3%
sub0-neg77.3%
distribute-lft-neg-out77.3%
distribute-rgt-neg-in77.3%
Simplified77.3%
Taylor expanded in x around 0 73.8%
Taylor expanded in t around 0 77.3%
associate-*r/77.3%
*-commutative77.3%
associate-/l*77.3%
associate-*r/99.6%
associate-/l*99.6%
associate-*r/99.6%
Simplified99.6%
if -9.99999999999999965e218 < (*.f64 x y) < 2.00000000000000007e282Initial program 95.5%
sub-neg95.5%
+-commutative95.5%
neg-sub095.5%
associate-+l-95.5%
sub0-neg95.5%
neg-mul-195.5%
associate-/l*95.1%
associate-/r/95.6%
*-commutative95.6%
sub-neg95.6%
+-commutative95.6%
neg-sub095.6%
associate-+l-95.6%
sub0-neg95.6%
distribute-lft-neg-out95.6%
distribute-rgt-neg-in95.6%
Simplified95.5%
Taylor expanded in x around 0 95.6%
if 2.00000000000000007e282 < (*.f64 x y) Initial program 61.7%
sub-neg61.7%
+-commutative61.7%
neg-sub061.7%
associate-+l-61.7%
sub0-neg61.7%
neg-mul-161.7%
associate-/l*61.8%
associate-/r/61.8%
*-commutative61.8%
sub-neg61.8%
+-commutative61.8%
neg-sub061.8%
associate-+l-61.8%
sub0-neg61.8%
distribute-lft-neg-out61.8%
distribute-rgt-neg-in61.8%
Simplified61.8%
Taylor expanded in x around inf 61.7%
associate-*r/61.7%
*-commutative61.7%
associate-*l/61.8%
associate-*r*99.8%
*-commutative99.8%
associate-*l/99.8%
Simplified99.8%
Final simplification96.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (or (<= y -1.02e-67) (not (<= y 4.9e+39))) (* y (* x (/ 0.5 a))) (* -4.5 (/ t (/ a z)))))
assert(x < y);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((y <= -1.02e-67) || !(y <= 4.9e+39)) {
tmp = y * (x * (0.5 / a));
} else {
tmp = -4.5 * (t / (a / z));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a)
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) :: tmp
if ((y <= (-1.02d-67)) .or. (.not. (y <= 4.9d+39))) then
tmp = y * (x * (0.5d0 / a))
else
tmp = (-4.5d0) * (t / (a / z))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((y <= -1.02e-67) || !(y <= 4.9e+39)) {
tmp = y * (x * (0.5 / a));
} else {
tmp = -4.5 * (t / (a / z));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): tmp = 0 if (y <= -1.02e-67) or not (y <= 4.9e+39): tmp = y * (x * (0.5 / a)) else: tmp = -4.5 * (t / (a / z)) return tmp
x, y = sort([x, y]) function code(x, y, z, t, a) tmp = 0.0 if ((y <= -1.02e-67) || !(y <= 4.9e+39)) tmp = Float64(y * Float64(x * Float64(0.5 / a))); else tmp = Float64(-4.5 * Float64(t / Float64(a / z))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((y <= -1.02e-67) || ~((y <= 4.9e+39)))
tmp = y * (x * (0.5 / a));
else
tmp = -4.5 * (t / (a / z));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[Or[LessEqual[y, -1.02e-67], N[Not[LessEqual[y, 4.9e+39]], $MachinePrecision]], N[(y * N[(x * N[(0.5 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.5 * N[(t / N[(a / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.02 \cdot 10^{-67} \lor \neg \left(y \leq 4.9 \cdot 10^{+39}\right):\\
\;\;\;\;y \cdot \left(x \cdot \frac{0.5}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;-4.5 \cdot \frac{t}{\frac{a}{z}}\\
\end{array}
\end{array}
if y < -1.01999999999999993e-67 or 4.89999999999999987e39 < y Initial program 86.4%
sub-neg86.4%
+-commutative86.4%
neg-sub086.4%
associate-+l-86.4%
sub0-neg86.4%
neg-mul-186.4%
associate-/l*86.0%
associate-/r/86.4%
*-commutative86.4%
sub-neg86.4%
+-commutative86.4%
neg-sub086.4%
associate-+l-86.4%
sub0-neg86.4%
distribute-lft-neg-out86.4%
distribute-rgt-neg-in86.4%
Simplified86.4%
Taylor expanded in x around 0 82.7%
Taylor expanded in t around 0 59.4%
associate-*r/59.4%
*-commutative59.4%
associate-/l*59.4%
associate-*r/66.8%
associate-/l*66.8%
associate-*r/66.8%
Simplified66.8%
if -1.01999999999999993e-67 < y < 4.89999999999999987e39Initial program 95.7%
sub-neg95.7%
+-commutative95.7%
neg-sub095.7%
associate-+l-95.7%
sub0-neg95.7%
neg-mul-195.7%
associate-/l*95.6%
associate-/r/95.8%
*-commutative95.8%
sub-neg95.8%
+-commutative95.8%
neg-sub095.8%
associate-+l-95.8%
sub0-neg95.8%
distribute-lft-neg-out95.8%
distribute-rgt-neg-in95.8%
Simplified95.8%
Taylor expanded in x around 0 72.9%
associate-/l*73.1%
Simplified73.1%
Final simplification69.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= y -1.6e-68) (* y (/ (* x 0.5) a)) (if (<= y 9.2e+39) (* -4.5 (/ t (/ a z))) (* y (* x (/ 0.5 a))))))
assert(x < y);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= -1.6e-68) {
tmp = y * ((x * 0.5) / a);
} else if (y <= 9.2e+39) {
tmp = -4.5 * (t / (a / z));
} else {
tmp = y * (x * (0.5 / a));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a)
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) :: tmp
if (y <= (-1.6d-68)) then
tmp = y * ((x * 0.5d0) / a)
else if (y <= 9.2d+39) then
tmp = (-4.5d0) * (t / (a / z))
else
tmp = y * (x * (0.5d0 / a))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= -1.6e-68) {
tmp = y * ((x * 0.5) / a);
} else if (y <= 9.2e+39) {
tmp = -4.5 * (t / (a / z));
} else {
tmp = y * (x * (0.5 / a));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): tmp = 0 if y <= -1.6e-68: tmp = y * ((x * 0.5) / a) elif y <= 9.2e+39: tmp = -4.5 * (t / (a / z)) else: tmp = y * (x * (0.5 / a)) return tmp
x, y = sort([x, y]) function code(x, y, z, t, a) tmp = 0.0 if (y <= -1.6e-68) tmp = Float64(y * Float64(Float64(x * 0.5) / a)); elseif (y <= 9.2e+39) tmp = Float64(-4.5 * Float64(t / Float64(a / z))); else tmp = Float64(y * Float64(x * Float64(0.5 / a))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if (y <= -1.6e-68)
tmp = y * ((x * 0.5) / a);
elseif (y <= 9.2e+39)
tmp = -4.5 * (t / (a / z));
else
tmp = y * (x * (0.5 / a));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[y, -1.6e-68], N[(y * N[(N[(x * 0.5), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9.2e+39], N[(-4.5 * N[(t / N[(a / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(x * N[(0.5 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.6 \cdot 10^{-68}:\\
\;\;\;\;y \cdot \frac{x \cdot 0.5}{a}\\
\mathbf{elif}\;y \leq 9.2 \cdot 10^{+39}:\\
\;\;\;\;-4.5 \cdot \frac{t}{\frac{a}{z}}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot \frac{0.5}{a}\right)\\
\end{array}
\end{array}
if y < -1.5999999999999999e-68Initial program 86.8%
sub-neg86.8%
+-commutative86.8%
neg-sub086.8%
associate-+l-86.8%
sub0-neg86.8%
neg-mul-186.8%
associate-/l*86.1%
associate-/r/86.8%
*-commutative86.8%
sub-neg86.8%
+-commutative86.8%
neg-sub086.8%
associate-+l-86.8%
sub0-neg86.8%
distribute-lft-neg-out86.8%
distribute-rgt-neg-in86.8%
Simplified86.7%
Taylor expanded in x around inf 58.0%
associate-*r/58.0%
*-commutative58.0%
associate-*l/58.0%
associate-*r*64.0%
*-commutative64.0%
associate-*l/64.1%
Simplified64.1%
if -1.5999999999999999e-68 < y < 9.20000000000000047e39Initial program 95.7%
sub-neg95.7%
+-commutative95.7%
neg-sub095.7%
associate-+l-95.7%
sub0-neg95.7%
neg-mul-195.7%
associate-/l*95.6%
associate-/r/95.8%
*-commutative95.8%
sub-neg95.8%
+-commutative95.8%
neg-sub095.8%
associate-+l-95.8%
sub0-neg95.8%
distribute-lft-neg-out95.8%
distribute-rgt-neg-in95.8%
Simplified95.8%
Taylor expanded in x around 0 72.9%
associate-/l*73.1%
Simplified73.1%
if 9.20000000000000047e39 < y Initial program 85.7%
sub-neg85.7%
+-commutative85.7%
neg-sub085.7%
associate-+l-85.7%
sub0-neg85.7%
neg-mul-185.7%
associate-/l*85.7%
associate-/r/85.7%
*-commutative85.7%
sub-neg85.7%
+-commutative85.7%
neg-sub085.7%
associate-+l-85.7%
sub0-neg85.7%
distribute-lft-neg-out85.7%
distribute-rgt-neg-in85.7%
Simplified85.7%
Taylor expanded in x around 0 83.7%
Taylor expanded in t around 0 62.1%
associate-*r/62.1%
*-commutative62.1%
associate-/l*62.1%
associate-*r/71.9%
associate-/l*71.9%
associate-*r/72.0%
Simplified72.0%
Final simplification69.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= y -1.15e-69) (* y (/ (* x 0.5) a)) (if (<= y 1e+40) (* -4.5 (/ t (/ a z))) (* (/ y a) (* x 0.5)))))
assert(x < y);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= -1.15e-69) {
tmp = y * ((x * 0.5) / a);
} else if (y <= 1e+40) {
tmp = -4.5 * (t / (a / z));
} else {
tmp = (y / a) * (x * 0.5);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a)
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) :: tmp
if (y <= (-1.15d-69)) then
tmp = y * ((x * 0.5d0) / a)
else if (y <= 1d+40) then
tmp = (-4.5d0) * (t / (a / z))
else
tmp = (y / a) * (x * 0.5d0)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= -1.15e-69) {
tmp = y * ((x * 0.5) / a);
} else if (y <= 1e+40) {
tmp = -4.5 * (t / (a / z));
} else {
tmp = (y / a) * (x * 0.5);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): tmp = 0 if y <= -1.15e-69: tmp = y * ((x * 0.5) / a) elif y <= 1e+40: tmp = -4.5 * (t / (a / z)) else: tmp = (y / a) * (x * 0.5) return tmp
x, y = sort([x, y]) function code(x, y, z, t, a) tmp = 0.0 if (y <= -1.15e-69) tmp = Float64(y * Float64(Float64(x * 0.5) / a)); elseif (y <= 1e+40) tmp = Float64(-4.5 * Float64(t / Float64(a / z))); else tmp = Float64(Float64(y / a) * Float64(x * 0.5)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if (y <= -1.15e-69)
tmp = y * ((x * 0.5) / a);
elseif (y <= 1e+40)
tmp = -4.5 * (t / (a / z));
else
tmp = (y / a) * (x * 0.5);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[y, -1.15e-69], N[(y * N[(N[(x * 0.5), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1e+40], N[(-4.5 * N[(t / N[(a / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.15 \cdot 10^{-69}:\\
\;\;\;\;y \cdot \frac{x \cdot 0.5}{a}\\
\mathbf{elif}\;y \leq 10^{+40}:\\
\;\;\;\;-4.5 \cdot \frac{t}{\frac{a}{z}}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} \cdot \left(x \cdot 0.5\right)\\
\end{array}
\end{array}
if y < -1.15e-69Initial program 86.9%
sub-neg86.9%
+-commutative86.9%
neg-sub086.9%
associate-+l-86.9%
sub0-neg86.9%
neg-mul-186.9%
associate-/l*86.3%
associate-/r/87.0%
*-commutative87.0%
sub-neg87.0%
+-commutative87.0%
neg-sub087.0%
associate-+l-87.0%
sub0-neg87.0%
distribute-lft-neg-out87.0%
distribute-rgt-neg-in87.0%
Simplified86.9%
Taylor expanded in x around inf 57.4%
associate-*r/57.4%
*-commutative57.4%
associate-*l/57.4%
associate-*r*63.3%
*-commutative63.3%
associate-*l/63.4%
Simplified63.4%
if -1.15e-69 < y < 1.00000000000000003e40Initial program 95.6%
sub-neg95.6%
+-commutative95.6%
neg-sub095.6%
associate-+l-95.6%
sub0-neg95.6%
neg-mul-195.6%
associate-/l*95.5%
associate-/r/95.7%
*-commutative95.7%
sub-neg95.7%
+-commutative95.7%
neg-sub095.7%
associate-+l-95.7%
sub0-neg95.7%
distribute-lft-neg-out95.7%
distribute-rgt-neg-in95.7%
Simplified95.7%
Taylor expanded in x around 0 72.7%
associate-/l*72.9%
Simplified72.9%
if 1.00000000000000003e40 < y Initial program 85.7%
sub-neg85.7%
+-commutative85.7%
neg-sub085.7%
associate-+l-85.7%
sub0-neg85.7%
neg-mul-185.7%
associate-/l*85.7%
associate-/r/85.7%
*-commutative85.7%
sub-neg85.7%
+-commutative85.7%
neg-sub085.7%
associate-+l-85.7%
sub0-neg85.7%
distribute-lft-neg-out85.7%
distribute-rgt-neg-in85.7%
Simplified85.7%
Taylor expanded in x around inf 62.1%
associate-*r/62.1%
associate-*l*62.1%
Applied egg-rr62.1%
associate-/l*72.2%
associate-/r/74.2%
Applied egg-rr74.2%
Final simplification69.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= y -1.3e-67) (* y (/ (* x 0.5) a)) (if (<= y 5.8e+39) (/ -4.5 (/ (/ a z) t)) (* (/ y a) (* x 0.5)))))
assert(x < y);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= -1.3e-67) {
tmp = y * ((x * 0.5) / a);
} else if (y <= 5.8e+39) {
tmp = -4.5 / ((a / z) / t);
} else {
tmp = (y / a) * (x * 0.5);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a)
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) :: tmp
if (y <= (-1.3d-67)) then
tmp = y * ((x * 0.5d0) / a)
else if (y <= 5.8d+39) then
tmp = (-4.5d0) / ((a / z) / t)
else
tmp = (y / a) * (x * 0.5d0)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= -1.3e-67) {
tmp = y * ((x * 0.5) / a);
} else if (y <= 5.8e+39) {
tmp = -4.5 / ((a / z) / t);
} else {
tmp = (y / a) * (x * 0.5);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): tmp = 0 if y <= -1.3e-67: tmp = y * ((x * 0.5) / a) elif y <= 5.8e+39: tmp = -4.5 / ((a / z) / t) else: tmp = (y / a) * (x * 0.5) return tmp
x, y = sort([x, y]) function code(x, y, z, t, a) tmp = 0.0 if (y <= -1.3e-67) tmp = Float64(y * Float64(Float64(x * 0.5) / a)); elseif (y <= 5.8e+39) tmp = Float64(-4.5 / Float64(Float64(a / z) / t)); else tmp = Float64(Float64(y / a) * Float64(x * 0.5)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if (y <= -1.3e-67)
tmp = y * ((x * 0.5) / a);
elseif (y <= 5.8e+39)
tmp = -4.5 / ((a / z) / t);
else
tmp = (y / a) * (x * 0.5);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[y, -1.3e-67], N[(y * N[(N[(x * 0.5), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.8e+39], N[(-4.5 / N[(N[(a / z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.3 \cdot 10^{-67}:\\
\;\;\;\;y \cdot \frac{x \cdot 0.5}{a}\\
\mathbf{elif}\;y \leq 5.8 \cdot 10^{+39}:\\
\;\;\;\;\frac{-4.5}{\frac{\frac{a}{z}}{t}}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} \cdot \left(x \cdot 0.5\right)\\
\end{array}
\end{array}
if y < -1.2999999999999999e-67Initial program 86.8%
sub-neg86.8%
+-commutative86.8%
neg-sub086.8%
associate-+l-86.8%
sub0-neg86.8%
neg-mul-186.8%
associate-/l*86.1%
associate-/r/86.8%
*-commutative86.8%
sub-neg86.8%
+-commutative86.8%
neg-sub086.8%
associate-+l-86.8%
sub0-neg86.8%
distribute-lft-neg-out86.8%
distribute-rgt-neg-in86.8%
Simplified86.7%
Taylor expanded in x around inf 58.0%
associate-*r/58.0%
*-commutative58.0%
associate-*l/58.0%
associate-*r*64.0%
*-commutative64.0%
associate-*l/64.1%
Simplified64.1%
if -1.2999999999999999e-67 < y < 5.80000000000000059e39Initial program 95.7%
sub-neg95.7%
+-commutative95.7%
neg-sub095.7%
associate-+l-95.7%
sub0-neg95.7%
neg-mul-195.7%
associate-/l*95.6%
associate-/r/95.8%
*-commutative95.8%
sub-neg95.8%
+-commutative95.8%
neg-sub095.8%
associate-+l-95.8%
sub0-neg95.8%
distribute-lft-neg-out95.8%
distribute-rgt-neg-in95.8%
Simplified95.8%
Taylor expanded in x around 0 72.9%
associate-/l*73.1%
Simplified73.1%
clear-num73.0%
un-div-inv73.1%
Applied egg-rr73.1%
if 5.80000000000000059e39 < y Initial program 85.7%
sub-neg85.7%
+-commutative85.7%
neg-sub085.7%
associate-+l-85.7%
sub0-neg85.7%
neg-mul-185.7%
associate-/l*85.7%
associate-/r/85.7%
*-commutative85.7%
sub-neg85.7%
+-commutative85.7%
neg-sub085.7%
associate-+l-85.7%
sub0-neg85.7%
distribute-lft-neg-out85.7%
distribute-rgt-neg-in85.7%
Simplified85.7%
Taylor expanded in x around inf 62.1%
associate-*r/62.1%
associate-*l*62.1%
Applied egg-rr62.1%
associate-/l*72.2%
associate-/r/74.2%
Applied egg-rr74.2%
Final simplification70.2%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= y -1.3e-67) (* y (/ (* x 0.5) a)) (if (<= y 5.5e+39) (/ (* t (* z -4.5)) a) (* (/ y a) (* x 0.5)))))
assert(x < y);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= -1.3e-67) {
tmp = y * ((x * 0.5) / a);
} else if (y <= 5.5e+39) {
tmp = (t * (z * -4.5)) / a;
} else {
tmp = (y / a) * (x * 0.5);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a)
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) :: tmp
if (y <= (-1.3d-67)) then
tmp = y * ((x * 0.5d0) / a)
else if (y <= 5.5d+39) then
tmp = (t * (z * (-4.5d0))) / a
else
tmp = (y / a) * (x * 0.5d0)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= -1.3e-67) {
tmp = y * ((x * 0.5) / a);
} else if (y <= 5.5e+39) {
tmp = (t * (z * -4.5)) / a;
} else {
tmp = (y / a) * (x * 0.5);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): tmp = 0 if y <= -1.3e-67: tmp = y * ((x * 0.5) / a) elif y <= 5.5e+39: tmp = (t * (z * -4.5)) / a else: tmp = (y / a) * (x * 0.5) return tmp
x, y = sort([x, y]) function code(x, y, z, t, a) tmp = 0.0 if (y <= -1.3e-67) tmp = Float64(y * Float64(Float64(x * 0.5) / a)); elseif (y <= 5.5e+39) tmp = Float64(Float64(t * Float64(z * -4.5)) / a); else tmp = Float64(Float64(y / a) * Float64(x * 0.5)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if (y <= -1.3e-67)
tmp = y * ((x * 0.5) / a);
elseif (y <= 5.5e+39)
tmp = (t * (z * -4.5)) / a;
else
tmp = (y / a) * (x * 0.5);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[y, -1.3e-67], N[(y * N[(N[(x * 0.5), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.5e+39], N[(N[(t * N[(z * -4.5), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.3 \cdot 10^{-67}:\\
\;\;\;\;y \cdot \frac{x \cdot 0.5}{a}\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{+39}:\\
\;\;\;\;\frac{t \cdot \left(z \cdot -4.5\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} \cdot \left(x \cdot 0.5\right)\\
\end{array}
\end{array}
if y < -1.2999999999999999e-67Initial program 86.8%
sub-neg86.8%
+-commutative86.8%
neg-sub086.8%
associate-+l-86.8%
sub0-neg86.8%
neg-mul-186.8%
associate-/l*86.1%
associate-/r/86.8%
*-commutative86.8%
sub-neg86.8%
+-commutative86.8%
neg-sub086.8%
associate-+l-86.8%
sub0-neg86.8%
distribute-lft-neg-out86.8%
distribute-rgt-neg-in86.8%
Simplified86.7%
Taylor expanded in x around inf 58.0%
associate-*r/58.0%
*-commutative58.0%
associate-*l/58.0%
associate-*r*64.0%
*-commutative64.0%
associate-*l/64.1%
Simplified64.1%
if -1.2999999999999999e-67 < y < 5.4999999999999997e39Initial program 95.7%
sub-neg95.7%
+-commutative95.7%
neg-sub095.7%
associate-+l-95.7%
sub0-neg95.7%
neg-mul-195.7%
associate-/l*95.6%
associate-/r/95.8%
*-commutative95.8%
sub-neg95.8%
+-commutative95.8%
neg-sub095.8%
associate-+l-95.8%
sub0-neg95.8%
distribute-lft-neg-out95.8%
distribute-rgt-neg-in95.8%
Simplified95.8%
Taylor expanded in x around 0 72.9%
associate-*r/72.9%
*-commutative72.9%
associate-*r*72.9%
Simplified72.9%
if 5.4999999999999997e39 < y Initial program 85.7%
sub-neg85.7%
+-commutative85.7%
neg-sub085.7%
associate-+l-85.7%
sub0-neg85.7%
neg-mul-185.7%
associate-/l*85.7%
associate-/r/85.7%
*-commutative85.7%
sub-neg85.7%
+-commutative85.7%
neg-sub085.7%
associate-+l-85.7%
sub0-neg85.7%
distribute-lft-neg-out85.7%
distribute-rgt-neg-in85.7%
Simplified85.7%
Taylor expanded in x around inf 62.1%
associate-*r/62.1%
associate-*l*62.1%
Applied egg-rr62.1%
associate-/l*72.2%
associate-/r/74.2%
Applied egg-rr74.2%
Final simplification70.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (* -4.5 (/ t (/ a z))))
assert(x < y);
double code(double x, double y, double z, double t, double a) {
return -4.5 * (t / (a / z));
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a)
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
code = (-4.5d0) * (t / (a / z))
end function
assert x < y;
public static double code(double x, double y, double z, double t, double a) {
return -4.5 * (t / (a / z));
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): return -4.5 * (t / (a / z))
x, y = sort([x, y]) function code(x, y, z, t, a) return Float64(-4.5 * Float64(t / Float64(a / z))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z, t, a)
tmp = -4.5 * (t / (a / z));
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := N[(-4.5 * N[(t / N[(a / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
-4.5 \cdot \frac{t}{\frac{a}{z}}
\end{array}
Initial program 90.8%
sub-neg90.8%
+-commutative90.8%
neg-sub090.8%
associate-+l-90.8%
sub0-neg90.8%
neg-mul-190.8%
associate-/l*90.5%
associate-/r/90.8%
*-commutative90.8%
sub-neg90.8%
+-commutative90.8%
neg-sub090.8%
associate-+l-90.8%
sub0-neg90.8%
distribute-lft-neg-out90.8%
distribute-rgt-neg-in90.8%
Simplified90.8%
Taylor expanded in x around 0 52.7%
associate-/l*52.8%
Simplified52.8%
Final simplification52.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (* -4.5 (/ (* t z) a)))
assert(x < y);
double code(double x, double y, double z, double t, double a) {
return -4.5 * ((t * z) / a);
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a)
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
code = (-4.5d0) * ((t * z) / a)
end function
assert x < y;
public static double code(double x, double y, double z, double t, double a) {
return -4.5 * ((t * z) / a);
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): return -4.5 * ((t * z) / a)
x, y = sort([x, y]) function code(x, y, z, t, a) return Float64(-4.5 * Float64(Float64(t * z) / a)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z, t, a)
tmp = -4.5 * ((t * z) / a);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := N[(-4.5 * N[(N[(t * z), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
-4.5 \cdot \frac{t \cdot z}{a}
\end{array}
Initial program 90.8%
sub-neg90.8%
+-commutative90.8%
neg-sub090.8%
associate-+l-90.8%
sub0-neg90.8%
neg-mul-190.8%
associate-/l*90.5%
associate-/r/90.8%
*-commutative90.8%
sub-neg90.8%
+-commutative90.8%
neg-sub090.8%
associate-+l-90.8%
sub0-neg90.8%
distribute-lft-neg-out90.8%
distribute-rgt-neg-in90.8%
Simplified90.8%
Taylor expanded in x around 0 52.7%
Final simplification52.7%
(FPCore (x y z t a)
:precision binary64
(if (< a -2.090464557976709e+86)
(- (* 0.5 (/ (* y x) a)) (* 4.5 (/ t (/ a z))))
(if (< a 2.144030707833976e+99)
(/ (- (* x y) (* z (* 9.0 t))) (* a 2.0))
(- (* (/ y a) (* x 0.5)) (* (/ t a) (* z 4.5))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a < -2.090464557976709e+86) {
tmp = (0.5 * ((y * x) / a)) - (4.5 * (t / (a / z)));
} else if (a < 2.144030707833976e+99) {
tmp = ((x * y) - (z * (9.0 * t))) / (a * 2.0);
} else {
tmp = ((y / a) * (x * 0.5)) - ((t / a) * (z * 4.5));
}
return tmp;
}
real(8) function code(x, y, z, t, a)
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) :: tmp
if (a < (-2.090464557976709d+86)) then
tmp = (0.5d0 * ((y * x) / a)) - (4.5d0 * (t / (a / z)))
else if (a < 2.144030707833976d+99) then
tmp = ((x * y) - (z * (9.0d0 * t))) / (a * 2.0d0)
else
tmp = ((y / a) * (x * 0.5d0)) - ((t / a) * (z * 4.5d0))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (a < -2.090464557976709e+86) {
tmp = (0.5 * ((y * x) / a)) - (4.5 * (t / (a / z)));
} else if (a < 2.144030707833976e+99) {
tmp = ((x * y) - (z * (9.0 * t))) / (a * 2.0);
} else {
tmp = ((y / a) * (x * 0.5)) - ((t / a) * (z * 4.5));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a < -2.090464557976709e+86: tmp = (0.5 * ((y * x) / a)) - (4.5 * (t / (a / z))) elif a < 2.144030707833976e+99: tmp = ((x * y) - (z * (9.0 * t))) / (a * 2.0) else: tmp = ((y / a) * (x * 0.5)) - ((t / a) * (z * 4.5)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a < -2.090464557976709e+86) tmp = Float64(Float64(0.5 * Float64(Float64(y * x) / a)) - Float64(4.5 * Float64(t / Float64(a / z)))); elseif (a < 2.144030707833976e+99) tmp = Float64(Float64(Float64(x * y) - Float64(z * Float64(9.0 * t))) / Float64(a * 2.0)); else tmp = Float64(Float64(Float64(y / a) * Float64(x * 0.5)) - Float64(Float64(t / a) * Float64(z * 4.5))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a < -2.090464557976709e+86) tmp = (0.5 * ((y * x) / a)) - (4.5 * (t / (a / z))); elseif (a < 2.144030707833976e+99) tmp = ((x * y) - (z * (9.0 * t))) / (a * 2.0); else tmp = ((y / a) * (x * 0.5)) - ((t / a) * (z * 4.5)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Less[a, -2.090464557976709e+86], N[(N[(0.5 * N[(N[(y * x), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] - N[(4.5 * N[(t / N[(a / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Less[a, 2.144030707833976e+99], N[(N[(N[(x * y), $MachinePrecision] - N[(z * N[(9.0 * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y / a), $MachinePrecision] * N[(x * 0.5), $MachinePrecision]), $MachinePrecision] - N[(N[(t / a), $MachinePrecision] * N[(z * 4.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a < -2.090464557976709 \cdot 10^{+86}:\\
\;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\
\mathbf{elif}\;a < 2.144030707833976 \cdot 10^{+99}:\\
\;\;\;\;\frac{x \cdot y - z \cdot \left(9 \cdot t\right)}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} \cdot \left(x \cdot 0.5\right) - \frac{t}{a} \cdot \left(z \cdot 4.5\right)\\
\end{array}
\end{array}
herbie shell --seed 2023200
(FPCore (x y z t a)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, I"
:precision binary64
:herbie-target
(if (< a -2.090464557976709e+86) (- (* 0.5 (/ (* y x) a)) (* 4.5 (/ t (/ a z)))) (if (< a 2.144030707833976e+99) (/ (- (* x y) (* z (* 9.0 t))) (* a 2.0)) (- (* (/ y a) (* x 0.5)) (* (/ t a) (* z 4.5)))))
(/ (- (* x y) (* (* z 9.0) t)) (* a 2.0)))