
(FPCore (x y) :precision binary64 (+ x (/ (fabs (- y x)) 2.0)))
double code(double x, double y) {
return x + (fabs((y - x)) / 2.0);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + (abs((y - x)) / 2.0d0)
end function
public static double code(double x, double y) {
return x + (Math.abs((y - x)) / 2.0);
}
def code(x, y): return x + (math.fabs((y - x)) / 2.0)
function code(x, y) return Float64(x + Float64(abs(Float64(y - x)) / 2.0)) end
function tmp = code(x, y) tmp = x + (abs((y - x)) / 2.0); end
code[x_, y_] := N[(x + N[(N[Abs[N[(y - x), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left|y - x\right|}{2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (+ x (/ (fabs (- y x)) 2.0)))
double code(double x, double y) {
return x + (fabs((y - x)) / 2.0);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + (abs((y - x)) / 2.0d0)
end function
public static double code(double x, double y) {
return x + (Math.abs((y - x)) / 2.0);
}
def code(x, y): return x + (math.fabs((y - x)) / 2.0)
function code(x, y) return Float64(x + Float64(abs(Float64(y - x)) / 2.0)) end
function tmp = code(x, y) tmp = x + (abs((y - x)) / 2.0); end
code[x_, y_] := N[(x + N[(N[Abs[N[(y - x), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left|y - x\right|}{2}
\end{array}
(FPCore (x y) :precision binary64 (fma 0.5 (fabs (- y x)) x))
double code(double x, double y) {
return fma(0.5, fabs((y - x)), x);
}
function code(x, y) return fma(0.5, abs(Float64(y - x)), x) end
code[x_, y_] := N[(0.5 * N[Abs[N[(y - x), $MachinePrecision]], $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(0.5, \left|y - x\right|, x\right)
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
metadata-evalN/A
*-lft-identityN/A
*-lft-identityN/A
metadata-evalN/A
cancel-sign-subN/A
lower-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6499.9
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= y -800000000000.0) (* (- x y) 0.5) (if (<= y 7.5e-150) (fma 0.5 (fabs x) x) (* 0.5 (+ x y)))))
double code(double x, double y) {
double tmp;
if (y <= -800000000000.0) {
tmp = (x - y) * 0.5;
} else if (y <= 7.5e-150) {
tmp = fma(0.5, fabs(x), x);
} else {
tmp = 0.5 * (x + y);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (y <= -800000000000.0) tmp = Float64(Float64(x - y) * 0.5); elseif (y <= 7.5e-150) tmp = fma(0.5, abs(x), x); else tmp = Float64(0.5 * Float64(x + y)); end return tmp end
code[x_, y_] := If[LessEqual[y, -800000000000.0], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[y, 7.5e-150], N[(0.5 * N[Abs[x], $MachinePrecision] + x), $MachinePrecision], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -800000000000:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{-150}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \left|x\right|, x\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\end{array}
\end{array}
if y < -8e11Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
metadata-evalN/A
*-lft-identityN/A
*-lft-identityN/A
metadata-evalN/A
cancel-sign-subN/A
lower-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64100.0
Applied rewrites100.0%
lift-fma.f64N/A
lift--.f64N/A
lift-fabs.f64N/A
*-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
rem-sqrt-square-revN/A
unpow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
lift--.f6418.6
Applied rewrites18.6%
Taylor expanded in x around 0
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6418.6
Applied rewrites18.6%
Taylor expanded in x around 0
fabs-subN/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrtN/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6495.7
Applied rewrites95.7%
if -8e11 < y < 7.5000000000000004e-150Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
metadata-evalN/A
*-lft-identityN/A
*-lft-identityN/A
metadata-evalN/A
cancel-sign-subN/A
lower-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in x around inf
Applied rewrites85.2%
if 7.5000000000000004e-150 < y Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
metadata-evalN/A
*-lft-identityN/A
*-lft-identityN/A
metadata-evalN/A
cancel-sign-subN/A
lower-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6499.9
Applied rewrites99.9%
lift-fma.f64N/A
lift--.f64N/A
lift-fabs.f64N/A
*-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
rem-sqrt-square-revN/A
unpow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
lift--.f6484.2
Applied rewrites84.2%
Taylor expanded in x around 0
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6484.2
Applied rewrites84.2%
(FPCore (x y) :precision binary64 (if (<= y -1.08e-16) (* -0.5 y) (if (<= y 1.18e-148) (* 0.5 x) (fma y 0.5 x))))
double code(double x, double y) {
double tmp;
if (y <= -1.08e-16) {
tmp = -0.5 * y;
} else if (y <= 1.18e-148) {
tmp = 0.5 * x;
} else {
tmp = fma(y, 0.5, x);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (y <= -1.08e-16) tmp = Float64(-0.5 * y); elseif (y <= 1.18e-148) tmp = Float64(0.5 * x); else tmp = fma(y, 0.5, x); end return tmp end
code[x_, y_] := If[LessEqual[y, -1.08e-16], N[(-0.5 * y), $MachinePrecision], If[LessEqual[y, 1.18e-148], N[(0.5 * x), $MachinePrecision], N[(y * 0.5 + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.08 \cdot 10^{-16}:\\
\;\;\;\;-0.5 \cdot y\\
\mathbf{elif}\;y \leq 1.18 \cdot 10^{-148}:\\
\;\;\;\;0.5 \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, 0.5, x\right)\\
\end{array}
\end{array}
if y < -1.08e-16Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
metadata-evalN/A
*-lft-identityN/A
*-lft-identityN/A
metadata-evalN/A
cancel-sign-subN/A
lower-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64100.0
Applied rewrites100.0%
lift-fma.f64N/A
lift--.f64N/A
lift-fabs.f64N/A
*-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
rem-sqrt-square-revN/A
unpow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
lift--.f6419.0
Applied rewrites19.0%
lift--.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
unpow2N/A
rem-sqrt-square-revN/A
fabs-subN/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower--.f6483.0
Applied rewrites83.0%
Taylor expanded in x around 0
Applied rewrites73.3%
if -1.08e-16 < y < 1.18e-148Initial program 99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
lift-/.f64N/A
lift-fma.f64N/A
lift--.f64N/A
lift-fabs.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-*r/N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
fabs-subN/A
rem-sqrt-square-revN/A
unpow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
lift--.f6464.0
Applied rewrites64.0%
Taylor expanded in x around inf
Applied rewrites59.2%
if 1.18e-148 < y Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
metadata-evalN/A
*-lft-identityN/A
*-lft-identityN/A
metadata-evalN/A
cancel-sign-subN/A
lower-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6499.9
Applied rewrites99.9%
lift-fma.f64N/A
lift--.f64N/A
lift-fabs.f64N/A
*-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
rem-sqrt-square-revN/A
unpow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
lift--.f6484.0
Applied rewrites84.0%
Taylor expanded in x around 0
Applied rewrites70.0%
(FPCore (x y) :precision binary64 (if (<= y -1.08e-16) (* -0.5 y) (if (<= y 1.65e-62) (* 0.5 x) (* y 0.5))))
double code(double x, double y) {
double tmp;
if (y <= -1.08e-16) {
tmp = -0.5 * y;
} else if (y <= 1.65e-62) {
tmp = 0.5 * x;
} else {
tmp = y * 0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.08d-16)) then
tmp = (-0.5d0) * y
else if (y <= 1.65d-62) then
tmp = 0.5d0 * x
else
tmp = y * 0.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.08e-16) {
tmp = -0.5 * y;
} else if (y <= 1.65e-62) {
tmp = 0.5 * x;
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.08e-16: tmp = -0.5 * y elif y <= 1.65e-62: tmp = 0.5 * x else: tmp = y * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.08e-16) tmp = Float64(-0.5 * y); elseif (y <= 1.65e-62) tmp = Float64(0.5 * x); else tmp = Float64(y * 0.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.08e-16) tmp = -0.5 * y; elseif (y <= 1.65e-62) tmp = 0.5 * x; else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.08e-16], N[(-0.5 * y), $MachinePrecision], If[LessEqual[y, 1.65e-62], N[(0.5 * x), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.08 \cdot 10^{-16}:\\
\;\;\;\;-0.5 \cdot y\\
\mathbf{elif}\;y \leq 1.65 \cdot 10^{-62}:\\
\;\;\;\;0.5 \cdot x\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < -1.08e-16Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
metadata-evalN/A
*-lft-identityN/A
*-lft-identityN/A
metadata-evalN/A
cancel-sign-subN/A
lower-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64100.0
Applied rewrites100.0%
lift-fma.f64N/A
lift--.f64N/A
lift-fabs.f64N/A
*-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
rem-sqrt-square-revN/A
unpow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
lift--.f6419.0
Applied rewrites19.0%
lift--.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
unpow2N/A
rem-sqrt-square-revN/A
fabs-subN/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower--.f6483.0
Applied rewrites83.0%
Taylor expanded in x around 0
Applied rewrites73.3%
if -1.08e-16 < y < 1.65000000000000002e-62Initial program 99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
lift-/.f64N/A
lift-fma.f64N/A
lift--.f64N/A
lift-fabs.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-*r/N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
fabs-subN/A
rem-sqrt-square-revN/A
unpow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
lift--.f6466.7
Applied rewrites66.7%
Taylor expanded in x around inf
Applied rewrites57.3%
if 1.65000000000000002e-62 < y Initial program 100.0%
Taylor expanded in x around 0
lower-*.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
metadata-evalN/A
*-lft-identityN/A
*-lft-identityN/A
metadata-evalN/A
cancel-sign-subN/A
lower-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6470.6
Applied rewrites70.6%
lift-*.f64N/A
lift--.f64N/A
lift-fabs.f64N/A
*-commutativeN/A
lower-*.f64N/A
fabs-subN/A
rem-sqrt-square-revN/A
unpow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
lift--.f6467.3
Applied rewrites67.3%
Taylor expanded in x around 0
Applied rewrites68.4%
(FPCore (x y) :precision binary64 (if (<= x -1.15e-76) (* 0.5 x) (if (<= x 5.5e-183) (* -0.5 y) (* 1.5 x))))
double code(double x, double y) {
double tmp;
if (x <= -1.15e-76) {
tmp = 0.5 * x;
} else if (x <= 5.5e-183) {
tmp = -0.5 * y;
} else {
tmp = 1.5 * x;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.15d-76)) then
tmp = 0.5d0 * x
else if (x <= 5.5d-183) then
tmp = (-0.5d0) * y
else
tmp = 1.5d0 * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.15e-76) {
tmp = 0.5 * x;
} else if (x <= 5.5e-183) {
tmp = -0.5 * y;
} else {
tmp = 1.5 * x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.15e-76: tmp = 0.5 * x elif x <= 5.5e-183: tmp = -0.5 * y else: tmp = 1.5 * x return tmp
function code(x, y) tmp = 0.0 if (x <= -1.15e-76) tmp = Float64(0.5 * x); elseif (x <= 5.5e-183) tmp = Float64(-0.5 * y); else tmp = Float64(1.5 * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.15e-76) tmp = 0.5 * x; elseif (x <= 5.5e-183) tmp = -0.5 * y; else tmp = 1.5 * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.15e-76], N[(0.5 * x), $MachinePrecision], If[LessEqual[x, 5.5e-183], N[(-0.5 * y), $MachinePrecision], N[(1.5 * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.15 \cdot 10^{-76}:\\
\;\;\;\;0.5 \cdot x\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{-183}:\\
\;\;\;\;-0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;1.5 \cdot x\\
\end{array}
\end{array}
if x < -1.15000000000000003e-76Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.8%
lift-/.f64N/A
lift-fma.f64N/A
lift--.f64N/A
lift-fabs.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-*r/N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
fabs-subN/A
rem-sqrt-square-revN/A
unpow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
lift--.f6484.6
Applied rewrites84.6%
Taylor expanded in x around inf
Applied rewrites70.1%
if -1.15000000000000003e-76 < x < 5.4999999999999999e-183Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
metadata-evalN/A
*-lft-identityN/A
*-lft-identityN/A
metadata-evalN/A
cancel-sign-subN/A
lower-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64100.0
Applied rewrites100.0%
lift-fma.f64N/A
lift--.f64N/A
lift-fabs.f64N/A
*-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
rem-sqrt-square-revN/A
unpow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
lift--.f6459.5
Applied rewrites59.5%
lift--.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
unpow2N/A
rem-sqrt-square-revN/A
fabs-subN/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower--.f6441.1
Applied rewrites41.1%
Taylor expanded in x around 0
Applied rewrites40.9%
if 5.4999999999999999e-183 < x Initial program 99.8%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
metadata-evalN/A
*-lft-identityN/A
*-lft-identityN/A
metadata-evalN/A
cancel-sign-subN/A
lower-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6499.8
Applied rewrites99.8%
lift-fma.f64N/A
lift--.f64N/A
lift-fabs.f64N/A
*-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
rem-sqrt-square-revN/A
unpow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
lift--.f6434.6
Applied rewrites34.6%
lift--.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
unpow2N/A
rem-sqrt-square-revN/A
fabs-subN/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower--.f6475.7
Applied rewrites75.7%
Taylor expanded in x around inf
rem-square-sqrtN/A
*-commutativeN/A
rem-square-sqrtN/A
sqrt-unprodN/A
rem-sqrt-square-revN/A
lower-*.f6460.9
Applied rewrites60.9%
(FPCore (x y) :precision binary64 (if (<= y -2e-222) (* (- x y) 0.5) (* 0.5 (+ x y))))
double code(double x, double y) {
double tmp;
if (y <= -2e-222) {
tmp = (x - y) * 0.5;
} else {
tmp = 0.5 * (x + y);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-2d-222)) then
tmp = (x - y) * 0.5d0
else
tmp = 0.5d0 * (x + y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -2e-222) {
tmp = (x - y) * 0.5;
} else {
tmp = 0.5 * (x + y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2e-222: tmp = (x - y) * 0.5 else: tmp = 0.5 * (x + y) return tmp
function code(x, y) tmp = 0.0 if (y <= -2e-222) tmp = Float64(Float64(x - y) * 0.5); else tmp = Float64(0.5 * Float64(x + y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2e-222) tmp = (x - y) * 0.5; else tmp = 0.5 * (x + y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2e-222], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{-222}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\end{array}
\end{array}
if y < -2.0000000000000001e-222Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
metadata-evalN/A
*-lft-identityN/A
*-lft-identityN/A
metadata-evalN/A
cancel-sign-subN/A
lower-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64100.0
Applied rewrites100.0%
lift-fma.f64N/A
lift--.f64N/A
lift-fabs.f64N/A
*-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
rem-sqrt-square-revN/A
unpow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
lift--.f6432.3
Applied rewrites32.3%
Taylor expanded in x around 0
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6432.3
Applied rewrites32.3%
Taylor expanded in x around 0
fabs-subN/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrtN/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6482.8
Applied rewrites82.8%
if -2.0000000000000001e-222 < y Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
metadata-evalN/A
*-lft-identityN/A
*-lft-identityN/A
metadata-evalN/A
cancel-sign-subN/A
lower-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6499.9
Applied rewrites99.9%
lift-fma.f64N/A
lift--.f64N/A
lift-fabs.f64N/A
*-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
rem-sqrt-square-revN/A
unpow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
lift--.f6479.7
Applied rewrites79.7%
Taylor expanded in x around 0
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6479.7
Applied rewrites79.7%
(FPCore (x y) :precision binary64 (if (<= y -1.08e-16) (* -0.5 y) (* 0.5 (+ x y))))
double code(double x, double y) {
double tmp;
if (y <= -1.08e-16) {
tmp = -0.5 * y;
} else {
tmp = 0.5 * (x + y);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.08d-16)) then
tmp = (-0.5d0) * y
else
tmp = 0.5d0 * (x + y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.08e-16) {
tmp = -0.5 * y;
} else {
tmp = 0.5 * (x + y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.08e-16: tmp = -0.5 * y else: tmp = 0.5 * (x + y) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.08e-16) tmp = Float64(-0.5 * y); else tmp = Float64(0.5 * Float64(x + y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.08e-16) tmp = -0.5 * y; else tmp = 0.5 * (x + y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.08e-16], N[(-0.5 * y), $MachinePrecision], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.08 \cdot 10^{-16}:\\
\;\;\;\;-0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\end{array}
\end{array}
if y < -1.08e-16Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
metadata-evalN/A
*-lft-identityN/A
*-lft-identityN/A
metadata-evalN/A
cancel-sign-subN/A
lower-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64100.0
Applied rewrites100.0%
lift-fma.f64N/A
lift--.f64N/A
lift-fabs.f64N/A
*-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
rem-sqrt-square-revN/A
unpow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
lift--.f6419.0
Applied rewrites19.0%
lift--.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
unpow2N/A
rem-sqrt-square-revN/A
fabs-subN/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower--.f6483.0
Applied rewrites83.0%
Taylor expanded in x around 0
Applied rewrites73.3%
if -1.08e-16 < y Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
metadata-evalN/A
*-lft-identityN/A
*-lft-identityN/A
metadata-evalN/A
cancel-sign-subN/A
lower-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6499.9
Applied rewrites99.9%
lift-fma.f64N/A
lift--.f64N/A
lift-fabs.f64N/A
*-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
rem-sqrt-square-revN/A
unpow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
lift--.f6474.3
Applied rewrites74.3%
Taylor expanded in x around 0
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6474.3
Applied rewrites74.3%
(FPCore (x y) :precision binary64 (if (<= y -880000000000.0) (* -0.5 y) (* 1.5 x)))
double code(double x, double y) {
double tmp;
if (y <= -880000000000.0) {
tmp = -0.5 * y;
} else {
tmp = 1.5 * x;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-880000000000.0d0)) then
tmp = (-0.5d0) * y
else
tmp = 1.5d0 * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -880000000000.0) {
tmp = -0.5 * y;
} else {
tmp = 1.5 * x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -880000000000.0: tmp = -0.5 * y else: tmp = 1.5 * x return tmp
function code(x, y) tmp = 0.0 if (y <= -880000000000.0) tmp = Float64(-0.5 * y); else tmp = Float64(1.5 * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -880000000000.0) tmp = -0.5 * y; else tmp = 1.5 * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -880000000000.0], N[(-0.5 * y), $MachinePrecision], N[(1.5 * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -880000000000:\\
\;\;\;\;-0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;1.5 \cdot x\\
\end{array}
\end{array}
if y < -8.8e11Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
metadata-evalN/A
*-lft-identityN/A
*-lft-identityN/A
metadata-evalN/A
cancel-sign-subN/A
lower-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64100.0
Applied rewrites100.0%
lift-fma.f64N/A
lift--.f64N/A
lift-fabs.f64N/A
*-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
rem-sqrt-square-revN/A
unpow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
lift--.f6418.6
Applied rewrites18.6%
lift--.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
unpow2N/A
rem-sqrt-square-revN/A
fabs-subN/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower--.f6482.4
Applied rewrites82.4%
Taylor expanded in x around 0
Applied rewrites77.9%
if -8.8e11 < y Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
metadata-evalN/A
*-lft-identityN/A
*-lft-identityN/A
metadata-evalN/A
cancel-sign-subN/A
lower-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6499.9
Applied rewrites99.9%
lift-fma.f64N/A
lift--.f64N/A
lift-fabs.f64N/A
*-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
rem-sqrt-square-revN/A
unpow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
lift--.f6472.2
Applied rewrites72.2%
lift--.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
unpow2N/A
rem-sqrt-square-revN/A
fabs-subN/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower--.f6432.7
Applied rewrites32.7%
Taylor expanded in x around inf
rem-square-sqrtN/A
*-commutativeN/A
rem-square-sqrtN/A
sqrt-unprodN/A
rem-sqrt-square-revN/A
lower-*.f6434.8
Applied rewrites34.8%
(FPCore (x y) :precision binary64 (if (<= y -1.05e-148) (* -0.5 y) x))
double code(double x, double y) {
double tmp;
if (y <= -1.05e-148) {
tmp = -0.5 * y;
} else {
tmp = x;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.05d-148)) then
tmp = (-0.5d0) * y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.05e-148) {
tmp = -0.5 * y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.05e-148: tmp = -0.5 * y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.05e-148) tmp = Float64(-0.5 * y); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.05e-148) tmp = -0.5 * y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.05e-148], N[(-0.5 * y), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.05 \cdot 10^{-148}:\\
\;\;\;\;-0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1.05e-148Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
metadata-evalN/A
*-lft-identityN/A
*-lft-identityN/A
metadata-evalN/A
cancel-sign-subN/A
lower-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64100.0
Applied rewrites100.0%
lift-fma.f64N/A
lift--.f64N/A
lift-fabs.f64N/A
*-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
rem-sqrt-square-revN/A
unpow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
lift--.f6428.9
Applied rewrites28.9%
lift--.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
unpow2N/A
rem-sqrt-square-revN/A
fabs-subN/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower--.f6474.2
Applied rewrites74.2%
Taylor expanded in x around 0
Applied rewrites58.6%
if -1.05e-148 < y Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites12.9%
(FPCore (x y) :precision binary64 x)
double code(double x, double y) {
return x;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x
end function
public static double code(double x, double y) {
return x;
}
def code(x, y): return x
function code(x, y) return x end
function tmp = code(x, y) tmp = x; end
code[x_, y_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites11.7%
herbie shell --seed 2025085
(FPCore (x y)
:name "Graphics.Rendering.Chart.Plot.AreaSpots:renderSpotLegend from Chart-1.5.3"
:precision binary64
(+ x (/ (fabs (- y x)) 2.0)))