
(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 (* (/ t a) z)))
(if (<= a -1.32e+38)
(- (* (/ y (pow (cbrt a) 2.0)) (/ x (cbrt a))) t_1)
(if (<= a 2.2e+114) (/ (fma x y (* t (- z))) a) (- (/ y (/ a x)) t_1)))))assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double t_1 = (t / a) * z;
double tmp;
if (a <= -1.32e+38) {
tmp = ((y / pow(cbrt(a), 2.0)) * (x / cbrt(a))) - t_1;
} else if (a <= 2.2e+114) {
tmp = fma(x, y, (t * -z)) / a;
} else {
tmp = (y / (a / x)) - t_1;
}
return tmp;
}
x, y = sort([x, y]) z, t = sort([z, t]) function code(x, y, z, t, a) t_1 = Float64(Float64(t / a) * z) tmp = 0.0 if (a <= -1.32e+38) tmp = Float64(Float64(Float64(y / (cbrt(a) ^ 2.0)) * Float64(x / cbrt(a))) - t_1); elseif (a <= 2.2e+114) tmp = Float64(fma(x, y, Float64(t * Float64(-z))) / a); else tmp = Float64(Float64(y / Float64(a / x)) - t_1); 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[(t / a), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[a, -1.32e+38], N[(N[(N[(y / N[Power[N[Power[a, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(x / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], If[LessEqual[a, 2.2e+114], N[(N[(x * y + N[(t * (-z)), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(y / N[(a / x), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
t_1 := \frac{t}{a} \cdot z\\
\mathbf{if}\;a \leq -1.32 \cdot 10^{+38}:\\
\;\;\;\;\frac{y}{{\left(\sqrt[3]{a}\right)}^{2}} \cdot \frac{x}{\sqrt[3]{a}} - t_1\\
\mathbf{elif}\;a \leq 2.2 \cdot 10^{+114}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y, t \cdot \left(-z\right)\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{a}{x}} - t_1\\
\end{array}
\end{array}
if a < -1.32e38Initial program 79.7%
div-sub79.6%
*-commutative79.6%
add-cube-cbrt79.0%
times-frac90.7%
fma-neg90.7%
pow290.7%
associate-/l*92.4%
Applied egg-rr92.4%
fma-neg92.3%
associate-/l*90.7%
*-commutative90.7%
associate-/l*98.0%
associate-/r/93.7%
Simplified93.7%
if -1.32e38 < a < 2.2e114Initial program 99.2%
fma-neg99.2%
distribute-lft-neg-out99.2%
*-commutative99.2%
Simplified99.2%
if 2.2e114 < a Initial program 76.7%
div-sub76.7%
*-commutative76.7%
add-cube-cbrt76.2%
times-frac91.8%
fma-neg91.8%
pow291.8%
associate-/l*90.0%
Applied egg-rr90.0%
fma-neg90.0%
associate-/l*91.8%
*-commutative91.8%
associate-/l*97.1%
associate-/r/91.2%
Simplified91.2%
frac-times75.6%
unpow275.6%
add-cube-cbrt76.1%
*-un-lft-identity76.1%
frac-times90.2%
/-rgt-identity90.2%
clear-num90.2%
un-div-inv90.2%
Applied egg-rr90.2%
Final simplification96.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 (or (<= a -1.7e-58) (not (<= a 9e+110))) (- (/ y (/ a x)) (* (/ t a) z)) (/ (fma x y (* t (- z))) a)))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -1.7e-58) || !(a <= 9e+110)) {
tmp = (y / (a / x)) - ((t / a) * z);
} else {
tmp = fma(x, y, (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 ((a <= -1.7e-58) || !(a <= 9e+110)) tmp = Float64(Float64(y / Float64(a / x)) - Float64(Float64(t / a) * z)); else tmp = Float64(fma(x, y, Float64(t * Float64(-z))) / 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_] := If[Or[LessEqual[a, -1.7e-58], N[Not[LessEqual[a, 9e+110]], $MachinePrecision]], N[(N[(y / N[(a / x), $MachinePrecision]), $MachinePrecision] - N[(N[(t / a), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(N[(x * y + N[(t * (-z)), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.7 \cdot 10^{-58} \lor \neg \left(a \leq 9 \cdot 10^{+110}\right):\\
\;\;\;\;\frac{y}{\frac{a}{x}} - \frac{t}{a} \cdot z\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y, t \cdot \left(-z\right)\right)}{a}\\
\end{array}
\end{array}
if a < -1.69999999999999987e-58 or 9.0000000000000005e110 < a Initial program 80.2%
div-sub80.2%
*-commutative80.2%
add-cube-cbrt79.6%
times-frac92.0%
fma-neg92.0%
pow292.0%
associate-/l*91.9%
Applied egg-rr91.9%
fma-neg91.9%
associate-/l*92.0%
*-commutative92.0%
associate-/l*97.7%
associate-/r/93.1%
Simplified93.1%
frac-times80.7%
unpow280.7%
add-cube-cbrt81.3%
*-un-lft-identity81.3%
frac-times91.7%
/-rgt-identity91.7%
clear-num91.7%
un-div-inv91.8%
Applied egg-rr91.8%
if -1.69999999999999987e-58 < a < 9.0000000000000005e110Initial program 99.1%
fma-neg99.1%
distribute-lft-neg-out99.1%
*-commutative99.1%
Simplified99.1%
Final simplification95.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 (<= (* y x) -2e+30)
(* y (/ x a))
(if (<= (* y x) 5e-75)
(/ (- z) (/ a t))
(if (<= (* y x) 0.05)
(/ x (/ a y))
(if (<= (* y x) 2e+28) (* t (/ (- z) a)) (/ y (/ a x)))))))assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((y * x) <= -2e+30) {
tmp = y * (x / a);
} else if ((y * x) <= 5e-75) {
tmp = -z / (a / t);
} else if ((y * x) <= 0.05) {
tmp = x / (a / y);
} else if ((y * x) <= 2e+28) {
tmp = t * (-z / a);
} else {
tmp = y / (a / x);
}
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 ((y * x) <= (-2d+30)) then
tmp = y * (x / a)
else if ((y * x) <= 5d-75) then
tmp = -z / (a / t)
else if ((y * x) <= 0.05d0) then
tmp = x / (a / y)
else if ((y * x) <= 2d+28) then
tmp = t * (-z / a)
else
tmp = y / (a / x)
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 ((y * x) <= -2e+30) {
tmp = y * (x / a);
} else if ((y * x) <= 5e-75) {
tmp = -z / (a / t);
} else if ((y * x) <= 0.05) {
tmp = x / (a / y);
} else if ((y * x) <= 2e+28) {
tmp = t * (-z / a);
} else {
tmp = y / (a / x);
}
return tmp;
}
[x, y] = sort([x, y]) [z, t] = sort([z, t]) def code(x, y, z, t, a): tmp = 0 if (y * x) <= -2e+30: tmp = y * (x / a) elif (y * x) <= 5e-75: tmp = -z / (a / t) elif (y * x) <= 0.05: tmp = x / (a / y) elif (y * x) <= 2e+28: tmp = t * (-z / a) else: tmp = y / (a / x) return tmp
x, y = sort([x, y]) z, t = sort([z, t]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(y * x) <= -2e+30) tmp = Float64(y * Float64(x / a)); elseif (Float64(y * x) <= 5e-75) tmp = Float64(Float64(-z) / Float64(a / t)); elseif (Float64(y * x) <= 0.05) tmp = Float64(x / Float64(a / y)); elseif (Float64(y * x) <= 2e+28) tmp = Float64(t * Float64(Float64(-z) / a)); else tmp = Float64(y / Float64(a / x)); 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 ((y * x) <= -2e+30)
tmp = y * (x / a);
elseif ((y * x) <= 5e-75)
tmp = -z / (a / t);
elseif ((y * x) <= 0.05)
tmp = x / (a / y);
elseif ((y * x) <= 2e+28)
tmp = t * (-z / a);
else
tmp = y / (a / x);
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[(y * x), $MachinePrecision], -2e+30], N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y * x), $MachinePrecision], 5e-75], N[((-z) / N[(a / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y * x), $MachinePrecision], 0.05], N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y * x), $MachinePrecision], 2e+28], N[(t * N[((-z) / a), $MachinePrecision]), $MachinePrecision], N[(y / N[(a / x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot x \leq -2 \cdot 10^{+30}:\\
\;\;\;\;y \cdot \frac{x}{a}\\
\mathbf{elif}\;y \cdot x \leq 5 \cdot 10^{-75}:\\
\;\;\;\;\frac{-z}{\frac{a}{t}}\\
\mathbf{elif}\;y \cdot x \leq 0.05:\\
\;\;\;\;\frac{x}{\frac{a}{y}}\\
\mathbf{elif}\;y \cdot x \leq 2 \cdot 10^{+28}:\\
\;\;\;\;t \cdot \frac{-z}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{a}{x}}\\
\end{array}
\end{array}
if (*.f64 x y) < -2e30Initial program 87.0%
Taylor expanded in x around inf 71.1%
associate-*l/75.9%
Simplified75.9%
if -2e30 < (*.f64 x y) < 4.99999999999999979e-75Initial program 92.7%
div-sub92.7%
*-commutative92.7%
add-cube-cbrt92.4%
times-frac91.6%
fma-neg91.6%
pow291.6%
associate-/l*88.9%
Applied egg-rr88.9%
fma-neg88.9%
associate-/l*91.6%
*-commutative91.6%
associate-/l*91.4%
associate-/r/90.1%
Simplified90.1%
Taylor expanded in y around 0 79.3%
mul-1-neg79.3%
*-commutative79.3%
associate-/l*76.6%
Simplified76.6%
if 4.99999999999999979e-75 < (*.f64 x y) < 0.050000000000000003Initial program 99.8%
Taylor expanded in x around inf 80.5%
associate-*l/74.1%
Simplified74.1%
associate-/r/74.2%
Applied egg-rr74.2%
if 0.050000000000000003 < (*.f64 x y) < 1.99999999999999992e28Initial program 99.7%
Taylor expanded in x around 0 77.8%
mul-1-neg77.8%
*-commutative77.8%
associate-*l/78.0%
*-commutative78.0%
distribute-rgt-neg-in78.0%
distribute-frac-neg78.0%
Simplified78.0%
if 1.99999999999999992e28 < (*.f64 x y) Initial program 87.3%
Taylor expanded in x around inf 69.7%
associate-*l/80.8%
Simplified80.8%
*-commutative80.8%
clear-num80.8%
un-div-inv81.1%
Applied egg-rr81.1%
Final simplification77.5%
NOTE: x and y should be sorted in increasing order before calling this function. NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (- (* y x) (* t z)) a))) (if (<= t_1 -1e+303) (- (/ x (/ a y)) (/ z (/ a t))) t_1)))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double t_1 = ((y * x) - (t * z)) / a;
double tmp;
if (t_1 <= -1e+303) {
tmp = (x / (a / y)) - (z / (a / t));
} else {
tmp = t_1;
}
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 = ((y * x) - (t * z)) / a
if (t_1 <= (-1d+303)) then
tmp = (x / (a / y)) - (z / (a / t))
else
tmp = t_1
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 = ((y * x) - (t * z)) / a;
double tmp;
if (t_1 <= -1e+303) {
tmp = (x / (a / y)) - (z / (a / t));
} else {
tmp = t_1;
}
return tmp;
}
[x, y] = sort([x, y]) [z, t] = sort([z, t]) def code(x, y, z, t, a): t_1 = ((y * x) - (t * z)) / a tmp = 0 if t_1 <= -1e+303: tmp = (x / (a / y)) - (z / (a / t)) else: tmp = t_1 return tmp
x, y = sort([x, y]) z, t = sort([z, t]) function code(x, y, z, t, a) t_1 = Float64(Float64(Float64(y * x) - Float64(t * z)) / a) tmp = 0.0 if (t_1 <= -1e+303) tmp = Float64(Float64(x / Float64(a / y)) - Float64(z / Float64(a / t))); else tmp = t_1; 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 = ((y * x) - (t * z)) / a;
tmp = 0.0;
if (t_1 <= -1e+303)
tmp = (x / (a / y)) - (z / (a / t));
else
tmp = t_1;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
NOTE: z and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(y * x), $MachinePrecision] - N[(t * z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+303], N[(N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision] - N[(z / N[(a / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
t_1 := \frac{y \cdot x - t \cdot z}{a}\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{+303}:\\
\;\;\;\;\frac{x}{\frac{a}{y}} - \frac{z}{\frac{a}{t}}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 x y) (*.f64 z t)) a) < -1e303Initial program 71.6%
div-sub69.7%
associate-/l*87.2%
associate-/l*96.1%
Applied egg-rr96.1%
if -1e303 < (/.f64 (-.f64 (*.f64 x y) (*.f64 z t)) a) Initial program 95.6%
Final simplification95.7%
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 (<= (* y x) (- INFINITY)) (/ x (/ a y)) (if (<= (* y x) 1e+305) (/ (- (* y x) (* t z)) a) (* x (/ y a)))))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((y * x) <= -((double) INFINITY)) {
tmp = x / (a / y);
} else if ((y * x) <= 1e+305) {
tmp = ((y * x) - (t * z)) / a;
} else {
tmp = x * (y / 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 ((y * x) <= -Double.POSITIVE_INFINITY) {
tmp = x / (a / y);
} else if ((y * x) <= 1e+305) {
tmp = ((y * x) - (t * z)) / a;
} else {
tmp = x * (y / a);
}
return tmp;
}
[x, y] = sort([x, y]) [z, t] = sort([z, t]) def code(x, y, z, t, a): tmp = 0 if (y * x) <= -math.inf: tmp = x / (a / y) elif (y * x) <= 1e+305: tmp = ((y * x) - (t * z)) / a else: tmp = x * (y / a) return tmp
x, y = sort([x, y]) z, t = sort([z, t]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(y * x) <= Float64(-Inf)) tmp = Float64(x / Float64(a / y)); elseif (Float64(y * x) <= 1e+305) tmp = Float64(Float64(Float64(y * x) - Float64(t * z)) / a); else tmp = Float64(x * Float64(y / a)); end return tmp end
x, y = num2cell(sort([x, y])){:}
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((y * x) <= -Inf)
tmp = x / (a / y);
elseif ((y * x) <= 1e+305)
tmp = ((y * x) - (t * z)) / a;
else
tmp = x * (y / a);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(y * x), $MachinePrecision], (-Infinity)], N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y * x), $MachinePrecision], 1e+305], N[(N[(N[(y * x), $MachinePrecision] - N[(t * z), $MachinePrecision]), $MachinePrecision] / a), $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}\;y \cdot x \leq -\infty:\\
\;\;\;\;\frac{x}{\frac{a}{y}}\\
\mathbf{elif}\;y \cdot x \leq 10^{+305}:\\
\;\;\;\;\frac{y \cdot x - t \cdot z}{a}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{a}\\
\end{array}
\end{array}
if (*.f64 x y) < -inf.0Initial program 67.4%
Taylor expanded in x around inf 67.4%
associate-*l/99.8%
Simplified99.8%
associate-/r/99.9%
Applied egg-rr99.9%
if -inf.0 < (*.f64 x y) < 9.9999999999999994e304Initial program 95.8%
if 9.9999999999999994e304 < (*.f64 x y) Initial program 57.7%
Taylor expanded in x around inf 57.7%
associate-*r/99.7%
Simplified99.7%
Final simplification96.5%
NOTE: x and y should be sorted in increasing order before calling this function. NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (or (<= a -1.8e-58) (not (<= a 1.5e+113))) (- (/ y (/ a x)) (* (/ t a) z)) (/ (- (* y x) (* t z)) a)))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -1.8e-58) || !(a <= 1.5e+113)) {
tmp = (y / (a / x)) - ((t / a) * z);
} else {
tmp = ((y * x) - (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 ((a <= (-1.8d-58)) .or. (.not. (a <= 1.5d+113))) then
tmp = (y / (a / x)) - ((t / a) * z)
else
tmp = ((y * x) - (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 ((a <= -1.8e-58) || !(a <= 1.5e+113)) {
tmp = (y / (a / x)) - ((t / a) * z);
} else {
tmp = ((y * x) - (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 (a <= -1.8e-58) or not (a <= 1.5e+113): tmp = (y / (a / x)) - ((t / a) * z) else: tmp = ((y * x) - (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 ((a <= -1.8e-58) || !(a <= 1.5e+113)) tmp = Float64(Float64(y / Float64(a / x)) - Float64(Float64(t / a) * z)); else tmp = Float64(Float64(Float64(y * x) - Float64(t * 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 ((a <= -1.8e-58) || ~((a <= 1.5e+113)))
tmp = (y / (a / x)) - ((t / a) * z);
else
tmp = ((y * x) - (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[Or[LessEqual[a, -1.8e-58], N[Not[LessEqual[a, 1.5e+113]], $MachinePrecision]], N[(N[(y / N[(a / x), $MachinePrecision]), $MachinePrecision] - N[(N[(t / a), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y * x), $MachinePrecision] - N[(t * z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.8 \cdot 10^{-58} \lor \neg \left(a \leq 1.5 \cdot 10^{+113}\right):\\
\;\;\;\;\frac{y}{\frac{a}{x}} - \frac{t}{a} \cdot z\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x - t \cdot z}{a}\\
\end{array}
\end{array}
if a < -1.80000000000000005e-58 or 1.5e113 < a Initial program 80.2%
div-sub80.2%
*-commutative80.2%
add-cube-cbrt79.6%
times-frac92.0%
fma-neg92.0%
pow292.0%
associate-/l*91.9%
Applied egg-rr91.9%
fma-neg91.9%
associate-/l*92.0%
*-commutative92.0%
associate-/l*97.7%
associate-/r/93.1%
Simplified93.1%
frac-times80.7%
unpow280.7%
add-cube-cbrt81.3%
*-un-lft-identity81.3%
frac-times91.7%
/-rgt-identity91.7%
clear-num91.7%
un-div-inv91.8%
Applied egg-rr91.8%
if -1.80000000000000005e-58 < a < 1.5e113Initial program 99.1%
Final simplification95.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 (<= (* y x) -2e+30) (* y (/ x a)) (if (<= (* y x) 5e-75) (/ (- z) (/ a t)) (/ x (/ a y)))))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((y * x) <= -2e+30) {
tmp = y * (x / a);
} else if ((y * x) <= 5e-75) {
tmp = -z / (a / t);
} 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 ((y * x) <= (-2d+30)) then
tmp = y * (x / a)
else if ((y * x) <= 5d-75) then
tmp = -z / (a / t)
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 ((y * x) <= -2e+30) {
tmp = y * (x / a);
} else if ((y * x) <= 5e-75) {
tmp = -z / (a / t);
} 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 (y * x) <= -2e+30: tmp = y * (x / a) elif (y * x) <= 5e-75: tmp = -z / (a / t) 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 (Float64(y * x) <= -2e+30) tmp = Float64(y * Float64(x / a)); elseif (Float64(y * x) <= 5e-75) tmp = Float64(Float64(-z) / Float64(a / t)); 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 ((y * x) <= -2e+30)
tmp = y * (x / a);
elseif ((y * x) <= 5e-75)
tmp = -z / (a / t);
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[N[(y * x), $MachinePrecision], -2e+30], N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y * x), $MachinePrecision], 5e-75], N[((-z) / N[(a / t), $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}\;y \cdot x \leq -2 \cdot 10^{+30}:\\
\;\;\;\;y \cdot \frac{x}{a}\\
\mathbf{elif}\;y \cdot x \leq 5 \cdot 10^{-75}:\\
\;\;\;\;\frac{-z}{\frac{a}{t}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{a}{y}}\\
\end{array}
\end{array}
if (*.f64 x y) < -2e30Initial program 87.0%
Taylor expanded in x around inf 71.1%
associate-*l/75.9%
Simplified75.9%
if -2e30 < (*.f64 x y) < 4.99999999999999979e-75Initial program 92.7%
div-sub92.7%
*-commutative92.7%
add-cube-cbrt92.4%
times-frac91.6%
fma-neg91.6%
pow291.6%
associate-/l*88.9%
Applied egg-rr88.9%
fma-neg88.9%
associate-/l*91.6%
*-commutative91.6%
associate-/l*91.4%
associate-/r/90.1%
Simplified90.1%
Taylor expanded in y around 0 79.3%
mul-1-neg79.3%
*-commutative79.3%
associate-/l*76.6%
Simplified76.6%
if 4.99999999999999979e-75 < (*.f64 x y) Initial program 90.6%
Taylor expanded in x around inf 67.1%
associate-*l/74.3%
Simplified74.3%
associate-/r/70.5%
Applied egg-rr70.5%
Final simplification74.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 (<= z -2.2e-144) (/ x (/ a y)) (* y (/ x a))))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -2.2e-144) {
tmp = x / (a / y);
} 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 (z <= (-2.2d-144)) then
tmp = x / (a / y)
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 (z <= -2.2e-144) {
tmp = x / (a / y);
} 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 z <= -2.2e-144: tmp = x / (a / y) 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 (z <= -2.2e-144) tmp = Float64(x / Float64(a / y)); 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 (z <= -2.2e-144)
tmp = x / (a / y);
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[LessEqual[z, -2.2e-144], N[(x / N[(a / y), $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}\;z \leq -2.2 \cdot 10^{-144}:\\
\;\;\;\;\frac{x}{\frac{a}{y}}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{a}\\
\end{array}
\end{array}
if z < -2.20000000000000006e-144Initial program 89.5%
Taylor expanded in x around inf 43.9%
associate-*l/46.6%
Simplified46.6%
associate-/r/48.0%
Applied egg-rr48.0%
if -2.20000000000000006e-144 < z Initial program 91.4%
Taylor expanded in x around inf 52.7%
associate-*l/54.7%
Simplified54.7%
Final simplification52.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 (* x (/ y a)))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
return x * (y / a);
}
NOTE: x and y should be sorted in increasing order before calling this function.
NOTE: z and t should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x * (y / a)
end function
assert x < y;
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
return x * (y / a);
}
[x, y] = sort([x, y]) [z, t] = sort([z, t]) def code(x, y, z, t, a): return x * (y / a)
x, y = sort([x, y]) z, t = sort([z, t]) function code(x, y, z, t, a) return Float64(x * Float64(y / a)) end
x, y = num2cell(sort([x, y])){:}
z, t = num2cell(sort([z, t])){:}
function tmp = code(x, y, z, t, a)
tmp = x * (y / a);
end
NOTE: x and y should be sorted in increasing order before calling this function. NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
x \cdot \frac{y}{a}
\end{array}
Initial program 90.6%
Taylor expanded in x around inf 49.3%
associate-*r/53.0%
Simplified53.0%
Final simplification53.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 (* 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 90.6%
Taylor expanded in x around inf 49.3%
associate-*l/51.6%
Simplified51.6%
Final simplification51.6%
(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 2023271
(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))