
(FPCore (x y z t) :precision binary64 (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))
double code(double x, double y, double z, double t) {
return x - (log(((1.0 - y) + (y * exp(z)))) / t);
}
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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x - (log(((1.0d0 - y) + (y * exp(z)))) / t)
end function
public static double code(double x, double y, double z, double t) {
return x - (Math.log(((1.0 - y) + (y * Math.exp(z)))) / t);
}
def code(x, y, z, t): return x - (math.log(((1.0 - y) + (y * math.exp(z)))) / t)
function code(x, y, z, t) return Float64(x - Float64(log(Float64(Float64(1.0 - y) + Float64(y * exp(z)))) / t)) end
function tmp = code(x, y, z, t) tmp = x - (log(((1.0 - y) + (y * exp(z)))) / t); end
code[x_, y_, z_, t_] := N[(x - N[(N[Log[N[(N[(1.0 - y), $MachinePrecision] + N[(y * N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\end{array}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))
double code(double x, double y, double z, double t) {
return x - (log(((1.0 - y) + (y * exp(z)))) / t);
}
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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x - (log(((1.0d0 - y) + (y * exp(z)))) / t)
end function
public static double code(double x, double y, double z, double t) {
return x - (Math.log(((1.0 - y) + (y * Math.exp(z)))) / t);
}
def code(x, y, z, t): return x - (math.log(((1.0 - y) + (y * math.exp(z)))) / t)
function code(x, y, z, t) return Float64(x - Float64(log(Float64(Float64(1.0 - y) + Float64(y * exp(z)))) / t)) end
function tmp = code(x, y, z, t) tmp = x - (log(((1.0 - y) + (y * exp(z)))) / t); end
code[x_, y_, z_, t_] := N[(x - N[(N[Log[N[(N[(1.0 - y), $MachinePrecision] + N[(y * N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\end{array}
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (log (+ (- 1.0 y) (* y (exp z))))))
(if (<= t_1 (- INFINITY))
(- x (/ (log1p (* z y)) t))
(if (<= t_1 0.0)
(- x (* (/ (expm1 z) t) y))
(- x (/ (log (* (expm1 z) y)) t))))))
double code(double x, double y, double z, double t) {
double t_1 = log(((1.0 - y) + (y * exp(z))));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = x - (log1p((z * y)) / t);
} else if (t_1 <= 0.0) {
tmp = x - ((expm1(z) / t) * y);
} else {
tmp = x - (log((expm1(z) * y)) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = Math.log(((1.0 - y) + (y * Math.exp(z))));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = x - (Math.log1p((z * y)) / t);
} else if (t_1 <= 0.0) {
tmp = x - ((Math.expm1(z) / t) * y);
} else {
tmp = x - (Math.log((Math.expm1(z) * y)) / t);
}
return tmp;
}
def code(x, y, z, t): t_1 = math.log(((1.0 - y) + (y * math.exp(z)))) tmp = 0 if t_1 <= -math.inf: tmp = x - (math.log1p((z * y)) / t) elif t_1 <= 0.0: tmp = x - ((math.expm1(z) / t) * y) else: tmp = x - (math.log((math.expm1(z) * y)) / t) return tmp
function code(x, y, z, t) t_1 = log(Float64(Float64(1.0 - y) + Float64(y * exp(z)))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(x - Float64(log1p(Float64(z * y)) / t)); elseif (t_1 <= 0.0) tmp = Float64(x - Float64(Float64(expm1(z) / t) * y)); else tmp = Float64(x - Float64(log(Float64(expm1(z) * y)) / t)); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Log[N[(N[(1.0 - y), $MachinePrecision] + N[(y * N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(x - N[(N[Log[1 + N[(z * y), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(x - N[(N[(N[(Exp[z] - 1), $MachinePrecision] / t), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[N[(N[(Exp[z] - 1), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log \left(\left(1 - y\right) + y \cdot e^{z}\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(z \cdot y\right)}{t}\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;x - \frac{\mathsf{expm1}\left(z\right)}{t} \cdot y\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(\mathsf{expm1}\left(z\right) \cdot y\right)}{t}\\
\end{array}
\end{array}
if (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) < -inf.0Initial program 2.2%
Applied rewrites99.8%
Taylor expanded in z around 0
Applied rewrites99.8%
if -inf.0 < (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) < 0.0Initial program 81.8%
Taylor expanded in y around 0
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lower-expm1.f6499.7
Applied rewrites99.7%
if 0.0 < (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) Initial program 95.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6493.8
Applied rewrites93.8%
(FPCore (x y z t) :precision binary64 (- x (/ (log1p (* (expm1 z) y)) t)))
double code(double x, double y, double z, double t) {
return x - (log1p((expm1(z) * y)) / t);
}
public static double code(double x, double y, double z, double t) {
return x - (Math.log1p((Math.expm1(z) * y)) / t);
}
def code(x, y, z, t): return x - (math.log1p((math.expm1(z) * y)) / t)
function code(x, y, z, t) return Float64(x - Float64(log1p(Float64(expm1(z) * y)) / t)) end
code[x_, y_, z_, t_] := N[(x - N[(N[Log[1 + N[(N[(Exp[z] - 1), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{\mathsf{log1p}\left(\mathsf{expm1}\left(z\right) \cdot y\right)}{t}
\end{array}
Initial program 61.9%
Applied rewrites98.6%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (log (+ (- 1.0 y) (* y (exp z))))))
(if (<= t_1 (- INFINITY))
(- x (/ (log1p (* z y)) t))
(if (<= t_1 20.0)
(- x (* (/ (expm1 z) t) y))
(/ (log (* (expm1 z) y)) (- t))))))
double code(double x, double y, double z, double t) {
double t_1 = log(((1.0 - y) + (y * exp(z))));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = x - (log1p((z * y)) / t);
} else if (t_1 <= 20.0) {
tmp = x - ((expm1(z) / t) * y);
} else {
tmp = log((expm1(z) * y)) / -t;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = Math.log(((1.0 - y) + (y * Math.exp(z))));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = x - (Math.log1p((z * y)) / t);
} else if (t_1 <= 20.0) {
tmp = x - ((Math.expm1(z) / t) * y);
} else {
tmp = Math.log((Math.expm1(z) * y)) / -t;
}
return tmp;
}
def code(x, y, z, t): t_1 = math.log(((1.0 - y) + (y * math.exp(z)))) tmp = 0 if t_1 <= -math.inf: tmp = x - (math.log1p((z * y)) / t) elif t_1 <= 20.0: tmp = x - ((math.expm1(z) / t) * y) else: tmp = math.log((math.expm1(z) * y)) / -t return tmp
function code(x, y, z, t) t_1 = log(Float64(Float64(1.0 - y) + Float64(y * exp(z)))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(x - Float64(log1p(Float64(z * y)) / t)); elseif (t_1 <= 20.0) tmp = Float64(x - Float64(Float64(expm1(z) / t) * y)); else tmp = Float64(log(Float64(expm1(z) * y)) / Float64(-t)); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Log[N[(N[(1.0 - y), $MachinePrecision] + N[(y * N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(x - N[(N[Log[1 + N[(z * y), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 20.0], N[(x - N[(N[(N[(Exp[z] - 1), $MachinePrecision] / t), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(N[Log[N[(N[(Exp[z] - 1), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] / (-t)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log \left(\left(1 - y\right) + y \cdot e^{z}\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(z \cdot y\right)}{t}\\
\mathbf{elif}\;t\_1 \leq 20:\\
\;\;\;\;x - \frac{\mathsf{expm1}\left(z\right)}{t} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(\mathsf{expm1}\left(z\right) \cdot y\right)}{-t}\\
\end{array}
\end{array}
if (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) < -inf.0Initial program 2.2%
Applied rewrites99.8%
Taylor expanded in z around 0
Applied rewrites99.8%
if -inf.0 < (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) < 20Initial program 81.8%
Taylor expanded in y around 0
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lower-expm1.f6499.2
Applied rewrites99.2%
if 20 < (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) Initial program 97.2%
Taylor expanded in x around 0
Applied rewrites48.1%
Taylor expanded in y around inf
*-commutativeN/A
lift-expm1.f64N/A
lift-*.f6448.0
Applied rewrites48.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (log (+ (- 1.0 y) (* y (exp z))))))
(if (<= t_1 (- INFINITY))
(- x (/ (log1p (* z y)) t))
(if (<= t_1 350.0) (- x (* (/ (expm1 z) t) y)) x))))
double code(double x, double y, double z, double t) {
double t_1 = log(((1.0 - y) + (y * exp(z))));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = x - (log1p((z * y)) / t);
} else if (t_1 <= 350.0) {
tmp = x - ((expm1(z) / t) * y);
} else {
tmp = x;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = Math.log(((1.0 - y) + (y * Math.exp(z))));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = x - (Math.log1p((z * y)) / t);
} else if (t_1 <= 350.0) {
tmp = x - ((Math.expm1(z) / t) * y);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): t_1 = math.log(((1.0 - y) + (y * math.exp(z)))) tmp = 0 if t_1 <= -math.inf: tmp = x - (math.log1p((z * y)) / t) elif t_1 <= 350.0: tmp = x - ((math.expm1(z) / t) * y) else: tmp = x return tmp
function code(x, y, z, t) t_1 = log(Float64(Float64(1.0 - y) + Float64(y * exp(z)))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(x - Float64(log1p(Float64(z * y)) / t)); elseif (t_1 <= 350.0) tmp = Float64(x - Float64(Float64(expm1(z) / t) * y)); else tmp = x; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Log[N[(N[(1.0 - y), $MachinePrecision] + N[(y * N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(x - N[(N[Log[1 + N[(z * y), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 350.0], N[(x - N[(N[(N[(Exp[z] - 1), $MachinePrecision] / t), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], x]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log \left(\left(1 - y\right) + y \cdot e^{z}\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(z \cdot y\right)}{t}\\
\mathbf{elif}\;t\_1 \leq 350:\\
\;\;\;\;x - \frac{\mathsf{expm1}\left(z\right)}{t} \cdot y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) < -inf.0Initial program 2.2%
Applied rewrites99.8%
Taylor expanded in z around 0
Applied rewrites99.8%
if -inf.0 < (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) < 350Initial program 83.1%
Taylor expanded in y around 0
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lower-expm1.f6494.9
Applied rewrites94.9%
if 350 < (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) Initial program 95.6%
Taylor expanded in x around inf
Applied rewrites51.3%
(FPCore (x y z t) :precision binary64 (if (<= y 7.2e+129) (- x (* (/ (expm1 z) t) y)) (- x (/ (log (fma z y 1.0)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7.2e+129) {
tmp = x - ((expm1(z) / t) * y);
} else {
tmp = x - (log(fma(z, y, 1.0)) / t);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 7.2e+129) tmp = Float64(x - Float64(Float64(expm1(z) / t) * y)); else tmp = Float64(x - Float64(log(fma(z, y, 1.0)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 7.2e+129], N[(x - N[(N[(N[(Exp[z] - 1), $MachinePrecision] / t), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[N[(z * y + 1.0), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.2 \cdot 10^{+129}:\\
\;\;\;\;x - \frac{\mathsf{expm1}\left(z\right)}{t} \cdot y\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(\mathsf{fma}\left(z, y, 1\right)\right)}{t}\\
\end{array}
\end{array}
if y < 7.2000000000000002e129Initial program 66.6%
Taylor expanded in y around 0
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lower-expm1.f6488.0
Applied rewrites88.0%
if 7.2000000000000002e129 < y Initial program 6.7%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6481.0
Applied rewrites81.0%
(FPCore (x y z t) :precision binary64 (if (<= y 7.2e+129) (- x (* (/ (expm1 z) t) y)) (- x (/ (log (* y z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7.2e+129) {
tmp = x - ((expm1(z) / t) * y);
} else {
tmp = x - (log((y * z)) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7.2e+129) {
tmp = x - ((Math.expm1(z) / t) * y);
} else {
tmp = x - (Math.log((y * z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 7.2e+129: tmp = x - ((math.expm1(z) / t) * y) else: tmp = x - (math.log((y * z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 7.2e+129) tmp = Float64(x - Float64(Float64(expm1(z) / t) * y)); else tmp = Float64(x - Float64(log(Float64(y * z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 7.2e+129], N[(x - N[(N[(N[(Exp[z] - 1), $MachinePrecision] / t), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[N[(y * z), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.2 \cdot 10^{+129}:\\
\;\;\;\;x - \frac{\mathsf{expm1}\left(z\right)}{t} \cdot y\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(y \cdot z\right)}{t}\\
\end{array}
\end{array}
if y < 7.2000000000000002e129Initial program 66.6%
Taylor expanded in y around 0
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lower-expm1.f6488.0
Applied rewrites88.0%
if 7.2000000000000002e129 < y Initial program 6.7%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6481.0
Applied rewrites81.0%
Taylor expanded in y around inf
lower-*.f6461.8
Applied rewrites61.8%
(FPCore (x y z t) :precision binary64 (if (<= z -7.2e+89) x (- x (* (/ z t) y))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7.2e+89) {
tmp = x;
} else {
tmp = x - ((z / t) * 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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-7.2d+89)) then
tmp = x
else
tmp = x - ((z / t) * y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7.2e+89) {
tmp = x;
} else {
tmp = x - ((z / t) * y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -7.2e+89: tmp = x else: tmp = x - ((z / t) * y) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -7.2e+89) tmp = x; else tmp = Float64(x - Float64(Float64(z / t) * y)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -7.2e+89) tmp = x; else tmp = x - ((z / t) * y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -7.2e+89], x, N[(x - N[(N[(z / t), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.2 \cdot 10^{+89}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{z}{t} \cdot y\\
\end{array}
\end{array}
if z < -7.2e89Initial program 82.9%
Taylor expanded in x around inf
Applied rewrites65.9%
if -7.2e89 < z Initial program 56.4%
Taylor expanded in y around 0
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lower-expm1.f6488.6
Applied rewrites88.6%
Taylor expanded in z around 0
Applied rewrites85.9%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 61.9%
Taylor expanded in x around inf
Applied rewrites72.1%
herbie shell --seed 2025130
(FPCore (x y z t)
:name "System.Random.MWC.Distributions:truncatedExp from mwc-random-0.13.3.2"
:precision binary64
(- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))