(FPCore (x y) :precision binary64 (/ (fabs (- x y)) (fabs y)))
double code(double x, double y) { return fabs((x - y)) / fabs(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 = abs((x - y)) / abs(y) end function
public static double code(double x, double y) { return Math.abs((x - y)) / Math.abs(y); }
def code(x, y): return math.fabs((x - y)) / math.fabs(y)
function code(x, y) return Float64(abs(Float64(x - y)) / abs(y)) end
function tmp = code(x, y) tmp = abs((x - y)) / abs(y); end
code[x_, y_] := N[(N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \frac{\left|x - y\right|}{\left|y\right|} \end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (x y) :precision binary64 (/ (fabs (- x y)) (fabs y)))
double code(double x, double y) { return fabs((x - y)) / fabs(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 = abs((x - y)) / abs(y) end function
public static double code(double x, double y) { return Math.abs((x - y)) / Math.abs(y); }
def code(x, y): return math.fabs((x - y)) / math.fabs(y)
function code(x, y) return Float64(abs(Float64(x - y)) / abs(y)) end
function tmp = code(x, y) tmp = abs((x - y)) / abs(y); end
code[x_, y_] := N[(N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \frac{\left|x - y\right|}{\left|y\right|} \end{array}
(FPCore (x y) :precision binary64 (fabs (/ (- y x) y)))
double code(double x, double y) { return fabs(((y - 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 = abs(((y - x) / y)) end function
public static double code(double x, double y) { return Math.abs(((y - x) / y)); }
def code(x, y): return math.fabs(((y - x) / y))
function code(x, y) return abs(Float64(Float64(y - x) / y)) end
function tmp = code(x, y) tmp = abs(((y - x) / y)); end
code[x_, y_] := N[Abs[N[(N[(y - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l} \\ \left|\frac{y - x}{y}\right| \end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (let* ((t_0 (fabs (/ (- y x) y)))) (if (<= t_0 2.0) 1.0 (if (<= t_0 1e+50) (/ x y) (/ (- x) y)))))
double code(double x, double y) { double t_0 = fabs(((y - x) / y)); double tmp; if (t_0 <= 2.0) { tmp = 1.0; } else if (t_0 <= 1e+50) { tmp = x / y; } else { tmp = -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) :: t_0 real(8) :: tmp t_0 = abs(((y - x) / y)) if (t_0 <= 2.0d0) then tmp = 1.0d0 else if (t_0 <= 1d+50) then tmp = x / y else tmp = -x / y end if code = tmp end function
public static double code(double x, double y) { double t_0 = Math.abs(((y - x) / y)); double tmp; if (t_0 <= 2.0) { tmp = 1.0; } else if (t_0 <= 1e+50) { tmp = x / y; } else { tmp = -x / y; } return tmp; }
def code(x, y): t_0 = math.fabs(((y - x) / y)) tmp = 0 if t_0 <= 2.0: tmp = 1.0 elif t_0 <= 1e+50: tmp = x / y else: tmp = -x / y return tmp
function code(x, y) t_0 = abs(Float64(Float64(y - x) / y)) tmp = 0.0 if (t_0 <= 2.0) tmp = 1.0; elseif (t_0 <= 1e+50) tmp = Float64(x / y); else tmp = Float64(Float64(-x) / y); end return tmp end
function tmp_2 = code(x, y) t_0 = abs(((y - x) / y)); tmp = 0.0; if (t_0 <= 2.0) tmp = 1.0; elseif (t_0 <= 1e+50) tmp = x / y; else tmp = -x / y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[Abs[N[(N[(y - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 2.0], 1.0, If[LessEqual[t$95$0, 1e+50], N[(x / y), $MachinePrecision], N[((-x) / y), $MachinePrecision]]]]
\begin{array}{l} \\ \begin{array}{l} t_0 := \left|\frac{y - x}{y}\right|\\ \mathbf{if}\;t\_0 \leq 2:\\ \;\;\;\;1\\ \mathbf{elif}\;t\_0 \leq 10^{+50}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{-x}{y}\\ \end{array} \end{array}
if (/.f64 (fabs.f64 (-.f64 x y)) (fabs.f64 y)) < 2
Initial program 99.9%
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites96.9%
if 2 < (/.f64 (fabs.f64 (-.f64 x y)) (fabs.f64 y)) < 1.0000000000000001e50
Initial program 99.8%
Applied rewrites70.3%
Taylor expanded in x around inf
lift-/.f64
64.7
Applied rewrites64.7%
if 1.0000000000000001e50 < (/.f64 (fabs.f64 (-.f64 x y)) (fabs.f64 y))
Initial program 100.0%
Applied rewrites57.7%
Taylor expanded in x around inf
mul-1-neg
N/A
distribute-neg-frac
N/A
lower-/.f64
N/A
lower-neg.f64
57.7
Applied rewrites57.7%
Final simplification77.1%
(FPCore (x y) :precision binary64 (if (<= (fabs (/ (- y x) y)) 2.0) 1.0 (/ x y)))
double code(double x, double y) { double tmp; if (fabs(((y - x) / y)) <= 2.0) { tmp = 1.0; } else { tmp = 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 (abs(((y - x) / y)) <= 2.0d0) then tmp = 1.0d0 else tmp = x / y end if code = tmp end function
public static double code(double x, double y) { double tmp; if (Math.abs(((y - x) / y)) <= 2.0) { tmp = 1.0; } else { tmp = x / y; } return tmp; }
def code(x, y): tmp = 0 if math.fabs(((y - x) / y)) <= 2.0: tmp = 1.0 else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (abs(Float64(Float64(y - x) / y)) <= 2.0) tmp = 1.0; else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (abs(((y - x) / y)) <= 2.0) tmp = 1.0; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Abs[N[(N[(y - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], 2.0], 1.0, N[(x / y), $MachinePrecision]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|\frac{y - x}{y}\right| \leq 2:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array}
if (/.f64 (fabs.f64 (-.f64 x y)) (fabs.f64 y)) < 2
Initial program 99.9%
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites96.9%
if 2 < (/.f64 (fabs.f64 (-.f64 x y)) (fabs.f64 y))
Initial program 100.0%
Applied rewrites46.9%
Taylor expanded in x around inf
lift-/.f64
46.0
Applied rewrites46.0%
Final simplification70.5%
(FPCore (x y) :precision binary64 (if (or (<= y 1.05e-289) (not (<= y 2.5e-206))) (- 1.0 (/ x y)) (- (/ x y) 1.0)))
double code(double x, double y) { double tmp; if ((y <= 1.05e-289) || !(y <= 2.5e-206)) { tmp = 1.0 - (x / y); } else { tmp = (x / y) - 1.0; } return tmp; }
module fmin_fmax_functions implicit none private public fmax public fmin interface fmax module procedure fmax88 module procedure fmax44 module procedure fmax84 module procedure fmax48 end interface interface fmin module procedure fmin88 module procedure fmin44 module procedure fmin84 module procedure fmin48 end interface contains real(8) function fmax88(x, y) result (res) real(8), intent (in) :: x real(8), intent (in) :: y res = merge(y, merge(x, max(x, y), y /= y), x /= x) end function real(4) function fmax44(x, y) result (res) real(4), intent (in) :: x real(4), intent (in) :: y res = merge(y, merge(x, max(x, y), y /= y), x /= x) end function real(8) function fmax84(x, y) result(res) real(8), intent (in) :: x real(4), intent (in) :: y res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x) end function real(8) function fmax48(x, y) result(res) real(4), intent (in) :: x real(8), intent (in) :: y res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x) end function real(8) function fmin88(x, y) result (res) real(8), intent (in) :: x real(8), intent (in) :: y res = merge(y, merge(x, min(x, y), y /= y), x /= x) end function real(4) function fmin44(x, y) result (res) real(4), intent (in) :: x real(4), intent (in) :: y res = merge(y, merge(x, min(x, y), y /= y), x /= x) end function real(8) function fmin84(x, y) result(res) real(8), intent (in) :: x real(4), intent (in) :: y res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x) end function real(8) function fmin48(x, y) result(res) real(4), intent (in) :: x real(8), intent (in) :: y res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x) end function end module real(8) function code(x, y) use fmin_fmax_functions real(8), intent (in) :: x real(8), intent (in) :: y real(8) :: tmp if ((y <= 1.05d-289) .or. (.not. (y <= 2.5d-206))) then tmp = 1.0d0 - (x / y) else tmp = (x / y) - 1.0d0 end if code = tmp end function
public static double code(double x, double y) { double tmp; if ((y <= 1.05e-289) || !(y <= 2.5e-206)) { tmp = 1.0 - (x / y); } else { tmp = (x / y) - 1.0; } return tmp; }
def code(x, y): tmp = 0 if (y <= 1.05e-289) or not (y <= 2.5e-206): tmp = 1.0 - (x / y) else: tmp = (x / y) - 1.0 return tmp
function code(x, y) tmp = 0.0 if ((y <= 1.05e-289) || !(y <= 2.5e-206)) tmp = Float64(1.0 - Float64(x / y)); else tmp = Float64(Float64(x / y) - 1.0); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= 1.05e-289) || ~((y <= 2.5e-206))) tmp = 1.0 - (x / y); else tmp = (x / y) - 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, 1.05e-289], N[Not[LessEqual[y, 2.5e-206]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] - 1.0), $MachinePrecision]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 1.05 \cdot 10^{-289} \lor \neg \left(y \leq 2.5 \cdot 10^{-206}\right):\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} - 1\\ \end{array} \end{array}
if y < 1.0499999999999999e-289 or 2.5e-206 < y
Initial program 100.0%
Applied rewrites79.6%
if 1.0499999999999999e-289 < y < 2.5e-206
Initial program 99.9%
Applied rewrites76.5%
Final simplification79.4%
(FPCore (x y) :precision binary64 (if (or (<= y 7.8e-286) (not (<= y 2.5e-206))) (- 1.0 (/ x y)) (/ x y)))
double code(double x, double y) { double tmp; if ((y <= 7.8e-286) || !(y <= 2.5e-206)) { tmp = 1.0 - (x / y); } else { tmp = 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 <= 7.8d-286) .or. (.not. (y <= 2.5d-206))) then tmp = 1.0d0 - (x / y) else tmp = x / y end if code = tmp end function
public static double code(double x, double y) { double tmp; if ((y <= 7.8e-286) || !(y <= 2.5e-206)) { tmp = 1.0 - (x / y); } else { tmp = x / y; } return tmp; }
def code(x, y): tmp = 0 if (y <= 7.8e-286) or not (y <= 2.5e-206): tmp = 1.0 - (x / y) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if ((y <= 7.8e-286) || !(y <= 2.5e-206)) tmp = Float64(1.0 - Float64(x / y)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= 7.8e-286) || ~((y <= 2.5e-206))) tmp = 1.0 - (x / y); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, 7.8e-286], N[Not[LessEqual[y, 2.5e-206]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 7.8 \cdot 10^{-286} \lor \neg \left(y \leq 2.5 \cdot 10^{-206}\right):\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array}
if y < 7.7999999999999999e-286 or 2.5e-206 < y
Initial program 100.0%
Applied rewrites79.6%
if 7.7999999999999999e-286 < y < 2.5e-206
Initial program 99.9%
Applied rewrites76.5%
Taylor expanded in x around inf
lift-/.f64
73.7
Applied rewrites73.7%
Final simplification79.2%
(FPCore (x y) :precision binary64 1.0)
double code(double x, double y) { return 1.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 = 1.0d0 end function
public static double code(double x, double y) { return 1.0; }
def code(x, y): return 1.0
function code(x, y) return 1.0 end
function tmp = code(x, y) tmp = 1.0; end
code[x_, y_] := 1.0
\begin{array}{l} \\ 1 \end{array}
Initial program 100.0%
Applied rewrites75.9%
Taylor expanded in x around 0
Applied rewrites49.1%
herbie shell --seed 2025051
(FPCore (x y)
:name "Numeric.LinearAlgebra.Util:formatSparse from hmatrix-0.16.1.5"
:precision binary64
(/ (fabs (- x y)) (fabs y)))