
(FPCore (x y) :precision binary64 (+ (- (* x (- y 1.0)) (* y 0.5)) 0.918938533204673))
double code(double x, double y) {
return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
}
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 * (y - 1.0d0)) - (y * 0.5d0)) + 0.918938533204673d0
end function
public static double code(double x, double y) {
return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
}
def code(x, y): return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673
function code(x, y) return Float64(Float64(Float64(x * Float64(y - 1.0)) - Float64(y * 0.5)) + 0.918938533204673) end
function tmp = code(x, y) tmp = ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673; end
code[x_, y_] := N[(N[(N[(x * N[(y - 1.0), $MachinePrecision]), $MachinePrecision] - N[(y * 0.5), $MachinePrecision]), $MachinePrecision] + 0.918938533204673), $MachinePrecision]
\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (+ (- (* x (- y 1.0)) (* y 0.5)) 0.918938533204673))
double code(double x, double y) {
return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
}
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 * (y - 1.0d0)) - (y * 0.5d0)) + 0.918938533204673d0
end function
public static double code(double x, double y) {
return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
}
def code(x, y): return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673
function code(x, y) return Float64(Float64(Float64(x * Float64(y - 1.0)) - Float64(y * 0.5)) + 0.918938533204673) end
function tmp = code(x, y) tmp = ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673; end
code[x_, y_] := N[(N[(N[(x * N[(y - 1.0), $MachinePrecision]), $MachinePrecision] - N[(y * 0.5), $MachinePrecision]), $MachinePrecision] + 0.918938533204673), $MachinePrecision]
\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673
(FPCore (x y) :precision binary64 (- 0.918938533204673 (fma y (- 0.5 x) x)))
double code(double x, double y) {
return 0.918938533204673 - fma(y, (0.5 - x), x);
}
function code(x, y) return Float64(0.918938533204673 - fma(y, Float64(0.5 - x), x)) end
code[x_, y_] := N[(0.918938533204673 - N[(y * N[(0.5 - x), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]
0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, x\right)
Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
associate--r+N/A
*-commutativeN/A
metadata-evalN/A
mul-1-negN/A
add-flip-revN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-out--N/A
*-rgt-identityN/A
remove-double-negN/A
distribute-rgt-neg-outN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
(FPCore (x y)
:precision binary64
(if (<= x -9.2e+18)
(- (* x y) x)
(if (<= x 95000000000.0)
(- 0.918938533204673 (* y (- 0.5 x)))
(* x (- y 1.0)))))double code(double x, double y) {
double tmp;
if (x <= -9.2e+18) {
tmp = (x * y) - x;
} else if (x <= 95000000000.0) {
tmp = 0.918938533204673 - (y * (0.5 - x));
} 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 (x <= (-9.2d+18)) then
tmp = (x * y) - x
else if (x <= 95000000000.0d0) then
tmp = 0.918938533204673d0 - (y * (0.5d0 - x))
else
tmp = x * (y - 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -9.2e+18) {
tmp = (x * y) - x;
} else if (x <= 95000000000.0) {
tmp = 0.918938533204673 - (y * (0.5 - x));
} else {
tmp = x * (y - 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -9.2e+18: tmp = (x * y) - x elif x <= 95000000000.0: tmp = 0.918938533204673 - (y * (0.5 - x)) else: tmp = x * (y - 1.0) return tmp
function code(x, y) tmp = 0.0 if (x <= -9.2e+18) tmp = Float64(Float64(x * y) - x); elseif (x <= 95000000000.0) tmp = Float64(0.918938533204673 - Float64(y * Float64(0.5 - x))); else tmp = Float64(x * Float64(y - 1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -9.2e+18) tmp = (x * y) - x; elseif (x <= 95000000000.0) tmp = 0.918938533204673 - (y * (0.5 - x)); else tmp = x * (y - 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -9.2e+18], N[(N[(x * y), $MachinePrecision] - x), $MachinePrecision], If[LessEqual[x, 95000000000.0], N[(0.918938533204673 - N[(y * N[(0.5 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(y - 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \leq -9.2 \cdot 10^{+18}:\\
\;\;\;\;x \cdot y - x\\
\mathbf{elif}\;x \leq 95000000000:\\
\;\;\;\;0.918938533204673 - y \cdot \left(0.5 - x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y - 1\right)\\
\end{array}
if x < -9.2e18Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6450.8%
Applied rewrites50.8%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f6451.5%
Applied rewrites51.5%
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
distribute-lft-inN/A
distribute-rgt-neg-outN/A
sub-flip-reverseN/A
lower--.f64N/A
*-rgt-identityN/A
lower-*.f64N/A
*-rgt-identityN/A
*-rgt-identity51.5%
Applied rewrites51.5%
if -9.2e18 < x < 9.5e10Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
associate--r+N/A
*-commutativeN/A
metadata-evalN/A
mul-1-negN/A
add-flip-revN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-out--N/A
*-rgt-identityN/A
remove-double-negN/A
distribute-rgt-neg-outN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6474.5%
Applied rewrites74.5%
if 9.5e10 < x Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6450.8%
Applied rewrites50.8%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f6451.5%
Applied rewrites51.5%
(FPCore (x y) :precision binary64 (if (<= x -0.59) (- (* x y) x) (if (<= x 7400000.0) (fma y -0.5 0.918938533204673) (* x (- y 1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -0.59) {
tmp = (x * y) - x;
} else if (x <= 7400000.0) {
tmp = fma(y, -0.5, 0.918938533204673);
} else {
tmp = x * (y - 1.0);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= -0.59) tmp = Float64(Float64(x * y) - x); elseif (x <= 7400000.0) tmp = fma(y, -0.5, 0.918938533204673); else tmp = Float64(x * Float64(y - 1.0)); end return tmp end
code[x_, y_] := If[LessEqual[x, -0.59], N[(N[(x * y), $MachinePrecision] - x), $MachinePrecision], If[LessEqual[x, 7400000.0], N[(y * -0.5 + 0.918938533204673), $MachinePrecision], N[(x * N[(y - 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \leq -0.59:\\
\;\;\;\;x \cdot y - x\\
\mathbf{elif}\;x \leq 7400000:\\
\;\;\;\;\mathsf{fma}\left(y, -0.5, 0.918938533204673\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y - 1\right)\\
\end{array}
if x < -0.589999999999999969Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6450.8%
Applied rewrites50.8%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f6451.5%
Applied rewrites51.5%
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
distribute-lft-inN/A
distribute-rgt-neg-outN/A
sub-flip-reverseN/A
lower--.f64N/A
*-rgt-identityN/A
lower-*.f64N/A
*-rgt-identityN/A
*-rgt-identity51.5%
Applied rewrites51.5%
if -0.589999999999999969 < x < 7.4e6Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-*.f6449.8%
Applied rewrites49.8%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
metadata-eval49.8%
Applied rewrites49.8%
if 7.4e6 < x Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6450.8%
Applied rewrites50.8%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f6451.5%
Applied rewrites51.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (- y 1.0))))
(if (<= x -0.59)
t_0
(if (<= x 7400000.0) (fma y -0.5 0.918938533204673) t_0))))double code(double x, double y) {
double t_0 = x * (y - 1.0);
double tmp;
if (x <= -0.59) {
tmp = t_0;
} else if (x <= 7400000.0) {
tmp = fma(y, -0.5, 0.918938533204673);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y) t_0 = Float64(x * Float64(y - 1.0)) tmp = 0.0 if (x <= -0.59) tmp = t_0; elseif (x <= 7400000.0) tmp = fma(y, -0.5, 0.918938533204673); else tmp = t_0; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(y - 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -0.59], t$95$0, If[LessEqual[x, 7400000.0], N[(y * -0.5 + 0.918938533204673), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := x \cdot \left(y - 1\right)\\
\mathbf{if}\;x \leq -0.59:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 7400000:\\
\;\;\;\;\mathsf{fma}\left(y, -0.5, 0.918938533204673\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if x < -0.589999999999999969 or 7.4e6 < x Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6450.8%
Applied rewrites50.8%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f6451.5%
Applied rewrites51.5%
if -0.589999999999999969 < x < 7.4e6Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-*.f6449.8%
Applied rewrites49.8%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
metadata-eval49.8%
Applied rewrites49.8%
(FPCore (x y)
:precision binary64
(if (<= y -6.5e+249)
(* y -0.5)
(if (<= y -5.6e+34)
(* x y)
(if (<= y -21000.0)
(fma y -0.5 0.918938533204673)
(if (<= y 980000000.0)
(- 0.918938533204673 x)
(if (<= y 4.1e+180) (* x y) (* y -0.5)))))))double code(double x, double y) {
double tmp;
if (y <= -6.5e+249) {
tmp = y * -0.5;
} else if (y <= -5.6e+34) {
tmp = x * y;
} else if (y <= -21000.0) {
tmp = fma(y, -0.5, 0.918938533204673);
} else if (y <= 980000000.0) {
tmp = 0.918938533204673 - x;
} else if (y <= 4.1e+180) {
tmp = x * y;
} else {
tmp = y * -0.5;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (y <= -6.5e+249) tmp = Float64(y * -0.5); elseif (y <= -5.6e+34) tmp = Float64(x * y); elseif (y <= -21000.0) tmp = fma(y, -0.5, 0.918938533204673); elseif (y <= 980000000.0) tmp = Float64(0.918938533204673 - x); elseif (y <= 4.1e+180) tmp = Float64(x * y); else tmp = Float64(y * -0.5); end return tmp end
code[x_, y_] := If[LessEqual[y, -6.5e+249], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -5.6e+34], N[(x * y), $MachinePrecision], If[LessEqual[y, -21000.0], N[(y * -0.5 + 0.918938533204673), $MachinePrecision], If[LessEqual[y, 980000000.0], N[(0.918938533204673 - x), $MachinePrecision], If[LessEqual[y, 4.1e+180], N[(x * y), $MachinePrecision], N[(y * -0.5), $MachinePrecision]]]]]]
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{+249}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq -5.6 \cdot 10^{+34}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;y \leq -21000:\\
\;\;\;\;\mathsf{fma}\left(y, -0.5, 0.918938533204673\right)\\
\mathbf{elif}\;y \leq 980000000:\\
\;\;\;\;0.918938533204673 - x\\
\mathbf{elif}\;y \leq 4.1 \cdot 10^{+180}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;y \cdot -0.5\\
\end{array}
if y < -6.50000000000000028e249 or 4.1e180 < y Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6450.8%
Applied rewrites50.8%
Taylor expanded in x around 0
Applied rewrites26.1%
if -6.50000000000000028e249 < y < -5.60000000000000016e34 or 9.8e8 < y < 4.1e180Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6450.8%
Applied rewrites50.8%
Taylor expanded in x around inf
lower-*.f6426.8%
Applied rewrites26.8%
if -5.60000000000000016e34 < y < -21000Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-*.f6449.8%
Applied rewrites49.8%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
metadata-eval49.8%
Applied rewrites49.8%
if -21000 < y < 9.8e8Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
associate--r+N/A
*-commutativeN/A
metadata-evalN/A
mul-1-negN/A
add-flip-revN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-out--N/A
*-rgt-identityN/A
remove-double-negN/A
distribute-rgt-neg-outN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in y around 0
lower--.f6450.3%
Applied rewrites50.3%
(FPCore (x y)
:precision binary64
(if (<= y -6.5e+249)
(* y -0.5)
(if (<= y -5.6e+34)
(* x y)
(if (<= y -21000.0)
(* y -0.5)
(if (<= y 980000000.0)
(- 0.918938533204673 x)
(if (<= y 4.1e+180) (* x y) (* y -0.5)))))))double code(double x, double y) {
double tmp;
if (y <= -6.5e+249) {
tmp = y * -0.5;
} else if (y <= -5.6e+34) {
tmp = x * y;
} else if (y <= -21000.0) {
tmp = y * -0.5;
} else if (y <= 980000000.0) {
tmp = 0.918938533204673 - x;
} else if (y <= 4.1e+180) {
tmp = x * y;
} else {
tmp = y * -0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-6.5d+249)) then
tmp = y * (-0.5d0)
else if (y <= (-5.6d+34)) then
tmp = x * y
else if (y <= (-21000.0d0)) then
tmp = y * (-0.5d0)
else if (y <= 980000000.0d0) then
tmp = 0.918938533204673d0 - x
else if (y <= 4.1d+180) then
tmp = x * y
else
tmp = y * (-0.5d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -6.5e+249) {
tmp = y * -0.5;
} else if (y <= -5.6e+34) {
tmp = x * y;
} else if (y <= -21000.0) {
tmp = y * -0.5;
} else if (y <= 980000000.0) {
tmp = 0.918938533204673 - x;
} else if (y <= 4.1e+180) {
tmp = x * y;
} else {
tmp = y * -0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -6.5e+249: tmp = y * -0.5 elif y <= -5.6e+34: tmp = x * y elif y <= -21000.0: tmp = y * -0.5 elif y <= 980000000.0: tmp = 0.918938533204673 - x elif y <= 4.1e+180: tmp = x * y else: tmp = y * -0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= -6.5e+249) tmp = Float64(y * -0.5); elseif (y <= -5.6e+34) tmp = Float64(x * y); elseif (y <= -21000.0) tmp = Float64(y * -0.5); elseif (y <= 980000000.0) tmp = Float64(0.918938533204673 - x); elseif (y <= 4.1e+180) tmp = Float64(x * y); else tmp = Float64(y * -0.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -6.5e+249) tmp = y * -0.5; elseif (y <= -5.6e+34) tmp = x * y; elseif (y <= -21000.0) tmp = y * -0.5; elseif (y <= 980000000.0) tmp = 0.918938533204673 - x; elseif (y <= 4.1e+180) tmp = x * y; else tmp = y * -0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -6.5e+249], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -5.6e+34], N[(x * y), $MachinePrecision], If[LessEqual[y, -21000.0], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 980000000.0], N[(0.918938533204673 - x), $MachinePrecision], If[LessEqual[y, 4.1e+180], N[(x * y), $MachinePrecision], N[(y * -0.5), $MachinePrecision]]]]]]
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{+249}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq -5.6 \cdot 10^{+34}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;y \leq -21000:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 980000000:\\
\;\;\;\;0.918938533204673 - x\\
\mathbf{elif}\;y \leq 4.1 \cdot 10^{+180}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;y \cdot -0.5\\
\end{array}
if y < -6.50000000000000028e249 or -5.60000000000000016e34 < y < -21000 or 4.1e180 < y Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6450.8%
Applied rewrites50.8%
Taylor expanded in x around 0
Applied rewrites26.1%
if -6.50000000000000028e249 < y < -5.60000000000000016e34 or 9.8e8 < y < 4.1e180Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6450.8%
Applied rewrites50.8%
Taylor expanded in x around inf
lower-*.f6426.8%
Applied rewrites26.8%
if -21000 < y < 9.8e8Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
associate--r+N/A
*-commutativeN/A
metadata-evalN/A
mul-1-negN/A
add-flip-revN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-out--N/A
*-rgt-identityN/A
remove-double-negN/A
distribute-rgt-neg-outN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in y around 0
lower--.f6450.3%
Applied rewrites50.3%
(FPCore (x y) :precision binary64 (if (<= y -520000000.0) (* x y) (if (<= y 980000000.0) (- 0.918938533204673 x) (* x y))))
double code(double x, double y) {
double tmp;
if (y <= -520000000.0) {
tmp = x * y;
} else if (y <= 980000000.0) {
tmp = 0.918938533204673 - x;
} 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 <= (-520000000.0d0)) then
tmp = x * y
else if (y <= 980000000.0d0) then
tmp = 0.918938533204673d0 - x
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -520000000.0) {
tmp = x * y;
} else if (y <= 980000000.0) {
tmp = 0.918938533204673 - x;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -520000000.0: tmp = x * y elif y <= 980000000.0: tmp = 0.918938533204673 - x else: tmp = x * y return tmp
function code(x, y) tmp = 0.0 if (y <= -520000000.0) tmp = Float64(x * y); elseif (y <= 980000000.0) tmp = Float64(0.918938533204673 - x); else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -520000000.0) tmp = x * y; elseif (y <= 980000000.0) tmp = 0.918938533204673 - x; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -520000000.0], N[(x * y), $MachinePrecision], If[LessEqual[y, 980000000.0], N[(0.918938533204673 - x), $MachinePrecision], N[(x * y), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;y \leq -520000000:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;y \leq 980000000:\\
\;\;\;\;0.918938533204673 - x\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
if y < -5.2e8 or 9.8e8 < y Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6450.8%
Applied rewrites50.8%
Taylor expanded in x around inf
lower-*.f6426.8%
Applied rewrites26.8%
if -5.2e8 < y < 9.8e8Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
associate--r+N/A
*-commutativeN/A
metadata-evalN/A
mul-1-negN/A
add-flip-revN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-out--N/A
*-rgt-identityN/A
remove-double-negN/A
distribute-rgt-neg-outN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in y around 0
lower--.f6450.3%
Applied rewrites50.3%
(FPCore (x y) :precision binary64 (- 0.918938533204673 x))
double code(double x, double y) {
return 0.918938533204673 - x;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.918938533204673d0 - x
end function
public static double code(double x, double y) {
return 0.918938533204673 - x;
}
def code(x, y): return 0.918938533204673 - x
function code(x, y) return Float64(0.918938533204673 - x) end
function tmp = code(x, y) tmp = 0.918938533204673 - x; end
code[x_, y_] := N[(0.918938533204673 - x), $MachinePrecision]
0.918938533204673 - x
Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
associate--r+N/A
*-commutativeN/A
metadata-evalN/A
mul-1-negN/A
add-flip-revN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-out--N/A
*-rgt-identityN/A
remove-double-negN/A
distribute-rgt-neg-outN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in y around 0
lower--.f6450.3%
Applied rewrites50.3%
(FPCore (x y) :precision binary64 0.918938533204673)
double code(double x, double y) {
return 0.918938533204673;
}
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.918938533204673d0
end function
public static double code(double x, double y) {
return 0.918938533204673;
}
def code(x, y): return 0.918938533204673
function code(x, y) return 0.918938533204673 end
function tmp = code(x, y) tmp = 0.918938533204673; end
code[x_, y_] := 0.918938533204673
0.918938533204673
Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-*.f6449.8%
Applied rewrites49.8%
Taylor expanded in y around 0
Applied rewrites25.5%
herbie shell --seed 2025183
(FPCore (x y)
:name "Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2, A"
:precision binary64
(+ (- (* x (- y 1.0)) (* y 0.5)) 0.918938533204673))