
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* z t)) a))
double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / 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 = ((x * y) - (z * t)) / a
end function
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
def code(x, y, z, t, a): return ((x * y) - (z * t)) / a
function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) - Float64(z * t)) / a) end
function tmp = code(x, y, z, t, a) tmp = ((x * y) - (z * t)) / a; end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y - z \cdot t}{a}
\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 t)) a))
double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / 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 = ((x * y) - (z * t)) / a
end function
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
def code(x, y, z, t, a): return ((x * y) - (z * t)) / a
function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) - Float64(z * t)) / a) end
function tmp = code(x, y, z, t, a) tmp = ((x * y) - (z * t)) / a; end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y - z \cdot t}{a}
\end{array}
NOTE: x and y should be sorted in increasing order before calling this function.
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 t)) a)) (t_2 (* z (/ (- t) a))))
(if (<= (* z t) (- INFINITY))
t_2
(if (<= (* z t) -5e-223)
t_1
(if (<= (* z t) 4e-252)
(* x (/ y a))
(if (<= (* z t) 5e+218) t_1 t_2))))))assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double t_1 = ((x * y) - (z * t)) / a;
double t_2 = z * (-t / a);
double tmp;
if ((z * t) <= -((double) INFINITY)) {
tmp = t_2;
} else if ((z * t) <= -5e-223) {
tmp = t_1;
} else if ((z * t) <= 4e-252) {
tmp = x * (y / a);
} else if ((z * t) <= 5e+218) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
assert x < y;
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
double t_1 = ((x * y) - (z * t)) / a;
double t_2 = z * (-t / a);
double tmp;
if ((z * t) <= -Double.POSITIVE_INFINITY) {
tmp = t_2;
} else if ((z * t) <= -5e-223) {
tmp = t_1;
} else if ((z * t) <= 4e-252) {
tmp = x * (y / a);
} else if ((z * t) <= 5e+218) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
[x, y] = sort([x, y]) [z, t] = sort([z, t]) def code(x, y, z, t, a): t_1 = ((x * y) - (z * t)) / a t_2 = z * (-t / a) tmp = 0 if (z * t) <= -math.inf: tmp = t_2 elif (z * t) <= -5e-223: tmp = t_1 elif (z * t) <= 4e-252: tmp = x * (y / a) elif (z * t) <= 5e+218: tmp = t_1 else: tmp = t_2 return tmp
x, y = sort([x, y]) z, t = sort([z, t]) function code(x, y, z, t, a) t_1 = Float64(Float64(Float64(x * y) - Float64(z * t)) / a) t_2 = Float64(z * Float64(Float64(-t) / a)) tmp = 0.0 if (Float64(z * t) <= Float64(-Inf)) tmp = t_2; elseif (Float64(z * t) <= -5e-223) tmp = t_1; elseif (Float64(z * t) <= 4e-252) tmp = Float64(x * Float64(y / a)); elseif (Float64(z * t) <= 5e+218) tmp = t_1; else tmp = t_2; end return tmp end
x, y = num2cell(sort([x, y])){:}
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t, a)
t_1 = ((x * y) - (z * t)) / a;
t_2 = z * (-t / a);
tmp = 0.0;
if ((z * t) <= -Inf)
tmp = t_2;
elseif ((z * t) <= -5e-223)
tmp = t_1;
elseif ((z * t) <= 4e-252)
tmp = x * (y / a);
elseif ((z * t) <= 5e+218)
tmp = t_1;
else
tmp = t_2;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
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[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, Block[{t$95$2 = N[(z * N[((-t) / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], (-Infinity)], t$95$2, If[LessEqual[N[(z * t), $MachinePrecision], -5e-223], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 4e-252], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e+218], t$95$1, t$95$2]]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
t_1 := \frac{x \cdot y - z \cdot t}{a}\\
t_2 := z \cdot \frac{-t}{a}\\
\mathbf{if}\;z \cdot t \leq -\infty:\\
\;\;\;\;t_2\\
\mathbf{elif}\;z \cdot t \leq -5 \cdot 10^{-223}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \cdot t \leq 4 \cdot 10^{-252}:\\
\;\;\;\;x \cdot \frac{y}{a}\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+218}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if (*.f64 z t) < -inf.0 or 4.99999999999999983e218 < (*.f64 z t) Initial program 53.2%
Taylor expanded in x around 0 60.2%
*-commutative60.2%
associate-*l/92.9%
associate-*l*92.9%
*-commutative92.9%
neg-mul-192.9%
Simplified92.9%
if -inf.0 < (*.f64 z t) < -5.00000000000000024e-223 or 3.99999999999999977e-252 < (*.f64 z t) < 4.99999999999999983e218Initial program 96.9%
if -5.00000000000000024e-223 < (*.f64 z t) < 3.99999999999999977e-252Initial program 83.6%
frac-2neg83.6%
neg-sub083.6%
sub-neg83.6%
+-commutative83.6%
associate--r+83.6%
neg-sub083.6%
remove-double-neg83.6%
div-sub83.6%
Applied egg-rr83.6%
associate-/l*86.4%
associate-/l*97.4%
Simplified97.4%
Taylor expanded in z around 0 81.9%
associate-*r/93.1%
Simplified93.1%
Final simplification95.6%
NOTE: x and y should be sorted in increasing order before calling this function. NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (or (<= a -7.8e+51) (not (<= a 1.05e+70))) (- (* x (/ y a)) (* z (/ t a))) (/ (- (* x y) (* z t)) a)))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -7.8e+51) || !(a <= 1.05e+70)) {
tmp = (x * (y / a)) - (z * (t / a));
} else {
tmp = ((x * y) - (z * t)) / a;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
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 <= (-7.8d+51)) .or. (.not. (a <= 1.05d+70))) then
tmp = (x * (y / a)) - (z * (t / a))
else
tmp = ((x * y) - (z * t)) / a
end if
code = tmp
end function
assert x < y;
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -7.8e+51) || !(a <= 1.05e+70)) {
tmp = (x * (y / a)) - (z * (t / a));
} else {
tmp = ((x * y) - (z * t)) / a;
}
return tmp;
}
[x, y] = sort([x, y]) [z, t] = sort([z, t]) def code(x, y, z, t, a): tmp = 0 if (a <= -7.8e+51) or not (a <= 1.05e+70): tmp = (x * (y / a)) - (z * (t / a)) else: tmp = ((x * y) - (z * t)) / a return tmp
x, y = sort([x, y]) z, t = sort([z, t]) function code(x, y, z, t, a) tmp = 0.0 if ((a <= -7.8e+51) || !(a <= 1.05e+70)) tmp = Float64(Float64(x * Float64(y / a)) - Float64(z * Float64(t / a))); else tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a); end return tmp end
x, y = num2cell(sort([x, y])){:}
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((a <= -7.8e+51) || ~((a <= 1.05e+70)))
tmp = (x * (y / a)) - (z * (t / a));
else
tmp = ((x * y) - (z * t)) / a;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -7.8e+51], N[Not[LessEqual[a, 1.05e+70]], $MachinePrecision]], N[(N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision] - N[(z * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -7.8 \cdot 10^{+51} \lor \neg \left(a \leq 1.05 \cdot 10^{+70}\right):\\
\;\;\;\;x \cdot \frac{y}{a} - z \cdot \frac{t}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\
\end{array}
\end{array}
if a < -7.79999999999999968e51 or 1.05000000000000004e70 < a Initial program 76.4%
div-sub76.4%
*-commutative76.4%
associate-/l*85.0%
associate-/l*92.6%
frac-sub35.7%
div-sub35.7%
Applied egg-rr35.7%
times-frac43.4%
*-inverses55.3%
associate-*l/55.3%
*-rgt-identity55.3%
associate-/r/54.5%
associate-/l*59.9%
associate-*r/47.6%
associate-/l/44.0%
associate-/l*41.9%
times-frac61.9%
*-inverses85.0%
associate-*r/85.0%
*-lft-identity85.0%
associate-*r/92.7%
Simplified92.7%
if -7.79999999999999968e51 < a < 1.05000000000000004e70Initial program 95.6%
Final simplification94.4%
NOTE: x and y should be sorted in increasing order before calling this function.
NOTE: z and t should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
:precision binary64
(if (<= a -1.25e+52)
(- (/ z (/ (- a) t)) (/ x (/ (- a) y)))
(if (<= a 3.8e+69)
(/ (- (* x y) (* z t)) a)
(- (* x (/ y a)) (* z (/ t a))))))assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -1.25e+52) {
tmp = (z / (-a / t)) - (x / (-a / y));
} else if (a <= 3.8e+69) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = (x * (y / a)) - (z * (t / a));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
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 <= (-1.25d+52)) then
tmp = (z / (-a / t)) - (x / (-a / y))
else if (a <= 3.8d+69) then
tmp = ((x * y) - (z * t)) / a
else
tmp = (x * (y / a)) - (z * (t / a))
end if
code = tmp
end function
assert x < y;
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -1.25e+52) {
tmp = (z / (-a / t)) - (x / (-a / y));
} else if (a <= 3.8e+69) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = (x * (y / a)) - (z * (t / a));
}
return tmp;
}
[x, y] = sort([x, y]) [z, t] = sort([z, t]) def code(x, y, z, t, a): tmp = 0 if a <= -1.25e+52: tmp = (z / (-a / t)) - (x / (-a / y)) elif a <= 3.8e+69: tmp = ((x * y) - (z * t)) / a else: tmp = (x * (y / a)) - (z * (t / a)) return tmp
x, y = sort([x, y]) z, t = sort([z, t]) function code(x, y, z, t, a) tmp = 0.0 if (a <= -1.25e+52) tmp = Float64(Float64(z / Float64(Float64(-a) / t)) - Float64(x / Float64(Float64(-a) / y))); elseif (a <= 3.8e+69) tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a); else tmp = Float64(Float64(x * Float64(y / a)) - Float64(z * Float64(t / a))); end return tmp end
x, y = num2cell(sort([x, y])){:}
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if (a <= -1.25e+52)
tmp = (z / (-a / t)) - (x / (-a / y));
elseif (a <= 3.8e+69)
tmp = ((x * y) - (z * t)) / a;
else
tmp = (x * (y / a)) - (z * (t / a));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[a, -1.25e+52], N[(N[(z / N[((-a) / t), $MachinePrecision]), $MachinePrecision] - N[(x / N[((-a) / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 3.8e+69], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision] - N[(z * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.25 \cdot 10^{+52}:\\
\;\;\;\;\frac{z}{\frac{-a}{t}} - \frac{x}{\frac{-a}{y}}\\
\mathbf{elif}\;a \leq 3.8 \cdot 10^{+69}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{a} - z \cdot \frac{t}{a}\\
\end{array}
\end{array}
if a < -1.25e52Initial program 76.7%
frac-2neg76.7%
neg-sub076.7%
sub-neg76.7%
+-commutative76.7%
associate--r+76.7%
neg-sub076.7%
remove-double-neg76.7%
div-sub76.7%
Applied egg-rr76.7%
associate-/l*88.0%
associate-/l*96.4%
Simplified96.4%
if -1.25e52 < a < 3.80000000000000028e69Initial program 95.6%
if 3.80000000000000028e69 < a Initial program 76.0%
div-sub76.0%
*-commutative76.0%
associate-/l*86.8%
associate-/l*90.4%
frac-sub20.5%
div-sub20.5%
Applied egg-rr20.5%
times-frac31.2%
*-inverses48.5%
associate-*l/48.5%
*-rgt-identity48.5%
associate-/r/46.8%
associate-/l*56.2%
associate-*r/48.7%
associate-/l/44.9%
associate-/l*42.9%
times-frac61.9%
*-inverses85.0%
associate-*r/85.0%
*-lft-identity85.0%
associate-*r/88.7%
Simplified88.7%
Final simplification94.4%
NOTE: x and y should be sorted in increasing order before calling this function. 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+67) (/ x (/ a y)) (if (<= (* x y) 5e-13) (* z (/ (- t) a)) (* x (/ y a)))))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -5e+67) {
tmp = x / (a / y);
} else if ((x * y) <= 5e-13) {
tmp = z * (-t / a);
} else {
tmp = x * (y / a);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
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+67)) then
tmp = x / (a / y)
else if ((x * y) <= 5d-13) then
tmp = z * (-t / a)
else
tmp = x * (y / a)
end if
code = tmp
end function
assert x < y;
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -5e+67) {
tmp = x / (a / y);
} else if ((x * y) <= 5e-13) {
tmp = z * (-t / a);
} else {
tmp = x * (y / a);
}
return tmp;
}
[x, y] = sort([x, y]) [z, t] = sort([z, t]) def code(x, y, z, t, a): tmp = 0 if (x * y) <= -5e+67: tmp = x / (a / y) elif (x * y) <= 5e-13: tmp = z * (-t / a) else: tmp = x * (y / a) return tmp
x, y = sort([x, y]) z, t = sort([z, t]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= -5e+67) tmp = Float64(x / Float64(a / y)); elseif (Float64(x * y) <= 5e-13) tmp = Float64(z * Float64(Float64(-t) / a)); else tmp = Float64(x * Float64(y / a)); end return tmp end
x, y = num2cell(sort([x, y])){:}
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((x * y) <= -5e+67)
tmp = x / (a / y);
elseif ((x * y) <= 5e-13)
tmp = z * (-t / a);
else
tmp = x * (y / a);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. 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+67], N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 5e-13], N[(z * N[((-t) / a), $MachinePrecision]), $MachinePrecision], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+67}:\\
\;\;\;\;\frac{x}{\frac{a}{y}}\\
\mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{-13}:\\
\;\;\;\;z \cdot \frac{-t}{a}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{a}\\
\end{array}
\end{array}
if (*.f64 x y) < -4.99999999999999976e67Initial program 82.8%
Taylor expanded in x around inf 78.5%
associate-*l/84.5%
*-commutative84.5%
Simplified84.5%
associate-*r/78.5%
*-commutative78.5%
associate-/l*82.7%
Applied egg-rr82.7%
if -4.99999999999999976e67 < (*.f64 x y) < 4.9999999999999999e-13Initial program 89.8%
Taylor expanded in x around 0 71.7%
*-commutative71.7%
associate-*l/72.7%
associate-*l*72.7%
*-commutative72.7%
neg-mul-172.7%
Simplified72.7%
if 4.9999999999999999e-13 < (*.f64 x y) Initial program 85.9%
frac-2neg85.9%
neg-sub085.9%
sub-neg85.9%
+-commutative85.9%
associate--r+85.9%
neg-sub085.9%
remove-double-neg85.9%
div-sub84.6%
Applied egg-rr84.6%
associate-/l*79.4%
associate-/l*84.6%
Simplified84.6%
Taylor expanded in z around 0 65.6%
associate-*r/74.3%
Simplified74.3%
Final simplification74.9%
NOTE: x and y should be sorted in increasing order before calling this function. 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+67) (/ x (/ a y)) (if (<= (* x y) 5e-13) (* t (/ (- z) a)) (* x (/ y a)))))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -5e+67) {
tmp = x / (a / y);
} else if ((x * y) <= 5e-13) {
tmp = t * (-z / a);
} else {
tmp = x * (y / a);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
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+67)) then
tmp = x / (a / y)
else if ((x * y) <= 5d-13) then
tmp = t * (-z / a)
else
tmp = x * (y / a)
end if
code = tmp
end function
assert x < y;
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -5e+67) {
tmp = x / (a / y);
} else if ((x * y) <= 5e-13) {
tmp = t * (-z / a);
} else {
tmp = x * (y / a);
}
return tmp;
}
[x, y] = sort([x, y]) [z, t] = sort([z, t]) def code(x, y, z, t, a): tmp = 0 if (x * y) <= -5e+67: tmp = x / (a / y) elif (x * y) <= 5e-13: tmp = t * (-z / a) else: tmp = x * (y / a) return tmp
x, y = sort([x, y]) z, t = sort([z, t]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= -5e+67) tmp = Float64(x / Float64(a / y)); elseif (Float64(x * y) <= 5e-13) tmp = Float64(t * Float64(Float64(-z) / a)); else tmp = Float64(x * Float64(y / a)); end return tmp end
x, y = num2cell(sort([x, y])){:}
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((x * y) <= -5e+67)
tmp = x / (a / y);
elseif ((x * y) <= 5e-13)
tmp = t * (-z / a);
else
tmp = x * (y / a);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. 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+67], N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 5e-13], N[(t * N[((-z) / a), $MachinePrecision]), $MachinePrecision], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+67}:\\
\;\;\;\;\frac{x}{\frac{a}{y}}\\
\mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{-13}:\\
\;\;\;\;t \cdot \frac{-z}{a}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{a}\\
\end{array}
\end{array}
if (*.f64 x y) < -4.99999999999999976e67Initial program 82.8%
Taylor expanded in x around inf 78.5%
associate-*l/84.5%
*-commutative84.5%
Simplified84.5%
associate-*r/78.5%
*-commutative78.5%
associate-/l*82.7%
Applied egg-rr82.7%
if -4.99999999999999976e67 < (*.f64 x y) < 4.9999999999999999e-13Initial program 89.8%
Taylor expanded in x around 0 71.7%
*-commutative71.7%
associate-*l/72.7%
associate-*l*72.7%
*-commutative72.7%
neg-mul-172.7%
Simplified72.7%
associate-*l/71.7%
associate-/l*78.1%
remove-double-neg78.1%
frac-2neg78.1%
clear-num78.0%
associate-/r*71.6%
neg-mul-171.6%
metadata-eval71.6%
*-commutative71.6%
times-frac78.0%
associate-/r*78.0%
clear-num78.1%
div-inv78.1%
metadata-eval78.1%
metadata-eval78.1%
metadata-eval78.1%
*-commutative78.1%
metadata-eval78.1%
neg-mul-178.1%
Applied egg-rr78.1%
clear-num78.0%
associate-/r/78.5%
*-commutative78.5%
/-rgt-identity78.5%
Applied egg-rr78.5%
if 4.9999999999999999e-13 < (*.f64 x y) Initial program 85.9%
frac-2neg85.9%
neg-sub085.9%
sub-neg85.9%
+-commutative85.9%
associate--r+85.9%
neg-sub085.9%
remove-double-neg85.9%
div-sub84.6%
Applied egg-rr84.6%
associate-/l*79.4%
associate-/l*84.6%
Simplified84.6%
Taylor expanded in z around 0 65.6%
associate-*r/74.3%
Simplified74.3%
Final simplification78.0%
NOTE: x and y should be sorted in increasing order before calling this function. 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+67) (/ x (/ a y)) (if (<= (* x y) 5e-13) (/ (- t) (/ a z)) (* x (/ y a)))))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -5e+67) {
tmp = x / (a / y);
} else if ((x * y) <= 5e-13) {
tmp = -t / (a / z);
} else {
tmp = x * (y / a);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
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+67)) then
tmp = x / (a / y)
else if ((x * y) <= 5d-13) then
tmp = -t / (a / z)
else
tmp = x * (y / a)
end if
code = tmp
end function
assert x < y;
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -5e+67) {
tmp = x / (a / y);
} else if ((x * y) <= 5e-13) {
tmp = -t / (a / z);
} else {
tmp = x * (y / a);
}
return tmp;
}
[x, y] = sort([x, y]) [z, t] = sort([z, t]) def code(x, y, z, t, a): tmp = 0 if (x * y) <= -5e+67: tmp = x / (a / y) elif (x * y) <= 5e-13: tmp = -t / (a / z) else: tmp = x * (y / a) return tmp
x, y = sort([x, y]) z, t = sort([z, t]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= -5e+67) tmp = Float64(x / Float64(a / y)); elseif (Float64(x * y) <= 5e-13) tmp = Float64(Float64(-t) / Float64(a / z)); else tmp = Float64(x * Float64(y / a)); end return tmp end
x, y = num2cell(sort([x, y])){:}
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((x * y) <= -5e+67)
tmp = x / (a / y);
elseif ((x * y) <= 5e-13)
tmp = -t / (a / z);
else
tmp = x * (y / a);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. 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+67], N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 5e-13], N[((-t) / N[(a / z), $MachinePrecision]), $MachinePrecision], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+67}:\\
\;\;\;\;\frac{x}{\frac{a}{y}}\\
\mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\frac{-t}{\frac{a}{z}}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{a}\\
\end{array}
\end{array}
if (*.f64 x y) < -4.99999999999999976e67Initial program 82.8%
Taylor expanded in x around inf 78.5%
associate-*l/84.5%
*-commutative84.5%
Simplified84.5%
associate-*r/78.5%
*-commutative78.5%
associate-/l*82.7%
Applied egg-rr82.7%
if -4.99999999999999976e67 < (*.f64 x y) < 4.9999999999999999e-13Initial program 89.8%
Taylor expanded in x around 0 71.7%
*-commutative71.7%
associate-*l/72.7%
associate-*l*72.7%
*-commutative72.7%
neg-mul-172.7%
Simplified72.7%
associate-*l/71.7%
associate-/l*78.1%
remove-double-neg78.1%
frac-2neg78.1%
clear-num78.0%
associate-/r*71.6%
neg-mul-171.6%
metadata-eval71.6%
*-commutative71.6%
times-frac78.0%
associate-/r*78.0%
clear-num78.1%
div-inv78.1%
metadata-eval78.1%
metadata-eval78.1%
metadata-eval78.1%
*-commutative78.1%
metadata-eval78.1%
neg-mul-178.1%
Applied egg-rr78.1%
if 4.9999999999999999e-13 < (*.f64 x y) Initial program 85.9%
frac-2neg85.9%
neg-sub085.9%
sub-neg85.9%
+-commutative85.9%
associate--r+85.9%
neg-sub085.9%
remove-double-neg85.9%
div-sub84.6%
Applied egg-rr84.6%
associate-/l*79.4%
associate-/l*84.6%
Simplified84.6%
Taylor expanded in z around 0 65.6%
associate-*r/74.3%
Simplified74.3%
Final simplification77.8%
NOTE: x and y should be sorted in increasing order before calling this function. NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (* x (/ y a)))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
return x * (y / a);
}
NOTE: x and y should be sorted in increasing order before calling this function.
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 = x * (y / a)
end function
assert x < y;
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
return x * (y / a);
}
[x, y] = sort([x, y]) [z, t] = sort([z, t]) def code(x, y, z, t, a): return x * (y / a)
x, y = sort([x, y]) z, t = sort([z, t]) function code(x, y, z, t, a) return Float64(x * Float64(y / a)) end
x, y = num2cell(sort([x, y])){:}
z, t = num2cell(sort([z, t])){:}
function tmp = code(x, y, z, t, a)
tmp = x * (y / a);
end
NOTE: x and y should be sorted in increasing order before calling this function. NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
x \cdot \frac{y}{a}
\end{array}
Initial program 87.4%
frac-2neg87.4%
neg-sub087.4%
sub-neg87.4%
+-commutative87.4%
associate--r+87.4%
neg-sub087.4%
remove-double-neg87.4%
div-sub85.9%
Applied egg-rr85.9%
associate-/l*85.0%
associate-/l*85.8%
Simplified85.8%
Taylor expanded in z around 0 48.2%
associate-*r/50.5%
Simplified50.5%
Final simplification50.5%
NOTE: x and y should be sorted in increasing order before calling this function. NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (/ x (/ a y)))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
return x / (a / y);
}
NOTE: x and y should be sorted in increasing order before calling this function.
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 = x / (a / y)
end function
assert x < y;
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
return x / (a / y);
}
[x, y] = sort([x, y]) [z, t] = sort([z, t]) def code(x, y, z, t, a): return x / (a / y)
x, y = sort([x, y]) z, t = sort([z, t]) function code(x, y, z, t, a) return Float64(x / Float64(a / y)) end
x, y = num2cell(sort([x, y])){:}
z, t = num2cell(sort([z, t])){:}
function tmp = code(x, y, z, t, a)
tmp = x / (a / y);
end
NOTE: x and y should be sorted in increasing order before calling this function. NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\frac{x}{\frac{a}{y}}
\end{array}
Initial program 87.4%
Taylor expanded in x around inf 48.2%
associate-*l/52.9%
*-commutative52.9%
Simplified52.9%
associate-*r/48.2%
*-commutative48.2%
associate-/l*51.0%
Applied egg-rr51.0%
Final simplification51.0%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- (* (/ y a) x) (* (/ t a) z))))
(if (< z -2.468684968699548e+170)
t_1
(if (< z 6.309831121978371e-71) (/ (- (* x y) (* z t)) a) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = ((y / a) * x) - ((t / a) * z);
double tmp;
if (z < -2.468684968699548e+170) {
tmp = t_1;
} else if (z < 6.309831121978371e-71) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_1 = ((y / a) * x) - ((t / a) * z)
if (z < (-2.468684968699548d+170)) then
tmp = t_1
else if (z < 6.309831121978371d-71) then
tmp = ((x * y) - (z * t)) / a
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = ((y / a) * x) - ((t / a) * z);
double tmp;
if (z < -2.468684968699548e+170) {
tmp = t_1;
} else if (z < 6.309831121978371e-71) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = ((y / a) * x) - ((t / a) * z) tmp = 0 if z < -2.468684968699548e+170: tmp = t_1 elif z < 6.309831121978371e-71: tmp = ((x * y) - (z * t)) / a else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(Float64(y / a) * x) - Float64(Float64(t / a) * z)) tmp = 0.0 if (z < -2.468684968699548e+170) tmp = t_1; elseif (z < 6.309831121978371e-71) tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = ((y / a) * x) - ((t / a) * z); tmp = 0.0; if (z < -2.468684968699548e+170) tmp = t_1; elseif (z < 6.309831121978371e-71) tmp = ((x * y) - (z * t)) / a; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(y / a), $MachinePrecision] * x), $MachinePrecision] - N[(N[(t / a), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[Less[z, -2.468684968699548e+170], t$95$1, If[Less[z, 6.309831121978371e-71], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\
\mathbf{if}\;z < -2.468684968699548 \cdot 10^{+170}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z < 6.309831121978371 \cdot 10^{-71}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
herbie shell --seed 2023297
(FPCore (x y z t a)
:name "Data.Colour.Matrix:inverse from colour-2.3.3, B"
:precision binary64
:herbie-target
(if (< z -2.468684968699548e+170) (- (* (/ y a) x) (* (/ t a) z)) (if (< z 6.309831121978371e-71) (/ (- (* x y) (* z t)) a) (- (* (/ y a) x) (* (/ t a) z))))
(/ (- (* x y) (* z t)) a))