
(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 10 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))))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 1e+252)))
(fma -1.0 (/ t (/ a z)) (/ y (/ a x)))
(/ (fma y x (- (* z t))) a))))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);
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 1e+252)) {
tmp = fma(-1.0, (t / (a / z)), (y / (a / x)));
} else {
tmp = fma(y, x, -(z * t)) / a;
}
return tmp;
}
x, y = sort([x, y]) z, t = sort([z, t]) function code(x, y, z, t, a) t_1 = Float64(Float64(x * y) - Float64(z * t)) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 1e+252)) tmp = fma(-1.0, Float64(t / Float64(a / z)), Float64(y / Float64(a / x))); else tmp = Float64(fma(y, x, Float64(-Float64(z * t))) / a); end return 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[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 1e+252]], $MachinePrecision]], N[(-1.0 * N[(t / N[(a / z), $MachinePrecision]), $MachinePrecision] + N[(y / N[(a / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * x + (-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}
t_1 := x \cdot y - z \cdot t\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 10^{+252}\right):\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{t}{\frac{a}{z}}, \frac{y}{\frac{a}{x}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, x, -z \cdot t\right)}{a}\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -inf.0 or 1.0000000000000001e252 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 70.1%
Taylor expanded in x around 0 68.4%
fma-def68.4%
associate-/l*80.8%
associate-/l*96.5%
Simplified96.5%
if -inf.0 < (-.f64 (*.f64 x y) (*.f64 z t)) < 1.0000000000000001e252Initial program 98.7%
Taylor expanded in x around 0 97.1%
+-commutative97.1%
mul-1-neg97.1%
sub-neg97.1%
div-sub98.7%
fma-neg98.7%
distribute-rgt-neg-out98.7%
Simplified98.7%
Final simplification98.2%
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 (/ a y))) (t_2 (- (* x y) (* z t))))
(if (<= t_2 -5e+286)
(- t_1 (* t (/ z a)))
(if (<= t_2 5e+257) (/ (fma y x (- (* z t))) a) (- t_1 (/ z (/ a t)))))))assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double t_1 = x / (a / y);
double t_2 = (x * y) - (z * t);
double tmp;
if (t_2 <= -5e+286) {
tmp = t_1 - (t * (z / a));
} else if (t_2 <= 5e+257) {
tmp = fma(y, x, -(z * t)) / a;
} else {
tmp = t_1 - (z / (a / t));
}
return tmp;
}
x, y = sort([x, y]) z, t = sort([z, t]) function code(x, y, z, t, a) t_1 = Float64(x / Float64(a / y)) t_2 = Float64(Float64(x * y) - Float64(z * t)) tmp = 0.0 if (t_2 <= -5e+286) tmp = Float64(t_1 - Float64(t * Float64(z / a))); elseif (t_2 <= 5e+257) tmp = Float64(fma(y, x, Float64(-Float64(z * t))) / a); else tmp = Float64(t_1 - Float64(z / Float64(a / t))); end return 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[(x / N[(a / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+286], N[(t$95$1 - N[(t * N[(z / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e+257], N[(N[(y * x + (-N[(z * t), $MachinePrecision])), $MachinePrecision] / a), $MachinePrecision], N[(t$95$1 - N[(z / N[(a / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
t_1 := \frac{x}{\frac{a}{y}}\\
t_2 := x \cdot y - z \cdot t\\
\mathbf{if}\;t_2 \leq -5 \cdot 10^{+286}:\\
\;\;\;\;t_1 - t \cdot \frac{z}{a}\\
\mathbf{elif}\;t_2 \leq 5 \cdot 10^{+257}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, x, -z \cdot t\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;t_1 - \frac{z}{\frac{a}{t}}\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -5.0000000000000004e286Initial program 65.6%
div-sub65.6%
associate-/l*82.6%
associate-/l*99.7%
Applied egg-rr99.7%
associate-/r/96.7%
Applied egg-rr96.7%
if -5.0000000000000004e286 < (-.f64 (*.f64 x y) (*.f64 z t)) < 5.00000000000000028e257Initial program 98.7%
Taylor expanded in x around 0 97.1%
+-commutative97.1%
mul-1-neg97.1%
sub-neg97.1%
div-sub98.7%
fma-neg98.7%
distribute-rgt-neg-out98.7%
Simplified98.7%
if 5.00000000000000028e257 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 79.8%
div-sub76.8%
associate-/l*85.6%
associate-/l*96.9%
Applied egg-rr96.9%
Final simplification98.2%
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))))
(if (or (<= t_1 -5e+286) (not (<= t_1 5e+257)))
(- (/ x (/ a y)) (* t (/ z a)))
(/ t_1 a))))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);
double tmp;
if ((t_1 <= -5e+286) || !(t_1 <= 5e+257)) {
tmp = (x / (a / y)) - (t * (z / a));
} else {
tmp = t_1 / 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) :: t_1
real(8) :: tmp
t_1 = (x * y) - (z * t)
if ((t_1 <= (-5d+286)) .or. (.not. (t_1 <= 5d+257))) then
tmp = (x / (a / y)) - (t * (z / a))
else
tmp = t_1 / 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 t_1 = (x * y) - (z * t);
double tmp;
if ((t_1 <= -5e+286) || !(t_1 <= 5e+257)) {
tmp = (x / (a / y)) - (t * (z / a));
} else {
tmp = t_1 / a;
}
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) tmp = 0 if (t_1 <= -5e+286) or not (t_1 <= 5e+257): tmp = (x / (a / y)) - (t * (z / a)) else: tmp = t_1 / a return tmp
x, y = sort([x, y]) z, t = sort([z, t]) function code(x, y, z, t, a) t_1 = Float64(Float64(x * y) - Float64(z * t)) tmp = 0.0 if ((t_1 <= -5e+286) || !(t_1 <= 5e+257)) tmp = Float64(Float64(x / Float64(a / y)) - Float64(t * Float64(z / a))); else tmp = Float64(t_1 / 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)
t_1 = (x * y) - (z * t);
tmp = 0.0;
if ((t_1 <= -5e+286) || ~((t_1 <= 5e+257)))
tmp = (x / (a / y)) - (t * (z / a));
else
tmp = t_1 / 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_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -5e+286], N[Not[LessEqual[t$95$1, 5e+257]], $MachinePrecision]], N[(N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision] - N[(t * N[(z / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / a), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{+286} \lor \neg \left(t_1 \leq 5 \cdot 10^{+257}\right):\\
\;\;\;\;\frac{x}{\frac{a}{y}} - t \cdot \frac{z}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{a}\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -5.0000000000000004e286 or 5.00000000000000028e257 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 72.7%
div-sub71.2%
associate-/l*84.1%
associate-/l*98.3%
Applied egg-rr98.3%
associate-/r/96.8%
Applied egg-rr96.8%
if -5.0000000000000004e286 < (-.f64 (*.f64 x y) (*.f64 z t)) < 5.00000000000000028e257Initial program 98.7%
Final simplification98.2%
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 (/ a y))) (t_2 (- (* x y) (* z t))))
(if (<= t_2 -5e+286)
(- t_1 (* t (/ z a)))
(if (<= t_2 5e+257) (/ t_2 a) (- t_1 (/ z (/ a t)))))))assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double t_1 = x / (a / y);
double t_2 = (x * y) - (z * t);
double tmp;
if (t_2 <= -5e+286) {
tmp = t_1 - (t * (z / a));
} else if (t_2 <= 5e+257) {
tmp = t_2 / a;
} else {
tmp = t_1 - (z / (a / t));
}
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = x / (a / y)
t_2 = (x * y) - (z * t)
if (t_2 <= (-5d+286)) then
tmp = t_1 - (t * (z / a))
else if (t_2 <= 5d+257) then
tmp = t_2 / a
else
tmp = t_1 - (z / (a / t))
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 t_1 = x / (a / y);
double t_2 = (x * y) - (z * t);
double tmp;
if (t_2 <= -5e+286) {
tmp = t_1 - (t * (z / a));
} else if (t_2 <= 5e+257) {
tmp = t_2 / a;
} else {
tmp = t_1 - (z / (a / t));
}
return tmp;
}
[x, y] = sort([x, y]) [z, t] = sort([z, t]) def code(x, y, z, t, a): t_1 = x / (a / y) t_2 = (x * y) - (z * t) tmp = 0 if t_2 <= -5e+286: tmp = t_1 - (t * (z / a)) elif t_2 <= 5e+257: tmp = t_2 / a else: tmp = t_1 - (z / (a / t)) return tmp
x, y = sort([x, y]) z, t = sort([z, t]) function code(x, y, z, t, a) t_1 = Float64(x / Float64(a / y)) t_2 = Float64(Float64(x * y) - Float64(z * t)) tmp = 0.0 if (t_2 <= -5e+286) tmp = Float64(t_1 - Float64(t * Float64(z / a))); elseif (t_2 <= 5e+257) tmp = Float64(t_2 / a); else tmp = Float64(t_1 - Float64(z / Float64(a / t))); 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 / (a / y);
t_2 = (x * y) - (z * t);
tmp = 0.0;
if (t_2 <= -5e+286)
tmp = t_1 - (t * (z / a));
elseif (t_2 <= 5e+257)
tmp = t_2 / a;
else
tmp = t_1 - (z / (a / t));
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[(x / N[(a / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+286], N[(t$95$1 - N[(t * N[(z / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e+257], N[(t$95$2 / a), $MachinePrecision], N[(t$95$1 - N[(z / N[(a / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
t_1 := \frac{x}{\frac{a}{y}}\\
t_2 := x \cdot y - z \cdot t\\
\mathbf{if}\;t_2 \leq -5 \cdot 10^{+286}:\\
\;\;\;\;t_1 - t \cdot \frac{z}{a}\\
\mathbf{elif}\;t_2 \leq 5 \cdot 10^{+257}:\\
\;\;\;\;\frac{t_2}{a}\\
\mathbf{else}:\\
\;\;\;\;t_1 - \frac{z}{\frac{a}{t}}\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -5.0000000000000004e286Initial program 65.6%
div-sub65.6%
associate-/l*82.6%
associate-/l*99.7%
Applied egg-rr99.7%
associate-/r/96.7%
Applied egg-rr96.7%
if -5.0000000000000004e286 < (-.f64 (*.f64 x y) (*.f64 z t)) < 5.00000000000000028e257Initial program 98.7%
if 5.00000000000000028e257 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 79.8%
div-sub76.8%
associate-/l*85.6%
associate-/l*96.9%
Applied egg-rr96.9%
Final simplification98.2%
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 -1.65e+252)
(* y (/ x a))
(if (<= x -2.6e+135)
(* x (/ y a))
(if (<= x -1.65e+56)
(/ y (/ a x))
(if (<= x 1.85e-33) (* (- z) (/ t a)) (/ x (/ a y)))))))assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (x <= -1.65e+252) {
tmp = y * (x / a);
} else if (x <= -2.6e+135) {
tmp = x * (y / a);
} else if (x <= -1.65e+56) {
tmp = y / (a / x);
} else if (x <= 1.85e-33) {
tmp = -z * (t / a);
} else {
tmp = x / (a / y);
}
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 <= (-1.65d+252)) then
tmp = y * (x / a)
else if (x <= (-2.6d+135)) then
tmp = x * (y / a)
else if (x <= (-1.65d+56)) then
tmp = y / (a / x)
else if (x <= 1.85d-33) then
tmp = -z * (t / a)
else
tmp = x / (a / y)
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 <= -1.65e+252) {
tmp = y * (x / a);
} else if (x <= -2.6e+135) {
tmp = x * (y / a);
} else if (x <= -1.65e+56) {
tmp = y / (a / x);
} else if (x <= 1.85e-33) {
tmp = -z * (t / a);
} else {
tmp = x / (a / y);
}
return tmp;
}
[x, y] = sort([x, y]) [z, t] = sort([z, t]) def code(x, y, z, t, a): tmp = 0 if x <= -1.65e+252: tmp = y * (x / a) elif x <= -2.6e+135: tmp = x * (y / a) elif x <= -1.65e+56: tmp = y / (a / x) elif x <= 1.85e-33: tmp = -z * (t / a) else: tmp = x / (a / y) return tmp
x, y = sort([x, y]) z, t = sort([z, t]) function code(x, y, z, t, a) tmp = 0.0 if (x <= -1.65e+252) tmp = Float64(y * Float64(x / a)); elseif (x <= -2.6e+135) tmp = Float64(x * Float64(y / a)); elseif (x <= -1.65e+56) tmp = Float64(y / Float64(a / x)); elseif (x <= 1.85e-33) tmp = Float64(Float64(-z) * Float64(t / a)); else tmp = Float64(x / Float64(a / y)); 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 <= -1.65e+252)
tmp = y * (x / a);
elseif (x <= -2.6e+135)
tmp = x * (y / a);
elseif (x <= -1.65e+56)
tmp = y / (a / x);
elseif (x <= 1.85e-33)
tmp = -z * (t / a);
else
tmp = x / (a / y);
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[x, -1.65e+252], N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2.6e+135], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.65e+56], N[(y / N[(a / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.85e-33], N[((-z) * N[(t / a), $MachinePrecision]), $MachinePrecision], N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.65 \cdot 10^{+252}:\\
\;\;\;\;y \cdot \frac{x}{a}\\
\mathbf{elif}\;x \leq -2.6 \cdot 10^{+135}:\\
\;\;\;\;x \cdot \frac{y}{a}\\
\mathbf{elif}\;x \leq -1.65 \cdot 10^{+56}:\\
\;\;\;\;\frac{y}{\frac{a}{x}}\\
\mathbf{elif}\;x \leq 1.85 \cdot 10^{-33}:\\
\;\;\;\;\left(-z\right) \cdot \frac{t}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{a}{y}}\\
\end{array}
\end{array}
if x < -1.65e252Initial program 85.7%
Taylor expanded in x around inf 78.3%
associate-*r/78.9%
Simplified78.9%
if -1.65e252 < x < -2.6e135Initial program 91.2%
Taylor expanded in x around inf 78.3%
associate-/l*78.1%
associate-/r/86.7%
Applied egg-rr86.7%
if -2.6e135 < x < -1.65000000000000001e56Initial program 74.6%
Taylor expanded in x around inf 57.9%
associate-/l*83.2%
Simplified83.2%
if -1.65000000000000001e56 < x < 1.85000000000000007e-33Initial program 94.8%
Taylor expanded in x around 0 94.0%
+-commutative94.0%
mul-1-neg94.0%
sub-neg94.0%
div-sub94.8%
fma-neg94.8%
distribute-rgt-neg-out94.8%
Simplified94.8%
Taylor expanded in y around 0 70.3%
mul-1-neg70.3%
associate-*l/69.5%
distribute-rgt-neg-in69.5%
Simplified69.5%
if 1.85000000000000007e-33 < x Initial program 92.3%
Taylor expanded in x around inf 63.9%
associate-*r/67.1%
Simplified67.1%
associate-*r/63.9%
*-commutative63.9%
associate-/l*62.9%
Applied egg-rr62.9%
Final simplification70.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 -2.3e+251)
(* y (/ x a))
(if (<= x -3.05e+134)
(* x (/ y a))
(if (<= x -3.9e+54)
(/ y (/ a x))
(if (<= x 3.05e-33) (/ (- (* z t)) a) (/ x (/ a y)))))))assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (x <= -2.3e+251) {
tmp = y * (x / a);
} else if (x <= -3.05e+134) {
tmp = x * (y / a);
} else if (x <= -3.9e+54) {
tmp = y / (a / x);
} else if (x <= 3.05e-33) {
tmp = -(z * t) / a;
} else {
tmp = x / (a / y);
}
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 <= (-2.3d+251)) then
tmp = y * (x / a)
else if (x <= (-3.05d+134)) then
tmp = x * (y / a)
else if (x <= (-3.9d+54)) then
tmp = y / (a / x)
else if (x <= 3.05d-33) then
tmp = -(z * t) / a
else
tmp = x / (a / y)
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 <= -2.3e+251) {
tmp = y * (x / a);
} else if (x <= -3.05e+134) {
tmp = x * (y / a);
} else if (x <= -3.9e+54) {
tmp = y / (a / x);
} else if (x <= 3.05e-33) {
tmp = -(z * t) / a;
} else {
tmp = x / (a / y);
}
return tmp;
}
[x, y] = sort([x, y]) [z, t] = sort([z, t]) def code(x, y, z, t, a): tmp = 0 if x <= -2.3e+251: tmp = y * (x / a) elif x <= -3.05e+134: tmp = x * (y / a) elif x <= -3.9e+54: tmp = y / (a / x) elif x <= 3.05e-33: tmp = -(z * t) / a else: tmp = x / (a / y) return tmp
x, y = sort([x, y]) z, t = sort([z, t]) function code(x, y, z, t, a) tmp = 0.0 if (x <= -2.3e+251) tmp = Float64(y * Float64(x / a)); elseif (x <= -3.05e+134) tmp = Float64(x * Float64(y / a)); elseif (x <= -3.9e+54) tmp = Float64(y / Float64(a / x)); elseif (x <= 3.05e-33) tmp = Float64(Float64(-Float64(z * t)) / a); else tmp = Float64(x / Float64(a / y)); 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 <= -2.3e+251)
tmp = y * (x / a);
elseif (x <= -3.05e+134)
tmp = x * (y / a);
elseif (x <= -3.9e+54)
tmp = y / (a / x);
elseif (x <= 3.05e-33)
tmp = -(z * t) / a;
else
tmp = x / (a / y);
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[x, -2.3e+251], N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -3.05e+134], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -3.9e+54], N[(y / N[(a / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.05e-33], N[((-N[(z * t), $MachinePrecision]) / a), $MachinePrecision], N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.3 \cdot 10^{+251}:\\
\;\;\;\;y \cdot \frac{x}{a}\\
\mathbf{elif}\;x \leq -3.05 \cdot 10^{+134}:\\
\;\;\;\;x \cdot \frac{y}{a}\\
\mathbf{elif}\;x \leq -3.9 \cdot 10^{+54}:\\
\;\;\;\;\frac{y}{\frac{a}{x}}\\
\mathbf{elif}\;x \leq 3.05 \cdot 10^{-33}:\\
\;\;\;\;\frac{-z \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{a}{y}}\\
\end{array}
\end{array}
if x < -2.29999999999999988e251Initial program 85.7%
Taylor expanded in x around inf 78.3%
associate-*r/78.9%
Simplified78.9%
if -2.29999999999999988e251 < x < -3.04999999999999989e134Initial program 91.2%
Taylor expanded in x around inf 78.3%
associate-/l*78.1%
associate-/r/86.7%
Applied egg-rr86.7%
if -3.04999999999999989e134 < x < -3.9000000000000003e54Initial program 74.6%
Taylor expanded in x around inf 57.9%
associate-/l*83.2%
Simplified83.2%
if -3.9000000000000003e54 < x < 3.0500000000000001e-33Initial program 94.9%
Taylor expanded in x around 0 70.0%
associate-*r/70.0%
associate-*r*70.0%
neg-mul-170.0%
Simplified70.0%
if 3.0500000000000001e-33 < x Initial program 92.1%
Taylor expanded in x around inf 63.1%
associate-*r/66.4%
Simplified66.4%
associate-*r/63.1%
*-commutative63.1%
associate-/l*63.1%
Applied egg-rr63.1%
Final simplification70.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+286) (* x (/ y 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 ((x * y) <= -5e+286) {
tmp = x * (y / 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 ((x * y) <= (-5d+286)) then
tmp = x * (y / 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 ((x * y) <= -5e+286) {
tmp = x * (y / 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 (x * y) <= -5e+286: tmp = x * (y / 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 (Float64(x * y) <= -5e+286) tmp = Float64(x * Float64(y / 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 ((x * y) <= -5e+286)
tmp = x * (y / 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[LessEqual[N[(x * y), $MachinePrecision], -5e+286], N[(x * N[(y / a), $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}\;x \cdot y \leq -5 \cdot 10^{+286}:\\
\;\;\;\;x \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\
\end{array}
\end{array}
if (*.f64 x y) < -5.0000000000000004e286Initial program 66.9%
Taylor expanded in x around inf 70.7%
associate-/l*96.0%
associate-/r/96.0%
Applied egg-rr96.0%
if -5.0000000000000004e286 < (*.f64 x y) Initial program 94.8%
Final simplification94.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 -2.5e+250) (* y (/ x 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 <= -2.5e+250) {
tmp = y * (x / 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 <= (-2.5d+250)) then
tmp = y * (x / 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 <= -2.5e+250) {
tmp = y * (x / 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 <= -2.5e+250: tmp = y * (x / 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 (x <= -2.5e+250) tmp = Float64(y * Float64(x / 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 <= -2.5e+250)
tmp = y * (x / 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[x, -2.5e+250], N[(y * N[(x / 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 \leq -2.5 \cdot 10^{+250}:\\
\;\;\;\;y \cdot \frac{x}{a}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{a}\\
\end{array}
\end{array}
if x < -2.5000000000000001e250Initial program 85.7%
Taylor expanded in x around inf 78.3%
associate-*r/78.9%
Simplified78.9%
if -2.5000000000000001e250 < x Initial program 92.3%
Taylor expanded in x around inf 50.5%
associate-/l*51.7%
associate-/r/51.8%
Applied egg-rr51.8%
Final simplification53.3%
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 -7.5e+248) (* y (/ x a)) (/ x (/ a y))))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (x <= -7.5e+248) {
tmp = y * (x / a);
} else {
tmp = x / (a / y);
}
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 <= (-7.5d+248)) then
tmp = y * (x / a)
else
tmp = x / (a / y)
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 <= -7.5e+248) {
tmp = y * (x / a);
} else {
tmp = x / (a / y);
}
return tmp;
}
[x, y] = sort([x, y]) [z, t] = sort([z, t]) def code(x, y, z, t, a): tmp = 0 if x <= -7.5e+248: tmp = y * (x / a) else: tmp = x / (a / y) return tmp
x, y = sort([x, y]) z, t = sort([z, t]) function code(x, y, z, t, a) tmp = 0.0 if (x <= -7.5e+248) tmp = Float64(y * Float64(x / a)); else tmp = Float64(x / Float64(a / y)); 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 <= -7.5e+248)
tmp = y * (x / a);
else
tmp = x / (a / y);
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[x, -7.5e+248], N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision], N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.5 \cdot 10^{+248}:\\
\;\;\;\;y \cdot \frac{x}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{a}{y}}\\
\end{array}
\end{array}
if x < -7.5000000000000004e248Initial program 80.4%
Taylor expanded in x around inf 73.5%
associate-*r/80.3%
Simplified80.3%
if -7.5000000000000004e248 < x Initial program 92.7%
Taylor expanded in x around inf 50.7%
associate-*r/51.6%
Simplified51.6%
associate-*r/50.7%
*-commutative50.7%
associate-/l*52.2%
Applied egg-rr52.2%
Final simplification53.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 (* y (/ x a)))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
return y * (x / 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 = y * (x / a)
end function
assert x < y;
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
return y * (x / a);
}
[x, y] = sort([x, y]) [z, t] = sort([z, t]) def code(x, y, z, t, a): return y * (x / a)
x, y = sort([x, y]) z, t = sort([z, t]) function code(x, y, z, t, a) return Float64(y * Float64(x / a)) end
x, y = num2cell(sort([x, y])){:}
z, t = num2cell(sort([z, t])){:}
function tmp = code(x, y, z, t, a)
tmp = y * (x / 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[(y * N[(x / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
y \cdot \frac{x}{a}
\end{array}
Initial program 92.0%
Taylor expanded in x around inf 52.1%
associate-*r/53.3%
Simplified53.3%
Final simplification53.3%
(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 2023257
(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))