
(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]
x + \frac{\left|y - x\right|}{2}
Herbie found 7 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]
x + \frac{\left|y - x\right|}{2}
(FPCore (x y) :precision binary64 (+ (* (+ (fabs (- x y)) x) 0.5) (* 0.5 x)))
double code(double x, double y) {
return ((fabs((x - y)) + x) * 0.5) + (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 = ((abs((x - y)) + x) * 0.5d0) + (0.5d0 * x)
end function
public static double code(double x, double y) {
return ((Math.abs((x - y)) + x) * 0.5) + (0.5 * x);
}
def code(x, y): return ((math.fabs((x - y)) + x) * 0.5) + (0.5 * x)
function code(x, y) return Float64(Float64(Float64(abs(Float64(x - y)) + x) * 0.5) + Float64(0.5 * x)) end
function tmp = code(x, y) tmp = ((abs((x - y)) + x) * 0.5) + (0.5 * x); end
code[x_, y_] := N[(N[(N[(N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision] + x), $MachinePrecision] * 0.5), $MachinePrecision] + N[(0.5 * x), $MachinePrecision]), $MachinePrecision]
\left(\left|x - y\right| + x\right) \cdot 0.5 + 0.5 \cdot x
Initial program 99.9%
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
mult-flipN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
count-2-revN/A
associate-+r+N/A
distribute-rgt-inN/A
mult-flipN/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
metadata-evalN/A
*-lft-identityN/A
metadata-evalN/A
times-fracN/A
Applied rewrites99.9%
(FPCore (x y) :precision binary64 (- x (* -0.5 (fabs (- x y)))))
double code(double x, double y) {
return x - (-0.5 * fabs((x - y)));
}
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 - ((-0.5d0) * abs((x - y)))
end function
public static double code(double x, double y) {
return x - (-0.5 * Math.abs((x - y)));
}
def code(x, y): return x - (-0.5 * math.fabs((x - y)))
function code(x, y) return Float64(x - Float64(-0.5 * abs(Float64(x - y)))) end
function tmp = code(x, y) tmp = x - (-0.5 * abs((x - y))); end
code[x_, y_] := N[(x - N[(-0.5 * N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x - -0.5 \cdot \left|x - y\right|
Initial program 99.9%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
mult-flip-revN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
metadata-eval99.9%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f6499.9%
Applied rewrites99.9%
(FPCore (x y) :precision binary64 (if (<= y 3.9e-198) (- x (* (- y x) 0.5)) (* 0.5 (fabs (- x y)))))
double code(double x, double y) {
double tmp;
if (y <= 3.9e-198) {
tmp = x - ((y - x) * 0.5);
} else {
tmp = 0.5 * fabs((x - y));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 3.9d-198) then
tmp = x - ((y - x) * 0.5d0)
else
tmp = 0.5d0 * abs((x - y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 3.9e-198) {
tmp = x - ((y - x) * 0.5);
} else {
tmp = 0.5 * Math.abs((x - y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 3.9e-198: tmp = x - ((y - x) * 0.5) else: tmp = 0.5 * math.fabs((x - y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 3.9e-198) tmp = Float64(x - Float64(Float64(y - x) * 0.5)); else tmp = Float64(0.5 * abs(Float64(x - y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 3.9e-198) tmp = x - ((y - x) * 0.5); else tmp = 0.5 * abs((x - y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 3.9e-198], N[(x - N[(N[(y - x), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;y \leq 3.9 \cdot 10^{-198}:\\
\;\;\;\;x - \left(y - x\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left|x - y\right|\\
\end{array}
if y < 3.8999999999999999e-198Initial program 99.9%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
mult-flip-revN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
metadata-eval99.9%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f6499.9%
Applied rewrites99.9%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6453.9%
Applied rewrites53.9%
if 3.8999999999999999e-198 < y Initial program 99.9%
lift-+.f64N/A
add-flipN/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
mult-flip-revN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
metadata-eval87.8%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f6487.8%
Applied rewrites87.8%
Taylor expanded in x around 0
lower-*.f64N/A
lower-fabs.f64N/A
lower--.f6453.9%
Applied rewrites53.9%
(FPCore (x y) :precision binary64 (if (<= y -1.45e-159) (- x (* y 0.5)) (if (<= y 3.9e-198) (* 1.5 x) (* 0.5 (fabs (- x y))))))
double code(double x, double y) {
double tmp;
if (y <= -1.45e-159) {
tmp = x - (y * 0.5);
} else if (y <= 3.9e-198) {
tmp = 1.5 * x;
} else {
tmp = 0.5 * fabs((x - y));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.45d-159)) then
tmp = x - (y * 0.5d0)
else if (y <= 3.9d-198) then
tmp = 1.5d0 * x
else
tmp = 0.5d0 * abs((x - y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.45e-159) {
tmp = x - (y * 0.5);
} else if (y <= 3.9e-198) {
tmp = 1.5 * x;
} else {
tmp = 0.5 * Math.abs((x - y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.45e-159: tmp = x - (y * 0.5) elif y <= 3.9e-198: tmp = 1.5 * x else: tmp = 0.5 * math.fabs((x - y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.45e-159) tmp = Float64(x - Float64(y * 0.5)); elseif (y <= 3.9e-198) tmp = Float64(1.5 * x); else tmp = Float64(0.5 * abs(Float64(x - y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.45e-159) tmp = x - (y * 0.5); elseif (y <= 3.9e-198) tmp = 1.5 * x; else tmp = 0.5 * abs((x - y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.45e-159], N[(x - N[(y * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.9e-198], N[(1.5 * x), $MachinePrecision], N[(0.5 * N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;y \leq -1.45 \cdot 10^{-159}:\\
\;\;\;\;x - y \cdot 0.5\\
\mathbf{elif}\;y \leq 3.9 \cdot 10^{-198}:\\
\;\;\;\;1.5 \cdot x\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left|x - y\right|\\
\end{array}
if y < -1.45e-159Initial program 99.9%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
mult-flip-revN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
metadata-eval99.9%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f6499.9%
Applied rewrites99.9%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6453.9%
Applied rewrites53.9%
Taylor expanded in x around 0
Applied rewrites34.3%
if -1.45e-159 < y < 3.8999999999999999e-198Initial program 99.9%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
mult-flip-revN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
metadata-eval99.9%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f6499.9%
Applied rewrites99.9%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6453.9%
Applied rewrites53.9%
Taylor expanded in x around inf
lower-*.f6430.0%
Applied rewrites30.0%
if 3.8999999999999999e-198 < y Initial program 99.9%
lift-+.f64N/A
add-flipN/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
mult-flip-revN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
metadata-eval87.8%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f6487.8%
Applied rewrites87.8%
Taylor expanded in x around 0
lower-*.f64N/A
lower-fabs.f64N/A
lower--.f6453.9%
Applied rewrites53.9%
(FPCore (x y) :precision binary64 (if (<= y -1.45e-159) (- x (* y 0.5)) (* 1.5 x)))
double code(double x, double y) {
double tmp;
if (y <= -1.45e-159) {
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 (y <= (-1.45d-159)) 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 (y <= -1.45e-159) {
tmp = x - (y * 0.5);
} else {
tmp = 1.5 * x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.45e-159: tmp = x - (y * 0.5) else: tmp = 1.5 * x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.45e-159) tmp = Float64(x - Float64(y * 0.5)); else tmp = Float64(1.5 * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.45e-159) tmp = x - (y * 0.5); else tmp = 1.5 * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.45e-159], N[(x - N[(y * 0.5), $MachinePrecision]), $MachinePrecision], N[(1.5 * x), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;y \leq -1.45 \cdot 10^{-159}:\\
\;\;\;\;x - y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;1.5 \cdot x\\
\end{array}
if y < -1.45e-159Initial program 99.9%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
mult-flip-revN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
metadata-eval99.9%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f6499.9%
Applied rewrites99.9%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6453.9%
Applied rewrites53.9%
Taylor expanded in x around 0
Applied rewrites34.3%
if -1.45e-159 < y Initial program 99.9%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
mult-flip-revN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
metadata-eval99.9%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f6499.9%
Applied rewrites99.9%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6453.9%
Applied rewrites53.9%
Taylor expanded in x around inf
lower-*.f6430.0%
Applied rewrites30.0%
(FPCore (x y) :precision binary64 (if (<= y -1.3e-136) (* -0.5 y) (* 1.5 x)))
double code(double x, double y) {
double tmp;
if (y <= -1.3e-136) {
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 <= (-1.3d-136)) 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 <= -1.3e-136) {
tmp = -0.5 * y;
} else {
tmp = 1.5 * x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.3e-136: tmp = -0.5 * y else: tmp = 1.5 * x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.3e-136) 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 <= -1.3e-136) tmp = -0.5 * y; else tmp = 1.5 * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.3e-136], N[(-0.5 * y), $MachinePrecision], N[(1.5 * x), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;y \leq -1.3 \cdot 10^{-136}:\\
\;\;\;\;-0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;1.5 \cdot x\\
\end{array}
if y < -1.3e-136Initial program 99.9%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
mult-flip-revN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
metadata-eval99.9%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f6499.9%
Applied rewrites99.9%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6453.9%
Applied rewrites53.9%
Taylor expanded in x around 0
lower-*.f6426.4%
Applied rewrites26.4%
if -1.3e-136 < y Initial program 99.9%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
mult-flip-revN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
metadata-eval99.9%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f6499.9%
Applied rewrites99.9%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6453.9%
Applied rewrites53.9%
Taylor expanded in x around inf
lower-*.f6430.0%
Applied rewrites30.0%
(FPCore (x y) :precision binary64 (* -0.5 y))
double code(double x, double y) {
return -0.5 * y;
}
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) * y
end function
public static double code(double x, double y) {
return -0.5 * y;
}
def code(x, y): return -0.5 * y
function code(x, y) return Float64(-0.5 * y) end
function tmp = code(x, y) tmp = -0.5 * y; end
code[x_, y_] := N[(-0.5 * y), $MachinePrecision]
-0.5 \cdot y
Initial program 99.9%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
mult-flip-revN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
metadata-eval99.9%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f6499.9%
Applied rewrites99.9%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6453.9%
Applied rewrites53.9%
Taylor expanded in x around 0
lower-*.f6426.4%
Applied rewrites26.4%
herbie shell --seed 2025258
(FPCore (x y)
:name "Graphics.Rendering.Chart.Plot.AreaSpots:renderSpotLegend from Chart-1.5.3"
:precision binary64
(+ x (/ (fabs (- y x)) 2.0)))