
(FPCore (x y z t) :precision binary64 (* (- (* x y) (* z y)) t))
double code(double x, double y, double z, double t) {
return ((x * y) - (z * y)) * t;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x * y) - (z * y)) * t
end function
public static double code(double x, double y, double z, double t) {
return ((x * y) - (z * y)) * t;
}
def code(x, y, z, t): return ((x * y) - (z * y)) * t
function code(x, y, z, t) return Float64(Float64(Float64(x * y) - Float64(z * y)) * t) end
function tmp = code(x, y, z, t) tmp = ((x * y) - (z * y)) * t; end
code[x_, y_, z_, t_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot y - z \cdot y\right) \cdot t
\end{array}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (* (- (* x y) (* z y)) t))
double code(double x, double y, double z, double t) {
return ((x * y) - (z * y)) * t;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x * y) - (z * y)) * t
end function
public static double code(double x, double y, double z, double t) {
return ((x * y) - (z * y)) * t;
}
def code(x, y, z, t): return ((x * y) - (z * y)) * t
function code(x, y, z, t) return Float64(Float64(Float64(x * y) - Float64(z * y)) * t) end
function tmp = code(x, y, z, t) tmp = ((x * y) - (z * y)) * t; end
code[x_, y_, z_, t_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot y - z \cdot y\right) \cdot t
\end{array}
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function. (FPCore (y_s x y_m z t) :precision binary64 (* y_s (if (<= t 6e-13) (* (* t (- x z)) y_m) (* (- x z) (* t y_m)))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z && z < t);
double code(double y_s, double x, double y_m, double z, double t) {
double tmp;
if (t <= 6e-13) {
tmp = (t * (x - z)) * y_m;
} else {
tmp = (x - z) * (t * y_m);
}
return y_s * tmp;
}
y\_m = private
y\_s = private
NOTE: x, y_m, z, and t 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(y_s, x, y_m, z, t)
use fmin_fmax_functions
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (t <= 6d-13) then
tmp = (t * (x - z)) * y_m
else
tmp = (x - z) * (t * y_m)
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z && z < t;
public static double code(double y_s, double x, double y_m, double z, double t) {
double tmp;
if (t <= 6e-13) {
tmp = (t * (x - z)) * y_m;
} else {
tmp = (x - z) * (t * y_m);
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z, t] = sort([x, y_m, z, t]) def code(y_s, x, y_m, z, t): tmp = 0 if t <= 6e-13: tmp = (t * (x - z)) * y_m else: tmp = (x - z) * (t * y_m) return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z, t = sort([x, y_m, z, t]) function code(y_s, x, y_m, z, t) tmp = 0.0 if (t <= 6e-13) tmp = Float64(Float64(t * Float64(x - z)) * y_m); else tmp = Float64(Float64(x - z) * Float64(t * y_m)); end return Float64(y_s * tmp) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z, t = num2cell(sort([x, y_m, z, t])){:}
function tmp_2 = code(y_s, x, y_m, z, t)
tmp = 0.0;
if (t <= 6e-13)
tmp = (t * (x - z)) * y_m;
else
tmp = (x - z) * (t * y_m);
end
tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_, t_] := N[(y$95$s * If[LessEqual[t, 6e-13], N[(N[(t * N[(x - z), $MachinePrecision]), $MachinePrecision] * y$95$m), $MachinePrecision], N[(N[(x - z), $MachinePrecision] * N[(t * y$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;t \leq 6 \cdot 10^{-13}:\\
\;\;\;\;\left(t \cdot \left(x - z\right)\right) \cdot y\_m\\
\mathbf{else}:\\
\;\;\;\;\left(x - z\right) \cdot \left(t \cdot y\_m\right)\\
\end{array}
\end{array}
if t < 5.99999999999999968e-13Initial program 93.4%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
distribute-rgt-out--N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f6489.5
Applied rewrites89.5%
if 5.99999999999999968e-13 < t Initial program 93.4%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
distribute-rgt-out--N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6492.3
Applied rewrites92.3%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function. (FPCore (y_s x y_m z t) :precision binary64 (* y_s (if (<= t 2.4e-40) (* (- (* x y_m) (* z y_m)) t) (* (- x z) (* t y_m)))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z && z < t);
double code(double y_s, double x, double y_m, double z, double t) {
double tmp;
if (t <= 2.4e-40) {
tmp = ((x * y_m) - (z * y_m)) * t;
} else {
tmp = (x - z) * (t * y_m);
}
return y_s * tmp;
}
y\_m = private
y\_s = private
NOTE: x, y_m, z, and t 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(y_s, x, y_m, z, t)
use fmin_fmax_functions
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (t <= 2.4d-40) then
tmp = ((x * y_m) - (z * y_m)) * t
else
tmp = (x - z) * (t * y_m)
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z && z < t;
public static double code(double y_s, double x, double y_m, double z, double t) {
double tmp;
if (t <= 2.4e-40) {
tmp = ((x * y_m) - (z * y_m)) * t;
} else {
tmp = (x - z) * (t * y_m);
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z, t] = sort([x, y_m, z, t]) def code(y_s, x, y_m, z, t): tmp = 0 if t <= 2.4e-40: tmp = ((x * y_m) - (z * y_m)) * t else: tmp = (x - z) * (t * y_m) return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z, t = sort([x, y_m, z, t]) function code(y_s, x, y_m, z, t) tmp = 0.0 if (t <= 2.4e-40) tmp = Float64(Float64(Float64(x * y_m) - Float64(z * y_m)) * t); else tmp = Float64(Float64(x - z) * Float64(t * y_m)); end return Float64(y_s * tmp) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z, t = num2cell(sort([x, y_m, z, t])){:}
function tmp_2 = code(y_s, x, y_m, z, t)
tmp = 0.0;
if (t <= 2.4e-40)
tmp = ((x * y_m) - (z * y_m)) * t;
else
tmp = (x - z) * (t * y_m);
end
tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_, t_] := N[(y$95$s * If[LessEqual[t, 2.4e-40], N[(N[(N[(x * y$95$m), $MachinePrecision] - N[(z * y$95$m), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision], N[(N[(x - z), $MachinePrecision] * N[(t * y$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;t \leq 2.4 \cdot 10^{-40}:\\
\;\;\;\;\left(x \cdot y\_m - z \cdot y\_m\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;\left(x - z\right) \cdot \left(t \cdot y\_m\right)\\
\end{array}
\end{array}
if t < 2.39999999999999991e-40Initial program 93.4%
if 2.39999999999999991e-40 < t Initial program 93.4%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
distribute-rgt-out--N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6492.3
Applied rewrites92.3%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z t)
:precision binary64
(let* ((t_1 (* (* (- z) y_m) t)))
(*
y_s
(if (<= z -1.15e+124)
t_1
(if (<= z 2.5e+158) (* (* t (- x z)) y_m) t_1)))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z && z < t);
double code(double y_s, double x, double y_m, double z, double t) {
double t_1 = (-z * y_m) * t;
double tmp;
if (z <= -1.15e+124) {
tmp = t_1;
} else if (z <= 2.5e+158) {
tmp = (t * (x - z)) * y_m;
} else {
tmp = t_1;
}
return y_s * tmp;
}
y\_m = private
y\_s = private
NOTE: x, y_m, z, and t 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(y_s, x, y_m, z, t)
use fmin_fmax_functions
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = (-z * y_m) * t
if (z <= (-1.15d+124)) then
tmp = t_1
else if (z <= 2.5d+158) then
tmp = (t * (x - z)) * y_m
else
tmp = t_1
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z && z < t;
public static double code(double y_s, double x, double y_m, double z, double t) {
double t_1 = (-z * y_m) * t;
double tmp;
if (z <= -1.15e+124) {
tmp = t_1;
} else if (z <= 2.5e+158) {
tmp = (t * (x - z)) * y_m;
} else {
tmp = t_1;
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z, t] = sort([x, y_m, z, t]) def code(y_s, x, y_m, z, t): t_1 = (-z * y_m) * t tmp = 0 if z <= -1.15e+124: tmp = t_1 elif z <= 2.5e+158: tmp = (t * (x - z)) * y_m else: tmp = t_1 return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z, t = sort([x, y_m, z, t]) function code(y_s, x, y_m, z, t) t_1 = Float64(Float64(Float64(-z) * y_m) * t) tmp = 0.0 if (z <= -1.15e+124) tmp = t_1; elseif (z <= 2.5e+158) tmp = Float64(Float64(t * Float64(x - z)) * y_m); else tmp = t_1; end return Float64(y_s * tmp) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z, t = num2cell(sort([x, y_m, z, t])){:}
function tmp_2 = code(y_s, x, y_m, z, t)
t_1 = (-z * y_m) * t;
tmp = 0.0;
if (z <= -1.15e+124)
tmp = t_1;
elseif (z <= 2.5e+158)
tmp = (t * (x - z)) * y_m;
else
tmp = t_1;
end
tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_, t_] := Block[{t$95$1 = N[(N[((-z) * y$95$m), $MachinePrecision] * t), $MachinePrecision]}, N[(y$95$s * If[LessEqual[z, -1.15e+124], t$95$1, If[LessEqual[z, 2.5e+158], N[(N[(t * N[(x - z), $MachinePrecision]), $MachinePrecision] * y$95$m), $MachinePrecision], t$95$1]]), $MachinePrecision]]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\
\\
\begin{array}{l}
t_1 := \left(\left(-z\right) \cdot y\_m\right) \cdot t\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -1.15 \cdot 10^{+124}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.5 \cdot 10^{+158}:\\
\;\;\;\;\left(t \cdot \left(x - z\right)\right) \cdot y\_m\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
\end{array}
if z < -1.14999999999999992e124 or 2.4999999999999998e158 < z Initial program 93.4%
Taylor expanded in x around 0
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6453.0
Applied rewrites53.0%
if -1.14999999999999992e124 < z < 2.4999999999999998e158Initial program 93.4%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
distribute-rgt-out--N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f6489.5
Applied rewrites89.5%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z t)
:precision binary64
(let* ((t_1 (* (* y_m x) t)))
(*
y_s
(if (<= x -6.8e+36) t_1 (if (<= x 2.55e-65) (* (* (- z) y_m) t) t_1)))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z && z < t);
double code(double y_s, double x, double y_m, double z, double t) {
double t_1 = (y_m * x) * t;
double tmp;
if (x <= -6.8e+36) {
tmp = t_1;
} else if (x <= 2.55e-65) {
tmp = (-z * y_m) * t;
} else {
tmp = t_1;
}
return y_s * tmp;
}
y\_m = private
y\_s = private
NOTE: x, y_m, z, and t 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(y_s, x, y_m, z, t)
use fmin_fmax_functions
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = (y_m * x) * t
if (x <= (-6.8d+36)) then
tmp = t_1
else if (x <= 2.55d-65) then
tmp = (-z * y_m) * t
else
tmp = t_1
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z && z < t;
public static double code(double y_s, double x, double y_m, double z, double t) {
double t_1 = (y_m * x) * t;
double tmp;
if (x <= -6.8e+36) {
tmp = t_1;
} else if (x <= 2.55e-65) {
tmp = (-z * y_m) * t;
} else {
tmp = t_1;
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z, t] = sort([x, y_m, z, t]) def code(y_s, x, y_m, z, t): t_1 = (y_m * x) * t tmp = 0 if x <= -6.8e+36: tmp = t_1 elif x <= 2.55e-65: tmp = (-z * y_m) * t else: tmp = t_1 return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z, t = sort([x, y_m, z, t]) function code(y_s, x, y_m, z, t) t_1 = Float64(Float64(y_m * x) * t) tmp = 0.0 if (x <= -6.8e+36) tmp = t_1; elseif (x <= 2.55e-65) tmp = Float64(Float64(Float64(-z) * y_m) * t); else tmp = t_1; end return Float64(y_s * tmp) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z, t = num2cell(sort([x, y_m, z, t])){:}
function tmp_2 = code(y_s, x, y_m, z, t)
t_1 = (y_m * x) * t;
tmp = 0.0;
if (x <= -6.8e+36)
tmp = t_1;
elseif (x <= 2.55e-65)
tmp = (-z * y_m) * t;
else
tmp = t_1;
end
tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_, t_] := Block[{t$95$1 = N[(N[(y$95$m * x), $MachinePrecision] * t), $MachinePrecision]}, N[(y$95$s * If[LessEqual[x, -6.8e+36], t$95$1, If[LessEqual[x, 2.55e-65], N[(N[((-z) * y$95$m), $MachinePrecision] * t), $MachinePrecision], t$95$1]]), $MachinePrecision]]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\
\\
\begin{array}{l}
t_1 := \left(y\_m \cdot x\right) \cdot t\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq -6.8 \cdot 10^{+36}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.55 \cdot 10^{-65}:\\
\;\;\;\;\left(\left(-z\right) \cdot y\_m\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
\end{array}
if x < -6.7999999999999996e36 or 2.55e-65 < x Initial program 93.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6455.3
Applied rewrites55.3%
if -6.7999999999999996e36 < x < 2.55e-65Initial program 93.4%
Taylor expanded in x around 0
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6453.0
Applied rewrites53.0%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z t)
:precision binary64
(let* ((t_1 (* (* y_m x) t)))
(*
y_s
(if (<= x -6.8e+36) t_1 (if (<= x 2.55e-65) (* (- z) (* t y_m)) t_1)))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z && z < t);
double code(double y_s, double x, double y_m, double z, double t) {
double t_1 = (y_m * x) * t;
double tmp;
if (x <= -6.8e+36) {
tmp = t_1;
} else if (x <= 2.55e-65) {
tmp = -z * (t * y_m);
} else {
tmp = t_1;
}
return y_s * tmp;
}
y\_m = private
y\_s = private
NOTE: x, y_m, z, and t 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(y_s, x, y_m, z, t)
use fmin_fmax_functions
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = (y_m * x) * t
if (x <= (-6.8d+36)) then
tmp = t_1
else if (x <= 2.55d-65) then
tmp = -z * (t * y_m)
else
tmp = t_1
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z && z < t;
public static double code(double y_s, double x, double y_m, double z, double t) {
double t_1 = (y_m * x) * t;
double tmp;
if (x <= -6.8e+36) {
tmp = t_1;
} else if (x <= 2.55e-65) {
tmp = -z * (t * y_m);
} else {
tmp = t_1;
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z, t] = sort([x, y_m, z, t]) def code(y_s, x, y_m, z, t): t_1 = (y_m * x) * t tmp = 0 if x <= -6.8e+36: tmp = t_1 elif x <= 2.55e-65: tmp = -z * (t * y_m) else: tmp = t_1 return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z, t = sort([x, y_m, z, t]) function code(y_s, x, y_m, z, t) t_1 = Float64(Float64(y_m * x) * t) tmp = 0.0 if (x <= -6.8e+36) tmp = t_1; elseif (x <= 2.55e-65) tmp = Float64(Float64(-z) * Float64(t * y_m)); else tmp = t_1; end return Float64(y_s * tmp) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z, t = num2cell(sort([x, y_m, z, t])){:}
function tmp_2 = code(y_s, x, y_m, z, t)
t_1 = (y_m * x) * t;
tmp = 0.0;
if (x <= -6.8e+36)
tmp = t_1;
elseif (x <= 2.55e-65)
tmp = -z * (t * y_m);
else
tmp = t_1;
end
tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_, t_] := Block[{t$95$1 = N[(N[(y$95$m * x), $MachinePrecision] * t), $MachinePrecision]}, N[(y$95$s * If[LessEqual[x, -6.8e+36], t$95$1, If[LessEqual[x, 2.55e-65], N[((-z) * N[(t * y$95$m), $MachinePrecision]), $MachinePrecision], t$95$1]]), $MachinePrecision]]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\
\\
\begin{array}{l}
t_1 := \left(y\_m \cdot x\right) \cdot t\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq -6.8 \cdot 10^{+36}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.55 \cdot 10^{-65}:\\
\;\;\;\;\left(-z\right) \cdot \left(t \cdot y\_m\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
\end{array}
if x < -6.7999999999999996e36 or 2.55e-65 < x Initial program 93.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6455.3
Applied rewrites55.3%
if -6.7999999999999996e36 < x < 2.55e-65Initial program 93.4%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
distribute-rgt-out--N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6492.3
Applied rewrites92.3%
Taylor expanded in x around 0
mul-1-negN/A
lift-neg.f6453.2
Applied rewrites53.2%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z t)
:precision binary64
(let* ((t_1 (* (* y_m x) t)))
(*
y_s
(if (<= x -7.8e+15) t_1 (if (<= x 2.55e-65) (* (* (- t) z) y_m) t_1)))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z && z < t);
double code(double y_s, double x, double y_m, double z, double t) {
double t_1 = (y_m * x) * t;
double tmp;
if (x <= -7.8e+15) {
tmp = t_1;
} else if (x <= 2.55e-65) {
tmp = (-t * z) * y_m;
} else {
tmp = t_1;
}
return y_s * tmp;
}
y\_m = private
y\_s = private
NOTE: x, y_m, z, and t 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(y_s, x, y_m, z, t)
use fmin_fmax_functions
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = (y_m * x) * t
if (x <= (-7.8d+15)) then
tmp = t_1
else if (x <= 2.55d-65) then
tmp = (-t * z) * y_m
else
tmp = t_1
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z && z < t;
public static double code(double y_s, double x, double y_m, double z, double t) {
double t_1 = (y_m * x) * t;
double tmp;
if (x <= -7.8e+15) {
tmp = t_1;
} else if (x <= 2.55e-65) {
tmp = (-t * z) * y_m;
} else {
tmp = t_1;
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z, t] = sort([x, y_m, z, t]) def code(y_s, x, y_m, z, t): t_1 = (y_m * x) * t tmp = 0 if x <= -7.8e+15: tmp = t_1 elif x <= 2.55e-65: tmp = (-t * z) * y_m else: tmp = t_1 return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z, t = sort([x, y_m, z, t]) function code(y_s, x, y_m, z, t) t_1 = Float64(Float64(y_m * x) * t) tmp = 0.0 if (x <= -7.8e+15) tmp = t_1; elseif (x <= 2.55e-65) tmp = Float64(Float64(Float64(-t) * z) * y_m); else tmp = t_1; end return Float64(y_s * tmp) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z, t = num2cell(sort([x, y_m, z, t])){:}
function tmp_2 = code(y_s, x, y_m, z, t)
t_1 = (y_m * x) * t;
tmp = 0.0;
if (x <= -7.8e+15)
tmp = t_1;
elseif (x <= 2.55e-65)
tmp = (-t * z) * y_m;
else
tmp = t_1;
end
tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_, t_] := Block[{t$95$1 = N[(N[(y$95$m * x), $MachinePrecision] * t), $MachinePrecision]}, N[(y$95$s * If[LessEqual[x, -7.8e+15], t$95$1, If[LessEqual[x, 2.55e-65], N[(N[((-t) * z), $MachinePrecision] * y$95$m), $MachinePrecision], t$95$1]]), $MachinePrecision]]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\
\\
\begin{array}{l}
t_1 := \left(y\_m \cdot x\right) \cdot t\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq -7.8 \cdot 10^{+15}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.55 \cdot 10^{-65}:\\
\;\;\;\;\left(\left(-t\right) \cdot z\right) \cdot y\_m\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
\end{array}
if x < -7.8e15 or 2.55e-65 < x Initial program 93.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6455.3
Applied rewrites55.3%
if -7.8e15 < x < 2.55e-65Initial program 93.4%
Taylor expanded in x around 0
mul-1-negN/A
distribute-lft-neg-inN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-neg.f6450.6
Applied rewrites50.6%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function. (FPCore (y_s x y_m z t) :precision binary64 (* y_s (* (* y_m x) t)))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z && z < t);
double code(double y_s, double x, double y_m, double z, double t) {
return y_s * ((y_m * x) * t);
}
y\_m = private
y\_s = private
NOTE: x, y_m, z, and t 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(y_s, x, y_m, z, t)
use fmin_fmax_functions
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
code = y_s * ((y_m * x) * t)
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z && z < t;
public static double code(double y_s, double x, double y_m, double z, double t) {
return y_s * ((y_m * x) * t);
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z, t] = sort([x, y_m, z, t]) def code(y_s, x, y_m, z, t): return y_s * ((y_m * x) * t)
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z, t = sort([x, y_m, z, t]) function code(y_s, x, y_m, z, t) return Float64(y_s * Float64(Float64(y_m * x) * t)) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z, t = num2cell(sort([x, y_m, z, t])){:}
function tmp = code(y_s, x, y_m, z, t)
tmp = y_s * ((y_m * x) * t);
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_, t_] := N[(y$95$s * N[(N[(y$95$m * x), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\
\\
y\_s \cdot \left(\left(y\_m \cdot x\right) \cdot t\right)
\end{array}
Initial program 93.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6455.3
Applied rewrites55.3%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function. (FPCore (y_s x y_m z t) :precision binary64 (* y_s (* (* t x) y_m)))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z && z < t);
double code(double y_s, double x, double y_m, double z, double t) {
return y_s * ((t * x) * y_m);
}
y\_m = private
y\_s = private
NOTE: x, y_m, z, and t 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(y_s, x, y_m, z, t)
use fmin_fmax_functions
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
code = y_s * ((t * x) * y_m)
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z && z < t;
public static double code(double y_s, double x, double y_m, double z, double t) {
return y_s * ((t * x) * y_m);
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z, t] = sort([x, y_m, z, t]) def code(y_s, x, y_m, z, t): return y_s * ((t * x) * y_m)
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z, t = sort([x, y_m, z, t]) function code(y_s, x, y_m, z, t) return Float64(y_s * Float64(Float64(t * x) * y_m)) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z, t = num2cell(sort([x, y_m, z, t])){:}
function tmp = code(y_s, x, y_m, z, t)
tmp = y_s * ((t * x) * y_m);
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_, t_] := N[(y$95$s * N[(N[(t * x), $MachinePrecision] * y$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\
\\
y\_s \cdot \left(\left(t \cdot x\right) \cdot y\_m\right)
\end{array}
Initial program 93.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6455.3
Applied rewrites55.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6452.9
Applied rewrites52.9%
herbie shell --seed 2025139
(FPCore (x y z t)
:name "Linear.Projection:inverseInfinitePerspective from linear-1.19.1.3"
:precision binary64
(* (- (* x y) (* z y)) t))