
(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 9 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
+-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%
(FPCore (x y) :precision binary64 (if (<= x -7.5e-85) (* (- x y) 0.5) (if (<= x 5.8e-108) (fma 0.5 (fabs (- y)) x) (fma (- x y) 0.5 x))))
double code(double x, double y) {
double tmp;
if (x <= -7.5e-85) {
tmp = (x - y) * 0.5;
} else if (x <= 5.8e-108) {
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 <= -7.5e-85) tmp = Float64(Float64(x - y) * 0.5); elseif (x <= 5.8e-108) 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, -7.5e-85], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 5.8e-108], 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 -7.5 \cdot 10^{-85}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{-108}:\\
\;\;\;\;\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 < -7.5000000000000003e-85Initial 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%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6498.5
Applied rewrites98.5%
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--.f6483.0
Applied rewrites83.0%
if -7.5000000000000003e-85 < x < 5.8000000000000002e-108Initial 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%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6484.8
Applied rewrites84.8%
if 5.8000000000000002e-108 < 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--.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lift--.f64N/A
lower-sqrt.f64N/A
lift--.f6483.1
Applied rewrites83.1%
lift-*.f64N/A
lift--.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6483.5
Applied rewrites83.5%
(FPCore (x y) :precision binary64 (if (<= x -7.5e-85) (* (- x y) 0.5) (if (<= x 5.8e-108) (* 0.5 (fabs (- x y))) (fma (- x y) 0.5 x))))
double code(double x, double y) {
double tmp;
if (x <= -7.5e-85) {
tmp = (x - y) * 0.5;
} else if (x <= 5.8e-108) {
tmp = 0.5 * fabs((x - y));
} else {
tmp = fma((x - y), 0.5, x);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= -7.5e-85) tmp = Float64(Float64(x - y) * 0.5); elseif (x <= 5.8e-108) tmp = Float64(0.5 * abs(Float64(x - y))); else tmp = fma(Float64(x - y), 0.5, x); end return tmp end
code[x_, y_] := If[LessEqual[x, -7.5e-85], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 5.8e-108], N[(0.5 * N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] * 0.5 + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.5 \cdot 10^{-85}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{-108}:\\
\;\;\;\;0.5 \cdot \left|x - y\right|\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x - y, 0.5, x\right)\\
\end{array}
\end{array}
if x < -7.5000000000000003e-85Initial 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%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6498.5
Applied rewrites98.5%
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--.f6483.0
Applied rewrites83.0%
if -7.5000000000000003e-85 < x < 5.8000000000000002e-108Initial 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--.f6483.1
Applied rewrites83.1%
if 5.8000000000000002e-108 < 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--.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lift--.f64N/A
lower-sqrt.f64N/A
lift--.f6483.1
Applied rewrites83.1%
lift-*.f64N/A
lift--.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6483.5
Applied rewrites83.5%
(FPCore (x y) :precision binary64 (if (<= (+ x (/ (fabs (- y x)) 2.0)) -2e-238) (* (- x y) 0.5) (fma (- x y) 0.5 x)))
double code(double x, double y) {
double tmp;
if ((x + (fabs((y - x)) / 2.0)) <= -2e-238) {
tmp = (x - y) * 0.5;
} else {
tmp = fma((x - y), 0.5, x);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (Float64(x + Float64(abs(Float64(y - x)) / 2.0)) <= -2e-238) tmp = Float64(Float64(x - y) * 0.5); else tmp = fma(Float64(x - y), 0.5, x); end return tmp end
code[x_, y_] := If[LessEqual[N[(x + N[(N[Abs[N[(y - x), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], -2e-238], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(x - y), $MachinePrecision] * 0.5 + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + \frac{\left|y - x\right|}{2} \leq -2 \cdot 10^{-238}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x - y, 0.5, x\right)\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (fabs.f64 (-.f64 y x)) #s(literal 2 binary64))) < -2e-238Initial 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%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f64100.0
Applied rewrites100.0%
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--.f6497.7
Applied rewrites97.7%
if -2e-238 < (+.f64 x (/.f64 (fabs.f64 (-.f64 y x)) #s(literal 2 binary64))) 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--.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lift--.f64N/A
lower-sqrt.f64N/A
lift--.f6465.9
Applied rewrites65.9%
lift-*.f64N/A
lift--.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6466.7
Applied rewrites66.7%
(FPCore (x y) :precision binary64 (if (<= y -8.2e-192) (* (- x y) 0.5) (fma 0.5 (fabs x) x)))
double code(double x, double y) {
double tmp;
if (y <= -8.2e-192) {
tmp = (x - y) * 0.5;
} else {
tmp = fma(0.5, fabs(x), x);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (y <= -8.2e-192) tmp = Float64(Float64(x - y) * 0.5); else tmp = fma(0.5, abs(x), x); end return tmp end
code[x_, y_] := If[LessEqual[y, -8.2e-192], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], N[(0.5 * N[Abs[x], $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.2 \cdot 10^{-192}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \left|x\right|, x\right)\\
\end{array}
\end{array}
if y < -8.19999999999999947e-192Initial 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
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6486.6
Applied rewrites86.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--.f6481.3
Applied rewrites81.3%
if -8.19999999999999947e-192 < 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%
Taylor expanded in x around inf
Applied rewrites57.1%
(FPCore (x y) :precision binary64 (if (<= x 7.2e-113) (* (- x y) 0.5) (* 1.5 x)))
double code(double x, double y) {
double tmp;
if (x <= 7.2e-113) {
tmp = (x - y) * 0.5;
} 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 <= 7.2d-113) then
tmp = (x - y) * 0.5d0
else
tmp = 1.5d0 * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 7.2e-113) {
tmp = (x - y) * 0.5;
} else {
tmp = 1.5 * x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 7.2e-113: tmp = (x - y) * 0.5 else: tmp = 1.5 * x return tmp
function code(x, y) tmp = 0.0 if (x <= 7.2e-113) tmp = Float64(Float64(x - y) * 0.5); else tmp = Float64(1.5 * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 7.2e-113) tmp = (x - y) * 0.5; else tmp = 1.5 * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 7.2e-113], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], N[(1.5 * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 7.2 \cdot 10^{-113}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;1.5 \cdot x\\
\end{array}
\end{array}
if x < 7.1999999999999995e-113Initial 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%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6483.8
Applied rewrites83.8%
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--.f6466.8
Applied rewrites66.8%
if 7.1999999999999995e-113 < 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--.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lift--.f64N/A
lower-sqrt.f64N/A
lift--.f6482.9
Applied rewrites82.9%
Taylor expanded in x around inf
lower-*.f6466.6
Applied rewrites66.6%
(FPCore (x y) :precision binary64 (if (<= y -2.2e-155) (* -0.5 y) (* 1.5 x)))
double code(double x, double y) {
double tmp;
if (y <= -2.2e-155) {
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.2d-155)) 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.2e-155) {
tmp = -0.5 * y;
} else {
tmp = 1.5 * x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.2e-155: tmp = -0.5 * y else: tmp = 1.5 * x return tmp
function code(x, y) tmp = 0.0 if (y <= -2.2e-155) 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.2e-155) tmp = -0.5 * y; else tmp = 1.5 * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.2e-155], N[(-0.5 * y), $MachinePrecision], N[(1.5 * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.2 \cdot 10^{-155}:\\
\;\;\;\;-0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;1.5 \cdot x\\
\end{array}
\end{array}
if y < -2.1999999999999999e-155Initial 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--.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lift--.f64N/A
lower-sqrt.f64N/A
lift--.f6481.1
Applied rewrites81.1%
Taylor expanded in x around 0
lower-*.f6462.3
Applied rewrites62.3%
if -2.1999999999999999e-155 < 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--.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lift--.f64N/A
lower-sqrt.f64N/A
lift--.f6430.2
Applied rewrites30.2%
Taylor expanded in x around inf
lower-*.f6434.1
Applied rewrites34.1%
(FPCore (x y) :precision binary64 (if (<= y -4.75e-194) (* -0.5 y) x))
double code(double x, double y) {
double tmp;
if (y <= -4.75e-194) {
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.75d-194)) 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.75e-194) {
tmp = -0.5 * y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -4.75e-194: tmp = -0.5 * y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -4.75e-194) tmp = Float64(-0.5 * y); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -4.75e-194) tmp = -0.5 * y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -4.75e-194], N[(-0.5 * y), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.75 \cdot 10^{-194}:\\
\;\;\;\;-0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -4.75000000000000005e-194Initial 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--.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lift--.f64N/A
lower-sqrt.f64N/A
lift--.f6479.6
Applied rewrites79.6%
Taylor expanded in x around 0
lower-*.f6459.5
Applied rewrites59.5%
if -4.75000000000000005e-194 < y Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites12.5%
(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.4%
herbie shell --seed 2025101
(FPCore (x y)
:name "Graphics.Rendering.Chart.Plot.AreaSpots:renderSpotLegend from Chart-1.5.3"
:precision binary64
(+ x (/ (fabs (- y x)) 2.0)))