
(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}
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;
}
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.
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 -4e+194)
(fma (/ y a) x (* (- z) (/ t a)))
(if (<= t_1 5e+299) (/ t_1 a) (fma (/ (- z) a) t (* x (/ y a)))))))assert(x < y && y < z && z < t && 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 <= -4e+194) {
tmp = fma((y / a), x, (-z * (t / a)));
} else if (t_1 <= 5e+299) {
tmp = t_1 / a;
} else {
tmp = fma((-z / a), t, (x * (y / a)));
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) 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 <= -4e+194) tmp = fma(Float64(y / a), x, Float64(Float64(-z) * Float64(t / a))); elseif (t_1 <= 5e+299) tmp = Float64(t_1 / a); else tmp = fma(Float64(Float64(-z) / a), t, Float64(x * Float64(y / a))); end return tmp end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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, -4e+194], N[(N[(y / a), $MachinePrecision] * x + N[((-z) * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+299], N[(t$95$1 / a), $MachinePrecision], N[(N[((-z) / a), $MachinePrecision] * t + N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[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 -4 \cdot 10^{+194}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, x, \left(-z\right) \cdot \frac{t}{a}\right)\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+299}:\\
\;\;\;\;\frac{t\_1}{a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-z}{a}, t, x \cdot \frac{y}{a}\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -3.99999999999999978e194Initial program 82.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
*-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.4%
if -3.99999999999999978e194 < (-.f64 (*.f64 x y) (*.f64 z t)) < 5.0000000000000003e299Initial program 98.8%
if 5.0000000000000003e299 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 65.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
frac-2negN/A
*-commutativeN/A
frac-2negN/A
div-subN/A
negate-subN/A
mul-1-negN/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
associate-*l*N/A
lower-fma.f64N/A
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6475.1
Applied rewrites75.1%
lift-*.f64N/A
*-commutativeN/A
lower-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6490.4
Applied rewrites90.4%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. 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))) (t_2 (fma (/ y a) x (* (- z) (/ t a))))) (if (<= t_1 -4e+194) t_2 (if (<= t_1 5e+284) (/ t_1 a) t_2))))
assert(x < y && y < z && z < t && 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 t_2 = fma((y / a), x, (-z * (t / a)));
double tmp;
if (t_1 <= -4e+194) {
tmp = t_2;
} else if (t_1 <= 5e+284) {
tmp = t_1 / a;
} else {
tmp = t_2;
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) 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)) t_2 = fma(Float64(y / a), x, Float64(Float64(-z) * Float64(t / a))) tmp = 0.0 if (t_1 <= -4e+194) tmp = t_2; elseif (t_1 <= 5e+284) tmp = Float64(t_1 / a); else tmp = t_2; end return tmp end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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]}, Block[{t$95$2 = N[(N[(y / a), $MachinePrecision] * x + N[((-z) * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+194], t$95$2, If[LessEqual[t$95$1, 5e+284], N[(t$95$1 / a), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
t_2 := \mathsf{fma}\left(\frac{y}{a}, x, \left(-z\right) \cdot \frac{t}{a}\right)\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+194}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+284}:\\
\;\;\;\;\frac{t\_1}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -3.99999999999999978e194 or 4.9999999999999999e284 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 76.5%
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 rewrites92.6%
if -3.99999999999999978e194 < (-.f64 (*.f64 x y) (*.f64 z t)) < 4.9999999999999999e284Initial program 98.8%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. 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))) (t_2 (fma (/ x a) y (* (- z) (/ t a))))) (if (<= t_1 -5e+299) t_2 (if (<= t_1 5e+202) (/ t_1 a) t_2))))
assert(x < y && y < z && z < t && 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 t_2 = fma((x / a), y, (-z * (t / a)));
double tmp;
if (t_1 <= -5e+299) {
tmp = t_2;
} else if (t_1 <= 5e+202) {
tmp = t_1 / a;
} else {
tmp = t_2;
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) 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)) t_2 = fma(Float64(x / a), y, Float64(Float64(-z) * Float64(t / a))) tmp = 0.0 if (t_1 <= -5e+299) tmp = t_2; elseif (t_1 <= 5e+202) tmp = Float64(t_1 / a); else tmp = t_2; end return tmp end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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]}, Block[{t$95$2 = N[(N[(x / a), $MachinePrecision] * y + N[((-z) * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+299], t$95$2, If[LessEqual[t$95$1, 5e+202], N[(t$95$1 / a), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
t_2 := \mathsf{fma}\left(\frac{x}{a}, y, \left(-z\right) \cdot \frac{t}{a}\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+299}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+202}:\\
\;\;\;\;\frac{t\_1}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -5.0000000000000003e299 or 4.9999999999999999e202 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 75.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 rewrites92.6%
if -5.0000000000000003e299 < (-.f64 (*.f64 x y) (*.f64 z t)) < 4.9999999999999999e202Initial program 98.8%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. 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) 2e+298) (/ (- (* x y) (* z t)) a) (* (- t) (* z (/ 1.0 a)))))
assert(x < y && y < z && z < t && t < a);
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) <= 2e+298) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = -t * (z * (1.0 / a));
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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) <= 2d+298) then
tmp = ((x * y) - (z * t)) / a
else
tmp = -t * (z * (1.0d0 / a))
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
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) <= 2e+298) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = -t * (z * (1.0 / a));
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) [x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (z * t) <= 2e+298: tmp = ((x * y) - (z * t)) / a else: tmp = -t * (z * (1.0 / a)) return tmp
x, y, z, t, a = sort([x, y, z, t, a]) 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) <= 2e+298) tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a); else tmp = Float64(Float64(-t) * Float64(z * Float64(1.0 / a))); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
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) <= 2e+298)
tmp = ((x * y) - (z * t)) / a;
else
tmp = -t * (z * (1.0 / a));
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. 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], 2e+298], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[((-t) * N[(z * N[(1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq 2 \cdot 10^{+298}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;\left(-t\right) \cdot \left(z \cdot \frac{1}{a}\right)\\
\end{array}
\end{array}
if (*.f64 z t) < 1.9999999999999999e298Initial program 93.1%
if 1.9999999999999999e298 < (*.f64 z t) Initial program 67.1%
Taylor expanded in y around inf
Applied rewrites75.2%
Taylor expanded in x around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6494.7
Applied rewrites94.7%
lift-/.f64N/A
frac-2negN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
frac-2negN/A
lower-*.f64N/A
lift-/.f6494.6
Applied rewrites94.6%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. 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) -5e-9) (/ (* (- z) t) a) (if (<= (* z t) 0.001) (/ (* y x) a) (* (- z) (/ t a)))))
assert(x < y && y < z && z < t && t < a);
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) <= -5e-9) {
tmp = (-z * t) / a;
} else if ((z * t) <= 0.001) {
tmp = (y * x) / a;
} else {
tmp = -z * (t / a);
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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) <= (-5d-9)) then
tmp = (-z * t) / a
else if ((z * t) <= 0.001d0) then
tmp = (y * x) / a
else
tmp = -z * (t / a)
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
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) <= -5e-9) {
tmp = (-z * t) / a;
} else if ((z * t) <= 0.001) {
tmp = (y * x) / a;
} else {
tmp = -z * (t / a);
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) [x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (z * t) <= -5e-9: tmp = (-z * t) / a elif (z * t) <= 0.001: tmp = (y * x) / a else: tmp = -z * (t / a) return tmp
x, y, z, t, a = sort([x, y, z, t, a]) 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) <= -5e-9) tmp = Float64(Float64(Float64(-z) * t) / a); elseif (Float64(z * t) <= 0.001) tmp = Float64(Float64(y * x) / a); else tmp = Float64(Float64(-z) * Float64(t / a)); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
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) <= -5e-9)
tmp = (-z * t) / a;
elseif ((z * t) <= 0.001)
tmp = (y * x) / a;
else
tmp = -z * (t / a);
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. 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], -5e-9], N[(N[((-z) * t), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 0.001], N[(N[(y * x), $MachinePrecision] / a), $MachinePrecision], N[((-z) * N[(t / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{-9}:\\
\;\;\;\;\frac{\left(-z\right) \cdot t}{a}\\
\mathbf{elif}\;z \cdot t \leq 0.001:\\
\;\;\;\;\frac{y \cdot x}{a}\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) \cdot \frac{t}{a}\\
\end{array}
\end{array}
if (*.f64 z t) < -5.0000000000000001e-9Initial program 88.9%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6469.7
Applied rewrites69.7%
if -5.0000000000000001e-9 < (*.f64 z t) < 1e-3Initial program 94.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6475.6
Applied rewrites75.6%
if 1e-3 < (*.f64 z t) Initial program 88.3%
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-/.f6473.0
Applied rewrites73.0%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. 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 (* (- z) (/ t a)))) (if (<= (* z t) -5e-9) t_1 (if (<= (* z t) 0.001) (/ (* y x) a) t_1))))
assert(x < y && y < z && z < t && 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 = -z * (t / a);
double tmp;
if ((z * t) <= -5e-9) {
tmp = t_1;
} else if ((z * t) <= 0.001) {
tmp = (y * x) / a;
} else {
tmp = t_1;
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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) :: t_1
real(8) :: tmp
t_1 = -z * (t / a)
if ((z * t) <= (-5d-9)) then
tmp = t_1
else if ((z * t) <= 0.001d0) then
tmp = (y * x) / a
else
tmp = t_1
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double t_1 = -z * (t / a);
double tmp;
if ((z * t) <= -5e-9) {
tmp = t_1;
} else if ((z * t) <= 0.001) {
tmp = (y * x) / a;
} else {
tmp = t_1;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) [x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): t_1 = -z * (t / a) tmp = 0 if (z * t) <= -5e-9: tmp = t_1 elif (z * t) <= 0.001: tmp = (y * x) / a else: tmp = t_1 return tmp
x, y, z, t, a = sort([x, y, z, t, a]) x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) t_1 = Float64(Float64(-z) * Float64(t / a)) tmp = 0.0 if (Float64(z * t) <= -5e-9) tmp = t_1; elseif (Float64(z * t) <= 0.001) tmp = Float64(Float64(y * x) / a); else tmp = t_1; end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
t_1 = -z * (t / a);
tmp = 0.0;
if ((z * t) <= -5e-9)
tmp = t_1;
elseif ((z * t) <= 0.001)
tmp = (y * x) / a;
else
tmp = t_1;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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[((-z) * N[(t / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -5e-9], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 0.001], N[(N[(y * x), $MachinePrecision] / a), $MachinePrecision], t$95$1]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := \left(-z\right) \cdot \frac{t}{a}\\
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{-9}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq 0.001:\\
\;\;\;\;\frac{y \cdot x}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 z t) < -5.0000000000000001e-9 or 1e-3 < (*.f64 z t) Initial program 88.6%
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-/.f6472.5
Applied rewrites72.5%
if -5.0000000000000001e-9 < (*.f64 z t) < 1e-3Initial program 94.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6475.6
Applied rewrites75.6%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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 (* (- t) (/ z a))))
(if (<= (* z t) -5e-9)
t_1
(if (<= (* z t) 2000000000.0) (/ (* y x) a) t_1))))assert(x < y && y < z && z < t && 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 = -t * (z / a);
double tmp;
if ((z * t) <= -5e-9) {
tmp = t_1;
} else if ((z * t) <= 2000000000.0) {
tmp = (y * x) / a;
} else {
tmp = t_1;
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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) :: t_1
real(8) :: tmp
t_1 = -t * (z / a)
if ((z * t) <= (-5d-9)) then
tmp = t_1
else if ((z * t) <= 2000000000.0d0) then
tmp = (y * x) / a
else
tmp = t_1
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double t_1 = -t * (z / a);
double tmp;
if ((z * t) <= -5e-9) {
tmp = t_1;
} else if ((z * t) <= 2000000000.0) {
tmp = (y * x) / a;
} else {
tmp = t_1;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) [x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): t_1 = -t * (z / a) tmp = 0 if (z * t) <= -5e-9: tmp = t_1 elif (z * t) <= 2000000000.0: tmp = (y * x) / a else: tmp = t_1 return tmp
x, y, z, t, a = sort([x, y, z, t, a]) x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) t_1 = Float64(Float64(-t) * Float64(z / a)) tmp = 0.0 if (Float64(z * t) <= -5e-9) tmp = t_1; elseif (Float64(z * t) <= 2000000000.0) tmp = Float64(Float64(y * x) / a); else tmp = t_1; end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
t_1 = -t * (z / a);
tmp = 0.0;
if ((z * t) <= -5e-9)
tmp = t_1;
elseif ((z * t) <= 2000000000.0)
tmp = (y * x) / a;
else
tmp = t_1;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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[((-t) * N[(z / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -5e-9], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 2000000000.0], N[(N[(y * x), $MachinePrecision] / a), $MachinePrecision], t$95$1]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := \left(-t\right) \cdot \frac{z}{a}\\
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{-9}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq 2000000000:\\
\;\;\;\;\frac{y \cdot x}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 z t) < -5.0000000000000001e-9 or 2e9 < (*.f64 z t) Initial program 88.5%
Taylor expanded in y around inf
Applied rewrites75.4%
Taylor expanded in x around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6472.8
Applied rewrites72.8%
if -5.0000000000000001e-9 < (*.f64 z t) < 2e9Initial program 94.3%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6475.0
Applied rewrites75.0%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. 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) (* z t)) a) 1e+169) (/ (* y x) a) (* x (/ y a))))
assert(x < y && y < z && z < t && t < a);
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) - (z * t)) / a) <= 1e+169) {
tmp = (y * x) / a;
} else {
tmp = x * (y / a);
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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 * y) - (z * t)) / a) <= 1d+169) then
tmp = (y * x) / a
else
tmp = x * (y / a)
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
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) - (z * t)) / a) <= 1e+169) {
tmp = (y * x) / a;
} else {
tmp = x * (y / a);
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) [x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (((x * y) - (z * t)) / a) <= 1e+169: tmp = (y * x) / a else: tmp = x * (y / a) return tmp
x, y, z, t, a = sort([x, y, z, t, a]) x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(Float64(Float64(x * y) - Float64(z * t)) / a) <= 1e+169) tmp = Float64(Float64(y * x) / a); else tmp = Float64(x * Float64(y / a)); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
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) - (z * t)) / a) <= 1e+169)
tmp = (y * x) / a;
else
tmp = x * (y / a);
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. 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[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], 1e+169], N[(N[(y * x), $MachinePrecision] / a), $MachinePrecision], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot y - z \cdot t}{a} \leq 10^{+169}:\\
\;\;\;\;\frac{y \cdot x}{a}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{a}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 x y) (*.f64 z t)) a) < 9.99999999999999934e168Initial program 94.3%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6452.1
Applied rewrites52.1%
if 9.99999999999999934e168 < (/.f64 (-.f64 (*.f64 x y) (*.f64 z t)) a) Initial program 82.9%
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 rewrites86.0%
lift-/.f64N/A
frac-2negN/A
mul-1-negN/A
*-commutativeN/A
associate-*r/N/A
metadata-evalN/A
frac-2negN/A
lower-*.f64N/A
lower-/.f6485.9
Applied rewrites85.9%
Taylor expanded in y around inf
Applied rewrites83.0%
Taylor expanded in x around inf
Applied rewrites54.0%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. 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 3.05e-235) (* (/ x a) y) (* x (/ y a))))
assert(x < y && y < z && z < t && t < a);
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 <= 3.05e-235) {
tmp = (x / a) * y;
} else {
tmp = x * (y / a);
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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 <= 3.05d-235) then
tmp = (x / a) * y
else
tmp = x * (y / a)
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
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 <= 3.05e-235) {
tmp = (x / a) * y;
} else {
tmp = x * (y / a);
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) [x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if x <= 3.05e-235: tmp = (x / a) * y else: tmp = x * (y / a) return tmp
x, y, z, t, a = sort([x, y, z, t, a]) x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (x <= 3.05e-235) tmp = Float64(Float64(x / a) * y); else tmp = Float64(x * Float64(y / a)); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
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 <= 3.05e-235)
tmp = (x / a) * y;
else
tmp = x * (y / a);
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. 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, 3.05e-235], N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.05 \cdot 10^{-235}:\\
\;\;\;\;\frac{x}{a} \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{a}\\
\end{array}
\end{array}
if x < 3.04999999999999994e-235Initial program 91.6%
Taylor expanded in y around inf
Applied rewrites77.1%
Taylor expanded in x around inf
lift-/.f6450.6
Applied rewrites50.6%
if 3.04999999999999994e-235 < x 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 rewrites90.0%
lift-/.f64N/A
frac-2negN/A
mul-1-negN/A
*-commutativeN/A
associate-*r/N/A
metadata-evalN/A
frac-2negN/A
lower-*.f64N/A
lower-/.f6489.9
Applied rewrites89.9%
Taylor expanded in y around inf
Applied rewrites90.1%
Taylor expanded in x around inf
Applied rewrites60.1%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. 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 (/ y a)))
assert(x < y && y < z && z < t && t < a);
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
return x * (y / a);
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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 * (y / a)
end function
assert x < y && y < z && z < t && t < a;
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 * (y / a);
}
[x, y, z, t, a] = sort([x, y, z, t, a]) [x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): return x * (y / a)
x, y, z, t, a = sort([x, y, z, t, a]) x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) return Float64(x * Float64(y / a)) end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp = code(x, y, z, t, a)
tmp = x * (y / a);
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. NOTE: x, y, z, t, and a 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, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
x \cdot \frac{y}{a}
\end{array}
Initial program 91.4%
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.3%
lift-/.f64N/A
frac-2negN/A
mul-1-negN/A
*-commutativeN/A
associate-*r/N/A
metadata-evalN/A
frac-2negN/A
lower-*.f64N/A
lower-/.f6488.2
Applied rewrites88.2%
Taylor expanded in y around inf
Applied rewrites82.6%
Taylor expanded in x around inf
Applied rewrites52.0%
herbie shell --seed 2025110
(FPCore (x y z t a)
:name "Data.Colour.Matrix:inverse from colour-2.3.3, B"
:precision binary64
(/ (- (* x y) (* z t)) a))