
(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
+-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
fabs-subN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
fabs-negN/A
lower-fabs.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f6499.9
Applied rewrites99.9%
(FPCore (x y) :precision binary64 (if (<= x -7.8e-39) (* (- x y) 0.5) (if (<= x 1.42e-11) (fma 0.5 (fabs (- y)) x) (fma 1.5 x (* -0.5 y)))))
double code(double x, double y) {
double tmp;
if (x <= -7.8e-39) {
tmp = (x - y) * 0.5;
} else if (x <= 1.42e-11) {
tmp = fma(0.5, fabs(-y), x);
} else {
tmp = fma(1.5, x, (-0.5 * y));
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= -7.8e-39) tmp = Float64(Float64(x - y) * 0.5); elseif (x <= 1.42e-11) tmp = fma(0.5, abs(Float64(-y)), x); else tmp = fma(1.5, x, Float64(-0.5 * y)); end return tmp end
code[x_, y_] := If[LessEqual[x, -7.8e-39], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 1.42e-11], N[(0.5 * N[Abs[(-y)], $MachinePrecision] + x), $MachinePrecision], N[(1.5 * x + N[(-0.5 * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.8 \cdot 10^{-39}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 1.42 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \left|-y\right|, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1.5, x, -0.5 \cdot y\right)\\
\end{array}
\end{array}
if x < -7.80000000000000059e-39Initial program 99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites88.4%
lift-*.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
*-commutativeN/A
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-*r/N/A
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-rgt-identityN/A
lower-fma.f64N/A
Applied rewrites88.5%
Taylor expanded in x around 0
fabs-subN/A
*-commutativeN/A
lower-*.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lift--.f6453.0
Applied rewrites53.0%
if -7.80000000000000059e-39 < x < 1.42e-11Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
fabs-subN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
fabs-negN/A
lower-fabs.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6458.5
Applied rewrites58.5%
if 1.42e-11 < x 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
fabs-subN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
fabs-negN/A
lower-fabs.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f6499.9
Applied rewrites99.9%
lift--.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
lower-sqrt.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lift--.f6449.2
Applied rewrites49.2%
Taylor expanded in x around inf
sqrt-pow2N/A
metadata-evalN/A
unpow1N/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
unpow1N/A
lift-*.f6430.6
Applied rewrites30.6%
Taylor expanded in x around 0
+-commutativeN/A
lift-neg.f64N/A
sqrt-pow2N/A
metadata-evalN/A
unpow1N/A
lift-neg.f64N/A
distribute-rgt-neg-outN/A
distribute-lft-neg-outN/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f6454.2
Applied rewrites54.2%
(FPCore (x y) :precision binary64 (if (<= x -7.8e-39) (* (- x y) 0.5) (if (<= x 1.42e-11) (fma 0.5 (fabs (- y)) x) (fma (- x y) 0.5 x))))
double code(double x, double y) {
double tmp;
if (x <= -7.8e-39) {
tmp = (x - y) * 0.5;
} else if (x <= 1.42e-11) {
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.8e-39) tmp = Float64(Float64(x - y) * 0.5); elseif (x <= 1.42e-11) 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.8e-39], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 1.42e-11], 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.8 \cdot 10^{-39}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 1.42 \cdot 10^{-11}:\\
\;\;\;\;\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.80000000000000059e-39Initial program 99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites88.4%
lift-*.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
*-commutativeN/A
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-*r/N/A
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-rgt-identityN/A
lower-fma.f64N/A
Applied rewrites88.5%
Taylor expanded in x around 0
fabs-subN/A
*-commutativeN/A
lower-*.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lift--.f6453.0
Applied rewrites53.0%
if -7.80000000000000059e-39 < x < 1.42e-11Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
fabs-subN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
fabs-negN/A
lower-fabs.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6458.5
Applied rewrites58.5%
if 1.42e-11 < x 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
fabs-subN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
fabs-negN/A
lower-fabs.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f6499.9
Applied rewrites99.9%
lift--.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
lower-sqrt.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lift--.f6449.2
Applied rewrites49.2%
lift-fma.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
rem-sqrt-square-revN/A
*-commutativeN/A
lower-fma.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lift--.f6454.1
Applied rewrites54.1%
(FPCore (x y) :precision binary64 (if (<= x -7.8e-39) (* (- x y) 0.5) (if (<= x 230000000.0) (fma 0.5 (fabs (- y)) x) (fma 0.5 x x))))
double code(double x, double y) {
double tmp;
if (x <= -7.8e-39) {
tmp = (x - y) * 0.5;
} else if (x <= 230000000.0) {
tmp = fma(0.5, fabs(-y), x);
} else {
tmp = fma(0.5, x, x);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= -7.8e-39) tmp = Float64(Float64(x - y) * 0.5); elseif (x <= 230000000.0) tmp = fma(0.5, abs(Float64(-y)), x); else tmp = fma(0.5, x, x); end return tmp end
code[x_, y_] := If[LessEqual[x, -7.8e-39], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 230000000.0], N[(0.5 * N[Abs[(-y)], $MachinePrecision] + x), $MachinePrecision], N[(0.5 * x + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.8 \cdot 10^{-39}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 230000000:\\
\;\;\;\;\mathsf{fma}\left(0.5, \left|-y\right|, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5, x, x\right)\\
\end{array}
\end{array}
if x < -7.80000000000000059e-39Initial program 99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites88.4%
lift-*.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
*-commutativeN/A
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-*r/N/A
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-rgt-identityN/A
lower-fma.f64N/A
Applied rewrites88.5%
Taylor expanded in x around 0
fabs-subN/A
*-commutativeN/A
lower-*.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lift--.f6453.0
Applied rewrites53.0%
if -7.80000000000000059e-39 < x < 2.3e8Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
fabs-subN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
fabs-negN/A
lower-fabs.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6458.5
Applied rewrites58.5%
if 2.3e8 < x 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
fabs-subN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
fabs-negN/A
lower-fabs.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f6499.9
Applied rewrites99.9%
lift--.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
lower-sqrt.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lift--.f6449.2
Applied rewrites49.2%
Taylor expanded in x around inf
sqrt-unprodN/A
rem-sqrt-square-revN/A
sqrt-pow2N/A
metadata-evalN/A
unpow1N/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
unpow130.6
Applied rewrites30.6%
(FPCore (x y) :precision binary64 (if (<= x -2.7e-39) (* (- x y) 0.5) (if (<= x 230000000.0) (* 0.5 (fabs (- x y))) (fma 0.5 x x))))
double code(double x, double y) {
double tmp;
if (x <= -2.7e-39) {
tmp = (x - y) * 0.5;
} else if (x <= 230000000.0) {
tmp = 0.5 * fabs((x - y));
} else {
tmp = fma(0.5, x, x);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= -2.7e-39) tmp = Float64(Float64(x - y) * 0.5); elseif (x <= 230000000.0) tmp = Float64(0.5 * abs(Float64(x - y))); else tmp = fma(0.5, x, x); end return tmp end
code[x_, y_] := If[LessEqual[x, -2.7e-39], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 230000000.0], N[(0.5 * N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * x + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{-39}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 230000000:\\
\;\;\;\;0.5 \cdot \left|x - y\right|\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5, x, x\right)\\
\end{array}
\end{array}
if x < -2.7000000000000001e-39Initial program 99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites88.4%
lift-*.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
*-commutativeN/A
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-*r/N/A
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-rgt-identityN/A
lower-fma.f64N/A
Applied rewrites88.5%
Taylor expanded in x around 0
fabs-subN/A
*-commutativeN/A
lower-*.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lift--.f6453.0
Applied rewrites53.0%
if -2.7000000000000001e-39 < x < 2.3e8Initial program 99.9%
Taylor expanded in x around 0
lower-*.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
fabs-subN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
fabs-negN/A
lower-fabs.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f6453.5
Applied rewrites53.5%
if 2.3e8 < x 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
fabs-subN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
fabs-negN/A
lower-fabs.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f6499.9
Applied rewrites99.9%
lift--.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
lower-sqrt.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lift--.f6449.2
Applied rewrites49.2%
Taylor expanded in x around inf
sqrt-unprodN/A
rem-sqrt-square-revN/A
sqrt-pow2N/A
metadata-evalN/A
unpow1N/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
unpow130.6
Applied rewrites30.6%
(FPCore (x y) :precision binary64 (if (<= x -2.7e-39) (* (- x y) 0.5) (if (<= x 135000000.0) (* 0.5 (fabs (- y))) (fma 0.5 x x))))
double code(double x, double y) {
double tmp;
if (x <= -2.7e-39) {
tmp = (x - y) * 0.5;
} else if (x <= 135000000.0) {
tmp = 0.5 * fabs(-y);
} else {
tmp = fma(0.5, x, x);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= -2.7e-39) tmp = Float64(Float64(x - y) * 0.5); elseif (x <= 135000000.0) tmp = Float64(0.5 * abs(Float64(-y))); else tmp = fma(0.5, x, x); end return tmp end
code[x_, y_] := If[LessEqual[x, -2.7e-39], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 135000000.0], N[(0.5 * N[Abs[(-y)], $MachinePrecision]), $MachinePrecision], N[(0.5 * x + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{-39}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 135000000:\\
\;\;\;\;0.5 \cdot \left|-y\right|\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5, x, x\right)\\
\end{array}
\end{array}
if x < -2.7000000000000001e-39Initial program 99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites88.4%
lift-*.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
*-commutativeN/A
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-*r/N/A
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-rgt-identityN/A
lower-fma.f64N/A
Applied rewrites88.5%
Taylor expanded in x around 0
fabs-subN/A
*-commutativeN/A
lower-*.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lift--.f6453.0
Applied rewrites53.0%
if -2.7000000000000001e-39 < x < 1.35e8Initial program 99.9%
Taylor expanded in x around 0
lower-*.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
fabs-subN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
fabs-negN/A
lower-fabs.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f6453.5
Applied rewrites53.5%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6450.5
Applied rewrites50.5%
if 1.35e8 < x 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
fabs-subN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
fabs-negN/A
lower-fabs.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f6499.9
Applied rewrites99.9%
lift--.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
lower-sqrt.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lift--.f6449.2
Applied rewrites49.2%
Taylor expanded in x around inf
sqrt-unprodN/A
rem-sqrt-square-revN/A
sqrt-pow2N/A
metadata-evalN/A
unpow1N/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
unpow130.6
Applied rewrites30.6%
(FPCore (x y) :precision binary64 (if (<= (+ x (/ (fabs (- y x)) 2.0)) -5e-252) (* 0.5 x) (* 0.5 (fabs (- y)))))
double code(double x, double y) {
double tmp;
if ((x + (fabs((y - x)) / 2.0)) <= -5e-252) {
tmp = 0.5 * x;
} else {
tmp = 0.5 * fabs(-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 ((x + (abs((y - x)) / 2.0d0)) <= (-5d-252)) then
tmp = 0.5d0 * x
else
tmp = 0.5d0 * abs(-y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x + (Math.abs((y - x)) / 2.0)) <= -5e-252) {
tmp = 0.5 * x;
} else {
tmp = 0.5 * Math.abs(-y);
}
return tmp;
}
def code(x, y): tmp = 0 if (x + (math.fabs((y - x)) / 2.0)) <= -5e-252: tmp = 0.5 * x else: tmp = 0.5 * math.fabs(-y) return tmp
function code(x, y) tmp = 0.0 if (Float64(x + Float64(abs(Float64(y - x)) / 2.0)) <= -5e-252) tmp = Float64(0.5 * x); else tmp = Float64(0.5 * abs(Float64(-y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x + (abs((y - x)) / 2.0)) <= -5e-252) tmp = 0.5 * x; else tmp = 0.5 * abs(-y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(x + N[(N[Abs[N[(y - x), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], -5e-252], N[(0.5 * x), $MachinePrecision], N[(0.5 * N[Abs[(-y)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + \frac{\left|y - x\right|}{2} \leq -5 \cdot 10^{-252}:\\
\;\;\;\;0.5 \cdot x\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left|-y\right|\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (fabs.f64 (-.f64 y x)) #s(literal 2 binary64))) < -5.00000000000000008e-252Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
fabs-subN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
fabs-negN/A
lower-fabs.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f6499.9
Applied rewrites99.9%
lift--.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
lower-sqrt.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lift--.f6449.2
Applied rewrites49.2%
Taylor expanded in x around inf
sqrt-pow2N/A
metadata-evalN/A
unpow1N/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
unpow1N/A
lift-*.f6430.6
Applied rewrites30.6%
if -5.00000000000000008e-252 < (+.f64 x (/.f64 (fabs.f64 (-.f64 y x)) #s(literal 2 binary64))) Initial program 99.9%
Taylor expanded in x around 0
lower-*.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
fabs-subN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
fabs-negN/A
lower-fabs.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f6453.5
Applied rewrites53.5%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6450.5
Applied rewrites50.5%
(FPCore (x y) :precision binary64 (if (<= x -1.8e-49) (* 0.5 x) (if (<= x 5e-90) (* y -0.5) (fma 0.5 x x))))
double code(double x, double y) {
double tmp;
if (x <= -1.8e-49) {
tmp = 0.5 * x;
} else if (x <= 5e-90) {
tmp = y * -0.5;
} else {
tmp = fma(0.5, x, x);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= -1.8e-49) tmp = Float64(0.5 * x); elseif (x <= 5e-90) tmp = Float64(y * -0.5); else tmp = fma(0.5, x, x); end return tmp end
code[x_, y_] := If[LessEqual[x, -1.8e-49], N[(0.5 * x), $MachinePrecision], If[LessEqual[x, 5e-90], N[(y * -0.5), $MachinePrecision], N[(0.5 * x + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.8 \cdot 10^{-49}:\\
\;\;\;\;0.5 \cdot x\\
\mathbf{elif}\;x \leq 5 \cdot 10^{-90}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5, x, x\right)\\
\end{array}
\end{array}
if x < -1.79999999999999985e-49Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
fabs-subN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
fabs-negN/A
lower-fabs.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f6499.9
Applied rewrites99.9%
lift--.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
lower-sqrt.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lift--.f6449.2
Applied rewrites49.2%
Taylor expanded in x around inf
sqrt-pow2N/A
metadata-evalN/A
unpow1N/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
unpow1N/A
lift-*.f6430.6
Applied rewrites30.6%
if -1.79999999999999985e-49 < x < 5.00000000000000019e-90Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
fabs-subN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
fabs-negN/A
lower-fabs.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f6499.9
Applied rewrites99.9%
lift--.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
lower-sqrt.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lift--.f6449.2
Applied rewrites49.2%
Taylor expanded in x around 0
*-commutativeN/A
lift-neg.f64N/A
sqrt-pow2N/A
metadata-evalN/A
unpow1N/A
lower-*.f6425.8
Applied rewrites25.8%
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
lower-*.f6425.8
Applied rewrites25.8%
if 5.00000000000000019e-90 < x 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
fabs-subN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
fabs-negN/A
lower-fabs.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f6499.9
Applied rewrites99.9%
lift--.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
lower-sqrt.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lift--.f6449.2
Applied rewrites49.2%
Taylor expanded in x around inf
sqrt-unprodN/A
rem-sqrt-square-revN/A
sqrt-pow2N/A
metadata-evalN/A
unpow1N/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
unpow130.6
Applied rewrites30.6%
(FPCore (x y) :precision binary64 (if (<= (+ x (/ (fabs (- y x)) 2.0)) 5e-285) (* 0.5 x) (* y -0.5)))
double code(double x, double y) {
double tmp;
if ((x + (fabs((y - x)) / 2.0)) <= 5e-285) {
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 ((x + (abs((y - x)) / 2.0d0)) <= 5d-285) 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 ((x + (Math.abs((y - x)) / 2.0)) <= 5e-285) {
tmp = 0.5 * x;
} else {
tmp = y * -0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if (x + (math.fabs((y - x)) / 2.0)) <= 5e-285: tmp = 0.5 * x else: tmp = y * -0.5 return tmp
function code(x, y) tmp = 0.0 if (Float64(x + Float64(abs(Float64(y - x)) / 2.0)) <= 5e-285) 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 ((x + (abs((y - x)) / 2.0)) <= 5e-285) tmp = 0.5 * x; else tmp = y * -0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(x + N[(N[Abs[N[(y - x), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], 5e-285], N[(0.5 * x), $MachinePrecision], N[(y * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + \frac{\left|y - x\right|}{2} \leq 5 \cdot 10^{-285}:\\
\;\;\;\;0.5 \cdot x\\
\mathbf{else}:\\
\;\;\;\;y \cdot -0.5\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (fabs.f64 (-.f64 y x)) #s(literal 2 binary64))) < 5.00000000000000018e-285Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
fabs-subN/A
*-lft-identityN/A
metadata-evalN/A
fabs-subN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
fabs-negN/A
lower-fabs.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f6499.9
Applied rewrites99.9%
lift--.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
lower-sqrt.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lift--.f6449.2
Applied rewrites49.2%
Taylor expanded in x around inf
sqrt-pow2N/A
metadata-evalN/A
unpow1N/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
unpow1N/A
lift-*.f6430.6
Applied rewrites30.6%
if 5.00000000000000018e-285 < (+.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
fabs-subN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
fabs-negN/A
lower-fabs.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f6499.9
Applied rewrites99.9%
lift--.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
lower-sqrt.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lift--.f6449.2
Applied rewrites49.2%
Taylor expanded in x around 0
*-commutativeN/A
lift-neg.f64N/A
sqrt-pow2N/A
metadata-evalN/A
unpow1N/A
lower-*.f6425.8
Applied rewrites25.8%
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
lower-*.f6425.8
Applied rewrites25.8%
(FPCore (x y) :precision binary64 (* 0.5 x))
double code(double x, double y) {
return 0.5 * 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 = 0.5d0 * x
end function
public static double code(double x, double y) {
return 0.5 * x;
}
def code(x, y): return 0.5 * x
function code(x, y) return Float64(0.5 * x) end
function tmp = code(x, y) tmp = 0.5 * x; end
code[x_, y_] := N[(0.5 * x), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot x
\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
fabs-subN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
fabs-negN/A
lower-fabs.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f6499.9
Applied rewrites99.9%
lift--.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
lower-sqrt.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lift--.f6449.2
Applied rewrites49.2%
Taylor expanded in x around inf
sqrt-pow2N/A
metadata-evalN/A
unpow1N/A
inv-powN/A
pow-prod-upN/A
metadata-evalN/A
unpow1N/A
lift-*.f6430.6
Applied rewrites30.6%
herbie shell --seed 2025139
(FPCore (x y)
:name "Graphics.Rendering.Chart.Plot.AreaSpots:renderSpotLegend from Chart-1.5.3"
:precision binary64
(+ x (/ (fabs (- y x)) 2.0)))