
(FPCore (x y z t) :precision binary64 (- (+ (* x (log y)) (* z (log (- 1.0 y)))) t))
double code(double x, double y, double z, double t) {
return ((x * log(y)) + (z * log((1.0 - 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 = ((x * log(y)) + (z * log((1.0d0 - y)))) - t
end function
public static double code(double x, double y, double z, double t) {
return ((x * Math.log(y)) + (z * Math.log((1.0 - y)))) - t;
}
def code(x, y, z, t): return ((x * math.log(y)) + (z * math.log((1.0 - y)))) - t
function code(x, y, z, t) return Float64(Float64(Float64(x * log(y)) + Float64(z * log(Float64(1.0 - y)))) - t) end
function tmp = code(x, y, z, t) tmp = ((x * log(y)) + (z * log((1.0 - y)))) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t
\end{array}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (- (+ (* x (log y)) (* z (log (- 1.0 y)))) t))
double code(double x, double y, double z, double t) {
return ((x * log(y)) + (z * log((1.0 - 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 = ((x * log(y)) + (z * log((1.0d0 - y)))) - t
end function
public static double code(double x, double y, double z, double t) {
return ((x * Math.log(y)) + (z * Math.log((1.0 - y)))) - t;
}
def code(x, y, z, t): return ((x * math.log(y)) + (z * math.log((1.0 - y)))) - t
function code(x, y, z, t) return Float64(Float64(Float64(x * log(y)) + Float64(z * log(Float64(1.0 - y)))) - t) end
function tmp = code(x, y, z, t) tmp = ((x * log(y)) + (z * log((1.0 - y)))) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t
\end{array}
(FPCore (x y z t) :precision binary64 (- (fma (log y) x (* (* z (fma -0.5 y -1.0)) y)) t))
double code(double x, double y, double z, double t) {
return fma(log(y), x, ((z * fma(-0.5, y, -1.0)) * y)) - t;
}
function code(x, y, z, t) return Float64(fma(log(y), x, Float64(Float64(z * fma(-0.5, y, -1.0)) * y)) - t) end
code[x_, y_, z_, t_] := N[(N[(N[Log[y], $MachinePrecision] * x + N[(N[(z * N[(-0.5 * y + -1.0), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\log y, x, \left(z \cdot \mathsf{fma}\left(-0.5, y, -1\right)\right) \cdot y\right) - t
\end{array}
Initial program 85.3%
Taylor expanded in y around 0
*-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lift-log.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.5%
(FPCore (x y z t) :precision binary64 (fma (log y) x (- (fma z y t))))
double code(double x, double y, double z, double t) {
return fma(log(y), x, -fma(z, y, t));
}
function code(x, y, z, t) return fma(log(y), x, Float64(-fma(z, y, t))) end
code[x_, y_, z_, t_] := N[(N[Log[y], $MachinePrecision] * x + (-N[(z * y + t), $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\log y, x, -\mathsf{fma}\left(z, y, t\right)\right)
\end{array}
Initial program 85.3%
Taylor expanded in y around 0
*-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lift-log.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.5%
Taylor expanded in y around 0
associate--l+N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
mul-1-negN/A
lift-neg.f64N/A
lift-neg.f64N/A
associate--l+N/A
Applied rewrites99.2%
lift--.f64N/A
lift-*.f64N/A
lift-log.f64N/A
*-commutativeN/A
lift-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
associate--r+N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
mul-1-negN/A
associate--l+N/A
*-commutativeN/A
fp-cancel-sub-signN/A
mul-1-negN/A
associate-*r*N/A
mul-1-negN/A
distribute-lft-inN/A
lower-fma.f64N/A
lift-log.f64N/A
mul-1-negN/A
+-commutativeN/A
*-commutativeN/A
Applied rewrites99.2%
(FPCore (x y z t) :precision binary64 (- (* (log y) x) (fma z y t)))
double code(double x, double y, double z, double t) {
return (log(y) * x) - fma(z, y, t);
}
function code(x, y, z, t) return Float64(Float64(log(y) * x) - fma(z, y, t)) end
code[x_, y_, z_, t_] := N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - N[(z * y + t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\log y \cdot x - \mathsf{fma}\left(z, y, t\right)
\end{array}
Initial program 85.3%
Taylor expanded in y around 0
*-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lift-log.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.5%
Taylor expanded in y around 0
associate--l+N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
mul-1-negN/A
lift-neg.f64N/A
lift-neg.f64N/A
associate--l+N/A
Applied rewrites99.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (log y) x)))
(if (<= t -1.45e-89)
(fma (log y) x (- t))
(if (<= t 1.22e-28) (- t_1 (* z y)) (- t_1 t)))))
double code(double x, double y, double z, double t) {
double t_1 = log(y) * x;
double tmp;
if (t <= -1.45e-89) {
tmp = fma(log(y), x, -t);
} else if (t <= 1.22e-28) {
tmp = t_1 - (z * y);
} else {
tmp = t_1 - t;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(log(y) * x) tmp = 0.0 if (t <= -1.45e-89) tmp = fma(log(y), x, Float64(-t)); elseif (t <= 1.22e-28) tmp = Float64(t_1 - Float64(z * y)); else tmp = Float64(t_1 - t); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[t, -1.45e-89], N[(N[Log[y], $MachinePrecision] * x + (-t)), $MachinePrecision], If[LessEqual[t, 1.22e-28], N[(t$95$1 - N[(z * y), $MachinePrecision]), $MachinePrecision], N[(t$95$1 - t), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log y \cdot x\\
\mathbf{if}\;t \leq -1.45 \cdot 10^{-89}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x, -t\right)\\
\mathbf{elif}\;t \leq 1.22 \cdot 10^{-28}:\\
\;\;\;\;t\_1 - z \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_1 - t\\
\end{array}
\end{array}
if t < -1.44999999999999996e-89Initial program 91.3%
Taylor expanded in y around 0
*-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lift-log.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.6%
Taylor expanded in y around 0
associate--l+N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
mul-1-negN/A
lift-neg.f64N/A
lift-neg.f64N/A
associate--l+N/A
Applied rewrites99.3%
lift--.f64N/A
lift-*.f64N/A
lift-log.f64N/A
*-commutativeN/A
lift-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
associate--r+N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
mul-1-negN/A
associate--l+N/A
*-commutativeN/A
fp-cancel-sub-signN/A
mul-1-negN/A
associate-*r*N/A
mul-1-negN/A
distribute-lft-inN/A
lower-fma.f64N/A
lift-log.f64N/A
mul-1-negN/A
+-commutativeN/A
*-commutativeN/A
Applied rewrites99.3%
Taylor expanded in y around 0
Applied rewrites90.4%
if -1.44999999999999996e-89 < t < 1.22e-28Initial program 74.9%
Taylor expanded in y around 0
*-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lift-log.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.3%
Taylor expanded in y around 0
associate--l+N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
mul-1-negN/A
lift-neg.f64N/A
lift-neg.f64N/A
associate--l+N/A
Applied rewrites98.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6487.2
Applied rewrites87.2%
if 1.22e-28 < t Initial program 93.4%
Taylor expanded in x around inf
*-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lift-log.f6492.8
Applied rewrites92.8%
(FPCore (x y z t) :precision binary64 (if (<= z -5.5e+185) (- (fma z y t)) (fma (log y) x (- t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5.5e+185) {
tmp = -fma(z, y, t);
} else {
tmp = fma(log(y), x, -t);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= -5.5e+185) tmp = Float64(-fma(z, y, t)); else tmp = fma(log(y), x, Float64(-t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -5.5e+185], (-N[(z * y + t), $MachinePrecision]), N[(N[Log[y], $MachinePrecision] * x + (-t)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{+185}:\\
\;\;\;\;-\mathsf{fma}\left(z, y, t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x, -t\right)\\
\end{array}
\end{array}
if z < -5.4999999999999996e185Initial program 56.5%
Taylor expanded in y around 0
*-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lift-log.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.0%
Taylor expanded in y around 0
associate--l+N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
mul-1-negN/A
lift-neg.f64N/A
lift-neg.f64N/A
associate--l+N/A
Applied rewrites98.4%
Taylor expanded in x around 0
mul-1-negN/A
+-commutativeN/A
*-commutativeN/A
lower-neg.f64N/A
lift-fma.f6471.7
Applied rewrites71.7%
if -5.4999999999999996e185 < z Initial program 88.3%
Taylor expanded in y around 0
*-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lift-log.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.5%
Taylor expanded in y around 0
associate--l+N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
mul-1-negN/A
lift-neg.f64N/A
lift-neg.f64N/A
associate--l+N/A
Applied rewrites99.2%
lift--.f64N/A
lift-*.f64N/A
lift-log.f64N/A
*-commutativeN/A
lift-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
associate--r+N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
mul-1-negN/A
associate--l+N/A
*-commutativeN/A
fp-cancel-sub-signN/A
mul-1-negN/A
associate-*r*N/A
mul-1-negN/A
distribute-lft-inN/A
lower-fma.f64N/A
lift-log.f64N/A
mul-1-negN/A
+-commutativeN/A
*-commutativeN/A
Applied rewrites99.2%
Taylor expanded in y around 0
Applied rewrites87.4%
(FPCore (x y z t) :precision binary64 (if (<= z -5.5e+185) (- (fma z y t)) (- (* (log y) x) t)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5.5e+185) {
tmp = -fma(z, y, t);
} else {
tmp = (log(y) * x) - t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= -5.5e+185) tmp = Float64(-fma(z, y, t)); else tmp = Float64(Float64(log(y) * x) - t); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -5.5e+185], (-N[(z * y + t), $MachinePrecision]), N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{+185}:\\
\;\;\;\;-\mathsf{fma}\left(z, y, t\right)\\
\mathbf{else}:\\
\;\;\;\;\log y \cdot x - t\\
\end{array}
\end{array}
if z < -5.4999999999999996e185Initial program 56.5%
Taylor expanded in y around 0
*-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lift-log.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.0%
Taylor expanded in y around 0
associate--l+N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
mul-1-negN/A
lift-neg.f64N/A
lift-neg.f64N/A
associate--l+N/A
Applied rewrites98.4%
Taylor expanded in x around 0
mul-1-negN/A
+-commutativeN/A
*-commutativeN/A
lower-neg.f64N/A
lift-fma.f6471.7
Applied rewrites71.7%
if -5.4999999999999996e185 < z Initial program 88.3%
Taylor expanded in x around inf
*-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lift-log.f6487.4
Applied rewrites87.4%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (log y) x))) (if (<= x -8.5e+114) t_1 (if (<= x 2.3e+88) (- (fma z y t)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = log(y) * x;
double tmp;
if (x <= -8.5e+114) {
tmp = t_1;
} else if (x <= 2.3e+88) {
tmp = -fma(z, y, t);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(log(y) * x) tmp = 0.0 if (x <= -8.5e+114) tmp = t_1; elseif (x <= 2.3e+88) tmp = Float64(-fma(z, y, t)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -8.5e+114], t$95$1, If[LessEqual[x, 2.3e+88], (-N[(z * y + t), $MachinePrecision]), t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log y \cdot x\\
\mathbf{if}\;x \leq -8.5 \cdot 10^{+114}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{+88}:\\
\;\;\;\;-\mathsf{fma}\left(z, y, t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -8.5000000000000001e114 or 2.3000000000000002e88 < x Initial program 97.3%
Taylor expanded in x around inf
*-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lift-log.f6481.1
Applied rewrites81.1%
if -8.5000000000000001e114 < x < 2.3000000000000002e88Initial program 79.3%
Taylor expanded in y around 0
*-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lift-log.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.5%
Taylor expanded in y around 0
associate--l+N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
mul-1-negN/A
lift-neg.f64N/A
lift-neg.f64N/A
associate--l+N/A
Applied rewrites99.1%
Taylor expanded in x around 0
mul-1-negN/A
+-commutativeN/A
*-commutativeN/A
lower-neg.f64N/A
lift-fma.f6476.4
Applied rewrites76.4%
(FPCore (x y z t) :precision binary64 (- (fma z y t)))
double code(double x, double y, double z, double t) {
return -fma(z, y, t);
}
function code(x, y, z, t) return Float64(-fma(z, y, t)) end
code[x_, y_, z_, t_] := (-N[(z * y + t), $MachinePrecision])
\begin{array}{l}
\\
-\mathsf{fma}\left(z, y, t\right)
\end{array}
Initial program 85.3%
Taylor expanded in y around 0
*-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lift-log.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.5%
Taylor expanded in y around 0
associate--l+N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
mul-1-negN/A
lift-neg.f64N/A
lift-neg.f64N/A
associate--l+N/A
Applied rewrites99.2%
Taylor expanded in x around 0
mul-1-negN/A
+-commutativeN/A
*-commutativeN/A
lower-neg.f64N/A
lift-fma.f6457.4
Applied rewrites57.4%
(FPCore (x y z t) :precision binary64 (if (<= t -1.45e-89) (- t) (if (<= t 1.22e-28) (* (- y) z) (- t))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.45e-89) {
tmp = -t;
} else if (t <= 1.22e-28) {
tmp = -y * z;
} else {
tmp = -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 (t <= (-1.45d-89)) then
tmp = -t
else if (t <= 1.22d-28) then
tmp = -y * z
else
tmp = -t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.45e-89) {
tmp = -t;
} else if (t <= 1.22e-28) {
tmp = -y * z;
} else {
tmp = -t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -1.45e-89: tmp = -t elif t <= 1.22e-28: tmp = -y * z else: tmp = -t return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -1.45e-89) tmp = Float64(-t); elseif (t <= 1.22e-28) tmp = Float64(Float64(-y) * z); else tmp = Float64(-t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -1.45e-89) tmp = -t; elseif (t <= 1.22e-28) tmp = -y * z; else tmp = -t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -1.45e-89], (-t), If[LessEqual[t, 1.22e-28], N[((-y) * z), $MachinePrecision], (-t)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.45 \cdot 10^{-89}:\\
\;\;\;\;-t\\
\mathbf{elif}\;t \leq 1.22 \cdot 10^{-28}:\\
\;\;\;\;\left(-y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;-t\\
\end{array}
\end{array}
if t < -1.44999999999999996e-89 or 1.22e-28 < t Initial program 92.3%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6462.8
Applied rewrites62.8%
if -1.44999999999999996e-89 < t < 1.22e-28Initial program 74.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f644.3
Applied rewrites4.3%
Taylor expanded in y around 0
mul-1-negN/A
lift-neg.f6427.1
Applied rewrites27.1%
(FPCore (x y z t) :precision binary64 (- t))
double code(double x, double y, double z, double t) {
return -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 = -t
end function
public static double code(double x, double y, double z, double t) {
return -t;
}
def code(x, y, z, t): return -t
function code(x, y, z, t) return Float64(-t) end
function tmp = code(x, y, z, t) tmp = -t; end
code[x_, y_, z_, t_] := (-t)
\begin{array}{l}
\\
-t
\end{array}
Initial program 85.3%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6442.9
Applied rewrites42.9%
herbie shell --seed 2025130
(FPCore (x y z t)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, B"
:precision binary64
(- (+ (* x (log y)) (* z (log (- 1.0 y)))) t))