
(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]
\begin{array}{l}
\\
\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 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]
\begin{array}{l}
\\
\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673
\end{array}
(FPCore (x y) :precision binary64 (fma (- y 1.0) x (fma -0.5 y 0.918938533204673)))
double code(double x, double y) {
return fma((y - 1.0), x, fma(-0.5, y, 0.918938533204673));
}
function code(x, y) return fma(Float64(y - 1.0), x, fma(-0.5, y, 0.918938533204673)) end
code[x_, y_] := N[(N[(y - 1.0), $MachinePrecision] * x + N[(-0.5 * y + 0.918938533204673), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y - 1, x, \mathsf{fma}\left(-0.5, y, 0.918938533204673\right)\right)
\end{array}
Initial program 100.0%
lift-+.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-+l-N/A
lift-*.f64N/A
*-commutativeN/A
associate-+l-N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
(FPCore (x y)
:precision binary64
(if (<= y -5.6e-10)
(fma -0.5 y 0.918938533204673)
(if (<= y 21000000.0)
(- 0.918938533204673 x)
(if (or (<= y 3.2e+136) (not (<= y 4e+278)))
(* y x)
(fma -0.5 y 0.918938533204673)))))
double code(double x, double y) {
double tmp;
if (y <= -5.6e-10) {
tmp = fma(-0.5, y, 0.918938533204673);
} else if (y <= 21000000.0) {
tmp = 0.918938533204673 - x;
} else if ((y <= 3.2e+136) || !(y <= 4e+278)) {
tmp = y * x;
} else {
tmp = fma(-0.5, y, 0.918938533204673);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (y <= -5.6e-10) tmp = fma(-0.5, y, 0.918938533204673); elseif (y <= 21000000.0) tmp = Float64(0.918938533204673 - x); elseif ((y <= 3.2e+136) || !(y <= 4e+278)) tmp = Float64(y * x); else tmp = fma(-0.5, y, 0.918938533204673); end return tmp end
code[x_, y_] := If[LessEqual[y, -5.6e-10], N[(-0.5 * y + 0.918938533204673), $MachinePrecision], If[LessEqual[y, 21000000.0], N[(0.918938533204673 - x), $MachinePrecision], If[Or[LessEqual[y, 3.2e+136], N[Not[LessEqual[y, 4e+278]], $MachinePrecision]], N[(y * x), $MachinePrecision], N[(-0.5 * y + 0.918938533204673), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.6 \cdot 10^{-10}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, y, 0.918938533204673\right)\\
\mathbf{elif}\;y \leq 21000000:\\
\;\;\;\;0.918938533204673 - x\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+136} \lor \neg \left(y \leq 4 \cdot 10^{+278}\right):\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, y, 0.918938533204673\right)\\
\end{array}
\end{array}
if y < -5.60000000000000031e-10 or 3.19999999999999988e136 < y < 3.99999999999999985e278Initial program 100.0%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f6460.1
Applied rewrites60.1%
if -5.60000000000000031e-10 < y < 2.1e7Initial program 100.0%
Taylor expanded in y around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6498.2
Applied rewrites98.2%
if 2.1e7 < y < 3.19999999999999988e136 or 3.99999999999999985e278 < y Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6474.1
Applied rewrites74.1%
Taylor expanded in y around inf
Applied rewrites73.1%
Final simplification80.5%
(FPCore (x y)
:precision binary64
(if (<= y -68.0)
(* -0.5 y)
(if (<= y 21000000.0)
(- 0.918938533204673 x)
(if (or (<= y 3.2e+136) (not (<= y 4e+278))) (* y x) (* -0.5 y)))))
double code(double x, double y) {
double tmp;
if (y <= -68.0) {
tmp = -0.5 * y;
} else if (y <= 21000000.0) {
tmp = 0.918938533204673 - x;
} else if ((y <= 3.2e+136) || !(y <= 4e+278)) {
tmp = y * x;
} else {
tmp = -0.5 * 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 <= (-68.0d0)) then
tmp = (-0.5d0) * y
else if (y <= 21000000.0d0) then
tmp = 0.918938533204673d0 - x
else if ((y <= 3.2d+136) .or. (.not. (y <= 4d+278))) then
tmp = y * x
else
tmp = (-0.5d0) * y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -68.0) {
tmp = -0.5 * y;
} else if (y <= 21000000.0) {
tmp = 0.918938533204673 - x;
} else if ((y <= 3.2e+136) || !(y <= 4e+278)) {
tmp = y * x;
} else {
tmp = -0.5 * y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -68.0: tmp = -0.5 * y elif y <= 21000000.0: tmp = 0.918938533204673 - x elif (y <= 3.2e+136) or not (y <= 4e+278): tmp = y * x else: tmp = -0.5 * y return tmp
function code(x, y) tmp = 0.0 if (y <= -68.0) tmp = Float64(-0.5 * y); elseif (y <= 21000000.0) tmp = Float64(0.918938533204673 - x); elseif ((y <= 3.2e+136) || !(y <= 4e+278)) tmp = Float64(y * x); else tmp = Float64(-0.5 * y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -68.0) tmp = -0.5 * y; elseif (y <= 21000000.0) tmp = 0.918938533204673 - x; elseif ((y <= 3.2e+136) || ~((y <= 4e+278))) tmp = y * x; else tmp = -0.5 * y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -68.0], N[(-0.5 * y), $MachinePrecision], If[LessEqual[y, 21000000.0], N[(0.918938533204673 - x), $MachinePrecision], If[Or[LessEqual[y, 3.2e+136], N[Not[LessEqual[y, 4e+278]], $MachinePrecision]], N[(y * x), $MachinePrecision], N[(-0.5 * y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -68:\\
\;\;\;\;-0.5 \cdot y\\
\mathbf{elif}\;y \leq 21000000:\\
\;\;\;\;0.918938533204673 - x\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+136} \lor \neg \left(y \leq 4 \cdot 10^{+278}\right):\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot y\\
\end{array}
\end{array}
if y < -68 or 3.19999999999999988e136 < y < 3.99999999999999985e278Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites59.7%
if -68 < y < 2.1e7Initial program 100.0%
Taylor expanded in y around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6497.8
Applied rewrites97.8%
if 2.1e7 < y < 3.19999999999999988e136 or 3.99999999999999985e278 < y Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6474.1
Applied rewrites74.1%
Taylor expanded in y around inf
Applied rewrites73.1%
Final simplification80.3%
(FPCore (x y) :precision binary64 (if (or (<= y -1.55e-7) (not (<= y 1.9e-6))) (+ (* (- x 0.5) y) 0.918938533204673) (fma (- y 1.0) x 0.918938533204673)))
double code(double x, double y) {
double tmp;
if ((y <= -1.55e-7) || !(y <= 1.9e-6)) {
tmp = ((x - 0.5) * y) + 0.918938533204673;
} else {
tmp = fma((y - 1.0), x, 0.918938533204673);
}
return tmp;
}
function code(x, y) tmp = 0.0 if ((y <= -1.55e-7) || !(y <= 1.9e-6)) tmp = Float64(Float64(Float64(x - 0.5) * y) + 0.918938533204673); else tmp = fma(Float64(y - 1.0), x, 0.918938533204673); end return tmp end
code[x_, y_] := If[Or[LessEqual[y, -1.55e-7], N[Not[LessEqual[y, 1.9e-6]], $MachinePrecision]], N[(N[(N[(x - 0.5), $MachinePrecision] * y), $MachinePrecision] + 0.918938533204673), $MachinePrecision], N[(N[(y - 1.0), $MachinePrecision] * x + 0.918938533204673), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.55 \cdot 10^{-7} \lor \neg \left(y \leq 1.9 \cdot 10^{-6}\right):\\
\;\;\;\;\left(x - 0.5\right) \cdot y + 0.918938533204673\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - 1, x, 0.918938533204673\right)\\
\end{array}
\end{array}
if y < -1.55e-7 or 1.9e-6 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6499.7
Applied rewrites99.7%
if -1.55e-7 < y < 1.9e-6Initial program 100.0%
lift-+.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-+l-N/A
lift-*.f64N/A
*-commutativeN/A
associate-+l-N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (or (<= y -12600000.0) (not (<= y 8000000.0))) (* (- x 0.5) y) (fma (- y 1.0) x 0.918938533204673)))
double code(double x, double y) {
double tmp;
if ((y <= -12600000.0) || !(y <= 8000000.0)) {
tmp = (x - 0.5) * y;
} else {
tmp = fma((y - 1.0), x, 0.918938533204673);
}
return tmp;
}
function code(x, y) tmp = 0.0 if ((y <= -12600000.0) || !(y <= 8000000.0)) tmp = Float64(Float64(x - 0.5) * y); else tmp = fma(Float64(y - 1.0), x, 0.918938533204673); end return tmp end
code[x_, y_] := If[Or[LessEqual[y, -12600000.0], N[Not[LessEqual[y, 8000000.0]], $MachinePrecision]], N[(N[(x - 0.5), $MachinePrecision] * y), $MachinePrecision], N[(N[(y - 1.0), $MachinePrecision] * x + 0.918938533204673), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -12600000 \lor \neg \left(y \leq 8000000\right):\\
\;\;\;\;\left(x - 0.5\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - 1, x, 0.918938533204673\right)\\
\end{array}
\end{array}
if y < -1.26e7 or 8e6 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6499.2
Applied rewrites99.2%
if -1.26e7 < y < 8e6Initial program 100.0%
lift-+.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-+l-N/A
lift-*.f64N/A
*-commutativeN/A
associate-+l-N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites99.1%
Final simplification99.1%
(FPCore (x y) :precision binary64 (if (<= y -12600000.0) (fma y x (* -0.5 y)) (if (<= y 8000000.0) (fma (- y 1.0) x 0.918938533204673) (* (- x 0.5) y))))
double code(double x, double y) {
double tmp;
if (y <= -12600000.0) {
tmp = fma(y, x, (-0.5 * y));
} else if (y <= 8000000.0) {
tmp = fma((y - 1.0), x, 0.918938533204673);
} else {
tmp = (x - 0.5) * y;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (y <= -12600000.0) tmp = fma(y, x, Float64(-0.5 * y)); elseif (y <= 8000000.0) tmp = fma(Float64(y - 1.0), x, 0.918938533204673); else tmp = Float64(Float64(x - 0.5) * y); end return tmp end
code[x_, y_] := If[LessEqual[y, -12600000.0], N[(y * x + N[(-0.5 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8000000.0], N[(N[(y - 1.0), $MachinePrecision] * x + 0.918938533204673), $MachinePrecision], N[(N[(x - 0.5), $MachinePrecision] * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -12600000:\\
\;\;\;\;\mathsf{fma}\left(y, x, -0.5 \cdot y\right)\\
\mathbf{elif}\;y \leq 8000000:\\
\;\;\;\;\mathsf{fma}\left(y - 1, x, 0.918938533204673\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x - 0.5\right) \cdot y\\
\end{array}
\end{array}
if y < -1.26e7Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6499.9
Applied rewrites99.9%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-outN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64100.0
Applied rewrites100.0%
if -1.26e7 < y < 8e6Initial program 100.0%
lift-+.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-+l-N/A
lift-*.f64N/A
*-commutativeN/A
associate-+l-N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites99.1%
if 8e6 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6498.5
Applied rewrites98.5%
(FPCore (x y) :precision binary64 (if (or (<= y -1.32) (not (<= y 1.75))) (* (- x 0.5) y) (- 0.918938533204673 x)))
double code(double x, double y) {
double tmp;
if ((y <= -1.32) || !(y <= 1.75)) {
tmp = (x - 0.5) * y;
} else {
tmp = 0.918938533204673 - x;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-1.32d0)) .or. (.not. (y <= 1.75d0))) then
tmp = (x - 0.5d0) * y
else
tmp = 0.918938533204673d0 - x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.32) || !(y <= 1.75)) {
tmp = (x - 0.5) * y;
} else {
tmp = 0.918938533204673 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.32) or not (y <= 1.75): tmp = (x - 0.5) * y else: tmp = 0.918938533204673 - x return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.32) || !(y <= 1.75)) tmp = Float64(Float64(x - 0.5) * y); else tmp = Float64(0.918938533204673 - x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.32) || ~((y <= 1.75))) tmp = (x - 0.5) * y; else tmp = 0.918938533204673 - x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.32], N[Not[LessEqual[y, 1.75]], $MachinePrecision]], N[(N[(x - 0.5), $MachinePrecision] * y), $MachinePrecision], N[(0.918938533204673 - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.32 \lor \neg \left(y \leq 1.75\right):\\
\;\;\;\;\left(x - 0.5\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673 - x\\
\end{array}
\end{array}
if y < -1.32000000000000006 or 1.75 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6499.2
Applied rewrites99.2%
if -1.32000000000000006 < y < 1.75Initial program 100.0%
Taylor expanded in y around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6498.6
Applied rewrites98.6%
Final simplification98.9%
(FPCore (x y) :precision binary64 (if (or (<= y -68.0) (not (<= y 1.85))) (* -0.5 y) (- 0.918938533204673 x)))
double code(double x, double y) {
double tmp;
if ((y <= -68.0) || !(y <= 1.85)) {
tmp = -0.5 * y;
} else {
tmp = 0.918938533204673 - x;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-68.0d0)) .or. (.not. (y <= 1.85d0))) then
tmp = (-0.5d0) * y
else
tmp = 0.918938533204673d0 - x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -68.0) || !(y <= 1.85)) {
tmp = -0.5 * y;
} else {
tmp = 0.918938533204673 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -68.0) or not (y <= 1.85): tmp = -0.5 * y else: tmp = 0.918938533204673 - x return tmp
function code(x, y) tmp = 0.0 if ((y <= -68.0) || !(y <= 1.85)) tmp = Float64(-0.5 * y); else tmp = Float64(0.918938533204673 - x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -68.0) || ~((y <= 1.85))) tmp = -0.5 * y; else tmp = 0.918938533204673 - x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -68.0], N[Not[LessEqual[y, 1.85]], $MachinePrecision]], N[(-0.5 * y), $MachinePrecision], N[(0.918938533204673 - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -68 \lor \neg \left(y \leq 1.85\right):\\
\;\;\;\;-0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673 - x\\
\end{array}
\end{array}
if y < -68 or 1.8500000000000001 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6499.2
Applied rewrites99.2%
Taylor expanded in x around 0
Applied rewrites51.2%
if -68 < y < 1.8500000000000001Initial program 100.0%
Taylor expanded in y around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6498.6
Applied rewrites98.6%
Final simplification74.5%
(FPCore (x y) :precision binary64 (if (or (<= x -0.92) (not (<= x 210000.0))) (- x) 0.918938533204673))
double code(double x, double y) {
double tmp;
if ((x <= -0.92) || !(x <= 210000.0)) {
tmp = -x;
} else {
tmp = 0.918938533204673;
}
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 <= (-0.92d0)) .or. (.not. (x <= 210000.0d0))) then
tmp = -x
else
tmp = 0.918938533204673d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -0.92) || !(x <= 210000.0)) {
tmp = -x;
} else {
tmp = 0.918938533204673;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -0.92) or not (x <= 210000.0): tmp = -x else: tmp = 0.918938533204673 return tmp
function code(x, y) tmp = 0.0 if ((x <= -0.92) || !(x <= 210000.0)) tmp = Float64(-x); else tmp = 0.918938533204673; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -0.92) || ~((x <= 210000.0))) tmp = -x; else tmp = 0.918938533204673; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -0.92], N[Not[LessEqual[x, 210000.0]], $MachinePrecision]], (-x), 0.918938533204673]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.92 \lor \neg \left(x \leq 210000\right):\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;0.918938533204673\\
\end{array}
\end{array}
if x < -0.92000000000000004 or 2.1e5 < x Initial program 100.0%
Taylor expanded in y around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6451.5
Applied rewrites51.5%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6451.5
Applied rewrites51.5%
if -0.92000000000000004 < x < 2.1e5Initial program 100.0%
Taylor expanded in y around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6448.9
Applied rewrites48.9%
Taylor expanded in x around 0
Applied rewrites46.2%
Final simplification48.7%
(FPCore (x y) :precision binary64 (fma (- x 0.5) y (- 0.918938533204673 x)))
double code(double x, double y) {
return fma((x - 0.5), y, (0.918938533204673 - x));
}
function code(x, y) return fma(Float64(x - 0.5), y, Float64(0.918938533204673 - x)) end
code[x_, y_] := N[(N[(x - 0.5), $MachinePrecision] * y + N[(0.918938533204673 - x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x - 0.5, y, 0.918938533204673 - x\right)
\end{array}
Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64100.0
Applied rewrites100.0%
(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]
\begin{array}{l}
\\
0.918938533204673 - x
\end{array}
Initial program 100.0%
Taylor expanded in y around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6450.2
Applied rewrites50.2%
(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
\begin{array}{l}
\\
0.918938533204673
\end{array}
Initial program 100.0%
Taylor expanded in y around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6450.2
Applied rewrites50.2%
Taylor expanded in x around 0
Applied rewrites25.3%
herbie shell --seed 2025072
(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))