
(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 8 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 (/ (+ x y) (- 1.0 (/ y z)))) (t_1 (/ (+ x y) (/ (- z y) z)))) (if (<= t_0 -4e-266) t_1 (if (<= t_0 2e-268) (- (fma z (/ x y) z)) t_1))))
double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double t_1 = (x + y) / ((z - y) / z);
double tmp;
if (t_0 <= -4e-266) {
tmp = t_1;
} else if (t_0 <= 2e-268) {
tmp = -fma(z, (x / y), z);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))) t_1 = Float64(Float64(x + y) / Float64(Float64(z - y) / z)) tmp = 0.0 if (t_0 <= -4e-266) tmp = t_1; elseif (t_0 <= 2e-268) tmp = Float64(-fma(z, Float64(x / y), z)); else tmp = t_1; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x + y), $MachinePrecision] / N[(N[(z - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -4e-266], t$95$1, If[LessEqual[t$95$0, 2e-268], (-N[(z * N[(x / y), $MachinePrecision] + z), $MachinePrecision]), t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
t_1 := \frac{x + y}{\frac{z - y}{z}}\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-266}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-268}:\\
\;\;\;\;-\mathsf{fma}\left(z, \frac{x}{y}, z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -3.9999999999999999e-266 or 1.99999999999999992e-268 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) Initial program 99.9%
Taylor expanded in z around 0
lower-/.f64N/A
lower--.f6499.9
Applied rewrites99.9%
if -3.9999999999999999e-266 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < 1.99999999999999992e-268Initial program 17.2%
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-+.f6491.1
Applied rewrites91.1%
Taylor expanded in x around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6483.7
Applied rewrites83.7%
lift-/.f64N/A
lift-fma.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6496.7
Applied rewrites96.7%
(FPCore (x y z) :precision binary64 (if (<= z -1.46e+72) (+ y x) (if (<= z 4.5e-34) (- (- (/ (* z x) y)) z) (+ y x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.46e+72) {
tmp = y + x;
} else if (z <= 4.5e-34) {
tmp = -((z * x) / y) - z;
} else {
tmp = y + 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, 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 <= (-1.46d+72)) then
tmp = y + x
else if (z <= 4.5d-34) then
tmp = -((z * x) / y) - z
else
tmp = y + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.46e+72) {
tmp = y + x;
} else if (z <= 4.5e-34) {
tmp = -((z * x) / y) - z;
} else {
tmp = y + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.46e+72: tmp = y + x elif z <= 4.5e-34: tmp = -((z * x) / y) - z else: tmp = y + x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.46e+72) tmp = Float64(y + x); elseif (z <= 4.5e-34) tmp = Float64(Float64(-Float64(Float64(z * x) / y)) - z); else tmp = Float64(y + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.46e+72) tmp = y + x; elseif (z <= 4.5e-34) tmp = -((z * x) / y) - z; else tmp = y + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.46e+72], N[(y + x), $MachinePrecision], If[LessEqual[z, 4.5e-34], N[((-N[(N[(z * x), $MachinePrecision] / y), $MachinePrecision]) - z), $MachinePrecision], N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.46 \cdot 10^{+72}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;z \leq 4.5 \cdot 10^{-34}:\\
\;\;\;\;\left(-\frac{z \cdot x}{y}\right) - z\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if z < -1.45999999999999999e72 or 4.50000000000000042e-34 < z Initial program 99.7%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6474.7
Applied rewrites74.7%
if -1.45999999999999999e72 < z < 4.50000000000000042e-34Initial program 77.1%
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-+.f6467.6
Applied rewrites67.6%
Taylor expanded in x around 0
lower--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6470.8
Applied rewrites70.8%
(FPCore (x y z) :precision binary64 (if (<= z -1.55e+72) (+ y x) (if (<= z 4.5e-34) (- (fma z (/ x y) z)) (+ y x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.55e+72) {
tmp = y + x;
} else if (z <= 4.5e-34) {
tmp = -fma(z, (x / y), z);
} else {
tmp = y + x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -1.55e+72) tmp = Float64(y + x); elseif (z <= 4.5e-34) tmp = Float64(-fma(z, Float64(x / y), z)); else tmp = Float64(y + x); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -1.55e+72], N[(y + x), $MachinePrecision], If[LessEqual[z, 4.5e-34], (-N[(z * N[(x / y), $MachinePrecision] + z), $MachinePrecision]), N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.55 \cdot 10^{+72}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;z \leq 4.5 \cdot 10^{-34}:\\
\;\;\;\;-\mathsf{fma}\left(z, \frac{x}{y}, z\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if z < -1.54999999999999994e72 or 4.50000000000000042e-34 < z Initial program 99.7%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6474.7
Applied rewrites74.7%
if -1.54999999999999994e72 < z < 4.50000000000000042e-34Initial program 77.1%
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-+.f6467.6
Applied rewrites67.6%
Taylor expanded in x around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6469.2
Applied rewrites69.2%
lift-/.f64N/A
lift-fma.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6469.1
Applied rewrites69.1%
(FPCore (x y z) :precision binary64 (if (<= z -1.55e+72) (+ y x) (if (<= z 4.5e-34) (- (fma x (/ z y) z)) (+ y x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.55e+72) {
tmp = y + x;
} else if (z <= 4.5e-34) {
tmp = -fma(x, (z / y), z);
} else {
tmp = y + x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -1.55e+72) tmp = Float64(y + x); elseif (z <= 4.5e-34) tmp = Float64(-fma(x, Float64(z / y), z)); else tmp = Float64(y + x); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -1.55e+72], N[(y + x), $MachinePrecision], If[LessEqual[z, 4.5e-34], (-N[(x * N[(z / y), $MachinePrecision] + z), $MachinePrecision]), N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.55 \cdot 10^{+72}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;z \leq 4.5 \cdot 10^{-34}:\\
\;\;\;\;-\mathsf{fma}\left(x, \frac{z}{y}, z\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if z < -1.54999999999999994e72 or 4.50000000000000042e-34 < z Initial program 99.7%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6474.7
Applied rewrites74.7%
if -1.54999999999999994e72 < z < 4.50000000000000042e-34Initial program 77.1%
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-+.f6467.6
Applied rewrites67.6%
Taylor expanded in x around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6469.2
Applied rewrites69.2%
(FPCore (x y z) :precision binary64 (if (<= y -2e+71) (- z) (if (<= y 4e+97) (+ y x) (- z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2e+71) {
tmp = -z;
} else if (y <= 4e+97) {
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 <= (-2d+71)) then
tmp = -z
else if (y <= 4d+97) 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 <= -2e+71) {
tmp = -z;
} else if (y <= 4e+97) {
tmp = y + x;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2e+71: tmp = -z elif y <= 4e+97: tmp = y + x else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2e+71) tmp = Float64(-z); elseif (y <= 4e+97) tmp = Float64(y + x); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2e+71) tmp = -z; elseif (y <= 4e+97) tmp = y + x; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2e+71], (-z), If[LessEqual[y, 4e+97], N[(y + x), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{+71}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+97}:\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -2.0000000000000001e71 or 4.0000000000000003e97 < y Initial program 69.6%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6468.8
Applied rewrites68.8%
if -2.0000000000000001e71 < y < 4.0000000000000003e97Initial program 98.3%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6468.1
Applied rewrites68.1%
(FPCore (x y z) :precision binary64 (if (<= y -7.2e+48) (- z) (if (<= y 8e-63) x (- z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -7.2e+48) {
tmp = -z;
} else if (y <= 8e-63) {
tmp = 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 <= (-7.2d+48)) then
tmp = -z
else if (y <= 8d-63) then
tmp = x
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -7.2e+48) {
tmp = -z;
} else if (y <= 8e-63) {
tmp = x;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7.2e+48: tmp = -z elif y <= 8e-63: tmp = x else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7.2e+48) tmp = Float64(-z); elseif (y <= 8e-63) tmp = x; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -7.2e+48) tmp = -z; elseif (y <= 8e-63) tmp = x; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7.2e+48], (-z), If[LessEqual[y, 8e-63], x, (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.2 \cdot 10^{+48}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 8 \cdot 10^{-63}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -7.19999999999999967e48 or 8.00000000000000053e-63 < y Initial program 76.8%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6457.9
Applied rewrites57.9%
if -7.19999999999999967e48 < y < 8.00000000000000053e-63Initial program 99.6%
Taylor expanded in y around 0
Applied rewrites58.1%
(FPCore (x y z) :precision binary64 (if (<= y -9.2e+68) y (if (<= y 15500000.0) x y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -9.2e+68) {
tmp = y;
} else if (y <= 15500000.0) {
tmp = x;
} 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 (y <= (-9.2d+68)) then
tmp = y
else if (y <= 15500000.0d0) then
tmp = x
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -9.2e+68) {
tmp = y;
} else if (y <= 15500000.0) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -9.2e+68: tmp = y elif y <= 15500000.0: tmp = x else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -9.2e+68) tmp = y; elseif (y <= 15500000.0) tmp = x; else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -9.2e+68) tmp = y; elseif (y <= 15500000.0) tmp = x; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -9.2e+68], y, If[LessEqual[y, 15500000.0], x, y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.2 \cdot 10^{+68}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 15500000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -9.1999999999999999e68 or 1.55e7 < y Initial program 73.2%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6422.8
Applied rewrites22.8%
Taylor expanded in x around 0
Applied rewrites16.6%
if -9.1999999999999999e68 < y < 1.55e7Initial program 99.4%
Taylor expanded in y around 0
Applied rewrites54.3%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 87.7%
Taylor expanded in y around 0
Applied rewrites34.3%
herbie shell --seed 2025120
(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))))