
(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 10 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: z and t should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0))))
(if (<= t_1 5e+286)
t_1
(- (* (* x y) (/ 0.5 a)) (* (/ z a) (/ (* 9.0 t) 2.0))))))assert(z < t);
double code(double x, double y, double z, double t, double a) {
double t_1 = ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
double tmp;
if (t_1 <= 5e+286) {
tmp = t_1;
} else {
tmp = ((x * y) * (0.5 / a)) - ((z / a) * ((9.0 * t) / 2.0));
}
return tmp;
}
NOTE: z and t 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) :: t_1
real(8) :: tmp
t_1 = ((x * y) - ((z * 9.0d0) * t)) / (a * 2.0d0)
if (t_1 <= 5d+286) then
tmp = t_1
else
tmp = ((x * y) * (0.5d0 / a)) - ((z / a) * ((9.0d0 * t) / 2.0d0))
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
double t_1 = ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
double tmp;
if (t_1 <= 5e+286) {
tmp = t_1;
} else {
tmp = ((x * y) * (0.5 / a)) - ((z / a) * ((9.0 * t) / 2.0));
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t, a): t_1 = ((x * y) - ((z * 9.0) * t)) / (a * 2.0) tmp = 0 if t_1 <= 5e+286: tmp = t_1 else: tmp = ((x * y) * (0.5 / a)) - ((z / a) * ((9.0 * t) / 2.0)) return tmp
z, t = sort([z, t]) function code(x, y, z, t, a) t_1 = Float64(Float64(Float64(x * y) - Float64(Float64(z * 9.0) * t)) / Float64(a * 2.0)) tmp = 0.0 if (t_1 <= 5e+286) tmp = t_1; else tmp = Float64(Float64(Float64(x * y) * Float64(0.5 / a)) - Float64(Float64(z / a) * Float64(Float64(9.0 * t) / 2.0))); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t, a)
t_1 = ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
tmp = 0.0;
if (t_1 <= 5e+286)
tmp = t_1;
else
tmp = ((x * y) * (0.5 / a)) - ((z / a) * ((9.0 * t) / 2.0));
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(x * y), $MachinePrecision] - N[(N[(z * 9.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e+286], t$95$1, N[(N[(N[(x * y), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision] - N[(N[(z / a), $MachinePrecision] * N[(N[(9.0 * t), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
t_1 := \frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\\
\mathbf{if}\;t_1 \leq 5 \cdot 10^{+286}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot y\right) \cdot \frac{0.5}{a} - \frac{z}{a} \cdot \frac{9 \cdot t}{2}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t)) (*.f64 a 2)) < 5.0000000000000004e286Initial program 97.4%
if 5.0000000000000004e286 < (/.f64 (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t)) (*.f64 a 2)) Initial program 78.3%
associate-*l*80.4%
Simplified80.4%
div-sub80.4%
div-inv80.5%
*-commutative80.5%
associate-/r*80.5%
metadata-eval80.5%
times-frac93.4%
Applied egg-rr93.4%
Final simplification96.7%
NOTE: z and t should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0))))
(if (<= t_1 5e+265)
t_1
(+ (/ z (* (/ a t) -0.2222222222222222)) (* 0.5 (/ (* x y) a))))))assert(z < t);
double code(double x, double y, double z, double t, double a) {
double t_1 = ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
double tmp;
if (t_1 <= 5e+265) {
tmp = t_1;
} else {
tmp = (z / ((a / t) * -0.2222222222222222)) + (0.5 * ((x * y) / a));
}
return tmp;
}
NOTE: z and t 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) :: t_1
real(8) :: tmp
t_1 = ((x * y) - ((z * 9.0d0) * t)) / (a * 2.0d0)
if (t_1 <= 5d+265) then
tmp = t_1
else
tmp = (z / ((a / t) * (-0.2222222222222222d0))) + (0.5d0 * ((x * y) / a))
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
double t_1 = ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
double tmp;
if (t_1 <= 5e+265) {
tmp = t_1;
} else {
tmp = (z / ((a / t) * -0.2222222222222222)) + (0.5 * ((x * y) / a));
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t, a): t_1 = ((x * y) - ((z * 9.0) * t)) / (a * 2.0) tmp = 0 if t_1 <= 5e+265: tmp = t_1 else: tmp = (z / ((a / t) * -0.2222222222222222)) + (0.5 * ((x * y) / a)) return tmp
z, t = sort([z, t]) function code(x, y, z, t, a) t_1 = Float64(Float64(Float64(x * y) - Float64(Float64(z * 9.0) * t)) / Float64(a * 2.0)) tmp = 0.0 if (t_1 <= 5e+265) tmp = t_1; else tmp = Float64(Float64(z / Float64(Float64(a / t) * -0.2222222222222222)) + Float64(0.5 * Float64(Float64(x * y) / a))); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t, a)
t_1 = ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
tmp = 0.0;
if (t_1 <= 5e+265)
tmp = t_1;
else
tmp = (z / ((a / t) * -0.2222222222222222)) + (0.5 * ((x * y) / a));
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(x * y), $MachinePrecision] - N[(N[(z * 9.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e+265], t$95$1, N[(N[(z / N[(N[(a / t), $MachinePrecision] * -0.2222222222222222), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(N[(x * y), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
t_1 := \frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\\
\mathbf{if}\;t_1 \leq 5 \cdot 10^{+265}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{\frac{a}{t} \cdot -0.2222222222222222} + 0.5 \cdot \frac{x \cdot y}{a}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t)) (*.f64 a 2)) < 5.0000000000000002e265Initial program 97.4%
if 5.0000000000000002e265 < (/.f64 (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t)) (*.f64 a 2)) Initial program 78.8%
associate-*l*80.9%
Simplified80.9%
Taylor expanded in x around 0 80.9%
metadata-eval80.9%
div-inv80.9%
*-commutative80.9%
associate-*l*89.3%
div-inv89.4%
clear-num89.4%
div-inv89.4%
times-frac89.3%
*-commutative89.3%
*-un-lft-identity89.3%
Applied egg-rr89.3%
Final simplification96.0%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= (* x y) 5e+276) (/ (- (* x y) (* z (* 9.0 t))) (* a 2.0)) (* 0.5 (/ x (/ a y)))))
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= 5e+276) {
tmp = ((x * y) - (z * (9.0 * t))) / (a * 2.0);
} else {
tmp = 0.5 * (x / (a / y));
}
return tmp;
}
NOTE: z and t 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) <= 5d+276) then
tmp = ((x * y) - (z * (9.0d0 * t))) / (a * 2.0d0)
else
tmp = 0.5d0 * (x / (a / y))
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= 5e+276) {
tmp = ((x * y) - (z * (9.0 * t))) / (a * 2.0);
} else {
tmp = 0.5 * (x / (a / y));
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t, a): tmp = 0 if (x * y) <= 5e+276: tmp = ((x * y) - (z * (9.0 * t))) / (a * 2.0) else: tmp = 0.5 * (x / (a / y)) return tmp
z, t = sort([z, t]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= 5e+276) tmp = Float64(Float64(Float64(x * y) - Float64(z * Float64(9.0 * t))) / Float64(a * 2.0)); else tmp = Float64(0.5 * Float64(x / Float64(a / y))); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((x * y) <= 5e+276)
tmp = ((x * y) - (z * (9.0 * t))) / (a * 2.0);
else
tmp = 0.5 * (x / (a / y));
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], 5e+276], N[(N[(N[(x * y), $MachinePrecision] - N[(z * N[(9.0 * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq 5 \cdot 10^{+276}:\\
\;\;\;\;\frac{x \cdot y - z \cdot \left(9 \cdot t\right)}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}}\\
\end{array}
\end{array}
if (*.f64 x y) < 5.00000000000000001e276Initial program 95.7%
associate-*l*95.7%
Simplified95.7%
if 5.00000000000000001e276 < (*.f64 x y) Initial program 74.6%
associate-*l*74.6%
Simplified74.6%
Taylor expanded in x around inf 74.8%
associate-/l*99.9%
Simplified99.9%
Final simplification96.0%
NOTE: z and t should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* 0.5 (/ x (/ a y)))))
(if (<= x -3e+164)
t_1
(if (<= x -1.15e+124)
(* -4.5 (/ t (/ a z)))
(if (or (<= x -3.5e+45) (not (<= x 2.2e-75)))
t_1
(* -4.5 (/ (* z t) a)))))))assert(z < t);
double code(double x, double y, double z, double t, double a) {
double t_1 = 0.5 * (x / (a / y));
double tmp;
if (x <= -3e+164) {
tmp = t_1;
} else if (x <= -1.15e+124) {
tmp = -4.5 * (t / (a / z));
} else if ((x <= -3.5e+45) || !(x <= 2.2e-75)) {
tmp = t_1;
} else {
tmp = -4.5 * ((z * t) / a);
}
return tmp;
}
NOTE: z and t 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) :: t_1
real(8) :: tmp
t_1 = 0.5d0 * (x / (a / y))
if (x <= (-3d+164)) then
tmp = t_1
else if (x <= (-1.15d+124)) then
tmp = (-4.5d0) * (t / (a / z))
else if ((x <= (-3.5d+45)) .or. (.not. (x <= 2.2d-75))) then
tmp = t_1
else
tmp = (-4.5d0) * ((z * t) / a)
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
double t_1 = 0.5 * (x / (a / y));
double tmp;
if (x <= -3e+164) {
tmp = t_1;
} else if (x <= -1.15e+124) {
tmp = -4.5 * (t / (a / z));
} else if ((x <= -3.5e+45) || !(x <= 2.2e-75)) {
tmp = t_1;
} else {
tmp = -4.5 * ((z * t) / a);
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t, a): t_1 = 0.5 * (x / (a / y)) tmp = 0 if x <= -3e+164: tmp = t_1 elif x <= -1.15e+124: tmp = -4.5 * (t / (a / z)) elif (x <= -3.5e+45) or not (x <= 2.2e-75): tmp = t_1 else: tmp = -4.5 * ((z * t) / a) return tmp
z, t = sort([z, t]) function code(x, y, z, t, a) t_1 = Float64(0.5 * Float64(x / Float64(a / y))) tmp = 0.0 if (x <= -3e+164) tmp = t_1; elseif (x <= -1.15e+124) tmp = Float64(-4.5 * Float64(t / Float64(a / z))); elseif ((x <= -3.5e+45) || !(x <= 2.2e-75)) tmp = t_1; else tmp = Float64(-4.5 * Float64(Float64(z * t) / a)); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t, a)
t_1 = 0.5 * (x / (a / y));
tmp = 0.0;
if (x <= -3e+164)
tmp = t_1;
elseif (x <= -1.15e+124)
tmp = -4.5 * (t / (a / z));
elseif ((x <= -3.5e+45) || ~((x <= 2.2e-75)))
tmp = t_1;
else
tmp = -4.5 * ((z * t) / a);
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(0.5 * N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3e+164], t$95$1, If[LessEqual[x, -1.15e+124], N[(-4.5 * N[(t / N[(a / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, -3.5e+45], N[Not[LessEqual[x, 2.2e-75]], $MachinePrecision]], t$95$1, N[(-4.5 * N[(N[(z * t), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
t_1 := 0.5 \cdot \frac{x}{\frac{a}{y}}\\
\mathbf{if}\;x \leq -3 \cdot 10^{+164}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -1.15 \cdot 10^{+124}:\\
\;\;\;\;-4.5 \cdot \frac{t}{\frac{a}{z}}\\
\mathbf{elif}\;x \leq -3.5 \cdot 10^{+45} \lor \neg \left(x \leq 2.2 \cdot 10^{-75}\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;-4.5 \cdot \frac{z \cdot t}{a}\\
\end{array}
\end{array}
if x < -3.00000000000000001e164 or -1.14999999999999992e124 < x < -3.50000000000000023e45 or 2.20000000000000005e-75 < x Initial program 93.7%
associate-*l*93.7%
Simplified93.7%
Taylor expanded in x around inf 74.5%
associate-/l*70.9%
Simplified70.9%
if -3.00000000000000001e164 < x < -1.14999999999999992e124Initial program 99.8%
associate-*l*99.6%
Simplified99.6%
Taylor expanded in x around 0 99.8%
*-commutative99.8%
*-commutative99.8%
associate-*r*99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in z around inf 72.1%
associate-/l*72.4%
Simplified72.4%
if -3.50000000000000023e45 < x < 2.20000000000000005e-75Initial program 94.2%
associate-*l*94.2%
Simplified94.2%
Taylor expanded in x around 0 68.4%
Final simplification69.7%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= (* x y) -1e-13) (* (* x y) (/ 0.5 a)) (if (<= (* x y) 4e+88) (* -4.5 (/ (* z t) a)) (* 0.5 (/ x (/ a y))))))
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -1e-13) {
tmp = (x * y) * (0.5 / a);
} else if ((x * y) <= 4e+88) {
tmp = -4.5 * ((z * t) / a);
} else {
tmp = 0.5 * (x / (a / y));
}
return tmp;
}
NOTE: z and t 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-13)) then
tmp = (x * y) * (0.5d0 / a)
else if ((x * y) <= 4d+88) then
tmp = (-4.5d0) * ((z * t) / a)
else
tmp = 0.5d0 * (x / (a / y))
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -1e-13) {
tmp = (x * y) * (0.5 / a);
} else if ((x * y) <= 4e+88) {
tmp = -4.5 * ((z * t) / a);
} else {
tmp = 0.5 * (x / (a / y));
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t, a): tmp = 0 if (x * y) <= -1e-13: tmp = (x * y) * (0.5 / a) elif (x * y) <= 4e+88: tmp = -4.5 * ((z * t) / a) else: tmp = 0.5 * (x / (a / y)) return tmp
z, t = sort([z, t]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= -1e-13) tmp = Float64(Float64(x * y) * Float64(0.5 / a)); elseif (Float64(x * y) <= 4e+88) tmp = Float64(-4.5 * Float64(Float64(z * t) / a)); else tmp = Float64(0.5 * Float64(x / Float64(a / y))); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((x * y) <= -1e-13)
tmp = (x * y) * (0.5 / a);
elseif ((x * y) <= 4e+88)
tmp = -4.5 * ((z * t) / a);
else
tmp = 0.5 * (x / (a / y));
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], -1e-13], N[(N[(x * y), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 4e+88], N[(-4.5 * N[(N[(z * t), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{-13}:\\
\;\;\;\;\left(x \cdot y\right) \cdot \frac{0.5}{a}\\
\mathbf{elif}\;x \cdot y \leq 4 \cdot 10^{+88}:\\
\;\;\;\;-4.5 \cdot \frac{z \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}}\\
\end{array}
\end{array}
if (*.f64 x y) < -1e-13Initial program 93.3%
associate-*l*93.2%
Simplified93.2%
Taylor expanded in x around inf 79.3%
clear-num79.3%
associate-/r/79.2%
*-commutative79.2%
associate-/r*79.2%
metadata-eval79.2%
Applied egg-rr79.2%
if -1e-13 < (*.f64 x y) < 3.99999999999999984e88Initial program 96.1%
associate-*l*96.2%
Simplified96.2%
Taylor expanded in x around 0 74.6%
if 3.99999999999999984e88 < (*.f64 x y) Initial program 89.7%
associate-*l*89.7%
Simplified89.7%
Taylor expanded in x around inf 80.7%
associate-/l*84.8%
Simplified84.8%
Final simplification77.8%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= (* x y) -1e-13) (* (* x y) (/ 0.5 a)) (if (<= (* x y) 2e+47) (* -4.5 (/ (* z t) a)) (* y (/ x (* a 2.0))))))
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -1e-13) {
tmp = (x * y) * (0.5 / a);
} else if ((x * y) <= 2e+47) {
tmp = -4.5 * ((z * t) / a);
} else {
tmp = y * (x / (a * 2.0));
}
return tmp;
}
NOTE: z and t 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-13)) then
tmp = (x * y) * (0.5d0 / a)
else if ((x * y) <= 2d+47) then
tmp = (-4.5d0) * ((z * t) / a)
else
tmp = y * (x / (a * 2.0d0))
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -1e-13) {
tmp = (x * y) * (0.5 / a);
} else if ((x * y) <= 2e+47) {
tmp = -4.5 * ((z * t) / a);
} else {
tmp = y * (x / (a * 2.0));
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t, a): tmp = 0 if (x * y) <= -1e-13: tmp = (x * y) * (0.5 / a) elif (x * y) <= 2e+47: tmp = -4.5 * ((z * t) / a) else: tmp = y * (x / (a * 2.0)) return tmp
z, t = sort([z, t]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= -1e-13) tmp = Float64(Float64(x * y) * Float64(0.5 / a)); elseif (Float64(x * y) <= 2e+47) tmp = Float64(-4.5 * Float64(Float64(z * t) / a)); else tmp = Float64(y * Float64(x / Float64(a * 2.0))); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((x * y) <= -1e-13)
tmp = (x * y) * (0.5 / a);
elseif ((x * y) <= 2e+47)
tmp = -4.5 * ((z * t) / a);
else
tmp = y * (x / (a * 2.0));
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], -1e-13], N[(N[(x * y), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2e+47], N[(-4.5 * N[(N[(z * t), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(y * N[(x / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{-13}:\\
\;\;\;\;\left(x \cdot y\right) \cdot \frac{0.5}{a}\\
\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+47}:\\
\;\;\;\;-4.5 \cdot \frac{z \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{a \cdot 2}\\
\end{array}
\end{array}
if (*.f64 x y) < -1e-13Initial program 93.3%
associate-*l*93.2%
Simplified93.2%
Taylor expanded in x around inf 79.3%
clear-num79.3%
associate-/r/79.2%
*-commutative79.2%
associate-/r*79.2%
metadata-eval79.2%
Applied egg-rr79.2%
if -1e-13 < (*.f64 x y) < 2.0000000000000001e47Initial program 95.8%
associate-*l*95.9%
Simplified95.9%
Taylor expanded in x around 0 76.9%
if 2.0000000000000001e47 < (*.f64 x y) Initial program 91.5%
associate-*l*91.6%
Simplified91.6%
Taylor expanded in x around inf 75.0%
associate-/l*78.3%
associate-/r/79.3%
Applied egg-rr79.3%
Final simplification78.1%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= (* x y) -1e-13) (/ (* x y) (* a 2.0)) (if (<= (* x y) 2e+47) (* -4.5 (/ (* z t) a)) (* y (/ x (* a 2.0))))))
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -1e-13) {
tmp = (x * y) / (a * 2.0);
} else if ((x * y) <= 2e+47) {
tmp = -4.5 * ((z * t) / a);
} else {
tmp = y * (x / (a * 2.0));
}
return tmp;
}
NOTE: z and t 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-13)) then
tmp = (x * y) / (a * 2.0d0)
else if ((x * y) <= 2d+47) then
tmp = (-4.5d0) * ((z * t) / a)
else
tmp = y * (x / (a * 2.0d0))
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -1e-13) {
tmp = (x * y) / (a * 2.0);
} else if ((x * y) <= 2e+47) {
tmp = -4.5 * ((z * t) / a);
} else {
tmp = y * (x / (a * 2.0));
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t, a): tmp = 0 if (x * y) <= -1e-13: tmp = (x * y) / (a * 2.0) elif (x * y) <= 2e+47: tmp = -4.5 * ((z * t) / a) else: tmp = y * (x / (a * 2.0)) return tmp
z, t = sort([z, t]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= -1e-13) tmp = Float64(Float64(x * y) / Float64(a * 2.0)); elseif (Float64(x * y) <= 2e+47) tmp = Float64(-4.5 * Float64(Float64(z * t) / a)); else tmp = Float64(y * Float64(x / Float64(a * 2.0))); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((x * y) <= -1e-13)
tmp = (x * y) / (a * 2.0);
elseif ((x * y) <= 2e+47)
tmp = -4.5 * ((z * t) / a);
else
tmp = y * (x / (a * 2.0));
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], -1e-13], N[(N[(x * y), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2e+47], N[(-4.5 * N[(N[(z * t), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(y * N[(x / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{-13}:\\
\;\;\;\;\frac{x \cdot y}{a \cdot 2}\\
\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+47}:\\
\;\;\;\;-4.5 \cdot \frac{z \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{a \cdot 2}\\
\end{array}
\end{array}
if (*.f64 x y) < -1e-13Initial program 93.3%
associate-*l*93.2%
Simplified93.2%
Taylor expanded in x around inf 79.3%
if -1e-13 < (*.f64 x y) < 2.0000000000000001e47Initial program 95.8%
associate-*l*95.9%
Simplified95.9%
Taylor expanded in x around 0 76.9%
if 2.0000000000000001e47 < (*.f64 x y) Initial program 91.5%
associate-*l*91.6%
Simplified91.6%
Taylor expanded in x around inf 75.0%
associate-/l*78.3%
associate-/r/79.3%
Applied egg-rr79.3%
Final simplification78.1%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= a 3.9e-123) (* -4.5 (/ t (/ a z))) (* -4.5 (* z (/ t a)))))
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= 3.9e-123) {
tmp = -4.5 * (t / (a / z));
} else {
tmp = -4.5 * (z * (t / a));
}
return tmp;
}
NOTE: z and t 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 (a <= 3.9d-123) then
tmp = (-4.5d0) * (t / (a / z))
else
tmp = (-4.5d0) * (z * (t / a))
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= 3.9e-123) {
tmp = -4.5 * (t / (a / z));
} else {
tmp = -4.5 * (z * (t / a));
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t, a): tmp = 0 if a <= 3.9e-123: tmp = -4.5 * (t / (a / z)) else: tmp = -4.5 * (z * (t / a)) return tmp
z, t = sort([z, t]) function code(x, y, z, t, a) tmp = 0.0 if (a <= 3.9e-123) tmp = Float64(-4.5 * Float64(t / Float64(a / z))); else tmp = Float64(-4.5 * Float64(z * Float64(t / a))); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if (a <= 3.9e-123)
tmp = -4.5 * (t / (a / z));
else
tmp = -4.5 * (z * (t / a));
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[a, 3.9e-123], N[(-4.5 * N[(t / N[(a / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.5 * N[(z * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq 3.9 \cdot 10^{-123}:\\
\;\;\;\;-4.5 \cdot \frac{t}{\frac{a}{z}}\\
\mathbf{else}:\\
\;\;\;\;-4.5 \cdot \left(z \cdot \frac{t}{a}\right)\\
\end{array}
\end{array}
if a < 3.89999999999999976e-123Initial program 94.6%
associate-*l*94.0%
Simplified94.0%
Taylor expanded in x around 0 94.5%
*-commutative94.5%
*-commutative94.5%
associate-*r*94.0%
fma-def94.0%
Simplified94.0%
Taylor expanded in z around inf 47.0%
associate-/l*45.9%
Simplified45.9%
if 3.89999999999999976e-123 < a Initial program 93.2%
associate-*l*94.3%
Simplified94.3%
Taylor expanded in x around 0 50.4%
associate-/l*49.8%
associate-/r/50.5%
Simplified50.5%
Final simplification47.5%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (* -4.5 (* z (/ t a))))
assert(z < t);
double code(double x, double y, double z, double t, double a) {
return -4.5 * (z * (t / a));
}
NOTE: z and t 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) * (z * (t / a))
end function
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
return -4.5 * (z * (t / a));
}
[z, t] = sort([z, t]) def code(x, y, z, t, a): return -4.5 * (z * (t / a))
z, t = sort([z, t]) function code(x, y, z, t, a) return Float64(-4.5 * Float64(z * Float64(t / a))) end
z, t = num2cell(sort([z, t])){:}
function tmp = code(x, y, z, t, a)
tmp = -4.5 * (z * (t / a));
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := N[(-4.5 * N[(z * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
-4.5 \cdot \left(z \cdot \frac{t}{a}\right)
\end{array}
Initial program 94.1%
associate-*l*94.1%
Simplified94.1%
Taylor expanded in x around 0 48.2%
associate-/l*47.3%
associate-/r/46.2%
Simplified46.2%
Final simplification46.2%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (* -4.5 (/ (* z t) a)))
assert(z < t);
double code(double x, double y, double z, double t, double a) {
return -4.5 * ((z * t) / a);
}
NOTE: z and t 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) * ((z * t) / a)
end function
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
return -4.5 * ((z * t) / a);
}
[z, t] = sort([z, t]) def code(x, y, z, t, a): return -4.5 * ((z * t) / a)
z, t = sort([z, t]) function code(x, y, z, t, a) return Float64(-4.5 * Float64(Float64(z * t) / a)) end
z, t = num2cell(sort([z, t])){:}
function tmp = code(x, y, z, t, a)
tmp = -4.5 * ((z * t) / a);
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := N[(-4.5 * N[(N[(z * t), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
-4.5 \cdot \frac{z \cdot t}{a}
\end{array}
Initial program 94.1%
associate-*l*94.1%
Simplified94.1%
Taylor expanded in x around 0 48.2%
Final simplification48.2%
(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 2023293
(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)))