
(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}
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 (- x y)) x))
double code(double x, double y) {
return fma(0.5, fabs((x - y)), x);
}
function code(x, y) return fma(0.5, abs(Float64(x - y)), x) end
code[x_, y_] := N[(0.5 * N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(0.5, \left|x - y\right|, x\right)
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
(FPCore (x y) :precision binary64 (if (<= x -1e-43) (* (- x y) 0.5) (if (<= x 2e-104) (fma 0.5 (fabs (- y)) x) (fma (- x y) 0.5 x))))
double code(double x, double y) {
double tmp;
if (x <= -1e-43) {
tmp = (x - y) * 0.5;
} else if (x <= 2e-104) {
tmp = fma(0.5, fabs(-y), x);
} else {
tmp = fma((x - y), 0.5, x);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= -1e-43) tmp = Float64(Float64(x - y) * 0.5); elseif (x <= 2e-104) tmp = fma(0.5, abs(Float64(-y)), x); else tmp = fma(Float64(x - y), 0.5, x); end return tmp end
code[x_, y_] := If[LessEqual[x, -1e-43], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 2e-104], N[(0.5 * N[Abs[(-y)], $MachinePrecision] + x), $MachinePrecision], N[(N[(x - y), $MachinePrecision] * 0.5 + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-43}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-104}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \left|-y\right|, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x - y, 0.5, x\right)\\
\end{array}
\end{array}
if x < -1.00000000000000008e-43Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Applied rewrites99.2%
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
Applied rewrites99.2%
Taylor expanded in x around 0
neg-fabsN/A
rem-square-sqrtN/A
fabs-sqrN/A
neg-fabsN/A
rem-square-sqrtN/A
fabs-sqrN/A
rem-square-sqrtN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.6%
if -1.00000000000000008e-43 < x < 1.99999999999999985e-104Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6482.6
Applied rewrites82.6%
if 1.99999999999999985e-104 < x Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites99.8%
Applied rewrites99.7%
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
Applied rewrites99.7%
neg-fabs99.7
rem-square-sqrt99.7
fabs-sqr99.7
lift-fma.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
lift-fma.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
associate-+r+N/A
Applied rewrites81.8%
(FPCore (x y) :precision binary64 (if (<= y -9.5e-185) (* (- x y) 0.5) (if (<= y 1.55e+44) (fma 0.5 (fabs x) x) (fma 0.5 (fabs (- y)) x))))
double code(double x, double y) {
double tmp;
if (y <= -9.5e-185) {
tmp = (x - y) * 0.5;
} else if (y <= 1.55e+44) {
tmp = fma(0.5, fabs(x), x);
} else {
tmp = fma(0.5, fabs(-y), x);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (y <= -9.5e-185) tmp = Float64(Float64(x - y) * 0.5); elseif (y <= 1.55e+44) tmp = fma(0.5, abs(x), x); else tmp = fma(0.5, abs(Float64(-y)), x); end return tmp end
code[x_, y_] := If[LessEqual[y, -9.5e-185], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[y, 1.55e+44], N[(0.5 * N[Abs[x], $MachinePrecision] + x), $MachinePrecision], N[(0.5 * N[Abs[(-y)], $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.5 \cdot 10^{-185}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\
\mathbf{elif}\;y \leq 1.55 \cdot 10^{+44}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \left|x\right|, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \left|-y\right|, x\right)\\
\end{array}
\end{array}
if y < -9.50000000000000042e-185Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Applied rewrites99.7%
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
Applied rewrites99.7%
Taylor expanded in x around 0
neg-fabsN/A
rem-square-sqrtN/A
fabs-sqrN/A
neg-fabsN/A
rem-square-sqrtN/A
fabs-sqrN/A
rem-square-sqrtN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites82.7%
if -9.50000000000000042e-185 < y < 1.54999999999999998e44Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around inf
Applied rewrites76.8%
if 1.54999999999999998e44 < y Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6482.6
Applied rewrites82.6%
(FPCore (x y) :precision binary64 (if (<= y -9.5e-185) (* (- x y) 0.5) (if (<= y 8.2e+44) (fma 0.5 (fabs x) x) (* 0.5 (fabs (- x y))))))
double code(double x, double y) {
double tmp;
if (y <= -9.5e-185) {
tmp = (x - y) * 0.5;
} else if (y <= 8.2e+44) {
tmp = fma(0.5, fabs(x), x);
} else {
tmp = 0.5 * fabs((x - y));
}
return tmp;
}
function code(x, y) tmp = 0.0 if (y <= -9.5e-185) tmp = Float64(Float64(x - y) * 0.5); elseif (y <= 8.2e+44) tmp = fma(0.5, abs(x), x); else tmp = Float64(0.5 * abs(Float64(x - y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -9.5e-185], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[y, 8.2e+44], N[(0.5 * N[Abs[x], $MachinePrecision] + x), $MachinePrecision], N[(0.5 * N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.5 \cdot 10^{-185}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\
\mathbf{elif}\;y \leq 8.2 \cdot 10^{+44}:\\
\;\;\;\;\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 < -9.50000000000000042e-185Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Applied rewrites99.7%
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
Applied rewrites99.7%
Taylor expanded in x around 0
neg-fabsN/A
rem-square-sqrtN/A
fabs-sqrN/A
neg-fabsN/A
rem-square-sqrtN/A
fabs-sqrN/A
rem-square-sqrtN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites82.7%
if -9.50000000000000042e-185 < y < 8.1999999999999993e44Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around inf
Applied rewrites76.8%
if 8.1999999999999993e44 < y Initial program 100.0%
Taylor expanded in x around 0
lower-*.f64N/A
rem-sqrt-square-revN/A
pow1/2N/A
pow2N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
pow2N/A
Applied rewrites80.8%
(FPCore (x y) :precision binary64 (if (<= y -9.5e-185) (* (- x y) 0.5) (if (<= y 8.2e+44) (fma 0.5 (fabs x) x) (* 0.5 (fabs (- y))))))
double code(double x, double y) {
double tmp;
if (y <= -9.5e-185) {
tmp = (x - y) * 0.5;
} else if (y <= 8.2e+44) {
tmp = fma(0.5, fabs(x), x);
} else {
tmp = 0.5 * fabs(-y);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (y <= -9.5e-185) tmp = Float64(Float64(x - y) * 0.5); elseif (y <= 8.2e+44) tmp = fma(0.5, abs(x), x); else tmp = Float64(0.5 * abs(Float64(-y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -9.5e-185], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[y, 8.2e+44], N[(0.5 * N[Abs[x], $MachinePrecision] + x), $MachinePrecision], N[(0.5 * N[Abs[(-y)], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.5 \cdot 10^{-185}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\
\mathbf{elif}\;y \leq 8.2 \cdot 10^{+44}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \left|x\right|, x\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left|-y\right|\\
\end{array}
\end{array}
if y < -9.50000000000000042e-185Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Applied rewrites99.7%
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
Applied rewrites99.7%
Taylor expanded in x around 0
neg-fabsN/A
rem-square-sqrtN/A
fabs-sqrN/A
neg-fabsN/A
rem-square-sqrtN/A
fabs-sqrN/A
rem-square-sqrtN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites82.7%
if -9.50000000000000042e-185 < y < 8.1999999999999993e44Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around inf
Applied rewrites76.8%
if 8.1999999999999993e44 < y Initial program 100.0%
Taylor expanded in x around 0
lower-*.f64N/A
rem-sqrt-square-revN/A
pow1/2N/A
pow2N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
pow2N/A
Applied rewrites80.8%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6479.6
Applied rewrites79.6%
(FPCore (x y) :precision binary64 (if (<= x -1e-43) (* (- x y) 0.5) (if (<= x 5.4e+41) (* 0.5 (fabs (- y))) (* 1.5 x))))
double code(double x, double y) {
double tmp;
if (x <= -1e-43) {
tmp = (x - y) * 0.5;
} else if (x <= 5.4e+41) {
tmp = 0.5 * fabs(-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 <= (-1d-43)) then
tmp = (x - y) * 0.5d0
else if (x <= 5.4d+41) then
tmp = 0.5d0 * abs(-y)
else
tmp = 1.5d0 * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1e-43) {
tmp = (x - y) * 0.5;
} else if (x <= 5.4e+41) {
tmp = 0.5 * Math.abs(-y);
} else {
tmp = 1.5 * x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1e-43: tmp = (x - y) * 0.5 elif x <= 5.4e+41: tmp = 0.5 * math.fabs(-y) else: tmp = 1.5 * x return tmp
function code(x, y) tmp = 0.0 if (x <= -1e-43) tmp = Float64(Float64(x - y) * 0.5); elseif (x <= 5.4e+41) tmp = Float64(0.5 * abs(Float64(-y))); else tmp = Float64(1.5 * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1e-43) tmp = (x - y) * 0.5; elseif (x <= 5.4e+41) tmp = 0.5 * abs(-y); else tmp = 1.5 * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1e-43], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 5.4e+41], N[(0.5 * N[Abs[(-y)], $MachinePrecision]), $MachinePrecision], N[(1.5 * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-43}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 5.4 \cdot 10^{+41}:\\
\;\;\;\;0.5 \cdot \left|-y\right|\\
\mathbf{else}:\\
\;\;\;\;1.5 \cdot x\\
\end{array}
\end{array}
if x < -1.00000000000000008e-43Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Applied rewrites99.2%
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
Applied rewrites99.2%
Taylor expanded in x around 0
neg-fabsN/A
rem-square-sqrtN/A
fabs-sqrN/A
neg-fabsN/A
rem-square-sqrtN/A
fabs-sqrN/A
rem-square-sqrtN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.6%
if -1.00000000000000008e-43 < x < 5.39999999999999999e41Initial program 99.9%
Taylor expanded in x around 0
lower-*.f64N/A
rem-sqrt-square-revN/A
pow1/2N/A
pow2N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
pow2N/A
Applied rewrites76.4%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6474.7
Applied rewrites74.7%
if 5.39999999999999999e41 < x Initial program 99.8%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6477.9
Applied rewrites77.9%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqr-neg-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-neg.f6477.9
Applied rewrites77.9%
Taylor expanded in x around inf
lower-*.f6477.9
Applied rewrites77.9%
(FPCore (x y) :precision binary64 (if (<= x 5.4e+41) (* 0.5 (fabs (- y))) (* 1.5 x)))
double code(double x, double y) {
double tmp;
if (x <= 5.4e+41) {
tmp = 0.5 * fabs(-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 <= 5.4d+41) then
tmp = 0.5d0 * abs(-y)
else
tmp = 1.5d0 * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 5.4e+41) {
tmp = 0.5 * Math.abs(-y);
} else {
tmp = 1.5 * x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 5.4e+41: tmp = 0.5 * math.fabs(-y) else: tmp = 1.5 * x return tmp
function code(x, y) tmp = 0.0 if (x <= 5.4e+41) tmp = Float64(0.5 * abs(Float64(-y))); else tmp = Float64(1.5 * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 5.4e+41) tmp = 0.5 * abs(-y); else tmp = 1.5 * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 5.4e+41], N[(0.5 * N[Abs[(-y)], $MachinePrecision]), $MachinePrecision], N[(1.5 * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.4 \cdot 10^{+41}:\\
\;\;\;\;0.5 \cdot \left|-y\right|\\
\mathbf{else}:\\
\;\;\;\;1.5 \cdot x\\
\end{array}
\end{array}
if x < 5.39999999999999999e41Initial program 100.0%
Taylor expanded in x around 0
lower-*.f64N/A
rem-sqrt-square-revN/A
pow1/2N/A
pow2N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
pow2N/A
Applied rewrites59.1%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6458.2
Applied rewrites58.2%
if 5.39999999999999999e41 < x Initial program 99.8%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6477.9
Applied rewrites77.9%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqr-neg-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-neg.f6477.9
Applied rewrites77.9%
Taylor expanded in x around inf
lower-*.f6477.9
Applied rewrites77.9%
(FPCore (x y) :precision binary64 (if (<= y -2.9e-33) (* -0.5 y) (* 1.5 x)))
double code(double x, double y) {
double tmp;
if (y <= -2.9e-33) {
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 <= (-2.9d-33)) 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 <= -2.9e-33) {
tmp = -0.5 * y;
} else {
tmp = 1.5 * x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.9e-33: tmp = -0.5 * y else: tmp = 1.5 * x return tmp
function code(x, y) tmp = 0.0 if (y <= -2.9e-33) 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 <= -2.9e-33) tmp = -0.5 * y; else tmp = 1.5 * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.9e-33], N[(-0.5 * y), $MachinePrecision], N[(1.5 * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.9 \cdot 10^{-33}:\\
\;\;\;\;-0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;1.5 \cdot x\\
\end{array}
\end{array}
if y < -2.90000000000000003e-33Initial program 100.0%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6428.4
Applied rewrites28.4%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqr-neg-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-neg.f6414.1
Applied rewrites14.1%
Taylor expanded in x around 0
lower-*.f6472.7
Applied rewrites72.7%
if -2.90000000000000003e-33 < y Initial program 99.9%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6458.5
Applied rewrites58.5%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqr-neg-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-neg.f6429.0
Applied rewrites29.0%
Taylor expanded in x around inf
lower-*.f6434.8
Applied rewrites34.8%
(FPCore (x y) :precision binary64 (if (<= y -4.5e-185) (* -0.5 y) x))
double code(double x, double y) {
double tmp;
if (y <= -4.5e-185) {
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 <= (-4.5d-185)) 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 <= -4.5e-185) {
tmp = -0.5 * y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -4.5e-185: tmp = -0.5 * y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -4.5e-185) tmp = Float64(-0.5 * y); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -4.5e-185) tmp = -0.5 * y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -4.5e-185], N[(-0.5 * y), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.5 \cdot 10^{-185}:\\
\;\;\;\;-0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -4.5000000000000001e-185Initial program 99.9%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6440.7
Applied rewrites40.7%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqr-neg-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-neg.f6419.9
Applied rewrites19.9%
Taylor expanded in x around 0
lower-*.f6460.4
Applied rewrites60.4%
if -4.5000000000000001e-185 < y Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites12.4%
(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.3%
herbie shell --seed 2025130
(FPCore (x y)
:name "Graphics.Rendering.Chart.Plot.AreaSpots:renderSpotLegend from Chart-1.5.3"
:precision binary64
(+ x (/ (fabs (- y x)) 2.0)))