
(FPCore (x y z) :precision binary64 (/ (+ x y) (- 1.0 (/ y z))))
double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
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, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + y) / (1.0d0 - (y / z))
end function
public static double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
def code(x, y, z): return (x + y) / (1.0 - (y / z))
function code(x, y, z) return Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))) end
function tmp = code(x, y, z) tmp = (x + y) / (1.0 - (y / z)); end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y}{1 - \frac{y}{z}}
\end{array}
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (+ x y) (- 1.0 (/ y z))))
double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
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, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + y) / (1.0d0 - (y / z))
end function
public static double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
def code(x, y, z): return (x + y) / (1.0 - (y / z))
function code(x, y, z) return Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))) end
function tmp = code(x, y, z) tmp = (x + y) / (1.0 - (y / z)); end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y}{1 - \frac{y}{z}}
\end{array}
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z))) (t_1 (/ (+ x y) t_0)))
(if (<= t_1 -1e-211)
(+ (/ y t_0) (/ x t_0))
(if (<= t_1 0.0) (* (/ (- (- y) x) y) z) t_1))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = (x + y) / t_0;
double tmp;
if (t_1 <= -1e-211) {
tmp = (y / t_0) + (x / t_0);
} else if (t_1 <= 0.0) {
tmp = ((-y - x) / y) * z;
} else {
tmp = t_1;
}
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, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (y / z)
t_1 = (x + y) / t_0
if (t_1 <= (-1d-211)) then
tmp = (y / t_0) + (x / t_0)
else if (t_1 <= 0.0d0) then
tmp = ((-y - x) / y) * z
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = (x + y) / t_0;
double tmp;
if (t_1 <= -1e-211) {
tmp = (y / t_0) + (x / t_0);
} else if (t_1 <= 0.0) {
tmp = ((-y - x) / y) * z;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) t_1 = (x + y) / t_0 tmp = 0 if t_1 <= -1e-211: tmp = (y / t_0) + (x / t_0) elif t_1 <= 0.0: tmp = ((-y - x) / y) * z else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) t_1 = Float64(Float64(x + y) / t_0) tmp = 0.0 if (t_1 <= -1e-211) tmp = Float64(Float64(y / t_0) + Float64(x / t_0)); elseif (t_1 <= 0.0) tmp = Float64(Float64(Float64(Float64(-y) - x) / y) * z); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y / z); t_1 = (x + y) / t_0; tmp = 0.0; if (t_1 <= -1e-211) tmp = (y / t_0) + (x / t_0); elseif (t_1 <= 0.0) tmp = ((-y - x) / y) * z; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x + y), $MachinePrecision] / t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -1e-211], N[(N[(y / t$95$0), $MachinePrecision] + N[(x / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[(N[((-y) - x), $MachinePrecision] / y), $MachinePrecision] * z), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
t_1 := \frac{x + y}{t\_0}\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{-211}:\\
\;\;\;\;\frac{y}{t\_0} + \frac{x}{t\_0}\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\left(-y\right) - x}{y} \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -1.00000000000000009e-211Initial program 88.6%
lift-+.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-add-revN/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift-/.f64N/A
lift--.f6488.6
Applied rewrites88.6%
if -1.00000000000000009e-211 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -0.0Initial program 88.6%
lift-+.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-add-revN/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift-/.f64N/A
lift--.f6488.6
Applied rewrites88.6%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6448.6
Applied rewrites48.6%
Taylor expanded in y around 0
lower-/.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f6448.6
Applied rewrites48.6%
if -0.0 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) Initial program 88.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (/ (+ x y) (- 1.0 (/ y z))))) (if (<= t_0 -2e-207) t_0 (if (<= t_0 0.0) (* (/ (- (- y) x) y) z) t_0))))
double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if (t_0 <= -2e-207) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = ((-y - x) / y) * z;
} else {
tmp = t_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, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (x + y) / (1.0d0 - (y / z))
if (t_0 <= (-2d-207)) then
tmp = t_0
else if (t_0 <= 0.0d0) then
tmp = ((-y - x) / y) * z
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if (t_0 <= -2e-207) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = ((-y - x) / y) * z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) / (1.0 - (y / z)) tmp = 0 if t_0 <= -2e-207: tmp = t_0 elif t_0 <= 0.0: tmp = ((-y - x) / y) * z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))) tmp = 0.0 if (t_0 <= -2e-207) tmp = t_0; elseif (t_0 <= 0.0) tmp = Float64(Float64(Float64(Float64(-y) - x) / y) * z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x + y) / (1.0 - (y / z)); tmp = 0.0; if (t_0 <= -2e-207) tmp = t_0; elseif (t_0 <= 0.0) tmp = ((-y - x) / y) * z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-207], t$95$0, If[LessEqual[t$95$0, 0.0], N[(N[(N[((-y) - x), $MachinePrecision] / y), $MachinePrecision] * z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-207}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\frac{\left(-y\right) - x}{y} \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -1.99999999999999985e-207 or -0.0 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) Initial program 88.6%
if -1.99999999999999985e-207 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -0.0Initial program 88.6%
lift-+.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-add-revN/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift-/.f64N/A
lift--.f6488.6
Applied rewrites88.6%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6448.6
Applied rewrites48.6%
Taylor expanded in y around 0
lower-/.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f6448.6
Applied rewrites48.6%
(FPCore (x y z) :precision binary64 (if (<= y -95000000.0) (* (/ (- (- y) x) y) z) (if (<= y 2.7e+32) (+ y x) (- (fma x (/ z y) z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -95000000.0) {
tmp = ((-y - x) / y) * z;
} else if (y <= 2.7e+32) {
tmp = y + x;
} else {
tmp = -fma(x, (z / y), z);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -95000000.0) tmp = Float64(Float64(Float64(Float64(-y) - x) / y) * z); elseif (y <= 2.7e+32) tmp = Float64(y + x); else tmp = Float64(-fma(x, Float64(z / y), z)); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -95000000.0], N[(N[(N[((-y) - x), $MachinePrecision] / y), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[y, 2.7e+32], N[(y + x), $MachinePrecision], (-N[(x * N[(z / y), $MachinePrecision] + z), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -95000000:\\
\;\;\;\;\frac{\left(-y\right) - x}{y} \cdot z\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{+32}:\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;-\mathsf{fma}\left(x, \frac{z}{y}, z\right)\\
\end{array}
\end{array}
if y < -9.5e7Initial program 88.6%
lift-+.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-add-revN/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift-/.f64N/A
lift--.f6488.6
Applied rewrites88.6%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6448.6
Applied rewrites48.6%
Taylor expanded in y around 0
lower-/.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f6448.6
Applied rewrites48.6%
if -9.5e7 < y < 2.70000000000000013e32Initial program 88.6%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6448.6
Applied rewrites48.6%
Taylor expanded in x around 0
Applied rewrites50.5%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6450.5
Applied rewrites50.5%
if 2.70000000000000013e32 < y Initial program 88.6%
Taylor expanded in z around 0
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6442.4
Applied rewrites42.4%
Taylor expanded in x around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6448.6
Applied rewrites48.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (fma x (/ z y) z)))) (if (<= y -95000000.0) t_0 (if (<= y 2.7e+32) (+ y x) t_0))))
double code(double x, double y, double z) {
double t_0 = -fma(x, (z / y), z);
double tmp;
if (y <= -95000000.0) {
tmp = t_0;
} else if (y <= 2.7e+32) {
tmp = y + x;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(-fma(x, Float64(z / y), z)) tmp = 0.0 if (y <= -95000000.0) tmp = t_0; elseif (y <= 2.7e+32) tmp = Float64(y + x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = (-N[(x * N[(z / y), $MachinePrecision] + z), $MachinePrecision])}, If[LessEqual[y, -95000000.0], t$95$0, If[LessEqual[y, 2.7e+32], N[(y + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\mathsf{fma}\left(x, \frac{z}{y}, z\right)\\
\mathbf{if}\;y \leq -95000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{+32}:\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -9.5e7 or 2.70000000000000013e32 < y Initial program 88.6%
Taylor expanded in z around 0
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6442.4
Applied rewrites42.4%
Taylor expanded in x around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6448.6
Applied rewrites48.6%
if -9.5e7 < y < 2.70000000000000013e32Initial program 88.6%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6448.6
Applied rewrites48.6%
Taylor expanded in x around 0
Applied rewrites50.5%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6450.5
Applied rewrites50.5%
(FPCore (x y z) :precision binary64 (if (<= y -1.15e+115) (- z) (if (<= y 4.2e+33) (+ y x) (- z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.15e+115) {
tmp = -z;
} else if (y <= 4.2e+33) {
tmp = y + x;
} else {
tmp = -z;
}
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, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-1.15d+115)) then
tmp = -z
else if (y <= 4.2d+33) then
tmp = y + x
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.15e+115) {
tmp = -z;
} else if (y <= 4.2e+33) {
tmp = y + x;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.15e+115: tmp = -z elif y <= 4.2e+33: tmp = y + x else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.15e+115) tmp = Float64(-z); elseif (y <= 4.2e+33) tmp = Float64(y + x); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.15e+115) tmp = -z; elseif (y <= 4.2e+33) tmp = y + x; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.15e+115], (-z), If[LessEqual[y, 4.2e+33], N[(y + x), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.15 \cdot 10^{+115}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{+33}:\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -1.15000000000000002e115 or 4.2000000000000001e33 < y Initial program 88.6%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6434.4
Applied rewrites34.4%
if -1.15000000000000002e115 < y < 4.2000000000000001e33Initial program 88.6%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6448.6
Applied rewrites48.6%
Taylor expanded in x around 0
Applied rewrites50.5%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6450.5
Applied rewrites50.5%
(FPCore (x y z) :precision binary64 (if (<= z -3.7e+117) y (if (<= z 9e+153) (- z) y)))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.7e+117) {
tmp = y;
} else if (z <= 9e+153) {
tmp = -z;
} else {
tmp = 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, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-3.7d+117)) then
tmp = y
else if (z <= 9d+153) then
tmp = -z
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3.7e+117) {
tmp = y;
} else if (z <= 9e+153) {
tmp = -z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.7e+117: tmp = y elif z <= 9e+153: tmp = -z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.7e+117) tmp = y; elseif (z <= 9e+153) tmp = Float64(-z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.7e+117) tmp = y; elseif (z <= 9e+153) tmp = -z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.7e+117], y, If[LessEqual[z, 9e+153], (-z), y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.7 \cdot 10^{+117}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq 9 \cdot 10^{+153}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if z < -3.6999999999999999e117 or 9.0000000000000002e153 < z Initial program 88.6%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6448.6
Applied rewrites48.6%
Taylor expanded in x around 0
Applied rewrites50.5%
Taylor expanded in x around 0
Applied rewrites18.7%
if -3.6999999999999999e117 < z < 9.0000000000000002e153Initial program 88.6%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6434.4
Applied rewrites34.4%
(FPCore (x y z) :precision binary64 y)
double code(double x, double y, double z) {
return 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, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y
end function
public static double code(double x, double y, double z) {
return y;
}
def code(x, y, z): return y
function code(x, y, z) return y end
function tmp = code(x, y, z) tmp = y; end
code[x_, y_, z_] := y
\begin{array}{l}
\\
y
\end{array}
Initial program 88.6%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6448.6
Applied rewrites48.6%
Taylor expanded in x around 0
Applied rewrites50.5%
Taylor expanded in x around 0
Applied rewrites18.7%
herbie shell --seed 2025139
(FPCore (x y z)
:name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A"
:precision binary64
(/ (+ x y) (- 1.0 (/ y z))))