
(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;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
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 7 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;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
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, y, z, t, and a 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))
(fma (/ y a) x (* (- t) (/ z a)))
(if (<= t_1 1e+273) (/ t_1 a) (fma (/ x a) y (* (- z) (/ t a)))))))assert(x < y && y < z && z < t && t < a);
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 = fma((y / a), x, (-t * (z / a)));
} else if (t_1 <= 1e+273) {
tmp = t_1 / a;
} else {
tmp = fma((x / a), y, (-z * (t / a)));
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) 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 = fma(Float64(y / a), x, Float64(Float64(-t) * Float64(z / a))); elseif (t_1 <= 1e+273) tmp = Float64(t_1 / a); else tmp = fma(Float64(x / a), y, Float64(Float64(-z) * Float64(t / a))); end return tmp end
NOTE: x, y, z, t, and a 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[(y / a), $MachinePrecision] * x + N[((-t) * N[(z / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+273], N[(t$95$1 / a), $MachinePrecision], N[(N[(x / a), $MachinePrecision] * y + N[((-z) * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, x, \left(-t\right) \cdot \frac{z}{a}\right)\\
\mathbf{elif}\;t\_1 \leq 10^{+273}:\\
\;\;\;\;\frac{t\_1}{a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{a}, y, \left(-z\right) \cdot \frac{t}{a}\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -inf.0Initial program 66.8%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
frac-2negN/A
*-commutativeN/A
frac-2negN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
div-addN/A
*-commutativeN/A
associate-*l/N/A
distribute-lft-neg-inN/A
*-commutativeN/A
mul-1-negN/A
associate-*r/N/A
lower-fma.f64N/A
lower-/.f64N/A
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
Applied rewrites93.3%
lift-neg.f64N/A
lift-/.f64N/A
lower-*.f64N/A
distribute-lft-neg-outN/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6496.6
Applied rewrites96.6%
if -inf.0 < (-.f64 (*.f64 x y) (*.f64 z t)) < 9.99999999999999945e272Initial program 98.6%
if 9.99999999999999945e272 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 73.3%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
frac-2negN/A
*-commutativeN/A
frac-2negN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
div-addN/A
associate-*l/N/A
distribute-lft-neg-inN/A
*-commutativeN/A
mul-1-negN/A
associate-*r/N/A
lower-fma.f64N/A
lower-/.f64N/A
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites96.8%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- (* x y) (* z t))))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 1e+273)))
(fma (/ x a) y (* (- z) (/ t a)))
(/ t_1 a))))assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double t_1 = (x * y) - (z * t);
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 1e+273)) {
tmp = fma((x / a), y, (-z * (t / a)));
} else {
tmp = t_1 / a;
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) t_1 = Float64(Float64(x * y) - Float64(z * t)) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 1e+273)) tmp = fma(Float64(x / a), y, Float64(Float64(-z) * Float64(t / a))); else tmp = Float64(t_1 / a); end return tmp end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 1e+273]], $MachinePrecision]], N[(N[(x / a), $MachinePrecision] * y + N[((-z) * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / a), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
\mathbf{if}\;t\_1 \leq -\infty \lor \neg \left(t\_1 \leq 10^{+273}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{a}, y, \left(-z\right) \cdot \frac{t}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{a}\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -inf.0 or 9.99999999999999945e272 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 70.1%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
frac-2negN/A
*-commutativeN/A
frac-2negN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
div-addN/A
associate-*l/N/A
distribute-lft-neg-inN/A
*-commutativeN/A
mul-1-negN/A
associate-*r/N/A
lower-fma.f64N/A
lower-/.f64N/A
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites95.2%
if -inf.0 < (-.f64 (*.f64 x y) (*.f64 z t)) < 9.99999999999999945e272Initial program 98.6%
Final simplification97.8%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= (* x y) (- INFINITY)) (* (/ x a) y) (if (<= (* x y) 2e+186) (/ (- (* x y) (* z t)) a) (* (/ y a) x))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -((double) INFINITY)) {
tmp = (x / a) * y;
} else if ((x * y) <= 2e+186) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = (y / a) * x;
}
return tmp;
}
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -Double.POSITIVE_INFINITY) {
tmp = (x / a) * y;
} else if ((x * y) <= 2e+186) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = (y / a) * x;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (x * y) <= -math.inf: tmp = (x / a) * y elif (x * y) <= 2e+186: tmp = ((x * y) - (z * t)) / a else: tmp = (y / a) * x return tmp
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= Float64(-Inf)) tmp = Float64(Float64(x / a) * y); elseif (Float64(x * y) <= 2e+186) tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a); else tmp = Float64(Float64(y / a) * x); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((x * y) <= -Inf)
tmp = (x / a) * y;
elseif ((x * y) <= 2e+186)
tmp = ((x * y) - (z * t)) / a;
else
tmp = (y / a) * x;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], (-Infinity)], N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2e+186], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -\infty:\\
\;\;\;\;\frac{x}{a} \cdot y\\
\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+186}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} \cdot x\\
\end{array}
\end{array}
if (*.f64 x y) < -inf.0Initial program 58.6%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
frac-2negN/A
*-commutativeN/A
frac-2negN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
div-addN/A
associate-*l/N/A
distribute-lft-neg-inN/A
*-commutativeN/A
mul-1-negN/A
associate-*r/N/A
lower-fma.f64N/A
lower-/.f64N/A
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites88.8%
Taylor expanded in x around inf
associate-*l/N/A
associate-*r/N/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
div-add-revN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
fp-cancel-sub-sign-invN/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6499.1
Applied rewrites99.1%
if -inf.0 < (*.f64 x y) < 1.99999999999999996e186Initial program 96.2%
if 1.99999999999999996e186 < (*.f64 x y) Initial program 68.3%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
frac-2negN/A
*-commutativeN/A
frac-2negN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
div-addN/A
associate-*l/N/A
distribute-lft-neg-inN/A
*-commutativeN/A
mul-1-negN/A
associate-*r/N/A
lower-fma.f64N/A
lower-/.f64N/A
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites94.4%
Taylor expanded in x around inf
associate-*l/N/A
associate-*r/N/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
div-add-revN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
fp-cancel-sub-sign-invN/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6494.4
Applied rewrites94.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6494.2
Applied rewrites94.2%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (or (<= (* z t) -4e+52) (not (<= (* z t) 5e+40))) (* (/ (- z) a) t) (* (/ x a) y)))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((z * t) <= -4e+52) || !((z * t) <= 5e+40)) {
tmp = (-z / a) * t;
} else {
tmp = (x / a) * y;
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
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) <= (-4d+52)) .or. (.not. ((z * t) <= 5d+40))) then
tmp = (-z / a) * t
else
tmp = (x / a) * y
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (((z * t) <= -4e+52) || !((z * t) <= 5e+40)) {
tmp = (-z / a) * t;
} else {
tmp = (x / a) * y;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if ((z * t) <= -4e+52) or not ((z * t) <= 5e+40): tmp = (-z / a) * t else: tmp = (x / a) * y return tmp
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if ((Float64(z * t) <= -4e+52) || !(Float64(z * t) <= 5e+40)) tmp = Float64(Float64(Float64(-z) / a) * t); else tmp = Float64(Float64(x / a) * y); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if (((z * t) <= -4e+52) || ~(((z * t) <= 5e+40)))
tmp = (-z / a) * t;
else
tmp = (x / a) * y;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[Or[LessEqual[N[(z * t), $MachinePrecision], -4e+52], N[Not[LessEqual[N[(z * t), $MachinePrecision], 5e+40]], $MachinePrecision]], N[(N[((-z) / a), $MachinePrecision] * t), $MachinePrecision], N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -4 \cdot 10^{+52} \lor \neg \left(z \cdot t \leq 5 \cdot 10^{+40}\right):\\
\;\;\;\;\frac{-z}{a} \cdot t\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{a} \cdot y\\
\end{array}
\end{array}
if (*.f64 z t) < -4e52 or 5.00000000000000003e40 < (*.f64 z t) Initial program 90.8%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
frac-2negN/A
*-commutativeN/A
frac-2negN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
div-addN/A
associate-*l/N/A
distribute-lft-neg-inN/A
*-commutativeN/A
mul-1-negN/A
associate-*r/N/A
lower-fma.f64N/A
lower-/.f64N/A
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites96.9%
Taylor expanded in t around inf
associate-*l/N/A
associate-*r/N/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
div-add-revN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites87.7%
Taylor expanded in x around 0
mul-1-negN/A
distribute-frac-negN/A
lift-/.f64N/A
lift-neg.f6484.8
Applied rewrites84.8%
if -4e52 < (*.f64 z t) < 5.00000000000000003e40Initial program 92.2%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
frac-2negN/A
*-commutativeN/A
frac-2negN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
div-addN/A
associate-*l/N/A
distribute-lft-neg-inN/A
*-commutativeN/A
mul-1-negN/A
associate-*r/N/A
lower-fma.f64N/A
lower-/.f64N/A
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.4%
Taylor expanded in x around inf
associate-*l/N/A
associate-*r/N/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
div-add-revN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
fp-cancel-sub-sign-invN/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6470.7
Applied rewrites70.7%
Final simplification76.4%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= (* z t) -4e+52) (* (- z) (/ t a)) (if (<= (* z t) 5e+40) (* (/ x a) y) (* (/ (- z) a) t))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z * t) <= -4e+52) {
tmp = -z * (t / a);
} else if ((z * t) <= 5e+40) {
tmp = (x / a) * y;
} else {
tmp = (-z / a) * t;
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
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) <= (-4d+52)) then
tmp = -z * (t / a)
else if ((z * t) <= 5d+40) then
tmp = (x / a) * y
else
tmp = (-z / a) * t
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z * t) <= -4e+52) {
tmp = -z * (t / a);
} else if ((z * t) <= 5e+40) {
tmp = (x / a) * y;
} else {
tmp = (-z / a) * t;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (z * t) <= -4e+52: tmp = -z * (t / a) elif (z * t) <= 5e+40: tmp = (x / a) * y else: tmp = (-z / a) * t return tmp
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(z * t) <= -4e+52) tmp = Float64(Float64(-z) * Float64(t / a)); elseif (Float64(z * t) <= 5e+40) tmp = Float64(Float64(x / a) * y); else tmp = Float64(Float64(Float64(-z) / a) * t); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((z * t) <= -4e+52)
tmp = -z * (t / a);
elseif ((z * t) <= 5e+40)
tmp = (x / a) * y;
else
tmp = (-z / a) * t;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(z * t), $MachinePrecision], -4e+52], N[((-z) * N[(t / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e+40], N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision], N[(N[((-z) / a), $MachinePrecision] * t), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -4 \cdot 10^{+52}:\\
\;\;\;\;\left(-z\right) \cdot \frac{t}{a}\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+40}:\\
\;\;\;\;\frac{x}{a} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{-z}{a} \cdot t\\
\end{array}
\end{array}
if (*.f64 z t) < -4e52Initial program 91.2%
Taylor expanded in x around 0
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6489.8
Applied rewrites89.8%
if -4e52 < (*.f64 z t) < 5.00000000000000003e40Initial program 92.2%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
frac-2negN/A
*-commutativeN/A
frac-2negN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
div-addN/A
associate-*l/N/A
distribute-lft-neg-inN/A
*-commutativeN/A
mul-1-negN/A
associate-*r/N/A
lower-fma.f64N/A
lower-/.f64N/A
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.4%
Taylor expanded in x around inf
associate-*l/N/A
associate-*r/N/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
div-add-revN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
fp-cancel-sub-sign-invN/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6470.7
Applied rewrites70.7%
if 5.00000000000000003e40 < (*.f64 z t) Initial program 90.3%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
frac-2negN/A
*-commutativeN/A
frac-2negN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
div-addN/A
associate-*l/N/A
distribute-lft-neg-inN/A
*-commutativeN/A
mul-1-negN/A
associate-*r/N/A
lower-fma.f64N/A
lower-/.f64N/A
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in t around inf
associate-*l/N/A
associate-*r/N/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
div-add-revN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites91.8%
Taylor expanded in x around 0
mul-1-negN/A
distribute-frac-negN/A
lift-/.f64N/A
lift-neg.f6488.5
Applied rewrites88.5%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= x -1.38e-232) (* (/ x a) y) (* (/ y a) x)))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (x <= -1.38e-232) {
tmp = (x / a) * y;
} else {
tmp = (y / a) * x;
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (x <= (-1.38d-232)) then
tmp = (x / a) * y
else
tmp = (y / a) * x
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (x <= -1.38e-232) {
tmp = (x / a) * y;
} else {
tmp = (y / a) * x;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if x <= -1.38e-232: tmp = (x / a) * y else: tmp = (y / a) * x return tmp
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (x <= -1.38e-232) tmp = Float64(Float64(x / a) * y); else tmp = Float64(Float64(y / a) * x); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if (x <= -1.38e-232)
tmp = (x / a) * y;
else
tmp = (y / a) * x;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[x, -1.38e-232], N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.38 \cdot 10^{-232}:\\
\;\;\;\;\frac{x}{a} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} \cdot x\\
\end{array}
\end{array}
if x < -1.3799999999999999e-232Initial program 91.6%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
frac-2negN/A
*-commutativeN/A
frac-2negN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
div-addN/A
associate-*l/N/A
distribute-lft-neg-inN/A
*-commutativeN/A
mul-1-negN/A
associate-*r/N/A
lower-fma.f64N/A
lower-/.f64N/A
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.5%
Taylor expanded in x around inf
associate-*l/N/A
associate-*r/N/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
div-add-revN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
fp-cancel-sub-sign-invN/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6459.5
Applied rewrites59.5%
if -1.3799999999999999e-232 < x Initial program 91.6%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
frac-2negN/A
*-commutativeN/A
frac-2negN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
div-addN/A
associate-*l/N/A
distribute-lft-neg-inN/A
*-commutativeN/A
mul-1-negN/A
associate-*r/N/A
lower-fma.f64N/A
lower-/.f64N/A
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.6%
Taylor expanded in x around inf
associate-*l/N/A
associate-*r/N/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
div-add-revN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
fp-cancel-sub-sign-invN/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6444.7
Applied rewrites44.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6443.7
Applied rewrites43.7%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (* (/ x a) y))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
return (x / a) * y;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
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 && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
return (x / a) * y;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): return (x / a) * y
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) return Float64(Float64(x / a) * y) end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp = code(x, y, z, t, a)
tmp = (x / a) * y;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\frac{x}{a} \cdot y
\end{array}
Initial program 91.6%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
frac-2negN/A
*-commutativeN/A
frac-2negN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
div-addN/A
associate-*l/N/A
distribute-lft-neg-inN/A
*-commutativeN/A
mul-1-negN/A
associate-*r/N/A
lower-fma.f64N/A
lower-/.f64N/A
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.5%
Taylor expanded in x around inf
associate-*l/N/A
associate-*r/N/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
div-add-revN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
fp-cancel-sub-sign-invN/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6451.4
Applied rewrites51.4%
(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;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
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 2025028
(FPCore (x y z t a)
:name "Data.Colour.Matrix:inverse from colour-2.3.3, B"
:precision binary64
:alt
(! :herbie-platform default (if (< z -246868496869954800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* (/ y a) x) (* (/ t a) z)) (if (< z 6309831121978371/100000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ (- (* x y) (* z t)) a) (- (* (/ y a) x) (* (/ t a) z)))))
(/ (- (* x y) (* z t)) a))