
(FPCore (x y z) :precision binary64 (- (+ (- x (* (+ y 0.5) (log y))) y) z))
double code(double x, double y, double z) {
return ((x - ((y + 0.5) * log(y))) + y) - z;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((x - ((y + 0.5d0) * log(y))) + y) - z
end function
public static double code(double x, double y, double z) {
return ((x - ((y + 0.5) * Math.log(y))) + y) - z;
}
def code(x, y, z): return ((x - ((y + 0.5) * math.log(y))) + y) - z
function code(x, y, z) return Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z) end
function tmp = code(x, y, z) tmp = ((x - ((y + 0.5) * log(y))) + y) - z; end
code[x_, y_, z_] := N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (- (+ (- x (* (+ y 0.5) (log y))) y) z))
double code(double x, double y, double z) {
return ((x - ((y + 0.5) * log(y))) + y) - z;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((x - ((y + 0.5d0) * log(y))) + y) - z
end function
public static double code(double x, double y, double z) {
return ((x - ((y + 0.5) * Math.log(y))) + y) - z;
}
def code(x, y, z): return ((x - ((y + 0.5) * math.log(y))) + y) - z
function code(x, y, z) return Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z) end
function tmp = code(x, y, z) tmp = ((x - ((y + 0.5) * log(y))) + y) - z; end
code[x_, y_, z_] := N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
\end{array}
(FPCore (x y z) :precision binary64 (- (- (+ y x) (* (log y) (+ 0.5 y))) z))
double code(double x, double y, double z) {
return ((y + x) - (log(y) * (0.5 + y))) - z;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((y + x) - (log(y) * (0.5d0 + y))) - z
end function
public static double code(double x, double y, double z) {
return ((y + x) - (Math.log(y) * (0.5 + y))) - z;
}
def code(x, y, z): return ((y + x) - (math.log(y) * (0.5 + y))) - z
function code(x, y, z) return Float64(Float64(Float64(y + x) - Float64(log(y) * Float64(0.5 + y))) - z) end
function tmp = code(x, y, z) tmp = ((y + x) - (log(y) * (0.5 + y))) - z; end
code[x_, y_, z_] := N[(N[(N[(y + x), $MachinePrecision] - N[(N[Log[y], $MachinePrecision] * N[(0.5 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(y + x\right) - \log y \cdot \left(0.5 + y\right)\right) - z
\end{array}
Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lower-+.f6499.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (- x (* (+ y 0.5) (log y))) y)) (t_1 (* (- y x) (- y 0.5))))
(if (<= t_0 -5e+140)
(* (- 1.0 (log y)) y)
(if (<= t_0 -2000000000000.0)
(- (/ (* (* (- y 0.5) x) (- x)) t_1) z)
(if (<= t_0 500.0)
(fma -0.5 (log y) (- z))
(- (/ (* (* x x) 0.5) t_1) z))))))
double code(double x, double y, double z) {
double t_0 = (x - ((y + 0.5) * log(y))) + y;
double t_1 = (y - x) * (y - 0.5);
double tmp;
if (t_0 <= -5e+140) {
tmp = (1.0 - log(y)) * y;
} else if (t_0 <= -2000000000000.0) {
tmp = ((((y - 0.5) * x) * -x) / t_1) - z;
} else if (t_0 <= 500.0) {
tmp = fma(-0.5, log(y), -z);
} else {
tmp = (((x * x) * 0.5) / t_1) - z;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) t_1 = Float64(Float64(y - x) * Float64(y - 0.5)) tmp = 0.0 if (t_0 <= -5e+140) tmp = Float64(Float64(1.0 - log(y)) * y); elseif (t_0 <= -2000000000000.0) tmp = Float64(Float64(Float64(Float64(Float64(y - 0.5) * x) * Float64(-x)) / t_1) - z); elseif (t_0 <= 500.0) tmp = fma(-0.5, log(y), Float64(-z)); else tmp = Float64(Float64(Float64(Float64(x * x) * 0.5) / t_1) - z); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision]}, Block[{t$95$1 = N[(N[(y - x), $MachinePrecision] * N[(y - 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+140], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$0, -2000000000000.0], N[(N[(N[(N[(N[(y - 0.5), $MachinePrecision] * x), $MachinePrecision] * (-x)), $MachinePrecision] / t$95$1), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[t$95$0, 500.0], N[(-0.5 * N[Log[y], $MachinePrecision] + (-z)), $MachinePrecision], N[(N[(N[(N[(x * x), $MachinePrecision] * 0.5), $MachinePrecision] / t$95$1), $MachinePrecision] - z), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - \left(y + 0.5\right) \cdot \log y\right) + y\\
t_1 := \left(y - x\right) \cdot \left(y - 0.5\right)\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+140}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y\\
\mathbf{elif}\;t\_0 \leq -2000000000000:\\
\;\;\;\;\frac{\left(\left(y - 0.5\right) \cdot x\right) \cdot \left(-x\right)}{t\_1} - z\\
\mathbf{elif}\;t\_0 \leq 500:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, -z\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x \cdot x\right) \cdot 0.5}{t\_1} - z\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -5.00000000000000008e140Initial program 99.7%
Taylor expanded in y around inf
*-commutativeN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6456.3
Applied rewrites56.3%
if -5.00000000000000008e140 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -2e12Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lower-+.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
flip-+N/A
distribute-lft-neg-outN/A
*-commutativeN/A
distribute-lft-neg-outN/A
lift-+.f64N/A
+-commutativeN/A
flip-+N/A
associate-*r/N/A
frac-addN/A
lower-/.f64N/A
Applied rewrites69.2%
Taylor expanded in x around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
unpow2N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f6456.9
Applied rewrites56.9%
Applied rewrites56.9%
if -2e12 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 500Initial program 99.9%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-lft-identityN/A
*-lft-identityN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6499.0
Applied rewrites99.0%
Taylor expanded in y around 0
Applied rewrites96.1%
if 500 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lower-+.f64100.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
flip-+N/A
distribute-lft-neg-outN/A
*-commutativeN/A
distribute-lft-neg-outN/A
lift-+.f64N/A
+-commutativeN/A
flip-+N/A
associate-*r/N/A
frac-addN/A
lower-/.f64N/A
Applied rewrites43.9%
Taylor expanded in x around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
unpow2N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f6443.9
Applied rewrites43.9%
Taylor expanded in y around 0
Applied rewrites45.8%
Final simplification66.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (+ (- x (* (+ y 0.5) (log y))) y) z)))
(if (<= t_0 -500000000.0)
(- (/ (/ (* (* (- y 0.5) x) (- x)) (- y x)) (- y 0.5)) z)
(if (<= t_0 500.0)
(* -0.5 (log y))
(- (/ (* (* x x) 0.5) (* (- y x) (- y 0.5))) z)))))
double code(double x, double y, double z) {
double t_0 = ((x - ((y + 0.5) * log(y))) + y) - z;
double tmp;
if (t_0 <= -500000000.0) {
tmp = (((((y - 0.5) * x) * -x) / (y - x)) / (y - 0.5)) - z;
} else if (t_0 <= 500.0) {
tmp = -0.5 * log(y);
} else {
tmp = (((x * x) * 0.5) / ((y - x) * (y - 0.5))) - z;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = ((x - ((y + 0.5d0) * log(y))) + y) - z
if (t_0 <= (-500000000.0d0)) then
tmp = (((((y - 0.5d0) * x) * -x) / (y - x)) / (y - 0.5d0)) - z
else if (t_0 <= 500.0d0) then
tmp = (-0.5d0) * log(y)
else
tmp = (((x * x) * 0.5d0) / ((y - x) * (y - 0.5d0))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((x - ((y + 0.5) * Math.log(y))) + y) - z;
double tmp;
if (t_0 <= -500000000.0) {
tmp = (((((y - 0.5) * x) * -x) / (y - x)) / (y - 0.5)) - z;
} else if (t_0 <= 500.0) {
tmp = -0.5 * Math.log(y);
} else {
tmp = (((x * x) * 0.5) / ((y - x) * (y - 0.5))) - z;
}
return tmp;
}
def code(x, y, z): t_0 = ((x - ((y + 0.5) * math.log(y))) + y) - z tmp = 0 if t_0 <= -500000000.0: tmp = (((((y - 0.5) * x) * -x) / (y - x)) / (y - 0.5)) - z elif t_0 <= 500.0: tmp = -0.5 * math.log(y) else: tmp = (((x * x) * 0.5) / ((y - x) * (y - 0.5))) - z return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z) tmp = 0.0 if (t_0 <= -500000000.0) tmp = Float64(Float64(Float64(Float64(Float64(Float64(y - 0.5) * x) * Float64(-x)) / Float64(y - x)) / Float64(y - 0.5)) - z); elseif (t_0 <= 500.0) tmp = Float64(-0.5 * log(y)); else tmp = Float64(Float64(Float64(Float64(x * x) * 0.5) / Float64(Float64(y - x) * Float64(y - 0.5))) - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((x - ((y + 0.5) * log(y))) + y) - z; tmp = 0.0; if (t_0 <= -500000000.0) tmp = (((((y - 0.5) * x) * -x) / (y - x)) / (y - 0.5)) - z; elseif (t_0 <= 500.0) tmp = -0.5 * log(y); else tmp = (((x * x) * 0.5) / ((y - x) * (y - 0.5))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[t$95$0, -500000000.0], N[(N[(N[(N[(N[(N[(y - 0.5), $MachinePrecision] * x), $MachinePrecision] * (-x)), $MachinePrecision] / N[(y - x), $MachinePrecision]), $MachinePrecision] / N[(y - 0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[t$95$0, 500.0], N[(-0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(x * x), $MachinePrecision] * 0.5), $MachinePrecision] / N[(N[(y - x), $MachinePrecision] * N[(y - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z\\
\mathbf{if}\;t\_0 \leq -500000000:\\
\;\;\;\;\frac{\frac{\left(\left(y - 0.5\right) \cdot x\right) \cdot \left(-x\right)}{y - x}}{y - 0.5} - z\\
\mathbf{elif}\;t\_0 \leq 500:\\
\;\;\;\;-0.5 \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x \cdot x\right) \cdot 0.5}{\left(y - x\right) \cdot \left(y - 0.5\right)} - z\\
\end{array}
\end{array}
if (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) z) < -5e8Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lower-+.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
flip-+N/A
distribute-lft-neg-outN/A
*-commutativeN/A
distribute-lft-neg-outN/A
lift-+.f64N/A
+-commutativeN/A
flip-+N/A
associate-*r/N/A
frac-addN/A
lower-/.f64N/A
Applied rewrites37.0%
Taylor expanded in x around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
unpow2N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f6429.5
Applied rewrites29.5%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites32.0%
if -5e8 < (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) z) < 500Initial program 99.9%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-lft-identityN/A
*-lft-identityN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6498.2
Applied rewrites98.2%
Taylor expanded in y around 0
Applied rewrites92.8%
Taylor expanded in z around 0
Applied rewrites91.4%
if 500 < (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) z) Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lower-+.f64100.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
flip-+N/A
distribute-lft-neg-outN/A
*-commutativeN/A
distribute-lft-neg-outN/A
lift-+.f64N/A
+-commutativeN/A
flip-+N/A
associate-*r/N/A
frac-addN/A
lower-/.f64N/A
Applied rewrites58.3%
Taylor expanded in x around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
unpow2N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f6463.3
Applied rewrites63.3%
Taylor expanded in y around 0
Applied rewrites64.8%
(FPCore (x y z)
:precision binary64
(if (<= x -2200000.0)
(- (/ (/ (* (* (- y 0.5) x) (- x)) (- y x)) (- y 0.5)) z)
(if (or (<= x 7.2e+20) (not (<= x 1.35e+154)))
(fma -0.5 (log y) (- z))
(- (/ (* (* x x) 0.5) (* (- y x) (- y 0.5))) z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2200000.0) {
tmp = (((((y - 0.5) * x) * -x) / (y - x)) / (y - 0.5)) - z;
} else if ((x <= 7.2e+20) || !(x <= 1.35e+154)) {
tmp = fma(-0.5, log(y), -z);
} else {
tmp = (((x * x) * 0.5) / ((y - x) * (y - 0.5))) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -2200000.0) tmp = Float64(Float64(Float64(Float64(Float64(Float64(y - 0.5) * x) * Float64(-x)) / Float64(y - x)) / Float64(y - 0.5)) - z); elseif ((x <= 7.2e+20) || !(x <= 1.35e+154)) tmp = fma(-0.5, log(y), Float64(-z)); else tmp = Float64(Float64(Float64(Float64(x * x) * 0.5) / Float64(Float64(y - x) * Float64(y - 0.5))) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -2200000.0], N[(N[(N[(N[(N[(N[(y - 0.5), $MachinePrecision] * x), $MachinePrecision] * (-x)), $MachinePrecision] / N[(y - x), $MachinePrecision]), $MachinePrecision] / N[(y - 0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[Or[LessEqual[x, 7.2e+20], N[Not[LessEqual[x, 1.35e+154]], $MachinePrecision]], N[(-0.5 * N[Log[y], $MachinePrecision] + (-z)), $MachinePrecision], N[(N[(N[(N[(x * x), $MachinePrecision] * 0.5), $MachinePrecision] / N[(N[(y - x), $MachinePrecision] * N[(y - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2200000:\\
\;\;\;\;\frac{\frac{\left(\left(y - 0.5\right) \cdot x\right) \cdot \left(-x\right)}{y - x}}{y - 0.5} - z\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{+20} \lor \neg \left(x \leq 1.35 \cdot 10^{+154}\right):\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, -z\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x \cdot x\right) \cdot 0.5}{\left(y - x\right) \cdot \left(y - 0.5\right)} - z\\
\end{array}
\end{array}
if x < -2.2e6Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lower-+.f6499.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
flip-+N/A
distribute-lft-neg-outN/A
*-commutativeN/A
distribute-lft-neg-outN/A
lift-+.f64N/A
+-commutativeN/A
flip-+N/A
associate-*r/N/A
frac-addN/A
lower-/.f64N/A
Applied rewrites29.5%
Taylor expanded in x around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
unpow2N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f6428.9
Applied rewrites28.9%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites33.2%
if -2.2e6 < x < 7.2e20 or 1.35000000000000003e154 < x Initial program 99.8%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-lft-identityN/A
*-lft-identityN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6486.7
Applied rewrites86.7%
Taylor expanded in y around 0
Applied rewrites59.6%
if 7.2e20 < x < 1.35000000000000003e154Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lower-+.f6499.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
flip-+N/A
distribute-lft-neg-outN/A
*-commutativeN/A
distribute-lft-neg-outN/A
lift-+.f64N/A
+-commutativeN/A
flip-+N/A
associate-*r/N/A
frac-addN/A
lower-/.f64N/A
Applied rewrites59.9%
Taylor expanded in x around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
unpow2N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f6460.5
Applied rewrites60.5%
Taylor expanded in y around 0
Applied rewrites67.4%
Final simplification54.8%
(FPCore (x y z) :precision binary64 (if (<= y 5.8e-8) (- (fma -0.5 (log y) x) z) (- (- (+ y x) (* (log y) y)) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 5.8e-8) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = ((y + x) - (log(y) * y)) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 5.8e-8) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = Float64(Float64(Float64(y + x) - Float64(log(y) * y)) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 5.8e-8], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[(y + x), $MachinePrecision] - N[(N[Log[y], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.8 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(\left(y + x\right) - \log y \cdot y\right) - z\\
\end{array}
\end{array}
if y < 5.8000000000000003e-8Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6499.6
Applied rewrites99.6%
if 5.8000000000000003e-8 < y Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lower-+.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
Taylor expanded in y around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
log-recN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-log.f6498.7
Applied rewrites98.7%
(FPCore (x y z) :precision binary64 (if (<= y 5.8e-8) (- (fma -0.5 (log y) x) z) (- (+ (- x (* (log y) y)) y) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 5.8e-8) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = ((x - (log(y) * y)) + y) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 5.8e-8) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = Float64(Float64(Float64(x - Float64(log(y) * y)) + y) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 5.8e-8], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[(x - N[(N[Log[y], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.8 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(\left(x - \log y \cdot y\right) + y\right) - z\\
\end{array}
\end{array}
if y < 5.8000000000000003e-8Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6499.6
Applied rewrites99.6%
if 5.8000000000000003e-8 < y Initial program 99.8%
Taylor expanded in y around inf
*-commutativeN/A
associate-*r*N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lower-*.f64N/A
lower-log.f6498.7
Applied rewrites98.7%
Final simplification99.1%
(FPCore (x y z) :precision binary64 (if (<= y 0.68) (- (fma -0.5 (log y) x) z) (- y (fma (+ 0.5 y) (log y) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 0.68) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = y - fma((0.5 + y), log(y), z);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 0.68) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = Float64(y - fma(Float64(0.5 + y), log(y), z)); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 0.68], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(y - N[(N[(0.5 + y), $MachinePrecision] * N[Log[y], $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.68:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;y - \mathsf{fma}\left(0.5 + y, \log y, z\right)\\
\end{array}
\end{array}
if y < 0.680000000000000049Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6499.6
Applied rewrites99.6%
if 0.680000000000000049 < y Initial program 99.8%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-lft-identityN/A
*-lft-identityN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6480.4
Applied rewrites80.4%
(FPCore (x y z) :precision binary64 (if (<= y 7.5e+26) (- (fma -0.5 (log y) x) z) (- (* (- 1.0 (log y)) y) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 7.5e+26) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = ((1.0 - log(y)) * y) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 7.5e+26) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = Float64(Float64(Float64(1.0 - log(y)) * y) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 7.5e+26], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.5 \cdot 10^{+26}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y - z\\
\end{array}
\end{array}
if y < 7.49999999999999941e26Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6497.8
Applied rewrites97.8%
if 7.49999999999999941e26 < y Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lower-+.f6499.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
Applied rewrites99.7%
Taylor expanded in y around inf
*-commutativeN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6480.3
Applied rewrites80.3%
(FPCore (x y z) :precision binary64 (- (+ (- x (* (+ y 0.5) (log y))) y) z))
double code(double x, double y, double z) {
return ((x - ((y + 0.5) * log(y))) + y) - z;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((x - ((y + 0.5d0) * log(y))) + y) - z
end function
public static double code(double x, double y, double z) {
return ((x - ((y + 0.5) * Math.log(y))) + y) - z;
}
def code(x, y, z): return ((x - ((y + 0.5) * math.log(y))) + y) - z
function code(x, y, z) return Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z) end
function tmp = code(x, y, z) tmp = ((x - ((y + 0.5) * log(y))) + y) - z; end
code[x_, y_, z_] := N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
\end{array}
Initial program 99.9%
(FPCore (x y z) :precision binary64 (if (<= y 7.2e+136) (- (fma -0.5 (log y) x) z) (* (- 1.0 (log y)) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 7.2e+136) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = (1.0 - log(y)) * y;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 7.2e+136) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = Float64(Float64(1.0 - log(y)) * y); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 7.2e+136], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.2 \cdot 10^{+136}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y\\
\end{array}
\end{array}
if y < 7.20000000000000011e136Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6488.1
Applied rewrites88.1%
if 7.20000000000000011e136 < y Initial program 99.6%
Taylor expanded in y around inf
*-commutativeN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6482.1
Applied rewrites82.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -6.5e+215) (not (<= z 1.5e+121))) (- z) (- (/ (/ (* (* (- y 0.5) x) (- x)) (- y x)) (- y 0.5)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -6.5e+215) || !(z <= 1.5e+121)) {
tmp = -z;
} else {
tmp = (((((y - 0.5) * x) * -x) / (y - x)) / (y - 0.5)) - z;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-6.5d+215)) .or. (.not. (z <= 1.5d+121))) then
tmp = -z
else
tmp = (((((y - 0.5d0) * x) * -x) / (y - x)) / (y - 0.5d0)) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -6.5e+215) || !(z <= 1.5e+121)) {
tmp = -z;
} else {
tmp = (((((y - 0.5) * x) * -x) / (y - x)) / (y - 0.5)) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -6.5e+215) or not (z <= 1.5e+121): tmp = -z else: tmp = (((((y - 0.5) * x) * -x) / (y - x)) / (y - 0.5)) - z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -6.5e+215) || !(z <= 1.5e+121)) tmp = Float64(-z); else tmp = Float64(Float64(Float64(Float64(Float64(Float64(y - 0.5) * x) * Float64(-x)) / Float64(y - x)) / Float64(y - 0.5)) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -6.5e+215) || ~((z <= 1.5e+121))) tmp = -z; else tmp = (((((y - 0.5) * x) * -x) / (y - x)) / (y - 0.5)) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -6.5e+215], N[Not[LessEqual[z, 1.5e+121]], $MachinePrecision]], (-z), N[(N[(N[(N[(N[(N[(y - 0.5), $MachinePrecision] * x), $MachinePrecision] * (-x)), $MachinePrecision] / N[(y - x), $MachinePrecision]), $MachinePrecision] / N[(y - 0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.5 \cdot 10^{+215} \lor \neg \left(z \leq 1.5 \cdot 10^{+121}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(\left(y - 0.5\right) \cdot x\right) \cdot \left(-x\right)}{y - x}}{y - 0.5} - z\\
\end{array}
\end{array}
if z < -6.4999999999999997e215 or 1.5000000000000001e121 < z Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6478.7
Applied rewrites78.7%
if -6.4999999999999997e215 < z < 1.5000000000000001e121Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lower-+.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
flip-+N/A
distribute-lft-neg-outN/A
*-commutativeN/A
distribute-lft-neg-outN/A
lift-+.f64N/A
+-commutativeN/A
flip-+N/A
associate-*r/N/A
frac-addN/A
lower-/.f64N/A
Applied rewrites54.8%
Taylor expanded in x around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
unpow2N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f6428.2
Applied rewrites28.2%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites29.7%
Final simplification41.2%
(FPCore (x y z) :precision binary64 (if (<= y 4.4e+55) (- (/ (* (* (- y 0.5) x) (- x)) (* (- y x) (- y 0.5))) z) (- z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 4.4e+55) {
tmp = ((((y - 0.5) * x) * -x) / ((y - x) * (y - 0.5))) - z;
} else {
tmp = -z;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 4.4d+55) then
tmp = ((((y - 0.5d0) * x) * -x) / ((y - x) * (y - 0.5d0))) - z
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 4.4e+55) {
tmp = ((((y - 0.5) * x) * -x) / ((y - x) * (y - 0.5))) - z;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 4.4e+55: tmp = ((((y - 0.5) * x) * -x) / ((y - x) * (y - 0.5))) - z else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= 4.4e+55) tmp = Float64(Float64(Float64(Float64(Float64(y - 0.5) * x) * Float64(-x)) / Float64(Float64(y - x) * Float64(y - 0.5))) - z); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 4.4e+55) tmp = ((((y - 0.5) * x) * -x) / ((y - x) * (y - 0.5))) - z; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 4.4e+55], N[(N[(N[(N[(N[(y - 0.5), $MachinePrecision] * x), $MachinePrecision] * (-x)), $MachinePrecision] / N[(N[(y - x), $MachinePrecision] * N[(y - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], (-z)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.4 \cdot 10^{+55}:\\
\;\;\;\;\frac{\left(\left(y - 0.5\right) \cdot x\right) \cdot \left(-x\right)}{\left(y - x\right) \cdot \left(y - 0.5\right)} - z\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < 4.40000000000000021e55Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lower-+.f64100.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
flip-+N/A
distribute-lft-neg-outN/A
*-commutativeN/A
distribute-lft-neg-outN/A
lift-+.f64N/A
+-commutativeN/A
flip-+N/A
associate-*r/N/A
frac-addN/A
lower-/.f64N/A
Applied rewrites79.4%
Taylor expanded in x around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
unpow2N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f6450.2
Applied rewrites50.2%
Applied rewrites50.2%
if 4.40000000000000021e55 < y Initial program 99.7%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6421.4
Applied rewrites21.4%
Final simplification38.8%
(FPCore (x y z) :precision binary64 (if (<= y 4.4e+55) (- (/ (* (* (- x) x) (- y 0.5)) (* (- y x) (- y 0.5))) z) (- z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 4.4e+55) {
tmp = (((-x * x) * (y - 0.5)) / ((y - x) * (y - 0.5))) - z;
} else {
tmp = -z;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 4.4d+55) then
tmp = (((-x * x) * (y - 0.5d0)) / ((y - x) * (y - 0.5d0))) - z
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 4.4e+55) {
tmp = (((-x * x) * (y - 0.5)) / ((y - x) * (y - 0.5))) - z;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 4.4e+55: tmp = (((-x * x) * (y - 0.5)) / ((y - x) * (y - 0.5))) - z else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= 4.4e+55) tmp = Float64(Float64(Float64(Float64(Float64(-x) * x) * Float64(y - 0.5)) / Float64(Float64(y - x) * Float64(y - 0.5))) - z); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 4.4e+55) tmp = (((-x * x) * (y - 0.5)) / ((y - x) * (y - 0.5))) - z; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 4.4e+55], N[(N[(N[(N[((-x) * x), $MachinePrecision] * N[(y - 0.5), $MachinePrecision]), $MachinePrecision] / N[(N[(y - x), $MachinePrecision] * N[(y - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], (-z)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.4 \cdot 10^{+55}:\\
\;\;\;\;\frac{\left(\left(-x\right) \cdot x\right) \cdot \left(y - 0.5\right)}{\left(y - x\right) \cdot \left(y - 0.5\right)} - z\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < 4.40000000000000021e55Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lower-+.f64100.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
flip-+N/A
distribute-lft-neg-outN/A
*-commutativeN/A
distribute-lft-neg-outN/A
lift-+.f64N/A
+-commutativeN/A
flip-+N/A
associate-*r/N/A
frac-addN/A
lower-/.f64N/A
Applied rewrites79.4%
Taylor expanded in x around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
unpow2N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f6450.2
Applied rewrites50.2%
if 4.40000000000000021e55 < y Initial program 99.7%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6421.4
Applied rewrites21.4%
(FPCore (x y z) :precision binary64 (if (<= x 1.35e+154) (- (/ (* (* x x) 0.5) (* (- y x) (- y 0.5))) z) (- z)))
double code(double x, double y, double z) {
double tmp;
if (x <= 1.35e+154) {
tmp = (((x * x) * 0.5) / ((y - x) * (y - 0.5))) - z;
} else {
tmp = -z;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= 1.35d+154) then
tmp = (((x * x) * 0.5d0) / ((y - x) * (y - 0.5d0))) - z
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 1.35e+154) {
tmp = (((x * x) * 0.5) / ((y - x) * (y - 0.5))) - z;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 1.35e+154: tmp = (((x * x) * 0.5) / ((y - x) * (y - 0.5))) - z else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (x <= 1.35e+154) tmp = Float64(Float64(Float64(Float64(x * x) * 0.5) / Float64(Float64(y - x) * Float64(y - 0.5))) - z); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 1.35e+154) tmp = (((x * x) * 0.5) / ((y - x) * (y - 0.5))) - z; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 1.35e+154], N[(N[(N[(N[(x * x), $MachinePrecision] * 0.5), $MachinePrecision] / N[(N[(y - x), $MachinePrecision] * N[(y - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], (-z)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{\left(x \cdot x\right) \cdot 0.5}{\left(y - x\right) \cdot \left(y - 0.5\right)} - z\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lower-+.f6499.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
flip-+N/A
distribute-lft-neg-outN/A
*-commutativeN/A
distribute-lft-neg-outN/A
lift-+.f64N/A
+-commutativeN/A
flip-+N/A
associate-*r/N/A
frac-addN/A
lower-/.f64N/A
Applied rewrites60.6%
Taylor expanded in x around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
unpow2N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f6440.2
Applied rewrites40.2%
Taylor expanded in y around 0
Applied rewrites40.8%
if 1.35000000000000003e154 < x Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6418.1
Applied rewrites18.1%
(FPCore (x y z) :precision binary64 (- z))
double code(double x, double y, double z) {
return -z;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -z
end function
public static double code(double x, double y, double z) {
return -z;
}
def code(x, y, z): return -z
function code(x, y, z) return Float64(-z) end
function tmp = code(x, y, z) tmp = -z; end
code[x_, y_, z_] := (-z)
\begin{array}{l}
\\
-z
\end{array}
Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6431.9
Applied rewrites31.9%
(FPCore (x y z) :precision binary64 (- (- (+ y x) z) (* (+ y 0.5) (log y))))
double code(double x, double y, double z) {
return ((y + x) - z) - ((y + 0.5) * log(y));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((y + x) - z) - ((y + 0.5d0) * log(y))
end function
public static double code(double x, double y, double z) {
return ((y + x) - z) - ((y + 0.5) * Math.log(y));
}
def code(x, y, z): return ((y + x) - z) - ((y + 0.5) * math.log(y))
function code(x, y, z) return Float64(Float64(Float64(y + x) - z) - Float64(Float64(y + 0.5) * log(y))) end
function tmp = code(x, y, z) tmp = ((y + x) - z) - ((y + 0.5) * log(y)); end
code[x_, y_, z_] := N[(N[(N[(y + x), $MachinePrecision] - z), $MachinePrecision] - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(y + x\right) - z\right) - \left(y + 0.5\right) \cdot \log y
\end{array}
herbie shell --seed 2025006
(FPCore (x y z)
:name "Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2"
:precision binary64
:alt
(! :herbie-platform default (- (- (+ y x) z) (* (+ y 1/2) (log y))))
(- (+ (- x (* (+ y 0.5) (log y))) y) z))