
(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}
Herbie found 10 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 (- x 0.5) (- 0.918938533204673 x)))
double code(double x, double y) {
return fma(y, (x - 0.5), (0.918938533204673 - x));
}
function code(x, y) return fma(y, Float64(x - 0.5), Float64(0.918938533204673 - x)) end
code[x_, y_] := N[(y * N[(x - 0.5), $MachinePrecision] + N[(0.918938533204673 - x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, x - 0.5, 0.918938533204673 - x\right)
\end{array}
Initial program 100.0%
Applied rewrites100.0%
(FPCore (x y) :precision binary64 (if (<= y -1.22) (* y (- x 0.5)) (if (<= y 1.2) (- 0.918938533204673 x) (fma -0.5 y (* x y)))))
double code(double x, double y) {
double tmp;
if (y <= -1.22) {
tmp = y * (x - 0.5);
} else if (y <= 1.2) {
tmp = 0.918938533204673 - x;
} else {
tmp = fma(-0.5, y, (x * y));
}
return tmp;
}
function code(x, y) tmp = 0.0 if (y <= -1.22) tmp = Float64(y * Float64(x - 0.5)); elseif (y <= 1.2) tmp = Float64(0.918938533204673 - x); else tmp = fma(-0.5, y, Float64(x * y)); end return tmp end
code[x_, y_] := If[LessEqual[y, -1.22], N[(y * N[(x - 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.2], N[(0.918938533204673 - x), $MachinePrecision], N[(-0.5 * y + N[(x * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.22:\\
\;\;\;\;y \cdot \left(x - 0.5\right)\\
\mathbf{elif}\;y \leq 1.2:\\
\;\;\;\;0.918938533204673 - x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, y, x \cdot y\right)\\
\end{array}
\end{array}
if y < -1.21999999999999997Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites50.7%
if -1.21999999999999997 < y < 1.19999999999999996Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites50.6%
if 1.19999999999999996 < y Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites50.7%
Taylor expanded in x around 0
Applied rewrites50.7%
(FPCore (x y) :precision binary64 (let* ((t_0 (* y (- x 0.5)))) (if (<= y -1.22) t_0 (if (<= y 1.2) (- 0.918938533204673 x) t_0))))
double code(double x, double y) {
double t_0 = y * (x - 0.5);
double tmp;
if (y <= -1.22) {
tmp = t_0;
} else if (y <= 1.2) {
tmp = 0.918938533204673 - x;
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = y * (x - 0.5d0)
if (y <= (-1.22d0)) then
tmp = t_0
else if (y <= 1.2d0) then
tmp = 0.918938533204673d0 - x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y * (x - 0.5);
double tmp;
if (y <= -1.22) {
tmp = t_0;
} else if (y <= 1.2) {
tmp = 0.918938533204673 - x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = y * (x - 0.5) tmp = 0 if y <= -1.22: tmp = t_0 elif y <= 1.2: tmp = 0.918938533204673 - x else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(y * Float64(x - 0.5)) tmp = 0.0 if (y <= -1.22) tmp = t_0; elseif (y <= 1.2) tmp = Float64(0.918938533204673 - x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = y * (x - 0.5); tmp = 0.0; if (y <= -1.22) tmp = t_0; elseif (y <= 1.2) tmp = 0.918938533204673 - x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(x - 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.22], t$95$0, If[LessEqual[y, 1.2], N[(0.918938533204673 - x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(x - 0.5\right)\\
\mathbf{if}\;y \leq -1.22:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.2:\\
\;\;\;\;0.918938533204673 - x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.21999999999999997 or 1.19999999999999996 < y Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites50.7%
if -1.21999999999999997 < y < 1.19999999999999996Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites50.6%
(FPCore (x y)
:precision binary64
(if (<= y -27.5)
(* x y)
(if (<= y 1.85)
(- 0.918938533204673 x)
(if (<= y 2.8e+51) (* y -0.5) (if (<= y 4e+191) (* x y) (* y -0.5))))))
double code(double x, double y) {
double tmp;
if (y <= -27.5) {
tmp = x * y;
} else if (y <= 1.85) {
tmp = 0.918938533204673 - x;
} else if (y <= 2.8e+51) {
tmp = y * -0.5;
} else if (y <= 4e+191) {
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 <= (-27.5d0)) then
tmp = x * y
else if (y <= 1.85d0) then
tmp = 0.918938533204673d0 - x
else if (y <= 2.8d+51) then
tmp = y * (-0.5d0)
else if (y <= 4d+191) 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 <= -27.5) {
tmp = x * y;
} else if (y <= 1.85) {
tmp = 0.918938533204673 - x;
} else if (y <= 2.8e+51) {
tmp = y * -0.5;
} else if (y <= 4e+191) {
tmp = x * y;
} else {
tmp = y * -0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -27.5: tmp = x * y elif y <= 1.85: tmp = 0.918938533204673 - x elif y <= 2.8e+51: tmp = y * -0.5 elif y <= 4e+191: tmp = x * y else: tmp = y * -0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= -27.5) tmp = Float64(x * y); elseif (y <= 1.85) tmp = Float64(0.918938533204673 - x); elseif (y <= 2.8e+51) tmp = Float64(y * -0.5); elseif (y <= 4e+191) 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 <= -27.5) tmp = x * y; elseif (y <= 1.85) tmp = 0.918938533204673 - x; elseif (y <= 2.8e+51) tmp = y * -0.5; elseif (y <= 4e+191) tmp = x * y; else tmp = y * -0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -27.5], N[(x * y), $MachinePrecision], If[LessEqual[y, 1.85], N[(0.918938533204673 - x), $MachinePrecision], If[LessEqual[y, 2.8e+51], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 4e+191], N[(x * y), $MachinePrecision], N[(y * -0.5), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -27.5:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;y \leq 1.85:\\
\;\;\;\;0.918938533204673 - x\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{+51}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+191}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;y \cdot -0.5\\
\end{array}
\end{array}
if y < -27.5 or 2.80000000000000005e51 < y < 4.00000000000000029e191Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites50.6%
Taylor expanded in x around inf
Applied rewrites51.2%
Taylor expanded in y around inf
Applied rewrites26.5%
if -27.5 < y < 1.8500000000000001Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites50.6%
if 1.8500000000000001 < y < 2.80000000000000005e51 or 4.00000000000000029e191 < y Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites50.7%
Taylor expanded in x around 0
Applied rewrites26.2%
(FPCore (x y)
:precision binary64
(if (<= y -4e-11)
(- (* y x) x)
(if (<= y 3.5e-11)
(- 0.918938533204673 x)
(if (<= y 4e+191) (* x (- y 1.0)) (* y -0.5)))))
double code(double x, double y) {
double tmp;
if (y <= -4e-11) {
tmp = (y * x) - x;
} else if (y <= 3.5e-11) {
tmp = 0.918938533204673 - x;
} else if (y <= 4e+191) {
tmp = x * (y - 1.0);
} 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 <= (-4d-11)) then
tmp = (y * x) - x
else if (y <= 3.5d-11) then
tmp = 0.918938533204673d0 - x
else if (y <= 4d+191) then
tmp = x * (y - 1.0d0)
else
tmp = y * (-0.5d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -4e-11) {
tmp = (y * x) - x;
} else if (y <= 3.5e-11) {
tmp = 0.918938533204673 - x;
} else if (y <= 4e+191) {
tmp = x * (y - 1.0);
} else {
tmp = y * -0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -4e-11: tmp = (y * x) - x elif y <= 3.5e-11: tmp = 0.918938533204673 - x elif y <= 4e+191: tmp = x * (y - 1.0) else: tmp = y * -0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= -4e-11) tmp = Float64(Float64(y * x) - x); elseif (y <= 3.5e-11) tmp = Float64(0.918938533204673 - x); elseif (y <= 4e+191) tmp = Float64(x * Float64(y - 1.0)); else tmp = Float64(y * -0.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -4e-11) tmp = (y * x) - x; elseif (y <= 3.5e-11) tmp = 0.918938533204673 - x; elseif (y <= 4e+191) tmp = x * (y - 1.0); else tmp = y * -0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -4e-11], N[(N[(y * x), $MachinePrecision] - x), $MachinePrecision], If[LessEqual[y, 3.5e-11], N[(0.918938533204673 - x), $MachinePrecision], If[LessEqual[y, 4e+191], N[(x * N[(y - 1.0), $MachinePrecision]), $MachinePrecision], N[(y * -0.5), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{-11}:\\
\;\;\;\;y \cdot x - x\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{-11}:\\
\;\;\;\;0.918938533204673 - x\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+191}:\\
\;\;\;\;x \cdot \left(y - 1\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot -0.5\\
\end{array}
\end{array}
if y < -3.99999999999999976e-11Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites50.6%
Taylor expanded in x around inf
Applied rewrites51.2%
Applied rewrites51.2%
if -3.99999999999999976e-11 < y < 3.50000000000000019e-11Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites50.6%
if 3.50000000000000019e-11 < y < 4.00000000000000029e191Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites50.6%
Taylor expanded in x around inf
Applied rewrites51.2%
if 4.00000000000000029e191 < y Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites50.7%
Taylor expanded in x around 0
Applied rewrites26.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (- y 1.0))))
(if (<= y -4e-11)
t_0
(if (<= y 3.5e-11)
(- 0.918938533204673 x)
(if (<= y 4e+191) t_0 (* y -0.5))))))
double code(double x, double y) {
double t_0 = x * (y - 1.0);
double tmp;
if (y <= -4e-11) {
tmp = t_0;
} else if (y <= 3.5e-11) {
tmp = 0.918938533204673 - x;
} else if (y <= 4e+191) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = x * (y - 1.0d0)
if (y <= (-4d-11)) then
tmp = t_0
else if (y <= 3.5d-11) then
tmp = 0.918938533204673d0 - x
else if (y <= 4d+191) then
tmp = t_0
else
tmp = y * (-0.5d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x * (y - 1.0);
double tmp;
if (y <= -4e-11) {
tmp = t_0;
} else if (y <= 3.5e-11) {
tmp = 0.918938533204673 - x;
} else if (y <= 4e+191) {
tmp = t_0;
} else {
tmp = y * -0.5;
}
return tmp;
}
def code(x, y): t_0 = x * (y - 1.0) tmp = 0 if y <= -4e-11: tmp = t_0 elif y <= 3.5e-11: tmp = 0.918938533204673 - x elif y <= 4e+191: tmp = t_0 else: tmp = y * -0.5 return tmp
function code(x, y) t_0 = Float64(x * Float64(y - 1.0)) tmp = 0.0 if (y <= -4e-11) tmp = t_0; elseif (y <= 3.5e-11) tmp = Float64(0.918938533204673 - x); elseif (y <= 4e+191) tmp = t_0; else tmp = Float64(y * -0.5); end return tmp end
function tmp_2 = code(x, y) t_0 = x * (y - 1.0); tmp = 0.0; if (y <= -4e-11) tmp = t_0; elseif (y <= 3.5e-11) tmp = 0.918938533204673 - x; elseif (y <= 4e+191) tmp = t_0; else tmp = y * -0.5; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(y - 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4e-11], t$95$0, If[LessEqual[y, 3.5e-11], N[(0.918938533204673 - x), $MachinePrecision], If[LessEqual[y, 4e+191], t$95$0, N[(y * -0.5), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(y - 1\right)\\
\mathbf{if}\;y \leq -4 \cdot 10^{-11}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{-11}:\\
\;\;\;\;0.918938533204673 - x\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+191}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;y \cdot -0.5\\
\end{array}
\end{array}
if y < -3.99999999999999976e-11 or 3.50000000000000019e-11 < y < 4.00000000000000029e191Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites50.6%
Taylor expanded in x around inf
Applied rewrites51.2%
if -3.99999999999999976e-11 < y < 3.50000000000000019e-11Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites50.6%
if 4.00000000000000029e191 < y Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites50.7%
Taylor expanded in x around 0
Applied rewrites26.2%
(FPCore (x y) :precision binary64 (if (<= y -27.5) (* x y) (if (<= y 1.15) (- 0.918938533204673 x) (* x y))))
double code(double x, double y) {
double tmp;
if (y <= -27.5) {
tmp = x * y;
} else if (y <= 1.15) {
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 <= (-27.5d0)) then
tmp = x * y
else if (y <= 1.15d0) 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 <= -27.5) {
tmp = x * y;
} else if (y <= 1.15) {
tmp = 0.918938533204673 - x;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -27.5: tmp = x * y elif y <= 1.15: tmp = 0.918938533204673 - x else: tmp = x * y return tmp
function code(x, y) tmp = 0.0 if (y <= -27.5) tmp = Float64(x * y); elseif (y <= 1.15) 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 <= -27.5) tmp = x * y; elseif (y <= 1.15) tmp = 0.918938533204673 - x; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -27.5], N[(x * y), $MachinePrecision], If[LessEqual[y, 1.15], N[(0.918938533204673 - x), $MachinePrecision], N[(x * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -27.5:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;y \leq 1.15:\\
\;\;\;\;0.918938533204673 - x\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if y < -27.5 or 1.1499999999999999 < y Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites50.6%
Taylor expanded in x around inf
Applied rewrites51.2%
Taylor expanded in y around inf
Applied rewrites26.5%
if -27.5 < y < 1.1499999999999999Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites50.6%
(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%
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites50.6%
(FPCore (x y) :precision binary64 (if (<= x -0.92) (- x) (if (<= x 0.92) 0.918938533204673 (- x))))
double code(double x, double y) {
double tmp;
if (x <= -0.92) {
tmp = -x;
} else if (x <= 0.92) {
tmp = 0.918938533204673;
} else {
tmp = -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 (x <= (-0.92d0)) then
tmp = -x
else if (x <= 0.92d0) then
tmp = 0.918938533204673d0
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -0.92) {
tmp = -x;
} else if (x <= 0.92) {
tmp = 0.918938533204673;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -0.92: tmp = -x elif x <= 0.92: tmp = 0.918938533204673 else: tmp = -x return tmp
function code(x, y) tmp = 0.0 if (x <= -0.92) tmp = Float64(-x); elseif (x <= 0.92) tmp = 0.918938533204673; else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -0.92) tmp = -x; elseif (x <= 0.92) tmp = 0.918938533204673; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -0.92], (-x), If[LessEqual[x, 0.92], 0.918938533204673, (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.92:\\
\;\;\;\;-x\\
\mathbf{elif}\;x \leq 0.92:\\
\;\;\;\;0.918938533204673\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if x < -0.92000000000000004 or 0.92000000000000004 < x Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites50.6%
Taylor expanded in x around inf
Applied rewrites26.7%
Applied rewrites26.7%
if -0.92000000000000004 < x < 0.92000000000000004Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites50.6%
Taylor expanded in x around 0
Applied rewrites25.7%
(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%
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites50.6%
Taylor expanded in x around 0
Applied rewrites25.7%
herbie shell --seed 2025153
(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))