
(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 (* (expm1 z) y)))
(if (<= (log (+ (- 1.0 y) (* y (exp z)))) 2e-11)
(- 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)))) <= 2e-11) {
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)))) <= 2e-11) {
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)))) <= 2e-11: 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)))) <= 2e-11) 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], 2e-11], 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 2 \cdot 10^{-11}:\\
\;\;\;\;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)))) < 1.99999999999999988e-11Initial program 57.2%
Taylor expanded in y around 0
Applied rewrites92.3%
if 1.99999999999999988e-11 < (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) Initial program 94.2%
Taylor expanded in y around inf
Applied rewrites93.3%
(FPCore (x y z t) :precision binary64 (if (<= (log (+ (- 1.0 y) (* y (exp z)))) 2e-11) (- 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)))) <= 2e-11) {
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)))) <= 2e-11) {
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)))) <= 2e-11: 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)))) <= 2e-11) 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], 2e-11], 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 2 \cdot 10^{-11}:\\
\;\;\;\;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)))) < 1.99999999999999988e-11Initial program 57.2%
Taylor expanded in y around 0
Applied rewrites92.3%
if 1.99999999999999988e-11 < (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) Initial program 94.2%
Taylor expanded in x around inf
Applied rewrites50.3%
(FPCore (x y z t) :precision binary64 (if (<= (exp z) 0.0) x (fma (/ (- z) t) y x)))
double code(double x, double y, double z, double t) {
double tmp;
if (exp(z) <= 0.0) {
tmp = x;
} else {
tmp = fma((-z / t), y, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (exp(z) <= 0.0) tmp = x; else tmp = fma(Float64(Float64(-z) / t), y, x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[Exp[z], $MachinePrecision], 0.0], x, N[(N[((-z) / t), $MachinePrecision] * y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{z} \leq 0:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-z}{t}, y, x\right)\\
\end{array}
\end{array}
if (exp.f64 z) < 0.0Initial program 81.4%
Taylor expanded in x around inf
Applied rewrites64.9%
if 0.0 < (exp.f64 z) Initial program 53.0%
Taylor expanded in y around 0
Applied rewrites74.2%
Taylor expanded in z around 0
Applied rewrites89.3%
(FPCore (x y z t) :precision binary64 (if (<= z -510000000.0) x (- x (/ (* z y) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -510000000.0) {
tmp = x;
} else {
tmp = x - ((z * y) / t);
}
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 <= (-510000000.0d0)) then
tmp = x
else
tmp = x - ((z * y) / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -510000000.0) {
tmp = x;
} else {
tmp = x - ((z * y) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -510000000.0: tmp = x else: tmp = x - ((z * y) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -510000000.0) tmp = x; else tmp = Float64(x - Float64(Float64(z * y) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -510000000.0) tmp = x; else tmp = x - ((z * y) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -510000000.0], x, N[(x - N[(N[(z * y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -510000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{z \cdot y}{t}\\
\end{array}
\end{array}
if z < -5.1e8Initial program 81.2%
Taylor expanded in x around inf
Applied rewrites64.9%
if -5.1e8 < z Initial program 53.4%
Taylor expanded in z around 0
Applied rewrites88.0%
(FPCore (x y z t) :precision binary64 (if (<= t -1.4e-169) x (if (<= t 4e-306) (* (/ (- z) t) y) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.4e-169) {
tmp = x;
} else if (t <= 4e-306) {
tmp = (-z / t) * y;
} 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, 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 (t <= (-1.4d-169)) then
tmp = x
else if (t <= 4d-306) then
tmp = (-z / t) * y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.4e-169) {
tmp = x;
} else if (t <= 4e-306) {
tmp = (-z / t) * y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -1.4e-169: tmp = x elif t <= 4e-306: tmp = (-z / t) * y else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -1.4e-169) tmp = x; elseif (t <= 4e-306) tmp = Float64(Float64(Float64(-z) / t) * y); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -1.4e-169) tmp = x; elseif (t <= 4e-306) tmp = (-z / t) * y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -1.4e-169], x, If[LessEqual[t, 4e-306], N[(N[((-z) / t), $MachinePrecision] * y), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.4 \cdot 10^{-169}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 4 \cdot 10^{-306}:\\
\;\;\;\;\frac{-z}{t} \cdot y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -1.39999999999999994e-169 or 4.00000000000000011e-306 < t Initial program 63.9%
Taylor expanded in x around inf
Applied rewrites75.9%
if -1.39999999999999994e-169 < t < 4.00000000000000011e-306Initial program 44.0%
Taylor expanded in y around 0
Applied rewrites51.6%
Taylor expanded in x around 0
Applied rewrites16.4%
Taylor expanded in z around 0
Applied rewrites32.6%
(FPCore (x y z t) :precision binary64 (if (<= t -1.4e-169) x (if (<= t 4e-306) (- (/ (* z y) t)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.4e-169) {
tmp = x;
} else if (t <= 4e-306) {
tmp = -((z * y) / t);
} 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, 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 (t <= (-1.4d-169)) then
tmp = x
else if (t <= 4d-306) then
tmp = -((z * y) / t)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.4e-169) {
tmp = x;
} else if (t <= 4e-306) {
tmp = -((z * y) / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -1.4e-169: tmp = x elif t <= 4e-306: tmp = -((z * y) / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -1.4e-169) tmp = x; elseif (t <= 4e-306) tmp = Float64(-Float64(Float64(z * y) / t)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -1.4e-169) tmp = x; elseif (t <= 4e-306) tmp = -((z * y) / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -1.4e-169], x, If[LessEqual[t, 4e-306], (-N[(N[(z * y), $MachinePrecision] / t), $MachinePrecision]), x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.4 \cdot 10^{-169}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 4 \cdot 10^{-306}:\\
\;\;\;\;-\frac{z \cdot y}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -1.39999999999999994e-169 or 4.00000000000000011e-306 < t Initial program 63.9%
Taylor expanded in x around inf
Applied rewrites75.9%
if -1.39999999999999994e-169 < t < 4.00000000000000011e-306Initial program 44.0%
Taylor expanded in y around 0
Applied rewrites51.6%
Taylor expanded in x around 0
Applied rewrites16.4%
Taylor expanded in z around 0
Applied rewrites29.1%
(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.6%
Taylor expanded in x around inf
Applied rewrites71.5%
herbie shell --seed 2025132
(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)))