
(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))))
(if (<= t_1 (- INFINITY))
(- (/ x (/ a y)) (* t (/ z a)))
(if (<= t_1 1e+125)
(/ t_1 a)
(if (<= t_1 INFINITY)
(fma -1.0 (/ t (/ a z)) (/ y (/ a x)))
(/ (- 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 * y) - (z * t);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = (x / (a / y)) - (t * (z / a));
} else if (t_1 <= 1e+125) {
tmp = t_1 / a;
} else if (t_1 <= ((double) INFINITY)) {
tmp = fma(-1.0, (t / (a / z)), (y / (a / x)));
} else {
tmp = -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(Float64(x * y) - Float64(z * t)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(Float64(x / Float64(a / y)) - Float64(t * Float64(z / a))); elseif (t_1 <= 1e+125) tmp = Float64(t_1 / a); elseif (t_1 <= Inf) tmp = fma(-1.0, Float64(t / Float64(a / z)), Float64(y / Float64(a / x))); else tmp = Float64(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[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision] - N[(t * N[(z / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+125], N[(t$95$1 / a), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(-1.0 * N[(t / N[(a / z), $MachinePrecision]), $MachinePrecision] + N[(y / N[(a / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-z) / N[(a / t), $MachinePrecision]), $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:\\
\;\;\;\;\frac{x}{\frac{a}{y}} - t \cdot \frac{z}{a}\\
\mathbf{elif}\;t_1 \leq 10^{+125}:\\
\;\;\;\;\frac{t_1}{a}\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{t}{\frac{a}{z}}, \frac{y}{\frac{a}{x}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-z}{\frac{a}{t}}\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -inf.0Initial program 51.1%
div-sub51.1%
associate-/l*69.5%
associate-/l*95.7%
Applied egg-rr95.7%
associate-/r/95.8%
Applied egg-rr95.8%
if -inf.0 < (-.f64 (*.f64 x y) (*.f64 z t)) < 9.9999999999999992e124Initial program 99.2%
if 9.9999999999999992e124 < (-.f64 (*.f64 x y) (*.f64 z t)) < +inf.0Initial program 89.8%
Taylor expanded in x around 0 89.8%
fma-def89.8%
associate-/l*89.7%
associate-/l*96.4%
Simplified96.4%
if +inf.0 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 0.0%
div-sub0.0%
associate-/l*0.0%
associate-/l*0.0%
Applied egg-rr0.0%
associate-/r/0.0%
Applied egg-rr0.0%
Taylor expanded in x around 0 100.0%
mul-1-neg100.0%
*-commutative100.0%
associate-/l*100.0%
Simplified100.0%
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 (/ z a)))) (t_2 (- (* x y) (* z t))))
(if (<= t_2 (- INFINITY))
t_1
(if (<= t_2 1e+85)
(/ t_2 a)
(if (<= t_2 INFINITY) 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)) - (t * (z / a));
double t_2 = (x * y) - (z * t);
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= 1e+85) {
tmp = t_2 / a;
} else if (t_2 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = -z / (a / t);
}
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 / (a / y)) - (t * (z / a));
double t_2 = (x * y) - (z * t);
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if (t_2 <= 1e+85) {
tmp = t_2 / a;
} else if (t_2 <= Double.POSITIVE_INFINITY) {
tmp = t_1;
} else {
tmp = -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 * (z / a)) t_2 = (x * y) - (z * t) tmp = 0 if t_2 <= -math.inf: tmp = t_1 elif t_2 <= 1e+85: tmp = t_2 / a elif t_2 <= math.inf: tmp = t_1 else: tmp = -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(Float64(x / Float64(a / y)) - Float64(t * Float64(z / a))) t_2 = Float64(Float64(x * y) - Float64(z * t)) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= 1e+85) tmp = Float64(t_2 / a); elseif (t_2 <= Inf) tmp = t_1; else tmp = Float64(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 * (z / a));
t_2 = (x * y) - (z * t);
tmp = 0.0;
if (t_2 <= -Inf)
tmp = t_1;
elseif (t_2 <= 1e+85)
tmp = t_2 / a;
elseif (t_2 <= Inf)
tmp = t_1;
else
tmp = -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[(N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision] - N[(t * N[(z / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 1e+85], N[(t$95$2 / a), $MachinePrecision], If[LessEqual[t$95$2, Infinity], t$95$1, N[((-z) / N[(a / t), $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 \cdot \frac{z}{a}\\
t_2 := x \cdot y - z \cdot t\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_2 \leq 10^{+85}:\\
\;\;\;\;\frac{t_2}{a}\\
\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{-z}{\frac{a}{t}}\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -inf.0 or 1e85 < (-.f64 (*.f64 x y) (*.f64 z t)) < +inf.0Initial program 79.4%
div-sub79.4%
associate-/l*86.7%
associate-/l*95.5%
Applied egg-rr95.5%
associate-/r/93.0%
Applied egg-rr93.0%
if -inf.0 < (-.f64 (*.f64 x y) (*.f64 z t)) < 1e85Initial program 99.1%
if +inf.0 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 0.0%
div-sub0.0%
associate-/l*0.0%
associate-/l*0.0%
Applied egg-rr0.0%
associate-/r/0.0%
Applied egg-rr0.0%
Taylor expanded in x around 0 100.0%
mul-1-neg100.0%
*-commutative100.0%
associate-/l*100.0%
Simplified100.0%
Final simplification97.1%
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) (- INFINITY)) (* y (/ x 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) <= -((double) INFINITY)) {
tmp = y * (x / a);
} else {
tmp = ((x * y) - (z * t)) / a;
}
return tmp;
}
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) <= -Double.POSITIVE_INFINITY) {
tmp = y * (x / 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) <= -math.inf: tmp = y * (x / 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) <= Float64(-Inf)) tmp = Float64(y * Float64(x / 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) <= -Inf)
tmp = y * (x / 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], (-Infinity)], N[(y * N[(x / 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 -\infty:\\
\;\;\;\;y \cdot \frac{x}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\
\end{array}
\end{array}
if (*.f64 x y) < -inf.0Initial program 36.8%
Taylor expanded in x around inf 36.8%
associate-*r/91.5%
Simplified91.5%
if -inf.0 < (*.f64 x y) Initial program 94.8%
Final simplification94.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 (<= t -6.2e-140) (not (<= t 8.9e+83))) (/ (- z) (/ a t)) (* y (/ x a))))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -6.2e-140) || !(t <= 8.9e+83)) {
tmp = -z / (a / t);
} else {
tmp = y * (x / 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 ((t <= (-6.2d-140)) .or. (.not. (t <= 8.9d+83))) then
tmp = -z / (a / t)
else
tmp = y * (x / 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 ((t <= -6.2e-140) || !(t <= 8.9e+83)) {
tmp = -z / (a / t);
} else {
tmp = y * (x / a);
}
return tmp;
}
[x, y] = sort([x, y]) [z, t] = sort([z, t]) def code(x, y, z, t, a): tmp = 0 if (t <= -6.2e-140) or not (t <= 8.9e+83): tmp = -z / (a / t) else: tmp = y * (x / a) return tmp
x, y = sort([x, y]) z, t = sort([z, t]) function code(x, y, z, t, a) tmp = 0.0 if ((t <= -6.2e-140) || !(t <= 8.9e+83)) tmp = Float64(Float64(-z) / Float64(a / t)); else tmp = Float64(y * Float64(x / 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 ((t <= -6.2e-140) || ~((t <= 8.9e+83)))
tmp = -z / (a / t);
else
tmp = y * (x / 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[t, -6.2e-140], N[Not[LessEqual[t, 8.9e+83]], $MachinePrecision]], N[((-z) / N[(a / t), $MachinePrecision]), $MachinePrecision], N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq -6.2 \cdot 10^{-140} \lor \neg \left(t \leq 8.9 \cdot 10^{+83}\right):\\
\;\;\;\;\frac{-z}{\frac{a}{t}}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{a}\\
\end{array}
\end{array}
if t < -6.1999999999999998e-140 or 8.90000000000000045e83 < t Initial program 90.2%
div-sub88.7%
associate-/l*82.3%
associate-/l*82.9%
Applied egg-rr82.9%
associate-/r/85.8%
Applied egg-rr85.8%
Taylor expanded in x around 0 61.8%
mul-1-neg61.8%
*-commutative61.8%
associate-/l*61.6%
Simplified61.6%
if -6.1999999999999998e-140 < t < 8.90000000000000045e83Initial program 94.2%
Taylor expanded in x around inf 72.1%
associate-*r/73.6%
Simplified73.6%
Final simplification67.1%
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 (<= t -9.8e-142) (* z (- (/ t a))) (if (<= t 8.5e+83) (* y (/ x a)) (/ (- z) (/ a t)))))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -9.8e-142) {
tmp = z * -(t / a);
} else if (t <= 8.5e+83) {
tmp = y * (x / a);
} else {
tmp = -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) :: tmp
if (t <= (-9.8d-142)) then
tmp = z * -(t / a)
else if (t <= 8.5d+83) then
tmp = y * (x / a)
else
tmp = -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 tmp;
if (t <= -9.8e-142) {
tmp = z * -(t / a);
} else if (t <= 8.5e+83) {
tmp = y * (x / a);
} else {
tmp = -z / (a / t);
}
return tmp;
}
[x, y] = sort([x, y]) [z, t] = sort([z, t]) def code(x, y, z, t, a): tmp = 0 if t <= -9.8e-142: tmp = z * -(t / a) elif t <= 8.5e+83: tmp = y * (x / a) else: tmp = -z / (a / t) return tmp
x, y = sort([x, y]) z, t = sort([z, t]) function code(x, y, z, t, a) tmp = 0.0 if (t <= -9.8e-142) tmp = Float64(z * Float64(-Float64(t / a))); elseif (t <= 8.5e+83) tmp = Float64(y * Float64(x / a)); else tmp = Float64(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)
tmp = 0.0;
if (t <= -9.8e-142)
tmp = z * -(t / a);
elseif (t <= 8.5e+83)
tmp = y * (x / a);
else
tmp = -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_] := If[LessEqual[t, -9.8e-142], N[(z * (-N[(t / a), $MachinePrecision])), $MachinePrecision], If[LessEqual[t, 8.5e+83], N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision], N[((-z) / N[(a / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq -9.8 \cdot 10^{-142}:\\
\;\;\;\;z \cdot \left(-\frac{t}{a}\right)\\
\mathbf{elif}\;t \leq 8.5 \cdot 10^{+83}:\\
\;\;\;\;y \cdot \frac{x}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-z}{\frac{a}{t}}\\
\end{array}
\end{array}
if t < -9.8000000000000007e-142Initial program 90.2%
Taylor expanded in x around 0 89.1%
+-commutative89.1%
mul-1-neg89.1%
sub-neg89.1%
div-sub90.2%
fma-neg90.2%
distribute-rgt-neg-out90.2%
Simplified90.2%
Taylor expanded in y around 0 60.1%
mul-1-neg60.1%
associate-*l/61.1%
distribute-rgt-neg-in61.1%
Simplified61.1%
if -9.8000000000000007e-142 < t < 8.4999999999999995e83Initial program 94.1%
Taylor expanded in x around inf 71.9%
associate-*r/73.4%
Simplified73.4%
if 8.4999999999999995e83 < t Initial program 90.4%
div-sub87.9%
associate-/l*78.1%
associate-/l*73.1%
Applied egg-rr73.1%
associate-/r/82.6%
Applied egg-rr82.6%
Taylor expanded in x around 0 64.5%
mul-1-neg64.5%
*-commutative64.5%
associate-/l*61.2%
Simplified61.2%
Final simplification66.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 (if (<= t -6.2e-140) (* z (- (/ t a))) (if (<= t 3.6e+83) (* y (/ x a)) (- (* t (/ z a))))))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -6.2e-140) {
tmp = z * -(t / a);
} else if (t <= 3.6e+83) {
tmp = y * (x / a);
} else {
tmp = -(t * (z / 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 (t <= (-6.2d-140)) then
tmp = z * -(t / a)
else if (t <= 3.6d+83) then
tmp = y * (x / a)
else
tmp = -(t * (z / 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 (t <= -6.2e-140) {
tmp = z * -(t / a);
} else if (t <= 3.6e+83) {
tmp = y * (x / a);
} else {
tmp = -(t * (z / a));
}
return tmp;
}
[x, y] = sort([x, y]) [z, t] = sort([z, t]) def code(x, y, z, t, a): tmp = 0 if t <= -6.2e-140: tmp = z * -(t / a) elif t <= 3.6e+83: tmp = y * (x / a) else: tmp = -(t * (z / a)) return tmp
x, y = sort([x, y]) z, t = sort([z, t]) function code(x, y, z, t, a) tmp = 0.0 if (t <= -6.2e-140) tmp = Float64(z * Float64(-Float64(t / a))); elseif (t <= 3.6e+83) tmp = Float64(y * Float64(x / a)); else tmp = Float64(-Float64(t * Float64(z / 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 (t <= -6.2e-140)
tmp = z * -(t / a);
elseif (t <= 3.6e+83)
tmp = y * (x / a);
else
tmp = -(t * (z / 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[t, -6.2e-140], N[(z * (-N[(t / a), $MachinePrecision])), $MachinePrecision], If[LessEqual[t, 3.6e+83], N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision], (-N[(t * N[(z / a), $MachinePrecision]), $MachinePrecision])]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq -6.2 \cdot 10^{-140}:\\
\;\;\;\;z \cdot \left(-\frac{t}{a}\right)\\
\mathbf{elif}\;t \leq 3.6 \cdot 10^{+83}:\\
\;\;\;\;y \cdot \frac{x}{a}\\
\mathbf{else}:\\
\;\;\;\;-t \cdot \frac{z}{a}\\
\end{array}
\end{array}
if t < -6.1999999999999998e-140Initial program 90.1%
Taylor expanded in x around 0 89.0%
+-commutative89.0%
mul-1-neg89.0%
sub-neg89.0%
div-sub90.1%
fma-neg90.1%
distribute-rgt-neg-out90.1%
Simplified90.1%
Taylor expanded in y around 0 60.7%
mul-1-neg60.7%
associate-*l/61.7%
distribute-rgt-neg-in61.7%
Simplified61.7%
if -6.1999999999999998e-140 < t < 3.5999999999999997e83Initial program 94.2%
Taylor expanded in x around inf 72.1%
associate-*r/73.6%
Simplified73.6%
if 3.5999999999999997e83 < t Initial program 90.4%
Taylor expanded in x around 0 64.5%
associate-*r/64.5%
mul-1-neg64.5%
distribute-rgt-neg-out64.5%
*-commutative64.5%
associate-/l*61.2%
associate-/r/69.0%
Simplified69.0%
Final simplification68.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 (<= z -4.6e+67) (* 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 (z <= -4.6e+67) {
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 (z <= (-4.6d+67)) 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 (z <= -4.6e+67) {
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 z <= -4.6e+67: 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 (z <= -4.6e+67) tmp = Float64(y * Float64(x / a)); else tmp = Float64(Float64(x * 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 (z <= -4.6e+67)
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[z, -4.6e+67], N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.6 \cdot 10^{+67}:\\
\;\;\;\;y \cdot \frac{x}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{a}\\
\end{array}
\end{array}
if z < -4.5999999999999997e67Initial program 74.1%
Taylor expanded in x around inf 20.7%
associate-*r/29.1%
Simplified29.1%
if -4.5999999999999997e67 < z Initial program 94.7%
Taylor expanded in x around inf 57.8%
Final simplification54.1%
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 53.1%
associate-*r/53.7%
Simplified53.7%
Final simplification53.7%
(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 2023238
(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))