
(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 (* y (expm1 z))))
(if (<= y -4e+16)
(- x (/ (log (+ 1.0 t_1)) t))
(if (<= y 8e+82)
(- x (/ t_1 t))
(-
x
(/
(log
(+
1.0
(* z (+ y (* z (fma 0.16666666666666666 (* y z) (* 0.5 y)))))))
t))))))
double code(double x, double y, double z, double t) {
double t_1 = y * expm1(z);
double tmp;
if (y <= -4e+16) {
tmp = x - (log((1.0 + t_1)) / t);
} else if (y <= 8e+82) {
tmp = x - (t_1 / t);
} else {
tmp = x - (log((1.0 + (z * (y + (z * fma(0.16666666666666666, (y * z), (0.5 * y))))))) / t);
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(y * expm1(z)) tmp = 0.0 if (y <= -4e+16) tmp = Float64(x - Float64(log(Float64(1.0 + t_1)) / t)); elseif (y <= 8e+82) tmp = Float64(x - Float64(t_1 / t)); else tmp = Float64(x - Float64(log(Float64(1.0 + Float64(z * Float64(y + Float64(z * fma(0.16666666666666666, Float64(y * z), Float64(0.5 * y))))))) / t)); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4e+16], N[(x - N[(N[Log[N[(1.0 + t$95$1), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8e+82], N[(x - N[(t$95$1 / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[N[(1.0 + N[(z * N[(y + N[(z * N[(0.16666666666666666 * N[(y * z), $MachinePrecision] + N[(0.5 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \mathsf{expm1}\left(z\right)\\
\mathbf{if}\;y \leq -4 \cdot 10^{+16}:\\
\;\;\;\;x - \frac{\log \left(1 + t\_1\right)}{t}\\
\mathbf{elif}\;y \leq 8 \cdot 10^{+82}:\\
\;\;\;\;x - \frac{t\_1}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(1 + z \cdot \left(y + z \cdot \mathsf{fma}\left(0.16666666666666666, y \cdot z, 0.5 \cdot y\right)\right)\right)}{t}\\
\end{array}
\end{array}
if y < -4e16Initial program 60.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower-expm1.f6481.6
Applied rewrites81.6%
if -4e16 < y < 7.9999999999999997e82Initial program 60.9%
Taylor expanded in y around 0
lower-*.f64N/A
lower-expm1.f6485.4
Applied rewrites85.4%
if 7.9999999999999997e82 < y Initial program 60.9%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6463.0
Applied rewrites63.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* y (expm1 z))) (t_2 (- x (/ (log (+ 1.0 t_1)) t)))) (if (<= y -4e+16) t_2 (if (<= y 8e+82) (- x (/ t_1 t)) t_2))))
double code(double x, double y, double z, double t) {
double t_1 = y * expm1(z);
double t_2 = x - (log((1.0 + t_1)) / t);
double tmp;
if (y <= -4e+16) {
tmp = t_2;
} else if (y <= 8e+82) {
tmp = x - (t_1 / t);
} else {
tmp = t_2;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = y * Math.expm1(z);
double t_2 = x - (Math.log((1.0 + t_1)) / t);
double tmp;
if (y <= -4e+16) {
tmp = t_2;
} else if (y <= 8e+82) {
tmp = x - (t_1 / t);
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t): t_1 = y * math.expm1(z) t_2 = x - (math.log((1.0 + t_1)) / t) tmp = 0 if y <= -4e+16: tmp = t_2 elif y <= 8e+82: tmp = x - (t_1 / t) else: tmp = t_2 return tmp
function code(x, y, z, t) t_1 = Float64(y * expm1(z)) t_2 = Float64(x - Float64(log(Float64(1.0 + t_1)) / t)) tmp = 0.0 if (y <= -4e+16) tmp = t_2; elseif (y <= 8e+82) tmp = Float64(x - Float64(t_1 / t)); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x - N[(N[Log[N[(1.0 + t$95$1), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4e+16], t$95$2, If[LessEqual[y, 8e+82], N[(x - N[(t$95$1 / t), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \mathsf{expm1}\left(z\right)\\
t_2 := x - \frac{\log \left(1 + t\_1\right)}{t}\\
\mathbf{if}\;y \leq -4 \cdot 10^{+16}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 8 \cdot 10^{+82}:\\
\;\;\;\;x - \frac{t\_1}{t}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if y < -4e16 or 7.9999999999999997e82 < y Initial program 60.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower-expm1.f6481.6
Applied rewrites81.6%
if -4e16 < y < 7.9999999999999997e82Initial program 60.9%
Taylor expanded in y around 0
lower-*.f64N/A
lower-expm1.f6485.4
Applied rewrites85.4%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (- x (/ (log (fma z y 1.0)) t)))) (if (<= y -7e+179) t_1 (if (<= y 8e+82) (- x (/ (* y (expm1 z)) t)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = x - (log(fma(z, y, 1.0)) / t);
double tmp;
if (y <= -7e+179) {
tmp = t_1;
} else if (y <= 8e+82) {
tmp = x - ((y * expm1(z)) / t);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(x - Float64(log(fma(z, y, 1.0)) / t)) tmp = 0.0 if (y <= -7e+179) tmp = t_1; elseif (y <= 8e+82) tmp = Float64(x - Float64(Float64(y * expm1(z)) / t)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x - N[(N[Log[N[(z * y + 1.0), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -7e+179], t$95$1, If[LessEqual[y, 8e+82], N[(x - N[(N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x - \frac{\log \left(\mathsf{fma}\left(z, y, 1\right)\right)}{t}\\
\mathbf{if}\;y \leq -7 \cdot 10^{+179}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 8 \cdot 10^{+82}:\\
\;\;\;\;x - \frac{y \cdot \mathsf{expm1}\left(z\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -7.0000000000000003e179 or 7.9999999999999997e82 < y Initial program 60.9%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f6470.0
Applied rewrites70.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6470.0
Applied rewrites70.0%
if -7.0000000000000003e179 < y < 7.9999999999999997e82Initial program 60.9%
Taylor expanded in y around 0
lower-*.f64N/A
lower-expm1.f6485.4
Applied rewrites85.4%
(FPCore (x y z t) :precision binary64 (if (<= y -3.2e+169) (- x (/ (log 1.0) t)) (- x (/ (* y (expm1 z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.2e+169) {
tmp = x - (log(1.0) / t);
} else {
tmp = x - ((y * expm1(z)) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.2e+169) {
tmp = x - (Math.log(1.0) / t);
} else {
tmp = x - ((y * Math.expm1(z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -3.2e+169: tmp = x - (math.log(1.0) / t) else: tmp = x - ((y * math.expm1(z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -3.2e+169) tmp = Float64(x - Float64(log(1.0) / t)); else tmp = Float64(x - Float64(Float64(y * expm1(z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -3.2e+169], N[(x - N[(N[Log[1.0], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.2 \cdot 10^{+169}:\\
\;\;\;\;x - \frac{\log 1}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y \cdot \mathsf{expm1}\left(z\right)}{t}\\
\end{array}
\end{array}
if y < -3.1999999999999998e169Initial program 60.9%
Taylor expanded in y around 0
Applied rewrites71.1%
if -3.1999999999999998e169 < y Initial program 60.9%
Taylor expanded in y around 0
lower-*.f64N/A
lower-expm1.f6485.4
Applied rewrites85.4%
(FPCore (x y z t) :precision binary64 (if (<= z -40000000.0) (- x (/ (log 1.0) t)) (- x (/ (* y z) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -40000000.0) {
tmp = x - (log(1.0) / t);
} else {
tmp = x - ((y * z) / 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 <= (-40000000.0d0)) then
tmp = x - (log(1.0d0) / t)
else
tmp = x - ((y * z) / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -40000000.0) {
tmp = x - (Math.log(1.0) / t);
} else {
tmp = x - ((y * z) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -40000000.0: tmp = x - (math.log(1.0) / t) else: tmp = x - ((y * z) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -40000000.0) tmp = Float64(x - Float64(log(1.0) / t)); else tmp = Float64(x - Float64(Float64(y * z) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -40000000.0) tmp = x - (log(1.0) / t); else tmp = x - ((y * z) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -40000000.0], N[(x - N[(N[Log[1.0], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -40000000:\\
\;\;\;\;x - \frac{\log 1}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y \cdot z}{t}\\
\end{array}
\end{array}
if z < -4e7Initial program 60.9%
Taylor expanded in y around 0
Applied rewrites71.1%
if -4e7 < z Initial program 60.9%
Taylor expanded in z around 0
lower-*.f6473.3
Applied rewrites73.3%
(FPCore (x y z t) :precision binary64 (- x (/ (* y z) t)))
double code(double x, double y, double z, double t) {
return x - ((y * 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 - ((y * z) / t)
end function
public static double code(double x, double y, double z, double t) {
return x - ((y * z) / t);
}
def code(x, y, z, t): return x - ((y * z) / t)
function code(x, y, z, t) return Float64(x - Float64(Float64(y * z) / t)) end
function tmp = code(x, y, z, t) tmp = x - ((y * z) / t); end
code[x_, y_, z_, t_] := N[(x - N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y \cdot z}{t}
\end{array}
Initial program 60.9%
Taylor expanded in z around 0
lower-*.f6473.3
Applied rewrites73.3%
(FPCore (x y z t) :precision binary64 (- (* z (/ y t))))
double code(double x, double y, double z, double t) {
return -(z * (y / 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 = -(z * (y / t))
end function
public static double code(double x, double y, double z, double t) {
return -(z * (y / t));
}
def code(x, y, z, t): return -(z * (y / t))
function code(x, y, z, t) return Float64(-Float64(z * Float64(y / t))) end
function tmp = code(x, y, z, t) tmp = -(z * (y / t)); end
code[x_, y_, z_, t_] := (-N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision])
\begin{array}{l}
\\
-z \cdot \frac{y}{t}
\end{array}
Initial program 60.9%
Taylor expanded in x around 0
lower-*.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-exp.f648.4
Applied rewrites8.4%
Taylor expanded in z around 0
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6414.4
Applied rewrites14.4%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6414.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.4
Applied rewrites14.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6413.1
Applied rewrites13.1%
herbie shell --seed 2025156
(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)))