
(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 11 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.
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- (* x y) (* z t))))
(if (<= t_1 (- INFINITY))
(- (* x (/ y a)) (/ z (/ a t)))
(if (<= t_1 5e+292) (/ t_1 a) (fma x (/ y a) (/ (- z) (/ a t)))))))assert(x < y);
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 * (y / a)) - (z / (a / t));
} else if (t_1 <= 5e+292) {
tmp = t_1 / a;
} else {
tmp = fma(x, (y / a), (-z / (a / t)));
}
return tmp;
}
x, y = sort([x, y]) 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(y / a)) - Float64(z / Float64(a / t))); elseif (t_1 <= 5e+292) tmp = Float64(t_1 / a); else tmp = fma(x, Float64(y / a), Float64(Float64(-z) / Float64(a / t))); end return tmp end
NOTE: x and y 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[(y / a), $MachinePrecision]), $MachinePrecision] - N[(z / N[(a / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+292], N[(t$95$1 / a), $MachinePrecision], N[(x * N[(y / a), $MachinePrecision] + N[((-z) / N[(a / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;x \cdot \frac{y}{a} - \frac{z}{\frac{a}{t}}\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+292}:\\
\;\;\;\;\frac{t_1}{a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{y}{a}, \frac{-z}{\frac{a}{t}}\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -inf.0Initial program 60.6%
div-sub56.4%
associate-/l*64.2%
associate-/l*95.5%
Applied egg-rr95.5%
clear-num95.6%
associate-/r/95.5%
clear-num95.5%
Applied egg-rr95.5%
if -inf.0 < (-.f64 (*.f64 x y) (*.f64 z t)) < 4.9999999999999996e292Initial program 97.7%
if 4.9999999999999996e292 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 66.6%
div-sub61.6%
*-un-lft-identity61.6%
times-frac78.1%
fma-neg80.6%
associate-/l*92.3%
Applied egg-rr92.3%
Final simplification96.6%
NOTE: x and y 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 5e+292)))
(- (* x (/ y a)) (/ z (/ a t)))
(/ t_1 a))))assert(x < y);
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 <= 5e+292)) {
tmp = (x * (y / a)) - (z / (a / t));
} else {
tmp = t_1 / a;
}
return tmp;
}
assert x < y;
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 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 5e+292)) {
tmp = (x * (y / a)) - (z / (a / t));
} else {
tmp = t_1 / a;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): t_1 = (x * y) - (z * t) tmp = 0 if (t_1 <= -math.inf) or not (t_1 <= 5e+292): tmp = (x * (y / a)) - (z / (a / t)) else: tmp = t_1 / a return tmp
x, y = sort([x, y]) 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 <= 5e+292)) tmp = Float64(Float64(x * Float64(y / a)) - Float64(z / Float64(a / t))); else tmp = Float64(t_1 / a); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t, a)
t_1 = (x * y) - (z * t);
tmp = 0.0;
if ((t_1 <= -Inf) || ~((t_1 <= 5e+292)))
tmp = (x * (y / a)) - (z / (a / t));
else
tmp = t_1 / a;
end
tmp_2 = tmp;
end
NOTE: x and y 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, 5e+292]], $MachinePrecision]], N[(N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision] - N[(z / N[(a / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / a), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 5 \cdot 10^{+292}\right):\\
\;\;\;\;x \cdot \frac{y}{a} - \frac{z}{\frac{a}{t}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{a}\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -inf.0 or 4.9999999999999996e292 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 64.3%
div-sub59.7%
associate-/l*72.9%
associate-/l*92.0%
Applied egg-rr92.0%
clear-num92.0%
associate-/r/92.0%
clear-num92.0%
Applied egg-rr92.0%
if -inf.0 < (-.f64 (*.f64 x y) (*.f64 z t)) < 4.9999999999999996e292Initial program 97.7%
Final simplification96.2%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ z (/ a t))) (t_2 (- (* x y) (* z t))))
(if (<= t_2 (- INFINITY))
(- (* x (/ y a)) t_1)
(if (<= t_2 5e+292) (/ t_2 a) (- (/ x (/ a y)) t_1)))))assert(x < y);
double code(double x, double y, double z, double t, double a) {
double t_1 = z / (a / t);
double t_2 = (x * y) - (z * t);
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = (x * (y / a)) - t_1;
} else if (t_2 <= 5e+292) {
tmp = t_2 / a;
} else {
tmp = (x / (a / y)) - t_1;
}
return tmp;
}
assert x < y;
public static double code(double x, double y, double z, double t, double a) {
double t_1 = z / (a / t);
double t_2 = (x * y) - (z * t);
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = (x * (y / a)) - t_1;
} else if (t_2 <= 5e+292) {
tmp = t_2 / a;
} else {
tmp = (x / (a / y)) - t_1;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): t_1 = z / (a / t) t_2 = (x * y) - (z * t) tmp = 0 if t_2 <= -math.inf: tmp = (x * (y / a)) - t_1 elif t_2 <= 5e+292: tmp = t_2 / a else: tmp = (x / (a / y)) - t_1 return tmp
x, y = sort([x, y]) function code(x, y, z, t, a) t_1 = Float64(z / Float64(a / t)) t_2 = Float64(Float64(x * y) - Float64(z * t)) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(Float64(x * Float64(y / a)) - t_1); elseif (t_2 <= 5e+292) tmp = Float64(t_2 / a); else tmp = Float64(Float64(x / Float64(a / y)) - t_1); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t, a)
t_1 = z / (a / t);
t_2 = (x * y) - (z * t);
tmp = 0.0;
if (t_2 <= -Inf)
tmp = (x * (y / a)) - t_1;
elseif (t_2 <= 5e+292)
tmp = t_2 / a;
else
tmp = (x / (a / y)) - t_1;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(z / N[(a / t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], If[LessEqual[t$95$2, 5e+292], N[(t$95$2 / a), $MachinePrecision], N[(N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_1 := \frac{z}{\frac{a}{t}}\\
t_2 := x \cdot y - z \cdot t\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;x \cdot \frac{y}{a} - t_1\\
\mathbf{elif}\;t_2 \leq 5 \cdot 10^{+292}:\\
\;\;\;\;\frac{t_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{a}{y}} - t_1\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -inf.0Initial program 60.6%
div-sub56.4%
associate-/l*64.2%
associate-/l*95.5%
Applied egg-rr95.5%
clear-num95.6%
associate-/r/95.5%
clear-num95.5%
Applied egg-rr95.5%
if -inf.0 < (-.f64 (*.f64 x y) (*.f64 z t)) < 4.9999999999999996e292Initial program 97.7%
if 4.9999999999999996e292 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 66.6%
div-sub61.6%
associate-/l*78.2%
associate-/l*89.9%
Applied egg-rr89.9%
Final simplification96.3%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
:precision binary64
(if (<= (* z t) -2e+140)
(/ z (- (/ a t)))
(if (<= (* z t) -4e-53)
(/ -1.0 (/ a (* z t)))
(if (<= (* z t) 50000000000.0) (/ (* x y) a) (* (- t) (/ z a))))))assert(x < y);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z * t) <= -2e+140) {
tmp = z / -(a / t);
} else if ((z * t) <= -4e-53) {
tmp = -1.0 / (a / (z * t));
} else if ((z * t) <= 50000000000.0) {
tmp = (x * y) / a;
} else {
tmp = -t * (z / a);
}
return tmp;
}
NOTE: x and y 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 * t) <= (-2d+140)) then
tmp = z / -(a / t)
else if ((z * t) <= (-4d-53)) then
tmp = (-1.0d0) / (a / (z * t))
else if ((z * t) <= 50000000000.0d0) then
tmp = (x * y) / a
else
tmp = -t * (z / a)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z * t) <= -2e+140) {
tmp = z / -(a / t);
} else if ((z * t) <= -4e-53) {
tmp = -1.0 / (a / (z * t));
} else if ((z * t) <= 50000000000.0) {
tmp = (x * y) / a;
} else {
tmp = -t * (z / a);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): tmp = 0 if (z * t) <= -2e+140: tmp = z / -(a / t) elif (z * t) <= -4e-53: tmp = -1.0 / (a / (z * t)) elif (z * t) <= 50000000000.0: tmp = (x * y) / a else: tmp = -t * (z / a) return tmp
x, y = sort([x, y]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(z * t) <= -2e+140) tmp = Float64(z / Float64(-Float64(a / t))); elseif (Float64(z * t) <= -4e-53) tmp = Float64(-1.0 / Float64(a / Float64(z * t))); elseif (Float64(z * t) <= 50000000000.0) tmp = Float64(Float64(x * y) / a); else tmp = Float64(Float64(-t) * Float64(z / a)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((z * t) <= -2e+140)
tmp = z / -(a / t);
elseif ((z * t) <= -4e-53)
tmp = -1.0 / (a / (z * t));
elseif ((z * t) <= 50000000000.0)
tmp = (x * y) / 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. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(z * t), $MachinePrecision], -2e+140], N[(z / (-N[(a / t), $MachinePrecision])), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], -4e-53], N[(-1.0 / N[(a / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 50000000000.0], N[(N[(x * y), $MachinePrecision] / a), $MachinePrecision], N[((-t) * N[(z / a), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+140}:\\
\;\;\;\;\frac{z}{-\frac{a}{t}}\\
\mathbf{elif}\;z \cdot t \leq -4 \cdot 10^{-53}:\\
\;\;\;\;\frac{-1}{\frac{a}{z \cdot t}}\\
\mathbf{elif}\;z \cdot t \leq 50000000000:\\
\;\;\;\;\frac{x \cdot y}{a}\\
\mathbf{else}:\\
\;\;\;\;\left(-t\right) \cdot \frac{z}{a}\\
\end{array}
\end{array}
if (*.f64 z t) < -2.00000000000000012e140Initial program 80.7%
Taylor expanded in x around 0 78.0%
associate-*r/78.0%
associate-*r*78.0%
neg-mul-178.0%
Simplified78.0%
associate-/l*91.3%
associate-/r/88.7%
add-sqr-sqrt40.0%
sqrt-unprod32.4%
sqr-neg32.4%
sqrt-unprod3.1%
add-sqr-sqrt3.3%
Applied egg-rr3.3%
*-commutative3.3%
clear-num3.3%
div-inv3.3%
frac-2neg3.3%
add-sqr-sqrt3.1%
sqrt-unprod43.3%
sqr-neg43.3%
sqrt-unprod40.1%
add-sqr-sqrt88.7%
distribute-neg-frac88.7%
Applied egg-rr88.7%
if -2.00000000000000012e140 < (*.f64 z t) < -4.00000000000000012e-53Initial program 94.5%
Taylor expanded in x around 0 71.5%
associate-*r/71.5%
associate-*r*71.5%
neg-mul-171.5%
Simplified71.5%
associate-/l*59.5%
associate-/r/57.3%
add-sqr-sqrt29.8%
sqrt-unprod13.1%
sqr-neg13.1%
sqrt-unprod1.0%
add-sqr-sqrt2.0%
Applied egg-rr2.0%
*-commutative2.0%
clear-num2.0%
div-inv2.0%
frac-2neg2.0%
neg-mul-12.0%
associate-/l*2.0%
add-sqr-sqrt1.1%
sqrt-unprod27.9%
sqr-neg27.9%
sqrt-unprod27.2%
add-sqr-sqrt57.6%
frac-2neg57.6%
associate-/l/71.6%
Applied egg-rr71.6%
if -4.00000000000000012e-53 < (*.f64 z t) < 5e10Initial program 94.2%
Taylor expanded in x around inf 76.5%
if 5e10 < (*.f64 z t) Initial program 81.8%
Taylor expanded in x around 0 69.1%
associate-*r/69.1%
mul-1-neg69.1%
distribute-rgt-neg-out69.1%
*-commutative69.1%
associate-/l*77.0%
associate-/r/79.1%
Simplified79.1%
Final simplification78.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= (* z t) (- INFINITY)) (/ z (- (/ a t))) (if (<= (* z t) 1e+306) (/ (- (* x y) (* z t)) a) (* z (/ (- t) a)))))
assert(x < y);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z * t) <= -((double) INFINITY)) {
tmp = z / -(a / t);
} else if ((z * t) <= 1e+306) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = z * (-t / a);
}
return tmp;
}
assert x < y;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z * t) <= -Double.POSITIVE_INFINITY) {
tmp = z / -(a / t);
} else if ((z * t) <= 1e+306) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = z * (-t / a);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): tmp = 0 if (z * t) <= -math.inf: tmp = z / -(a / t) elif (z * t) <= 1e+306: tmp = ((x * y) - (z * t)) / a else: tmp = z * (-t / a) return tmp
x, y = sort([x, y]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(z * t) <= Float64(-Inf)) tmp = Float64(z / Float64(-Float64(a / t))); elseif (Float64(z * t) <= 1e+306) tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a); else tmp = Float64(z * Float64(Float64(-t) / a)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((z * t) <= -Inf)
tmp = z / -(a / t);
elseif ((z * t) <= 1e+306)
tmp = ((x * y) - (z * t)) / a;
else
tmp = z * (-t / a);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(z * t), $MachinePrecision], (-Infinity)], N[(z / (-N[(a / t), $MachinePrecision])), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 1e+306], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(z * N[((-t) / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -\infty:\\
\;\;\;\;\frac{z}{-\frac{a}{t}}\\
\mathbf{elif}\;z \cdot t \leq 10^{+306}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{-t}{a}\\
\end{array}
\end{array}
if (*.f64 z t) < -inf.0Initial program 71.1%
Taylor expanded in x around 0 76.1%
associate-*r/76.1%
associate-*r*76.1%
neg-mul-176.1%
Simplified76.1%
associate-/l*94.9%
associate-/r/94.8%
add-sqr-sqrt34.8%
sqrt-unprod30.4%
sqr-neg30.4%
sqrt-unprod5.0%
add-sqr-sqrt5.1%
Applied egg-rr5.1%
*-commutative5.1%
clear-num5.1%
div-inv5.1%
frac-2neg5.1%
add-sqr-sqrt5.0%
sqrt-unprod35.3%
sqr-neg35.3%
sqrt-unprod34.9%
add-sqr-sqrt94.9%
distribute-neg-frac94.9%
Applied egg-rr94.9%
if -inf.0 < (*.f64 z t) < 1.00000000000000002e306Initial program 94.1%
if 1.00000000000000002e306 < (*.f64 z t) Initial program 52.4%
clear-num52.4%
inv-pow52.4%
fma-neg52.7%
*-commutative52.7%
distribute-rgt-neg-in52.7%
Applied egg-rr52.7%
Taylor expanded in x around 0 52.7%
mul-1-neg52.7%
associate-*l/96.3%
distribute-rgt-neg-in96.3%
Simplified96.3%
Final simplification94.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= (* x y) -1e-14) (/ (* x y) a) (if (<= (* x y) 4e-26) (/ (* z (- t)) a) (* y (/ x a)))))
assert(x < y);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -1e-14) {
tmp = (x * y) / a;
} else if ((x * y) <= 4e-26) {
tmp = (z * -t) / a;
} else {
tmp = y * (x / a);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if ((x * y) <= (-1d-14)) then
tmp = (x * y) / a
else if ((x * y) <= 4d-26) then
tmp = (z * -t) / a
else
tmp = y * (x / a)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -1e-14) {
tmp = (x * y) / a;
} else if ((x * y) <= 4e-26) {
tmp = (z * -t) / a;
} else {
tmp = y * (x / a);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): tmp = 0 if (x * y) <= -1e-14: tmp = (x * y) / a elif (x * y) <= 4e-26: tmp = (z * -t) / a else: tmp = y * (x / a) return tmp
x, y = sort([x, y]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= -1e-14) tmp = Float64(Float64(x * y) / a); elseif (Float64(x * y) <= 4e-26) tmp = Float64(Float64(z * Float64(-t)) / a); else tmp = Float64(y * Float64(x / a)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((x * y) <= -1e-14)
tmp = (x * y) / a;
elseif ((x * y) <= 4e-26)
tmp = (z * -t) / a;
else
tmp = y * (x / a);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], -1e-14], N[(N[(x * y), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 4e-26], N[(N[(z * (-t)), $MachinePrecision] / a), $MachinePrecision], N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{-14}:\\
\;\;\;\;\frac{x \cdot y}{a}\\
\mathbf{elif}\;x \cdot y \leq 4 \cdot 10^{-26}:\\
\;\;\;\;\frac{z \cdot \left(-t\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{a}\\
\end{array}
\end{array}
if (*.f64 x y) < -9.99999999999999999e-15Initial program 89.0%
Taylor expanded in x around inf 69.6%
if -9.99999999999999999e-15 < (*.f64 x y) < 4.0000000000000002e-26Initial program 91.8%
Taylor expanded in x around 0 79.4%
associate-*r/79.4%
associate-*r*79.4%
neg-mul-179.4%
Simplified79.4%
if 4.0000000000000002e-26 < (*.f64 x y) Initial program 84.5%
Taylor expanded in x around inf 69.7%
associate-*r/77.4%
Simplified77.4%
Final simplification76.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (or (<= y -5.5e-84) (not (<= y 1.7e+103))) (* y (/ x a)) (* z (/ (- t) a))))
assert(x < y);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((y <= -5.5e-84) || !(y <= 1.7e+103)) {
tmp = y * (x / a);
} else {
tmp = z * (-t / a);
}
return tmp;
}
NOTE: x and y 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 ((y <= (-5.5d-84)) .or. (.not. (y <= 1.7d+103))) then
tmp = y * (x / a)
else
tmp = z * (-t / a)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((y <= -5.5e-84) || !(y <= 1.7e+103)) {
tmp = y * (x / a);
} else {
tmp = z * (-t / a);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): tmp = 0 if (y <= -5.5e-84) or not (y <= 1.7e+103): tmp = y * (x / a) else: tmp = z * (-t / a) return tmp
x, y = sort([x, y]) function code(x, y, z, t, a) tmp = 0.0 if ((y <= -5.5e-84) || !(y <= 1.7e+103)) tmp = Float64(y * Float64(x / a)); else tmp = Float64(z * Float64(Float64(-t) / a)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((y <= -5.5e-84) || ~((y <= 1.7e+103)))
tmp = y * (x / a);
else
tmp = z * (-t / a);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[Or[LessEqual[y, -5.5e-84], N[Not[LessEqual[y, 1.7e+103]], $MachinePrecision]], N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision], N[(z * N[((-t) / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{-84} \lor \neg \left(y \leq 1.7 \cdot 10^{+103}\right):\\
\;\;\;\;y \cdot \frac{x}{a}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{-t}{a}\\
\end{array}
\end{array}
if y < -5.50000000000000019e-84 or 1.6999999999999999e103 < y Initial program 88.4%
Taylor expanded in x around inf 61.7%
associate-*r/66.2%
Simplified66.2%
if -5.50000000000000019e-84 < y < 1.6999999999999999e103Initial program 90.2%
clear-num90.2%
inv-pow90.2%
fma-neg90.2%
*-commutative90.2%
distribute-rgt-neg-in90.2%
Applied egg-rr90.2%
Taylor expanded in x around 0 70.8%
mul-1-neg70.8%
associate-*l/70.9%
distribute-rgt-neg-in70.9%
Simplified70.9%
Final simplification68.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (or (<= y -7.6e-23) (not (<= y 4.8e+103))) (* y (/ x a)) (* (- t) (/ z a))))
assert(x < y);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((y <= -7.6e-23) || !(y <= 4.8e+103)) {
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.
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 ((y <= (-7.6d-23)) .or. (.not. (y <= 4.8d+103))) then
tmp = y * (x / a)
else
tmp = -t * (z / a)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((y <= -7.6e-23) || !(y <= 4.8e+103)) {
tmp = y * (x / a);
} else {
tmp = -t * (z / a);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): tmp = 0 if (y <= -7.6e-23) or not (y <= 4.8e+103): tmp = y * (x / a) else: tmp = -t * (z / a) return tmp
x, y = sort([x, y]) function code(x, y, z, t, a) tmp = 0.0 if ((y <= -7.6e-23) || !(y <= 4.8e+103)) tmp = Float64(y * Float64(x / a)); else tmp = Float64(Float64(-t) * Float64(z / a)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((y <= -7.6e-23) || ~((y <= 4.8e+103)))
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. code[x_, y_, z_, t_, a_] := If[Or[LessEqual[y, -7.6e-23], N[Not[LessEqual[y, 4.8e+103]], $MachinePrecision]], N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision], N[((-t) * N[(z / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.6 \cdot 10^{-23} \lor \neg \left(y \leq 4.8 \cdot 10^{+103}\right):\\
\;\;\;\;y \cdot \frac{x}{a}\\
\mathbf{else}:\\
\;\;\;\;\left(-t\right) \cdot \frac{z}{a}\\
\end{array}
\end{array}
if y < -7.60000000000000023e-23 or 4.7999999999999997e103 < y Initial program 87.8%
Taylor expanded in x around inf 64.4%
associate-*r/69.4%
Simplified69.4%
if -7.60000000000000023e-23 < y < 4.7999999999999997e103Initial program 90.6%
Taylor expanded in x around 0 69.2%
associate-*r/69.2%
mul-1-neg69.2%
distribute-rgt-neg-out69.2%
*-commutative69.2%
associate-/l*70.0%
associate-/r/68.6%
Simplified68.6%
Final simplification69.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (* y (/ x a)))
assert(x < y);
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.
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;
public static double code(double x, double y, double z, double t, double a) {
return y * (x / a);
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): return y * (x / a)
x, y = sort([x, y]) function code(x, y, z, t, a) return Float64(y * Float64(x / a)) end
x, y = num2cell(sort([x, y])){:}
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. code[x_, y_, z_, t_, a_] := N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
y \cdot \frac{x}{a}
\end{array}
Initial program 89.3%
Taylor expanded in x around inf 46.2%
associate-*r/48.2%
Simplified48.2%
Final simplification48.2%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (* x (/ y a)))
assert(x < y);
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.
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;
public static double code(double x, double y, double z, double t, double a) {
return x * (y / a);
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): return x * (y / a)
x, y = sort([x, y]) function code(x, y, z, t, a) return Float64(x * Float64(y / a)) end
x, y = num2cell(sort([x, y])){:}
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. code[x_, y_, z_, t_, a_] := N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
x \cdot \frac{y}{a}
\end{array}
Initial program 89.3%
Taylor expanded in x around inf 46.2%
associate-/l*47.8%
associate-/r/47.3%
Applied egg-rr47.3%
Final simplification47.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (/ x (/ a y)))
assert(x < y);
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.
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;
public static double code(double x, double y, double z, double t, double a) {
return x / (a / y);
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): return x / (a / y)
x, y = sort([x, y]) function code(x, y, z, t, a) return Float64(x / Float64(a / y)) end
x, y = num2cell(sort([x, y])){:}
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. code[x_, y_, z_, t_, a_] := N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{x}{\frac{a}{y}}
\end{array}
Initial program 89.3%
Taylor expanded in x around inf 46.2%
associate-*r/48.2%
Simplified48.2%
associate-*r/46.2%
*-commutative46.2%
associate-/l*47.1%
Applied egg-rr47.1%
Final simplification47.1%
(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 2023176
(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))