
(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 7 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 (/ (log (fma z y 1.0)) t))
(if (<= t_1 0.0)
(-
x
(* (fma -0.5 (/ (* (* (expm1 z) (expm1 z)) y) t) (/ (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 - (log(fma(z, y, 1.0)) / t);
} else if (t_1 <= 0.0) {
tmp = x - (fma(-0.5, (((expm1(z) * expm1(z)) * y) / t), (expm1(z) / t)) * y);
} else {
tmp = x - (log((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(log(fma(z, y, 1.0)) / t)); elseif (t_1 <= 0.0) tmp = Float64(x - Float64(fma(-0.5, Float64(Float64(Float64(expm1(z) * expm1(z)) * y) / t), 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[N[(z * y + 1.0), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(x - N[(N[(-0.5 * N[(N[(N[(N[(Exp[z] - 1), $MachinePrecision] * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] / t), $MachinePrecision] + N[(N[(Exp[z] - 1), $MachinePrecision] / t), $MachinePrecision]), $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{\log \left(\mathsf{fma}\left(z, y, 1\right)\right)}{t}\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;x - \mathsf{fma}\left(-0.5, \frac{\left(\mathsf{expm1}\left(z\right) \cdot \mathsf{expm1}\left(z\right)\right) \cdot y}{t}, \frac{\mathsf{expm1}\left(z\right)}{t}\right) \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%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6477.8
Applied rewrites77.8%
if -inf.0 < (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) < 0.0Initial program 81.4%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
if 0.0 < (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) Initial program 93.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6492.8
Applied rewrites92.8%
(FPCore (x y z t) :precision binary64 (if (<= y -3.2e+51) (- x (/ (log (* (expm1 z) y)) t)) (- x (/ (/ y (/ 1.0 (expm1 z))) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.2e+51) {
tmp = x - (log((expm1(z) * y)) / t);
} else {
tmp = x - ((y / (1.0 / expm1(z))) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.2e+51) {
tmp = x - (Math.log((Math.expm1(z) * y)) / t);
} else {
tmp = x - ((y / (1.0 / Math.expm1(z))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -3.2e+51: tmp = x - (math.log((math.expm1(z) * y)) / t) else: tmp = x - ((y / (1.0 / math.expm1(z))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -3.2e+51) tmp = Float64(x - Float64(log(Float64(expm1(z) * y)) / t)); else tmp = Float64(x - Float64(Float64(y / Float64(1.0 / expm1(z))) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -3.2e+51], N[(x - N[(N[Log[N[(N[(Exp[z] - 1), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(y / N[(1.0 / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.2 \cdot 10^{+51}:\\
\;\;\;\;x - \frac{\log \left(\mathsf{expm1}\left(z\right) \cdot y\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\frac{y}{\frac{1}{\mathsf{expm1}\left(z\right)}}}{t}\\
\end{array}
\end{array}
if y < -3.2000000000000002e51Initial program 43.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6472.3
Applied rewrites72.3%
if -3.2000000000000002e51 < y Initial program 65.9%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6492.4
Applied rewrites92.4%
lift-expm1.f64N/A
unpow1N/A
metadata-evalN/A
pow-negN/A
lower-/.f64N/A
lower-pow.f64N/A
lift-expm1.f6492.4
Applied rewrites92.4%
lift-*.f64N/A
lift-/.f64N/A
lift-expm1.f64N/A
lift-pow.f64N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
inv-powN/A
lower-/.f64N/A
lift-expm1.f6492.4
Applied rewrites92.4%
Taylor expanded in y around 0
Applied rewrites92.4%
(FPCore (x y z t) :precision binary64 (if (<= y -9.2e+107) (- x (/ (log (fma z y 1.0)) t)) (- x (/ (/ y (/ 1.0 (expm1 z))) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -9.2e+107) {
tmp = x - (log(fma(z, y, 1.0)) / t);
} else {
tmp = x - ((y / (1.0 / expm1(z))) / t);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -9.2e+107) tmp = Float64(x - Float64(log(fma(z, y, 1.0)) / t)); else tmp = Float64(x - Float64(Float64(y / Float64(1.0 / expm1(z))) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -9.2e+107], N[(x - N[(N[Log[N[(z * y + 1.0), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(y / N[(1.0 / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.2 \cdot 10^{+107}:\\
\;\;\;\;x - \frac{\log \left(\mathsf{fma}\left(z, y, 1\right)\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\frac{y}{\frac{1}{\mathsf{expm1}\left(z\right)}}}{t}\\
\end{array}
\end{array}
if y < -9.2000000000000001e107Initial program 44.8%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6456.3
Applied rewrites56.3%
if -9.2000000000000001e107 < y Initial program 64.5%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6491.5
Applied rewrites91.5%
lift-expm1.f64N/A
unpow1N/A
metadata-evalN/A
pow-negN/A
lower-/.f64N/A
lower-pow.f64N/A
lift-expm1.f6491.5
Applied rewrites91.5%
lift-*.f64N/A
lift-/.f64N/A
lift-expm1.f64N/A
lift-pow.f64N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
inv-powN/A
lower-/.f64N/A
lift-expm1.f6491.4
Applied rewrites91.4%
Taylor expanded in y around 0
Applied rewrites91.4%
(FPCore (x y z t) :precision binary64 (if (<= y -9.2e+107) (- x (/ (log (fma z y 1.0)) t)) (- x (/ (* (expm1 z) y) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -9.2e+107) {
tmp = x - (log(fma(z, y, 1.0)) / t);
} else {
tmp = x - ((expm1(z) * y) / t);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -9.2e+107) tmp = Float64(x - Float64(log(fma(z, y, 1.0)) / t)); else tmp = Float64(x - Float64(Float64(expm1(z) * y) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -9.2e+107], N[(x - N[(N[Log[N[(z * y + 1.0), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(N[(Exp[z] - 1), $MachinePrecision] * y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.2 \cdot 10^{+107}:\\
\;\;\;\;x - \frac{\log \left(\mathsf{fma}\left(z, y, 1\right)\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{expm1}\left(z\right) \cdot y}{t}\\
\end{array}
\end{array}
if y < -9.2000000000000001e107Initial program 44.8%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6456.3
Applied rewrites56.3%
if -9.2000000000000001e107 < y Initial program 64.5%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6491.5
Applied rewrites91.5%
(FPCore (x y z t) :precision binary64 (if (<= y -1.5e+178) (- x (/ (log (* z y)) t)) (- x (/ (* (expm1 z) y) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.5e+178) {
tmp = x - (log((z * y)) / t);
} else {
tmp = x - ((expm1(z) * y) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.5e+178) {
tmp = x - (Math.log((z * y)) / t);
} else {
tmp = x - ((Math.expm1(z) * y) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.5e+178: tmp = x - (math.log((z * y)) / t) else: tmp = x - ((math.expm1(z) * y) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.5e+178) tmp = Float64(x - Float64(log(Float64(z * y)) / t)); else tmp = Float64(x - Float64(Float64(expm1(z) * y) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.5e+178], N[(x - N[(N[Log[N[(z * y), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(N[(Exp[z] - 1), $MachinePrecision] * y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.5 \cdot 10^{+178}:\\
\;\;\;\;x - \frac{\log \left(z \cdot y\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{expm1}\left(z\right) \cdot y}{t}\\
\end{array}
\end{array}
if y < -1.50000000000000008e178Initial program 47.1%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6482.7
Applied rewrites82.7%
Taylor expanded in z around 0
Applied rewrites45.6%
if -1.50000000000000008e178 < y Initial program 63.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6489.6
Applied rewrites89.6%
(FPCore (x y z t) :precision binary64 (if (<= (exp z) 0.9999999999999998) x (- x (* (/ z t) y))))
double code(double x, double y, double z, double t) {
double tmp;
if (exp(z) <= 0.9999999999999998) {
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 (exp(z) <= 0.9999999999999998d0) 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 (Math.exp(z) <= 0.9999999999999998) {
tmp = x;
} else {
tmp = x - ((z / t) * y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if math.exp(z) <= 0.9999999999999998: tmp = x else: tmp = x - ((z / t) * y) return tmp
function code(x, y, z, t) tmp = 0.0 if (exp(z) <= 0.9999999999999998) 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 (exp(z) <= 0.9999999999999998) tmp = x; else tmp = x - ((z / t) * y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[Exp[z], $MachinePrecision], 0.9999999999999998], x, N[(x - N[(N[(z / t), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{z} \leq 0.9999999999999998:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{z}{t} \cdot y\\
\end{array}
\end{array}
if (exp.f64 z) < 0.99999999999999978Initial program 81.6%
Taylor expanded in x around inf
Applied rewrites65.1%
if 0.99999999999999978 < (exp.f64 z) Initial program 52.5%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites88.6%
Taylor expanded in z around 0
lower-/.f6490.2
Applied rewrites90.2%
(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.5%
Taylor expanded in x around inf
Applied rewrites72.0%
herbie shell --seed 2025120
(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)))