
(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 (- x (/ (log (fma (expm1 z) y 1.0)) t))))
(if (<= y -1.65e+17)
t_1
(if (<= y 6e+65)
(-
x
(* (fma -0.5 (/ (* (* (expm1 z) (expm1 z)) y) t) (/ (expm1 z) t)) y))
t_1))))
double code(double x, double y, double z, double t) {
double t_1 = x - (log(fma(expm1(z), y, 1.0)) / t);
double tmp;
if (y <= -1.65e+17) {
tmp = t_1;
} else if (y <= 6e+65) {
tmp = x - (fma(-0.5, (((expm1(z) * expm1(z)) * y) / t), (expm1(z) / t)) * y);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(x - Float64(log(fma(expm1(z), y, 1.0)) / t)) tmp = 0.0 if (y <= -1.65e+17) tmp = t_1; elseif (y <= 6e+65) tmp = Float64(x - Float64(fma(-0.5, Float64(Float64(Float64(expm1(z) * expm1(z)) * y) / t), Float64(expm1(z) / t)) * y)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x - N[(N[Log[N[(N[(Exp[z] - 1), $MachinePrecision] * y + 1.0), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.65e+17], t$95$1, If[LessEqual[y, 6e+65], 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], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x - \frac{\log \left(\mathsf{fma}\left(\mathsf{expm1}\left(z\right), y, 1\right)\right)}{t}\\
\mathbf{if}\;y \leq -1.65 \cdot 10^{+17}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 6 \cdot 10^{+65}:\\
\;\;\;\;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}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1.65e17 or 6.0000000000000004e65 < y Initial program 30.1%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-expm1.f6484.9
Applied rewrites84.9%
if -1.65e17 < y < 6.0000000000000004e65Initial program 77.2%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.7%
(FPCore (x y z t) :precision binary64 (if (<= (log (+ (- 1.0 y) (* y (exp z)))) 0.0) (- x (/ (* (expm1 z) y) t)) (- x (/ (log (fma (expm1 z) y 1.0)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (log(((1.0 - y) + (y * exp(z)))) <= 0.0) {
tmp = x - ((expm1(z) * y) / t);
} else {
tmp = x - (log(fma(expm1(z), y, 1.0)) / t);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (log(Float64(Float64(1.0 - y) + Float64(y * exp(z)))) <= 0.0) tmp = Float64(x - Float64(Float64(expm1(z) * y) / t)); else tmp = Float64(x - Float64(log(fma(expm1(z), y, 1.0)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[Log[N[(N[(1.0 - y), $MachinePrecision] + N[(y * N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 0.0], N[(x - N[(N[(N[(Exp[z] - 1), $MachinePrecision] * y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[N[(N[(Exp[z] - 1), $MachinePrecision] * y + 1.0), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\log \left(\left(1 - y\right) + y \cdot e^{z}\right) \leq 0:\\
\;\;\;\;x - \frac{\mathsf{expm1}\left(z\right) \cdot y}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(\mathsf{fma}\left(\mathsf{expm1}\left(z\right), y, 1\right)\right)}{t}\\
\end{array}
\end{array}
if (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) < 0.0Initial program 56.1%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6491.6
Applied rewrites91.6%
if 0.0 < (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) Initial program 94.6%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-expm1.f6495.8
Applied rewrites95.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (expm1 z) y)))
(if (<= (log (+ (- 1.0 y) (* y (exp z)))) 0.0004)
(- x (/ t_1 t))
(- x (/ (log t_1) t)))))
double code(double x, double y, double z, double t) {
double t_1 = expm1(z) * y;
double tmp;
if (log(((1.0 - y) + (y * exp(z)))) <= 0.0004) {
tmp = x - (t_1 / t);
} else {
tmp = x - (log(t_1) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = Math.expm1(z) * y;
double tmp;
if (Math.log(((1.0 - y) + (y * Math.exp(z)))) <= 0.0004) {
tmp = x - (t_1 / t);
} else {
tmp = x - (Math.log(t_1) / t);
}
return tmp;
}
def code(x, y, z, t): t_1 = math.expm1(z) * y tmp = 0 if math.log(((1.0 - y) + (y * math.exp(z)))) <= 0.0004: tmp = x - (t_1 / t) else: tmp = x - (math.log(t_1) / t) return tmp
function code(x, y, z, t) t_1 = Float64(expm1(z) * y) tmp = 0.0 if (log(Float64(Float64(1.0 - y) + Float64(y * exp(z)))) <= 0.0004) tmp = Float64(x - Float64(t_1 / t)); else tmp = Float64(x - Float64(log(t_1) / t)); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(Exp[z] - 1), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[N[Log[N[(N[(1.0 - y), $MachinePrecision] + N[(y * N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 0.0004], N[(x - N[(t$95$1 / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[t$95$1], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{expm1}\left(z\right) \cdot y\\
\mathbf{if}\;\log \left(\left(1 - y\right) + y \cdot e^{z}\right) \leq 0.0004:\\
\;\;\;\;x - \frac{t\_1}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\log t\_1}{t}\\
\end{array}
\end{array}
if (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) < 4.00000000000000019e-4Initial program 56.2%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6491.5
Applied rewrites91.5%
if 4.00000000000000019e-4 < (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) Initial program 95.7%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6495.3
Applied rewrites95.3%
(FPCore (x y z t) :precision binary64 (if (<= (log (+ (- 1.0 y) (* y (exp z)))) 1.0) (- x (/ (* (expm1 z) y) t)) (- (* (- (/ (log (- 1.0 y)) (* t x)) 1.0) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (log(((1.0 - y) + (y * exp(z)))) <= 1.0) {
tmp = x - ((expm1(z) * y) / t);
} else {
tmp = -(((log((1.0 - y)) / (t * x)) - 1.0) * x);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (Math.log(((1.0 - y) + (y * Math.exp(z)))) <= 1.0) {
tmp = x - ((Math.expm1(z) * y) / t);
} else {
tmp = -(((Math.log((1.0 - y)) / (t * x)) - 1.0) * x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if math.log(((1.0 - y) + (y * math.exp(z)))) <= 1.0: tmp = x - ((math.expm1(z) * y) / t) else: tmp = -(((math.log((1.0 - y)) / (t * x)) - 1.0) * x) return tmp
function code(x, y, z, t) tmp = 0.0 if (log(Float64(Float64(1.0 - y) + Float64(y * exp(z)))) <= 1.0) tmp = Float64(x - Float64(Float64(expm1(z) * y) / t)); else tmp = Float64(-Float64(Float64(Float64(log(Float64(1.0 - y)) / Float64(t * x)) - 1.0) * x)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[Log[N[(N[(1.0 - y), $MachinePrecision] + N[(y * N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0], N[(x - N[(N[(N[(Exp[z] - 1), $MachinePrecision] * y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], (-N[(N[(N[(N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision] / N[(t * x), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\log \left(\left(1 - y\right) + y \cdot e^{z}\right) \leq 1:\\
\;\;\;\;x - \frac{\mathsf{expm1}\left(z\right) \cdot y}{t}\\
\mathbf{else}:\\
\;\;\;\;-\left(\frac{\log \left(1 - y\right)}{t \cdot x} - 1\right) \cdot x\\
\end{array}
\end{array}
if (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) < 1Initial program 56.3%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6491.5
Applied rewrites91.5%
if 1 < (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) Initial program 95.8%
Taylor expanded in x around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites83.6%
Taylor expanded in y around 0
Applied rewrites78.5%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (log (+ (- 1.0 y) (* y (exp z))))))
(if (<= t_1 21.0)
(- x (/ (* (expm1 z) y) t))
(if (<= t_1 400.0) (- (/ (log (* y (expm1 z))) t)) 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 <= 21.0) {
tmp = x - ((expm1(z) * y) / t);
} else if (t_1 <= 400.0) {
tmp = -(log((y * expm1(z))) / t);
} 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 <= 21.0) {
tmp = x - ((Math.expm1(z) * y) / t);
} else if (t_1 <= 400.0) {
tmp = -(Math.log((y * Math.expm1(z))) / t);
} 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 <= 21.0: tmp = x - ((math.expm1(z) * y) / t) elif t_1 <= 400.0: tmp = -(math.log((y * math.expm1(z))) / t) 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 <= 21.0) tmp = Float64(x - Float64(Float64(expm1(z) * y) / t)); elseif (t_1 <= 400.0) tmp = Float64(-Float64(log(Float64(y * expm1(z))) / t)); 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, 21.0], N[(x - N[(N[(N[(Exp[z] - 1), $MachinePrecision] * y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 400.0], (-N[(N[Log[N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $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 21:\\
\;\;\;\;x - \frac{\mathsf{expm1}\left(z\right) \cdot y}{t}\\
\mathbf{elif}\;t\_1 \leq 400:\\
\;\;\;\;-\frac{\log \left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) < 21Initial program 56.4%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6491.3
Applied rewrites91.3%
if 21 < (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) < 400Initial program 98.7%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-exp.f6451.6
Applied rewrites51.6%
Taylor expanded in y around inf
lower-*.f64N/A
lift-expm1.f6452.5
Applied rewrites52.5%
if 400 < (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) Initial program 92.5%
Taylor expanded in x around inf
Applied rewrites49.9%
(FPCore (x y z t) :precision binary64 (if (<= (log (+ (- 1.0 y) (* y (exp z)))) 120.0) (- x (/ (* (expm1 z) y) t)) x))
double code(double x, double y, double z, double t) {
double tmp;
if (log(((1.0 - y) + (y * exp(z)))) <= 120.0) {
tmp = x - ((expm1(z) * y) / t);
} else {
tmp = x;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (Math.log(((1.0 - y) + (y * Math.exp(z)))) <= 120.0) {
tmp = x - ((Math.expm1(z) * y) / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if math.log(((1.0 - y) + (y * math.exp(z)))) <= 120.0: tmp = x - ((math.expm1(z) * y) / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (log(Float64(Float64(1.0 - y) + Float64(y * exp(z)))) <= 120.0) tmp = Float64(x - Float64(Float64(expm1(z) * y) / t)); else tmp = x; end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[Log[N[(N[(1.0 - y), $MachinePrecision] + N[(y * N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 120.0], N[(x - N[(N[(N[(Exp[z] - 1), $MachinePrecision] * y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\log \left(\left(1 - y\right) + y \cdot e^{z}\right) \leq 120:\\
\;\;\;\;x - \frac{\mathsf{expm1}\left(z\right) \cdot y}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) < 120Initial program 57.1%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6490.6
Applied rewrites90.6%
if 120 < (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) Initial program 95.2%
Taylor expanded in x around inf
Applied rewrites49.0%
(FPCore (x y z t) :precision binary64 (if (<= z -1.05e+43) x (- x (* (/ z t) y))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.05e+43) {
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 <= (-1.05d+43)) 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 <= -1.05e+43) {
tmp = x;
} else {
tmp = x - ((z / t) * y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.05e+43: tmp = x else: tmp = x - ((z / t) * y) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.05e+43) 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 <= -1.05e+43) tmp = x; else tmp = x - ((z / t) * y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.05e+43], x, N[(x - N[(N[(z / t), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05 \cdot 10^{+43}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{z}{t} \cdot y\\
\end{array}
\end{array}
if z < -1.05000000000000001e43Initial program 81.1%
Taylor expanded in x around inf
Applied rewrites63.0%
if -1.05000000000000001e43 < z Initial program 53.8%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites87.2%
Taylor expanded in z around 0
lower-/.f6487.8
Applied rewrites87.8%
(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 60.7%
Taylor expanded in x around inf
Applied rewrites71.1%
herbie shell --seed 2025115
(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)))