
(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 14 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 (- (fma (- 1.0 (log y)) y (fma -0.5 (log y) x)) z))
double code(double x, double y, double z) {
return fma((1.0 - log(y)), y, fma(-0.5, log(y), x)) - z;
}
function code(x, y, z) return Float64(fma(Float64(1.0 - log(y)), y, fma(-0.5, log(y), x)) - z) end
code[x_, y_, z_] := N[(N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y + N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(1 - \log y, y, \mathsf{fma}\left(-0.5, \log y, x\right)\right) - z
\end{array}
Initial program 99.7%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
associate-+l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
lift-fma.f64N/A
lift-+.f64N/A
distribute-lft-inN/A
associate-+l+N/A
lower-fma.f64N/A
lower-fma.f6499.8
Applied rewrites99.8%
lift-+.f64N/A
lift-fma.f64N/A
associate-+r+N/A
+-commutativeN/A
lift-fma.f64N/A
distribute-lft1-inN/A
lower-fma.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lift-neg.f64N/A
fp-cancel-sub-signN/A
*-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lift-fma.f6499.8
Applied rewrites99.8%
Taylor expanded in y around 0
lower--.f64N/A
lower-log.f6499.8
Applied rewrites99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (- x (* (+ y 0.5) (log y))) y)))
(if (<= t_0 -2e+295)
(fma (- -0.5 y) (log y) x)
(if (<= t_0 -4.8e+188)
(* (- 1.0 (log y)) y)
(if (or (<= t_0 -1e+24) (not (<= t_0 500.0)))
(- x z)
(- (* -0.5 (log y)) z))))))
double code(double x, double y, double z) {
double t_0 = (x - ((y + 0.5) * log(y))) + y;
double tmp;
if (t_0 <= -2e+295) {
tmp = fma((-0.5 - y), log(y), x);
} else if (t_0 <= -4.8e+188) {
tmp = (1.0 - log(y)) * y;
} else if ((t_0 <= -1e+24) || !(t_0 <= 500.0)) {
tmp = x - z;
} else {
tmp = (-0.5 * log(y)) - z;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) tmp = 0.0 if (t_0 <= -2e+295) tmp = fma(Float64(-0.5 - y), log(y), x); elseif (t_0 <= -4.8e+188) tmp = Float64(Float64(1.0 - log(y)) * y); elseif ((t_0 <= -1e+24) || !(t_0 <= 500.0)) tmp = Float64(x - z); else tmp = Float64(Float64(-0.5 * log(y)) - 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]}, If[LessEqual[t$95$0, -2e+295], N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t$95$0, -4.8e+188], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[Or[LessEqual[t$95$0, -1e+24], N[Not[LessEqual[t$95$0, 500.0]], $MachinePrecision]], N[(x - z), $MachinePrecision], N[(N[(-0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - \left(y + 0.5\right) \cdot \log y\right) + y\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+295}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, x\right)\\
\mathbf{elif}\;t\_0 \leq -4.8 \cdot 10^{+188}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y\\
\mathbf{elif}\;t\_0 \leq -1 \cdot 10^{+24} \lor \neg \left(t\_0 \leq 500\right):\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \log y - z\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -2e295Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
distribute-neg-inN/A
metadata-evalN/A
mul-1-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
Taylor expanded in x around inf
Applied rewrites70.6%
if -2e295 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -4.7999999999999999e188Initial 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.f6470.5
Applied rewrites70.5%
if -4.7999999999999999e188 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -9.9999999999999998e23 or 500 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) Initial program 99.8%
Taylor expanded in x around inf
Applied rewrites74.3%
if -9.9999999999999998e23 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 500Initial program 99.9%
Taylor expanded in y around 0
fp-cancel-sub-sign-invN/A
+-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6491.4
Applied rewrites91.4%
Taylor expanded in x around 0
lower-*.f64N/A
lower-log.f6489.8
Applied rewrites89.8%
Final simplification77.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (- x (* (+ y 0.5) (log y))) y)))
(if (<= t_0 -4.8e+188)
(* (- 1.0 (log y)) y)
(if (or (<= t_0 -1e+24) (not (<= t_0 500.0)))
(- x z)
(- (* -0.5 (log y)) z)))))
double code(double x, double y, double z) {
double t_0 = (x - ((y + 0.5) * log(y))) + y;
double tmp;
if (t_0 <= -4.8e+188) {
tmp = (1.0 - log(y)) * y;
} else if ((t_0 <= -1e+24) || !(t_0 <= 500.0)) {
tmp = x - z;
} else {
tmp = (-0.5 * log(y)) - 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
if (t_0 <= (-4.8d+188)) then
tmp = (1.0d0 - log(y)) * y
else if ((t_0 <= (-1d+24)) .or. (.not. (t_0 <= 500.0d0))) then
tmp = x - z
else
tmp = ((-0.5d0) * log(y)) - 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;
double tmp;
if (t_0 <= -4.8e+188) {
tmp = (1.0 - Math.log(y)) * y;
} else if ((t_0 <= -1e+24) || !(t_0 <= 500.0)) {
tmp = x - z;
} else {
tmp = (-0.5 * Math.log(y)) - z;
}
return tmp;
}
def code(x, y, z): t_0 = (x - ((y + 0.5) * math.log(y))) + y tmp = 0 if t_0 <= -4.8e+188: tmp = (1.0 - math.log(y)) * y elif (t_0 <= -1e+24) or not (t_0 <= 500.0): tmp = x - z else: tmp = (-0.5 * math.log(y)) - z return tmp
function code(x, y, z) t_0 = Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) tmp = 0.0 if (t_0 <= -4.8e+188) tmp = Float64(Float64(1.0 - log(y)) * y); elseif ((t_0 <= -1e+24) || !(t_0 <= 500.0)) tmp = Float64(x - z); else tmp = Float64(Float64(-0.5 * log(y)) - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x - ((y + 0.5) * log(y))) + y; tmp = 0.0; if (t_0 <= -4.8e+188) tmp = (1.0 - log(y)) * y; elseif ((t_0 <= -1e+24) || ~((t_0 <= 500.0))) tmp = x - z; else tmp = (-0.5 * log(y)) - z; end tmp_2 = 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]}, If[LessEqual[t$95$0, -4.8e+188], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[Or[LessEqual[t$95$0, -1e+24], N[Not[LessEqual[t$95$0, 500.0]], $MachinePrecision]], N[(x - z), $MachinePrecision], N[(N[(-0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - \left(y + 0.5\right) \cdot \log y\right) + y\\
\mathbf{if}\;t\_0 \leq -4.8 \cdot 10^{+188}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y\\
\mathbf{elif}\;t\_0 \leq -1 \cdot 10^{+24} \lor \neg \left(t\_0 \leq 500\right):\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \log y - z\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -4.7999999999999999e188Initial 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.f6463.9
Applied rewrites63.9%
if -4.7999999999999999e188 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -9.9999999999999998e23 or 500 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) Initial program 99.8%
Taylor expanded in x around inf
Applied rewrites74.3%
if -9.9999999999999998e23 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 500Initial program 99.9%
Taylor expanded in y around 0
fp-cancel-sub-sign-invN/A
+-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6491.4
Applied rewrites91.4%
Taylor expanded in x around 0
lower-*.f64N/A
lower-log.f6489.8
Applied rewrites89.8%
Final simplification75.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.8e+88) (not (<= z 1.15e+127))) (- x z) (+ (fma (- -0.5 y) (log y) y) x)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.8e+88) || !(z <= 1.15e+127)) {
tmp = x - z;
} else {
tmp = fma((-0.5 - y), log(y), y) + x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((z <= -5.8e+88) || !(z <= 1.15e+127)) tmp = Float64(x - z); else tmp = Float64(fma(Float64(-0.5 - y), log(y), y) + x); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.8e+88], N[Not[LessEqual[z, 1.15e+127]], $MachinePrecision]], N[(x - z), $MachinePrecision], N[(N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + y), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.8 \cdot 10^{+88} \lor \neg \left(z \leq 1.15 \cdot 10^{+127}\right):\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, y\right) + x\\
\end{array}
\end{array}
if z < -5.7999999999999999e88 or 1.1500000000000001e127 < z Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites88.1%
if -5.7999999999999999e88 < z < 1.1500000000000001e127Initial program 99.7%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
distribute-neg-inN/A
metadata-evalN/A
mul-1-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f6494.7
Applied rewrites94.7%
lift-fma.f64N/A
lift-+.f64N/A
associate-+r+N/A
lower-+.f64N/A
lower-fma.f6494.8
Applied rewrites94.8%
Final simplification92.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.8e+88) (not (<= z 1.15e+127))) (- x z) (+ (fma (- -0.5 y) (log y) x) y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.8e+88) || !(z <= 1.15e+127)) {
tmp = x - z;
} else {
tmp = fma((-0.5 - y), log(y), x) + y;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((z <= -5.8e+88) || !(z <= 1.15e+127)) tmp = Float64(x - z); else tmp = Float64(fma(Float64(-0.5 - y), log(y), x) + y); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.8e+88], N[Not[LessEqual[z, 1.15e+127]], $MachinePrecision]], N[(x - z), $MachinePrecision], N[(N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + x), $MachinePrecision] + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.8 \cdot 10^{+88} \lor \neg \left(z \leq 1.15 \cdot 10^{+127}\right):\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, x\right) + y\\
\end{array}
\end{array}
if z < -5.7999999999999999e88 or 1.1500000000000001e127 < z Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites88.1%
if -5.7999999999999999e88 < z < 1.1500000000000001e127Initial program 99.7%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
distribute-neg-inN/A
metadata-evalN/A
mul-1-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f6494.7
Applied rewrites94.7%
lift-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lower-+.f64N/A
lower-fma.f6494.7
Applied rewrites94.7%
Final simplification92.6%
(FPCore (x y z) :precision binary64 (if (<= y 0.28) (- (fma -0.5 (log y) x) z) (- (+ (- x (* y (log y))) y) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 0.28) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = ((x - (y * log(y))) + y) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 0.28) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = Float64(Float64(Float64(x - Float64(y * log(y))) + y) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 0.28], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[(x - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.28:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(\left(x - y \cdot \log y\right) + y\right) - z\\
\end{array}
\end{array}
if y < 0.28000000000000003Initial program 100.0%
Taylor expanded in y around 0
fp-cancel-sub-sign-invN/A
+-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6498.7
Applied rewrites98.7%
if 0.28000000000000003 < y Initial program 99.6%
Taylor expanded in y around inf
Applied rewrites98.5%
(FPCore (x y z) :precision binary64 (if (<= y 1.65e+60) (- (fma -0.5 (log y) x) z) (+ (fma (- y) (log y) y) x)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.65e+60) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = fma(-y, log(y), y) + x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 1.65e+60) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = Float64(fma(Float64(-y), log(y), y) + x); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 1.65e+60], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(N[((-y) * N[Log[y], $MachinePrecision] + y), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.65 \cdot 10^{+60}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, \log y, y\right) + x\\
\end{array}
\end{array}
if y < 1.6499999999999999e60Initial program 99.9%
Taylor expanded in y around 0
fp-cancel-sub-sign-invN/A
+-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6491.7
Applied rewrites91.7%
if 1.6499999999999999e60 < y Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
distribute-neg-inN/A
metadata-evalN/A
mul-1-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f6486.6
Applied rewrites86.6%
lift-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f6486.5
Applied rewrites86.5%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6486.5
Applied rewrites86.5%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6486.6
Applied rewrites86.6%
(FPCore (x y z) :precision binary64 (if (<= y 1.65e+60) (- (fma -0.5 (log y) x) z) (+ (fma (- y) (log y) x) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.65e+60) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = fma(-y, log(y), x) + y;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 1.65e+60) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = Float64(fma(Float64(-y), log(y), x) + y); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 1.65e+60], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(N[((-y) * N[Log[y], $MachinePrecision] + x), $MachinePrecision] + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.65 \cdot 10^{+60}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, \log y, x\right) + y\\
\end{array}
\end{array}
if y < 1.6499999999999999e60Initial program 99.9%
Taylor expanded in y around 0
fp-cancel-sub-sign-invN/A
+-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6491.7
Applied rewrites91.7%
if 1.6499999999999999e60 < y Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
distribute-neg-inN/A
metadata-evalN/A
mul-1-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f6486.6
Applied rewrites86.6%
lift-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f6486.5
Applied rewrites86.5%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6486.5
Applied rewrites86.5%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-+r+N/A
lower-+.f64N/A
lift-*.f64N/A
lower-fma.f6486.5
Applied rewrites86.5%
(FPCore (x y z) :precision binary64 (- (+ x (fma (- (log y)) (+ 0.5 y) y)) z))
double code(double x, double y, double z) {
return (x + fma(-log(y), (0.5 + y), y)) - z;
}
function code(x, y, z) return Float64(Float64(x + fma(Float64(-log(y)), Float64(0.5 + y), y)) - z) end
code[x_, y_, z_] := N[(N[(x + N[((-N[Log[y], $MachinePrecision]) * N[(0.5 + y), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \mathsf{fma}\left(-\log y, 0.5 + y, y\right)\right) - z
\end{array}
Initial program 99.7%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
associate-+l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
(FPCore (x y z) :precision binary64 (if (<= y 3.5e+182) (- (fma -0.5 (log y) x) z) (* (- 1.0 (log y)) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.5e+182) {
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 <= 3.5e+182) 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, 3.5e+182], 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 3.5 \cdot 10^{+182}:\\
\;\;\;\;\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 < 3.50000000000000023e182Initial program 99.8%
Taylor expanded in y around 0
fp-cancel-sub-sign-invN/A
+-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6483.1
Applied rewrites83.1%
if 3.50000000000000023e182 < y Initial program 99.4%
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.f6485.6
Applied rewrites85.6%
(FPCore (x y z) :precision binary64 (if (<= y 3.5e+182) (- x z) (* (- 1.0 (log y)) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.5e+182) {
tmp = x - z;
} else {
tmp = (1.0 - log(y)) * y;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 3.5d+182) then
tmp = x - z
else
tmp = (1.0d0 - log(y)) * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 3.5e+182) {
tmp = x - z;
} else {
tmp = (1.0 - Math.log(y)) * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 3.5e+182: tmp = x - z else: tmp = (1.0 - math.log(y)) * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 3.5e+182) tmp = Float64(x - z); else tmp = Float64(Float64(1.0 - log(y)) * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 3.5e+182) tmp = x - z; else tmp = (1.0 - log(y)) * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 3.5e+182], N[(x - z), $MachinePrecision], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.5 \cdot 10^{+182}:\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y\\
\end{array}
\end{array}
if y < 3.50000000000000023e182Initial program 99.8%
Taylor expanded in x around inf
Applied rewrites66.9%
if 3.50000000000000023e182 < y Initial program 99.4%
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.f6485.6
Applied rewrites85.6%
(FPCore (x y z) :precision binary64 (if (<= x -3.35e+38) x (if (<= x 44000000000000.0) (- z) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -3.35e+38) {
tmp = x;
} else if (x <= 44000000000000.0) {
tmp = -z;
} 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, 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 <= (-3.35d+38)) then
tmp = x
else if (x <= 44000000000000.0d0) then
tmp = -z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -3.35e+38) {
tmp = x;
} else if (x <= 44000000000000.0) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -3.35e+38: tmp = x elif x <= 44000000000000.0: tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -3.35e+38) tmp = x; elseif (x <= 44000000000000.0) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -3.35e+38) tmp = x; elseif (x <= 44000000000000.0) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -3.35e+38], x, If[LessEqual[x, 44000000000000.0], (-z), x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.35 \cdot 10^{+38}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 44000000000000:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -3.35000000000000012e38 or 4.4e13 < x Initial program 99.8%
Taylor expanded in x around inf
Applied rewrites63.9%
if -3.35000000000000012e38 < x < 4.4e13Initial program 99.7%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6435.5
Applied rewrites35.5%
(FPCore (x y z) :precision binary64 (- x z))
double code(double x, double y, double z) {
return x - 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 - z
end function
public static double code(double x, double y, double z) {
return x - z;
}
def code(x, y, z): return x - z
function code(x, y, z) return Float64(x - z) end
function tmp = code(x, y, z) tmp = x - z; end
code[x_, y_, z_] := N[(x - z), $MachinePrecision]
\begin{array}{l}
\\
x - z
\end{array}
Initial program 99.7%
Taylor expanded in x around inf
Applied rewrites55.7%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 99.7%
Taylor expanded in x around inf
Applied rewrites30.2%
(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 2025026
(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))