
(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 7 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}
(FPCore (x y z t a) :precision binary64 (if (<= (* (* z 9.0) t) -5e+202) (* z (+ (* -4.5 (/ t a)) (* 0.5 (/ (* x y) (* z a))))) (* (fma z (* t -9.0) (* x y)) (/ 0.5 a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((z * 9.0) * t) <= -5e+202) {
tmp = z * ((-4.5 * (t / a)) + (0.5 * ((x * y) / (z * a))));
} else {
tmp = fma(z, (t * -9.0), (x * y)) * (0.5 / a);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (Float64(Float64(z * 9.0) * t) <= -5e+202) tmp = Float64(z * Float64(Float64(-4.5 * Float64(t / a)) + Float64(0.5 * Float64(Float64(x * y) / Float64(z * a))))); else tmp = Float64(fma(z, Float64(t * -9.0), Float64(x * y)) * Float64(0.5 / a)); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(N[(z * 9.0), $MachinePrecision] * t), $MachinePrecision], -5e+202], N[(z * N[(N[(-4.5 * N[(t / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(N[(x * y), $MachinePrecision] / N[(z * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z * N[(t * -9.0), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(z \cdot 9\right) \cdot t \leq -5 \cdot 10^{+202}:\\
\;\;\;\;z \cdot \left(-4.5 \cdot \frac{t}{a} + 0.5 \cdot \frac{x \cdot y}{z \cdot a}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t \cdot -9, x \cdot y\right) \cdot \frac{0.5}{a}\\
\end{array}
\end{array}
if (*.f64 (*.f64 z #s(literal 9 binary64)) t) < -4.9999999999999999e202Initial program 77.7%
div-sub74.4%
*-commutative74.4%
div-sub77.7%
cancel-sign-sub-inv77.7%
*-commutative77.7%
fma-define77.7%
distribute-rgt-neg-in77.7%
associate-*r*77.6%
distribute-lft-neg-in77.6%
*-commutative77.6%
distribute-rgt-neg-in77.6%
metadata-eval77.6%
Simplified77.6%
Taylor expanded in z around inf 99.8%
if -4.9999999999999999e202 < (*.f64 (*.f64 z #s(literal 9 binary64)) t) Initial program 93.8%
div-sub92.9%
*-commutative92.9%
div-sub93.8%
cancel-sign-sub-inv93.8%
*-commutative93.8%
fma-define93.8%
distribute-rgt-neg-in93.8%
associate-*r*93.8%
distribute-lft-neg-in93.8%
*-commutative93.8%
distribute-rgt-neg-in93.8%
metadata-eval93.8%
Simplified93.8%
Taylor expanded in a around 0 93.8%
associate-*r/93.8%
+-commutative93.8%
metadata-eval93.8%
cancel-sign-sub-inv93.8%
cancel-sign-sub-inv93.8%
metadata-eval93.8%
*-commutative93.8%
*-commutative93.8%
associate-*r*93.8%
fma-define93.8%
associate-*l/93.8%
*-commutative93.8%
fma-define93.8%
+-commutative93.8%
fma-define94.2%
Simplified94.2%
Final simplification94.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (* z 9.0) t)))
(if (<= t_1 (- INFINITY))
(* t (* -4.5 (/ z a)))
(/ (- (* x y) t_1) (* a 2.0)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (z * 9.0) * t;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t * (-4.5 * (z / a));
} else {
tmp = ((x * y) - t_1) / (a * 2.0);
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (z * 9.0) * t;
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = t * (-4.5 * (z / a));
} else {
tmp = ((x * y) - t_1) / (a * 2.0);
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (z * 9.0) * t tmp = 0 if t_1 <= -math.inf: tmp = t * (-4.5 * (z / a)) else: tmp = ((x * y) - t_1) / (a * 2.0) return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(z * 9.0) * t) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(t * Float64(-4.5 * Float64(z / a))); else tmp = Float64(Float64(Float64(x * y) - t_1) / Float64(a * 2.0)); end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (z * 9.0) * t; tmp = 0.0; if (t_1 <= -Inf) tmp = t * (-4.5 * (z / a)); else tmp = ((x * y) - t_1) / (a * 2.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z * 9.0), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(t * N[(-4.5 * N[(z / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * y), $MachinePrecision] - t$95$1), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(z \cdot 9\right) \cdot t\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;t \cdot \left(-4.5 \cdot \frac{z}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y - t\_1}{a \cdot 2}\\
\end{array}
\end{array}
if (*.f64 (*.f64 z #s(literal 9 binary64)) t) < -inf.0Initial program 60.9%
div-sub60.9%
*-commutative60.9%
div-sub60.9%
cancel-sign-sub-inv60.9%
*-commutative60.9%
fma-define60.9%
distribute-rgt-neg-in60.9%
associate-*r*60.9%
distribute-lft-neg-in60.9%
*-commutative60.9%
distribute-rgt-neg-in60.9%
metadata-eval60.9%
Simplified60.9%
Taylor expanded in x around 0 60.9%
*-commutative60.9%
associate-/l*99.7%
associate-*r*99.8%
*-commutative99.8%
Simplified99.8%
if -inf.0 < (*.f64 (*.f64 z #s(literal 9 binary64)) t) Initial program 94.1%
(FPCore (x y z t a) :precision binary64 (if (or (<= (* x y) -2e+64) (not (<= (* x y) 5e-6))) (* y (* 0.5 (/ x a))) (* -4.5 (/ (* z t) a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((x * y) <= -2e+64) || !((x * y) <= 5e-6)) {
tmp = y * (0.5 * (x / a));
} else {
tmp = -4.5 * ((z * t) / a);
}
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 (((x * y) <= (-2d+64)) .or. (.not. ((x * y) <= 5d-6))) then
tmp = y * (0.5d0 * (x / a))
else
tmp = (-4.5d0) * ((z * t) / a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (((x * y) <= -2e+64) || !((x * y) <= 5e-6)) {
tmp = y * (0.5 * (x / a));
} else {
tmp = -4.5 * ((z * t) / a);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if ((x * y) <= -2e+64) or not ((x * y) <= 5e-6): tmp = y * (0.5 * (x / a)) else: tmp = -4.5 * ((z * t) / a) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((Float64(x * y) <= -2e+64) || !(Float64(x * y) <= 5e-6)) tmp = Float64(y * Float64(0.5 * Float64(x / a))); else tmp = Float64(-4.5 * Float64(Float64(z * t) / a)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (((x * y) <= -2e+64) || ~(((x * y) <= 5e-6))) tmp = y * (0.5 * (x / a)); else tmp = -4.5 * ((z * t) / a); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -2e+64], N[Not[LessEqual[N[(x * y), $MachinePrecision], 5e-6]], $MachinePrecision]], N[(y * N[(0.5 * N[(x / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.5 * N[(N[(z * t), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+64} \lor \neg \left(x \cdot y \leq 5 \cdot 10^{-6}\right):\\
\;\;\;\;y \cdot \left(0.5 \cdot \frac{x}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;-4.5 \cdot \frac{z \cdot t}{a}\\
\end{array}
\end{array}
if (*.f64 x y) < -2.00000000000000004e64 or 5.00000000000000041e-6 < (*.f64 x y) Initial program 90.0%
div-sub87.7%
*-commutative87.7%
div-sub90.0%
cancel-sign-sub-inv90.0%
*-commutative90.0%
fma-define90.0%
distribute-rgt-neg-in90.0%
associate-*r*90.0%
distribute-lft-neg-in90.0%
*-commutative90.0%
distribute-rgt-neg-in90.0%
metadata-eval90.0%
Simplified90.0%
Taylor expanded in x around inf 77.7%
associate-/l*79.1%
Simplified79.1%
associate-*r*79.1%
clear-num79.0%
un-div-inv79.1%
Applied egg-rr79.1%
associate-/r/78.3%
associate-/l*77.6%
Applied egg-rr77.6%
if -2.00000000000000004e64 < (*.f64 x y) < 5.00000000000000041e-6Initial program 93.8%
div-sub93.8%
*-commutative93.8%
div-sub93.8%
cancel-sign-sub-inv93.8%
*-commutative93.8%
fma-define93.8%
distribute-rgt-neg-in93.8%
associate-*r*93.8%
distribute-lft-neg-in93.8%
*-commutative93.8%
distribute-rgt-neg-in93.8%
metadata-eval93.8%
Simplified93.8%
Taylor expanded in x around 0 77.6%
Final simplification77.6%
(FPCore (x y z t a) :precision binary64 (if (<= (* x y) 1e+235) (* (/ 0.5 a) (+ (* x y) (* z (* t -9.0)))) (/ (* 0.5 x) (/ a y))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= 1e+235) {
tmp = (0.5 / a) * ((x * y) + (z * (t * -9.0)));
} else {
tmp = (0.5 * x) / (a / y);
}
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 ((x * y) <= 1d+235) then
tmp = (0.5d0 / a) * ((x * y) + (z * (t * (-9.0d0))))
else
tmp = (0.5d0 * x) / (a / y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= 1e+235) {
tmp = (0.5 / a) * ((x * y) + (z * (t * -9.0)));
} else {
tmp = (0.5 * x) / (a / y);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (x * y) <= 1e+235: tmp = (0.5 / a) * ((x * y) + (z * (t * -9.0))) else: tmp = (0.5 * x) / (a / y) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= 1e+235) tmp = Float64(Float64(0.5 / a) * Float64(Float64(x * y) + Float64(z * Float64(t * -9.0)))); else tmp = Float64(Float64(0.5 * x) / Float64(a / y)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((x * y) <= 1e+235) tmp = (0.5 / a) * ((x * y) + (z * (t * -9.0))); else tmp = (0.5 * x) / (a / y); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], 1e+235], N[(N[(0.5 / a), $MachinePrecision] * N[(N[(x * y), $MachinePrecision] + N[(z * N[(t * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * x), $MachinePrecision] / N[(a / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq 10^{+235}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(x \cdot y + z \cdot \left(t \cdot -9\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 \cdot x}{\frac{a}{y}}\\
\end{array}
\end{array}
if (*.f64 x y) < 1.0000000000000001e235Initial program 93.1%
div-sub92.2%
*-commutative92.2%
div-sub93.1%
cancel-sign-sub-inv93.1%
*-commutative93.1%
fma-define93.1%
distribute-rgt-neg-in93.1%
associate-*r*93.1%
distribute-lft-neg-in93.1%
*-commutative93.1%
distribute-rgt-neg-in93.1%
metadata-eval93.1%
Simplified93.1%
Taylor expanded in a around 0 93.1%
associate-*r/93.1%
+-commutative93.1%
metadata-eval93.1%
cancel-sign-sub-inv93.1%
cancel-sign-sub-inv93.1%
metadata-eval93.1%
*-commutative93.1%
*-commutative93.1%
associate-*r*93.1%
fma-define93.1%
associate-*l/93.0%
*-commutative93.0%
fma-define93.0%
+-commutative93.0%
fma-define93.0%
Simplified93.0%
fma-undefine93.0%
Applied egg-rr93.0%
if 1.0000000000000001e235 < (*.f64 x y) Initial program 82.0%
div-sub78.3%
*-commutative78.3%
div-sub82.0%
cancel-sign-sub-inv82.0%
*-commutative82.0%
fma-define82.0%
distribute-rgt-neg-in82.0%
associate-*r*82.0%
distribute-lft-neg-in82.0%
*-commutative82.0%
distribute-rgt-neg-in82.0%
metadata-eval82.0%
Simplified82.0%
Taylor expanded in x around inf 85.9%
associate-/l*99.8%
Simplified99.8%
associate-*r*99.8%
clear-num99.8%
un-div-inv99.9%
Applied egg-rr99.9%
Final simplification93.8%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1.28e+70) (not (<= z 3.5e-104))) (* t (* -4.5 (/ z a))) (* 0.5 (* x (/ y a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.28e+70) || !(z <= 3.5e-104)) {
tmp = t * (-4.5 * (z / a));
} else {
tmp = 0.5 * (x * (y / a));
}
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 ((z <= (-1.28d+70)) .or. (.not. (z <= 3.5d-104))) then
tmp = t * ((-4.5d0) * (z / a))
else
tmp = 0.5d0 * (x * (y / a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.28e+70) || !(z <= 3.5e-104)) {
tmp = t * (-4.5 * (z / a));
} else {
tmp = 0.5 * (x * (y / a));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -1.28e+70) or not (z <= 3.5e-104): tmp = t * (-4.5 * (z / a)) else: tmp = 0.5 * (x * (y / a)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -1.28e+70) || !(z <= 3.5e-104)) tmp = Float64(t * Float64(-4.5 * Float64(z / a))); else tmp = Float64(0.5 * Float64(x * Float64(y / a))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -1.28e+70) || ~((z <= 3.5e-104))) tmp = t * (-4.5 * (z / a)); else tmp = 0.5 * (x * (y / a)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -1.28e+70], N[Not[LessEqual[z, 3.5e-104]], $MachinePrecision]], N[(t * N[(-4.5 * N[(z / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.28 \cdot 10^{+70} \lor \neg \left(z \leq 3.5 \cdot 10^{-104}\right):\\
\;\;\;\;t \cdot \left(-4.5 \cdot \frac{z}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\
\end{array}
\end{array}
if z < -1.27999999999999994e70 or 3.50000000000000029e-104 < z Initial program 89.4%
div-sub87.1%
*-commutative87.1%
div-sub89.4%
cancel-sign-sub-inv89.4%
*-commutative89.4%
fma-define89.4%
distribute-rgt-neg-in89.4%
associate-*r*89.4%
distribute-lft-neg-in89.4%
*-commutative89.4%
distribute-rgt-neg-in89.4%
metadata-eval89.4%
Simplified89.4%
Taylor expanded in x around 0 65.1%
*-commutative65.1%
associate-/l*73.0%
associate-*r*73.0%
*-commutative73.0%
Simplified73.0%
if -1.27999999999999994e70 < z < 3.50000000000000029e-104Initial program 94.5%
div-sub94.5%
*-commutative94.5%
div-sub94.5%
cancel-sign-sub-inv94.5%
*-commutative94.5%
fma-define94.5%
distribute-rgt-neg-in94.5%
associate-*r*94.5%
distribute-lft-neg-in94.5%
*-commutative94.5%
distribute-rgt-neg-in94.5%
metadata-eval94.5%
Simplified94.5%
Taylor expanded in x around inf 71.9%
associate-/l*71.8%
Simplified71.8%
Final simplification72.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1.05e+70) (not (<= z 2.3e-109))) (* -4.5 (* t (/ z a))) (* 0.5 (* x (/ y a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.05e+70) || !(z <= 2.3e-109)) {
tmp = -4.5 * (t * (z / a));
} else {
tmp = 0.5 * (x * (y / a));
}
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 ((z <= (-1.05d+70)) .or. (.not. (z <= 2.3d-109))) then
tmp = (-4.5d0) * (t * (z / a))
else
tmp = 0.5d0 * (x * (y / a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.05e+70) || !(z <= 2.3e-109)) {
tmp = -4.5 * (t * (z / a));
} else {
tmp = 0.5 * (x * (y / a));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -1.05e+70) or not (z <= 2.3e-109): tmp = -4.5 * (t * (z / a)) else: tmp = 0.5 * (x * (y / a)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -1.05e+70) || !(z <= 2.3e-109)) tmp = Float64(-4.5 * Float64(t * Float64(z / a))); else tmp = Float64(0.5 * Float64(x * Float64(y / a))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -1.05e+70) || ~((z <= 2.3e-109))) tmp = -4.5 * (t * (z / a)); else tmp = 0.5 * (x * (y / a)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -1.05e+70], N[Not[LessEqual[z, 2.3e-109]], $MachinePrecision]], N[(-4.5 * N[(t * N[(z / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05 \cdot 10^{+70} \lor \neg \left(z \leq 2.3 \cdot 10^{-109}\right):\\
\;\;\;\;-4.5 \cdot \left(t \cdot \frac{z}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\
\end{array}
\end{array}
if z < -1.05000000000000004e70 or 2.3000000000000001e-109 < z Initial program 89.4%
div-sub87.1%
*-commutative87.1%
div-sub89.4%
cancel-sign-sub-inv89.4%
*-commutative89.4%
fma-define89.4%
distribute-rgt-neg-in89.4%
associate-*r*89.4%
distribute-lft-neg-in89.4%
*-commutative89.4%
distribute-rgt-neg-in89.4%
metadata-eval89.4%
Simplified89.4%
Taylor expanded in x around 0 65.1%
associate-/l*73.0%
Simplified73.0%
if -1.05000000000000004e70 < z < 2.3000000000000001e-109Initial program 94.5%
div-sub94.5%
*-commutative94.5%
div-sub94.5%
cancel-sign-sub-inv94.5%
*-commutative94.5%
fma-define94.5%
distribute-rgt-neg-in94.5%
associate-*r*94.5%
distribute-lft-neg-in94.5%
*-commutative94.5%
distribute-rgt-neg-in94.5%
metadata-eval94.5%
Simplified94.5%
Taylor expanded in x around inf 71.9%
associate-/l*71.8%
Simplified71.8%
Final simplification72.4%
(FPCore (x y z t a) :precision binary64 (* -4.5 (* t (/ z a))))
double code(double x, double y, double z, double t, double a) {
return -4.5 * (t * (z / a));
}
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
public static double code(double x, double y, double z, double t, double a) {
return -4.5 * (t * (z / a));
}
def code(x, y, z, t, a): return -4.5 * (t * (z / a))
function code(x, y, z, t, a) return Float64(-4.5 * Float64(t * Float64(z / a))) end
function tmp = code(x, y, z, t, a) tmp = -4.5 * (t * (z / a)); end
code[x_, y_, z_, t_, a_] := N[(-4.5 * N[(t * N[(z / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-4.5 \cdot \left(t \cdot \frac{z}{a}\right)
\end{array}
Initial program 91.9%
div-sub90.8%
*-commutative90.8%
div-sub91.9%
cancel-sign-sub-inv91.9%
*-commutative91.9%
fma-define91.9%
distribute-rgt-neg-in91.9%
associate-*r*91.9%
distribute-lft-neg-in91.9%
*-commutative91.9%
distribute-rgt-neg-in91.9%
metadata-eval91.9%
Simplified91.9%
Taylor expanded in x around 0 48.7%
associate-/l*51.1%
Simplified51.1%
(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 2024148
(FPCore (x y z t a)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, I"
:precision binary64
:alt
(! :herbie-platform default (if (< a -209046455797670900000000000000000000000000000000000000000000000000000000000000000000000) (- (* 1/2 (/ (* y x) a)) (* 9/2 (/ t (/ a z)))) (if (< a 2144030707833976000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ (- (* x y) (* z (* 9 t))) (* a 2)) (- (* (/ y a) (* x 1/2)) (* (/ t a) (* z 9/2))))))
(/ (- (* x y) (* (* z 9.0) t)) (* a 2.0)))