
(FPCore (x y z t) :precision binary64 (- (+ (* (- x 1.0) (log y)) (* (- z 1.0) (log (- 1.0 y)))) t))
double code(double x, double y, double z, double t) {
return (((x - 1.0) * log(y)) + ((z - 1.0) * 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 - 1.0d0) * log(y)) + ((z - 1.0d0) * log((1.0d0 - y)))) - t
end function
public static double code(double x, double y, double z, double t) {
return (((x - 1.0) * Math.log(y)) + ((z - 1.0) * Math.log((1.0 - y)))) - t;
}
def code(x, y, z, t): return (((x - 1.0) * math.log(y)) + ((z - 1.0) * math.log((1.0 - y)))) - t
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x - 1.0) * log(y)) + Float64(Float64(z - 1.0) * log(Float64(1.0 - y)))) - t) end
function tmp = code(x, y, z, t) tmp = (((x - 1.0) * log(y)) + ((z - 1.0) * log((1.0 - y)))) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[(N[(z - 1.0), $MachinePrecision] * N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (- (+ (* (- x 1.0) (log y)) (* (- z 1.0) (log (- 1.0 y)))) t))
double code(double x, double y, double z, double t) {
return (((x - 1.0) * log(y)) + ((z - 1.0) * 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 - 1.0d0) * log(y)) + ((z - 1.0d0) * log((1.0d0 - y)))) - t
end function
public static double code(double x, double y, double z, double t) {
return (((x - 1.0) * Math.log(y)) + ((z - 1.0) * Math.log((1.0 - y)))) - t;
}
def code(x, y, z, t): return (((x - 1.0) * math.log(y)) + ((z - 1.0) * math.log((1.0 - y)))) - t
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x - 1.0) * log(y)) + Float64(Float64(z - 1.0) * log(Float64(1.0 - y)))) - t) end
function tmp = code(x, y, z, t) tmp = (((x - 1.0) * log(y)) + ((z - 1.0) * log((1.0 - y)))) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[(N[(z - 1.0), $MachinePrecision] * N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t
\end{array}
(FPCore (x y z t) :precision binary64 (fma (- z 1.0) (log1p (- y)) (- (* (log y) (- x 1.0)) t)))
double code(double x, double y, double z, double t) {
return fma((z - 1.0), log1p(-y), ((log(y) * (x - 1.0)) - t));
}
function code(x, y, z, t) return fma(Float64(z - 1.0), log1p(Float64(-y)), Float64(Float64(log(y) * Float64(x - 1.0)) - t)) end
code[x_, y_, z_, t_] := N[(N[(z - 1.0), $MachinePrecision] * N[Log[1 + (-y)], $MachinePrecision] + N[(N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z - 1, \mathsf{log1p}\left(-y\right), \log y \cdot \left(x - 1\right) - t\right)
\end{array}
Initial program 91.0%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift-log.f64N/A
unpow1N/A
unpow1N/A
lift--.f64N/A
*-lft-identityN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
*-lft-identityN/A
lower-log1p.f64N/A
lower-neg.f64N/A
lower--.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ (* (- x 1.0) (log y)) (* (- z 1.0) (log (- 1.0 y))))))
(if (or (<= t_1 -20000.0) (not (<= t_1 800.0)))
(- (* (log y) x) t)
(- (- (- (log y) y)) t))))
double code(double x, double y, double z, double t) {
double t_1 = ((x - 1.0) * log(y)) + ((z - 1.0) * log((1.0 - y)));
double tmp;
if ((t_1 <= -20000.0) || !(t_1 <= 800.0)) {
tmp = (log(y) * x) - t;
} else {
tmp = -(log(y) - 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) :: t_1
real(8) :: tmp
t_1 = ((x - 1.0d0) * log(y)) + ((z - 1.0d0) * log((1.0d0 - y)))
if ((t_1 <= (-20000.0d0)) .or. (.not. (t_1 <= 800.0d0))) then
tmp = (log(y) * x) - t
else
tmp = -(log(y) - y) - t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = ((x - 1.0) * Math.log(y)) + ((z - 1.0) * Math.log((1.0 - y)));
double tmp;
if ((t_1 <= -20000.0) || !(t_1 <= 800.0)) {
tmp = (Math.log(y) * x) - t;
} else {
tmp = -(Math.log(y) - y) - t;
}
return tmp;
}
def code(x, y, z, t): t_1 = ((x - 1.0) * math.log(y)) + ((z - 1.0) * math.log((1.0 - y))) tmp = 0 if (t_1 <= -20000.0) or not (t_1 <= 800.0): tmp = (math.log(y) * x) - t else: tmp = -(math.log(y) - y) - t return tmp
function code(x, y, z, t) t_1 = Float64(Float64(Float64(x - 1.0) * log(y)) + Float64(Float64(z - 1.0) * log(Float64(1.0 - y)))) tmp = 0.0 if ((t_1 <= -20000.0) || !(t_1 <= 800.0)) tmp = Float64(Float64(log(y) * x) - t); else tmp = Float64(Float64(-Float64(log(y) - y)) - t); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = ((x - 1.0) * log(y)) + ((z - 1.0) * log((1.0 - y))); tmp = 0.0; if ((t_1 <= -20000.0) || ~((t_1 <= 800.0))) tmp = (log(y) * x) - t; else tmp = -(log(y) - y) - t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[(N[(z - 1.0), $MachinePrecision] * N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -20000.0], N[Not[LessEqual[t$95$1, 800.0]], $MachinePrecision]], N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - t), $MachinePrecision], N[((-N[(N[Log[y], $MachinePrecision] - y), $MachinePrecision]) - t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\\
\mathbf{if}\;t\_1 \leq -20000 \lor \neg \left(t\_1 \leq 800\right):\\
\;\;\;\;\log y \cdot x - t\\
\mathbf{else}:\\
\;\;\;\;\left(-\left(\log y - y\right)\right) - t\\
\end{array}
\end{array}
if (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y)))) < -2e4 or 800 < (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y)))) Initial program 92.1%
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
lower-log.f6489.1
Applied rewrites89.1%
if -2e4 < (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y)))) < 800Initial program 89.9%
Taylor expanded in y around 0
+-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites98.2%
Taylor expanded in z around 0
Applied rewrites88.1%
Final simplification88.6%
(FPCore (x y z t)
:precision binary64
(-
(fma
(+ -1.0 x)
(log y)
(fma
(- z 1.0)
(- y)
(* (* (* (fma y -0.3333333333333333 -0.5) y) (- z 1.0)) y)))
t))
double code(double x, double y, double z, double t) {
return fma((-1.0 + x), log(y), fma((z - 1.0), -y, (((fma(y, -0.3333333333333333, -0.5) * y) * (z - 1.0)) * y))) - t;
}
function code(x, y, z, t) return Float64(fma(Float64(-1.0 + x), log(y), fma(Float64(z - 1.0), Float64(-y), Float64(Float64(Float64(fma(y, -0.3333333333333333, -0.5) * y) * Float64(z - 1.0)) * y))) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(-1.0 + x), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(N[(z - 1.0), $MachinePrecision] * (-y) + N[(N[(N[(N[(y * -0.3333333333333333 + -0.5), $MachinePrecision] * y), $MachinePrecision] * N[(z - 1.0), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-1 + x, \log y, \mathsf{fma}\left(z - 1, -y, \left(\left(\mathsf{fma}\left(y, -0.3333333333333333, -0.5\right) \cdot y\right) \cdot \left(z - 1\right)\right) \cdot y\right)\right) - t
\end{array}
Initial program 91.0%
Taylor expanded in y around 0
+-commutativeN/A
Applied rewrites99.6%
Applied rewrites99.6%
(FPCore (x y z t) :precision binary64 (- (fma (+ -1.0 x) (log y) (* (fma (* (- z 1.0) (fma -0.3333333333333333 y -0.5)) y (- (- z 1.0))) y)) t))
double code(double x, double y, double z, double t) {
return fma((-1.0 + x), log(y), (fma(((z - 1.0) * fma(-0.3333333333333333, y, -0.5)), y, -(z - 1.0)) * y)) - t;
}
function code(x, y, z, t) return Float64(fma(Float64(-1.0 + x), log(y), Float64(fma(Float64(Float64(z - 1.0) * fma(-0.3333333333333333, y, -0.5)), y, Float64(-Float64(z - 1.0))) * y)) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(-1.0 + x), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(N[(N[(N[(z - 1.0), $MachinePrecision] * N[(-0.3333333333333333 * y + -0.5), $MachinePrecision]), $MachinePrecision] * y + (-N[(z - 1.0), $MachinePrecision])), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-1 + x, \log y, \mathsf{fma}\left(\left(z - 1\right) \cdot \mathsf{fma}\left(-0.3333333333333333, y, -0.5\right), y, -\left(z - 1\right)\right) \cdot y\right) - t
\end{array}
Initial program 91.0%
Taylor expanded in y around 0
+-commutativeN/A
Applied rewrites99.6%
(FPCore (x y z t) :precision binary64 (fma (- z 1.0) (* (- (* (- (* -0.3333333333333333 y) 0.5) y) 1.0) y) (- (* (log y) (- x 1.0)) t)))
double code(double x, double y, double z, double t) {
return fma((z - 1.0), (((((-0.3333333333333333 * y) - 0.5) * y) - 1.0) * y), ((log(y) * (x - 1.0)) - t));
}
function code(x, y, z, t) return fma(Float64(z - 1.0), Float64(Float64(Float64(Float64(Float64(-0.3333333333333333 * y) - 0.5) * y) - 1.0) * y), Float64(Float64(log(y) * Float64(x - 1.0)) - t)) end
code[x_, y_, z_, t_] := N[(N[(z - 1.0), $MachinePrecision] * N[(N[(N[(N[(N[(-0.3333333333333333 * y), $MachinePrecision] - 0.5), $MachinePrecision] * y), $MachinePrecision] - 1.0), $MachinePrecision] * y), $MachinePrecision] + N[(N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z - 1, \left(\left(-0.3333333333333333 \cdot y - 0.5\right) \cdot y - 1\right) \cdot y, \log y \cdot \left(x - 1\right) - t\right)
\end{array}
Initial program 91.0%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift-log.f64N/A
unpow1N/A
unpow1N/A
lift--.f64N/A
*-lft-identityN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
*-lft-identityN/A
lower-log1p.f64N/A
lower-neg.f64N/A
lower--.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6499.6
Applied rewrites99.6%
(FPCore (x y z t) :precision binary64 (- (fma (* (- z 1.0) (fma -0.5 y -1.0)) y (* (log y) (- x 1.0))) t))
double code(double x, double y, double z, double t) {
return fma(((z - 1.0) * fma(-0.5, y, -1.0)), y, (log(y) * (x - 1.0))) - t;
}
function code(x, y, z, t) return Float64(fma(Float64(Float64(z - 1.0) * fma(-0.5, y, -1.0)), y, Float64(log(y) * Float64(x - 1.0))) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(N[(z - 1.0), $MachinePrecision] * N[(-0.5 * y + -1.0), $MachinePrecision]), $MachinePrecision] * y + N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(z - 1\right) \cdot \mathsf{fma}\left(-0.5, y, -1\right), y, \log y \cdot \left(x - 1\right)\right) - t
\end{array}
Initial program 91.0%
Taylor expanded in y around 0
+-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
Applied rewrites99.0%
Taylor expanded in y around 0
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower--.f64N/A
lower-fma.f64N/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
lower-*.f64N/A
Applied rewrites99.5%
(FPCore (x y z t) :precision binary64 (if (or (<= x -0.00038) (not (<= x 3.3e-21))) (- (* (+ -1.0 x) (log y)) t) (- (- (fma (- z 1.0) y (log y))) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -0.00038) || !(x <= 3.3e-21)) {
tmp = ((-1.0 + x) * log(y)) - t;
} else {
tmp = -fma((z - 1.0), y, log(y)) - t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((x <= -0.00038) || !(x <= 3.3e-21)) tmp = Float64(Float64(Float64(-1.0 + x) * log(y)) - t); else tmp = Float64(Float64(-fma(Float64(z - 1.0), y, log(y))) - t); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -0.00038], N[Not[LessEqual[x, 3.3e-21]], $MachinePrecision]], N[(N[(N[(-1.0 + x), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[((-N[(N[(z - 1.0), $MachinePrecision] * y + N[Log[y], $MachinePrecision]), $MachinePrecision]) - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00038 \lor \neg \left(x \leq 3.3 \cdot 10^{-21}\right):\\
\;\;\;\;\left(-1 + x\right) \cdot \log y - t\\
\mathbf{else}:\\
\;\;\;\;\left(-\mathsf{fma}\left(z - 1, y, \log y\right)\right) - t\\
\end{array}
\end{array}
if x < -3.8000000000000002e-4 or 3.30000000000000009e-21 < x Initial program 93.3%
Taylor expanded in y around 0
remove-double-negN/A
log-recN/A
mul-1-negN/A
distribute-rgt-out--N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
+-commutativeN/A
distribute-rgt-outN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f64N/A
mul-1-negN/A
log-recN/A
Applied rewrites93.3%
if -3.8000000000000002e-4 < x < 3.30000000000000009e-21Initial program 88.4%
Taylor expanded in y around 0
+-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
Applied rewrites98.3%
Taylor expanded in x around 0
Applied rewrites97.5%
Final simplification95.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (log y) x)))
(if (<= x -13500.0)
t_1
(if (<= x 2.95e-64)
(- (- (- (log y) y)) t)
(if (<= x 6.6e+66)
(- (* (* (- (* (- (* -0.3333333333333333 y) 0.5) y) 1.0) 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 <= -13500.0) {
tmp = t_1;
} else if (x <= 2.95e-64) {
tmp = -(log(y) - y) - t;
} else if (x <= 6.6e+66) {
tmp = ((((((-0.3333333333333333 * y) - 0.5) * y) - 1.0) * z) * y) - t;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_1 = log(y) * x
if (x <= (-13500.0d0)) then
tmp = t_1
else if (x <= 2.95d-64) then
tmp = -(log(y) - y) - t
else if (x <= 6.6d+66) then
tmp = (((((((-0.3333333333333333d0) * y) - 0.5d0) * y) - 1.0d0) * z) * y) - t
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = Math.log(y) * x;
double tmp;
if (x <= -13500.0) {
tmp = t_1;
} else if (x <= 2.95e-64) {
tmp = -(Math.log(y) - y) - t;
} else if (x <= 6.6e+66) {
tmp = ((((((-0.3333333333333333 * y) - 0.5) * y) - 1.0) * z) * y) - t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = math.log(y) * x tmp = 0 if x <= -13500.0: tmp = t_1 elif x <= 2.95e-64: tmp = -(math.log(y) - y) - t elif x <= 6.6e+66: tmp = ((((((-0.3333333333333333 * y) - 0.5) * y) - 1.0) * 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 <= -13500.0) tmp = t_1; elseif (x <= 2.95e-64) tmp = Float64(Float64(-Float64(log(y) - y)) - t); elseif (x <= 6.6e+66) tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.3333333333333333 * y) - 0.5) * y) - 1.0) * z) * y) - t); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = log(y) * x; tmp = 0.0; if (x <= -13500.0) tmp = t_1; elseif (x <= 2.95e-64) tmp = -(log(y) - y) - t; elseif (x <= 6.6e+66) tmp = ((((((-0.3333333333333333 * y) - 0.5) * y) - 1.0) * z) * y) - t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -13500.0], t$95$1, If[LessEqual[x, 2.95e-64], N[((-N[(N[Log[y], $MachinePrecision] - y), $MachinePrecision]) - t), $MachinePrecision], If[LessEqual[x, 6.6e+66], N[(N[(N[(N[(N[(N[(N[(-0.3333333333333333 * y), $MachinePrecision] - 0.5), $MachinePrecision] * y), $MachinePrecision] - 1.0), $MachinePrecision] * z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log y \cdot x\\
\mathbf{if}\;x \leq -13500:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.95 \cdot 10^{-64}:\\
\;\;\;\;\left(-\left(\log y - y\right)\right) - t\\
\mathbf{elif}\;x \leq 6.6 \cdot 10^{+66}:\\
\;\;\;\;\left(\left(\left(-0.3333333333333333 \cdot y - 0.5\right) \cdot y - 1\right) \cdot z\right) \cdot y - t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -13500 or 6.6000000000000003e66 < x Initial program 95.2%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift-log.f64N/A
unpow1N/A
unpow1N/A
lift--.f64N/A
*-lft-identityN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
*-lft-identityN/A
lower-log1p.f64N/A
lower-neg.f64N/A
lower--.f6499.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.6
Applied rewrites99.6%
Taylor expanded in x around inf
*-commutativeN/A
remove-double-negN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
log-recN/A
lower-*.f64N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lower-log.f6480.4
Applied rewrites80.4%
if -13500 < x < 2.94999999999999997e-64Initial program 90.5%
Taylor expanded in y around 0
+-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites97.4%
Taylor expanded in z around 0
Applied rewrites87.5%
if 2.94999999999999997e-64 < x < 6.6000000000000003e66Initial program 77.4%
Taylor expanded in y around 0
+-commutativeN/A
Applied rewrites98.0%
Taylor expanded in z around inf
Applied rewrites76.3%
Final simplification83.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (log y) x)))
(if (<= x -13500.0)
t_1
(if (<= x 2.95e-64)
(- (- (log y)) t)
(if (<= x 6.6e+66)
(- (* (* (- (* (- (* -0.3333333333333333 y) 0.5) y) 1.0) 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 <= -13500.0) {
tmp = t_1;
} else if (x <= 2.95e-64) {
tmp = -log(y) - t;
} else if (x <= 6.6e+66) {
tmp = ((((((-0.3333333333333333 * y) - 0.5) * y) - 1.0) * z) * y) - t;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_1 = log(y) * x
if (x <= (-13500.0d0)) then
tmp = t_1
else if (x <= 2.95d-64) then
tmp = -log(y) - t
else if (x <= 6.6d+66) then
tmp = (((((((-0.3333333333333333d0) * y) - 0.5d0) * y) - 1.0d0) * z) * y) - t
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = Math.log(y) * x;
double tmp;
if (x <= -13500.0) {
tmp = t_1;
} else if (x <= 2.95e-64) {
tmp = -Math.log(y) - t;
} else if (x <= 6.6e+66) {
tmp = ((((((-0.3333333333333333 * y) - 0.5) * y) - 1.0) * z) * y) - t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = math.log(y) * x tmp = 0 if x <= -13500.0: tmp = t_1 elif x <= 2.95e-64: tmp = -math.log(y) - t elif x <= 6.6e+66: tmp = ((((((-0.3333333333333333 * y) - 0.5) * y) - 1.0) * 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 <= -13500.0) tmp = t_1; elseif (x <= 2.95e-64) tmp = Float64(Float64(-log(y)) - t); elseif (x <= 6.6e+66) tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.3333333333333333 * y) - 0.5) * y) - 1.0) * z) * y) - t); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = log(y) * x; tmp = 0.0; if (x <= -13500.0) tmp = t_1; elseif (x <= 2.95e-64) tmp = -log(y) - t; elseif (x <= 6.6e+66) tmp = ((((((-0.3333333333333333 * y) - 0.5) * y) - 1.0) * z) * y) - t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -13500.0], t$95$1, If[LessEqual[x, 2.95e-64], N[((-N[Log[y], $MachinePrecision]) - t), $MachinePrecision], If[LessEqual[x, 6.6e+66], N[(N[(N[(N[(N[(N[(N[(-0.3333333333333333 * y), $MachinePrecision] - 0.5), $MachinePrecision] * y), $MachinePrecision] - 1.0), $MachinePrecision] * z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log y \cdot x\\
\mathbf{if}\;x \leq -13500:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.95 \cdot 10^{-64}:\\
\;\;\;\;\left(-\log y\right) - t\\
\mathbf{elif}\;x \leq 6.6 \cdot 10^{+66}:\\
\;\;\;\;\left(\left(\left(-0.3333333333333333 \cdot y - 0.5\right) \cdot y - 1\right) \cdot z\right) \cdot y - t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -13500 or 6.6000000000000003e66 < x Initial program 95.2%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift-log.f64N/A
unpow1N/A
unpow1N/A
lift--.f64N/A
*-lft-identityN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
*-lft-identityN/A
lower-log1p.f64N/A
lower-neg.f64N/A
lower--.f6499.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.6
Applied rewrites99.6%
Taylor expanded in x around inf
*-commutativeN/A
remove-double-negN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
log-recN/A
lower-*.f64N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lower-log.f6480.4
Applied rewrites80.4%
if -13500 < x < 2.94999999999999997e-64Initial program 90.5%
Taylor expanded in y around 0
+-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites97.4%
Taylor expanded in y around 0
Applied rewrites87.2%
if 2.94999999999999997e-64 < x < 6.6000000000000003e66Initial program 77.4%
Taylor expanded in y around 0
+-commutativeN/A
Applied rewrites98.0%
Taylor expanded in z around inf
Applied rewrites76.3%
Final simplification83.0%
(FPCore (x y z t) :precision binary64 (- (fma (+ -1.0 x) (log y) (fma (- y) z y)) t))
double code(double x, double y, double z, double t) {
return fma((-1.0 + x), log(y), fma(-y, z, y)) - t;
}
function code(x, y, z, t) return Float64(fma(Float64(-1.0 + x), log(y), fma(Float64(-y), z, y)) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(-1.0 + x), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[((-y) * z + y), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-1 + x, \log y, \mathsf{fma}\left(-y, z, y\right)\right) - t
\end{array}
Initial program 91.0%
Taylor expanded in y around 0
+-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
Applied rewrites99.0%
Taylor expanded in z around 0
Applied rewrites99.0%
(FPCore (x y z t) :precision binary64 (if (<= z -1.5e+218) (- (* (* (- (* (- (* -0.3333333333333333 y) 0.5) y) 1.0) z) y) t) (- (fma (log y) (- x 1.0) y) t)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.5e+218) {
tmp = ((((((-0.3333333333333333 * y) - 0.5) * y) - 1.0) * z) * y) - t;
} else {
tmp = fma(log(y), (x - 1.0), y) - t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= -1.5e+218) tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.3333333333333333 * y) - 0.5) * y) - 1.0) * z) * y) - t); else tmp = Float64(fma(log(y), Float64(x - 1.0), y) - t); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.5e+218], N[(N[(N[(N[(N[(N[(N[(-0.3333333333333333 * y), $MachinePrecision] - 0.5), $MachinePrecision] * y), $MachinePrecision] - 1.0), $MachinePrecision] * z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision] + y), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.5 \cdot 10^{+218}:\\
\;\;\;\;\left(\left(\left(-0.3333333333333333 \cdot y - 0.5\right) \cdot y - 1\right) \cdot z\right) \cdot y - t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x - 1, y\right) - t\\
\end{array}
\end{array}
if z < -1.5e218Initial program 59.4%
Taylor expanded in y around 0
+-commutativeN/A
Applied rewrites99.9%
Taylor expanded in z around inf
Applied rewrites81.2%
if -1.5e218 < z Initial program 93.7%
Taylor expanded in y around 0
+-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
Applied rewrites99.1%
Taylor expanded in z around 0
Applied rewrites92.7%
(FPCore (x y z t) :precision binary64 (if (or (<= x -2.7e+47) (not (<= x 6.6e+66))) (* (log y) x) (- (* (* (- (* (- (* -0.3333333333333333 y) 0.5) y) 1.0) z) y) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -2.7e+47) || !(x <= 6.6e+66)) {
tmp = log(y) * x;
} else {
tmp = ((((((-0.3333333333333333 * y) - 0.5) * y) - 1.0) * 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 ((x <= (-2.7d+47)) .or. (.not. (x <= 6.6d+66))) then
tmp = log(y) * x
else
tmp = (((((((-0.3333333333333333d0) * y) - 0.5d0) * y) - 1.0d0) * z) * y) - t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -2.7e+47) || !(x <= 6.6e+66)) {
tmp = Math.log(y) * x;
} else {
tmp = ((((((-0.3333333333333333 * y) - 0.5) * y) - 1.0) * z) * y) - t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -2.7e+47) or not (x <= 6.6e+66): tmp = math.log(y) * x else: tmp = ((((((-0.3333333333333333 * y) - 0.5) * y) - 1.0) * z) * y) - t return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -2.7e+47) || !(x <= 6.6e+66)) tmp = Float64(log(y) * x); else tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.3333333333333333 * y) - 0.5) * y) - 1.0) * z) * y) - t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -2.7e+47) || ~((x <= 6.6e+66))) tmp = log(y) * x; else tmp = ((((((-0.3333333333333333 * y) - 0.5) * y) - 1.0) * z) * y) - t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -2.7e+47], N[Not[LessEqual[x, 6.6e+66]], $MachinePrecision]], N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[(-0.3333333333333333 * y), $MachinePrecision] - 0.5), $MachinePrecision] * y), $MachinePrecision] - 1.0), $MachinePrecision] * z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{+47} \lor \neg \left(x \leq 6.6 \cdot 10^{+66}\right):\\
\;\;\;\;\log y \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(-0.3333333333333333 \cdot y - 0.5\right) \cdot y - 1\right) \cdot z\right) \cdot y - t\\
\end{array}
\end{array}
if x < -2.69999999999999996e47 or 6.6000000000000003e66 < x Initial program 97.7%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift-log.f64N/A
unpow1N/A
unpow1N/A
lift--.f64N/A
*-lft-identityN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
*-lft-identityN/A
lower-log1p.f64N/A
lower-neg.f64N/A
lower--.f6499.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.6
Applied rewrites99.6%
Taylor expanded in x around inf
*-commutativeN/A
remove-double-negN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
log-recN/A
lower-*.f64N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lower-log.f6483.4
Applied rewrites83.4%
if -2.69999999999999996e47 < x < 6.6000000000000003e66Initial program 86.5%
Taylor expanded in y around 0
+-commutativeN/A
Applied rewrites99.6%
Taylor expanded in z around inf
Applied rewrites63.0%
Final simplification71.2%
(FPCore (x y z t) :precision binary64 (if (<= z -1.5e+218) (- (* (* (- (* (- (* -0.3333333333333333 y) 0.5) y) 1.0) z) y) t) (- (* (+ -1.0 x) (log y)) t)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.5e+218) {
tmp = ((((((-0.3333333333333333 * y) - 0.5) * y) - 1.0) * z) * y) - t;
} else {
tmp = ((-1.0 + x) * log(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 <= (-1.5d+218)) then
tmp = (((((((-0.3333333333333333d0) * y) - 0.5d0) * y) - 1.0d0) * z) * y) - t
else
tmp = (((-1.0d0) + x) * log(y)) - t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.5e+218) {
tmp = ((((((-0.3333333333333333 * y) - 0.5) * y) - 1.0) * z) * y) - t;
} else {
tmp = ((-1.0 + x) * Math.log(y)) - t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.5e+218: tmp = ((((((-0.3333333333333333 * y) - 0.5) * y) - 1.0) * z) * y) - t else: tmp = ((-1.0 + x) * math.log(y)) - t return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.5e+218) tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.3333333333333333 * y) - 0.5) * y) - 1.0) * z) * y) - t); else tmp = Float64(Float64(Float64(-1.0 + x) * log(y)) - t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -1.5e+218) tmp = ((((((-0.3333333333333333 * y) - 0.5) * y) - 1.0) * z) * y) - t; else tmp = ((-1.0 + x) * log(y)) - t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.5e+218], N[(N[(N[(N[(N[(N[(N[(-0.3333333333333333 * y), $MachinePrecision] - 0.5), $MachinePrecision] * y), $MachinePrecision] - 1.0), $MachinePrecision] * z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision], N[(N[(N[(-1.0 + x), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.5 \cdot 10^{+218}:\\
\;\;\;\;\left(\left(\left(-0.3333333333333333 \cdot y - 0.5\right) \cdot y - 1\right) \cdot z\right) \cdot y - t\\
\mathbf{else}:\\
\;\;\;\;\left(-1 + x\right) \cdot \log y - t\\
\end{array}
\end{array}
if z < -1.5e218Initial program 59.4%
Taylor expanded in y around 0
+-commutativeN/A
Applied rewrites99.9%
Taylor expanded in z around inf
Applied rewrites81.2%
if -1.5e218 < z Initial program 93.7%
Taylor expanded in y around 0
remove-double-negN/A
log-recN/A
mul-1-negN/A
distribute-rgt-out--N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
+-commutativeN/A
distribute-rgt-outN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f64N/A
mul-1-negN/A
log-recN/A
Applied rewrites92.6%
(FPCore (x y z t) :precision binary64 (- (* (* (- (* (- (* -0.3333333333333333 y) 0.5) y) 1.0) z) y) t))
double code(double x, double y, double z, double t) {
return ((((((-0.3333333333333333 * y) - 0.5) * y) - 1.0) * 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 = (((((((-0.3333333333333333d0) * y) - 0.5d0) * y) - 1.0d0) * z) * y) - t
end function
public static double code(double x, double y, double z, double t) {
return ((((((-0.3333333333333333 * y) - 0.5) * y) - 1.0) * z) * y) - t;
}
def code(x, y, z, t): return ((((((-0.3333333333333333 * y) - 0.5) * y) - 1.0) * z) * y) - t
function code(x, y, z, t) return Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.3333333333333333 * y) - 0.5) * y) - 1.0) * z) * y) - t) end
function tmp = code(x, y, z, t) tmp = ((((((-0.3333333333333333 * y) - 0.5) * y) - 1.0) * z) * y) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(N[(N[(N[(N[(-0.3333333333333333 * y), $MachinePrecision] - 0.5), $MachinePrecision] * y), $MachinePrecision] - 1.0), $MachinePrecision] * z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(-0.3333333333333333 \cdot y - 0.5\right) \cdot y - 1\right) \cdot z\right) \cdot y - t
\end{array}
Initial program 91.0%
Taylor expanded in y around 0
+-commutativeN/A
Applied rewrites99.6%
Taylor expanded in z around inf
Applied rewrites45.2%
(FPCore (x y z t) :precision binary64 (- (* (* (- (* -0.5 y) 1.0) z) y) t))
double code(double x, double y, double z, double t) {
return ((((-0.5 * y) - 1.0) * 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 = (((((-0.5d0) * y) - 1.0d0) * z) * y) - t
end function
public static double code(double x, double y, double z, double t) {
return ((((-0.5 * y) - 1.0) * z) * y) - t;
}
def code(x, y, z, t): return ((((-0.5 * y) - 1.0) * z) * y) - t
function code(x, y, z, t) return Float64(Float64(Float64(Float64(Float64(-0.5 * y) - 1.0) * z) * y) - t) end
function tmp = code(x, y, z, t) tmp = ((((-0.5 * y) - 1.0) * z) * y) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(N[(N[(-0.5 * y), $MachinePrecision] - 1.0), $MachinePrecision] * z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(-0.5 \cdot y - 1\right) \cdot z\right) \cdot y - t
\end{array}
Initial program 91.0%
Taylor expanded in y around 0
+-commutativeN/A
remove-double-negN/A
distribute-lft-neg-outN/A
log-recN/A
mul-1-negN/A
Applied rewrites99.5%
Taylor expanded in z around inf
Applied rewrites45.1%
(FPCore (x y z t) :precision binary64 (- (* (- 1.0 z) y) t))
double code(double x, double y, double z, double t) {
return ((1.0 - 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 = ((1.0d0 - z) * y) - t
end function
public static double code(double x, double y, double z, double t) {
return ((1.0 - z) * y) - t;
}
def code(x, y, z, t): return ((1.0 - z) * y) - t
function code(x, y, z, t) return Float64(Float64(Float64(1.0 - z) * y) - t) end
function tmp = code(x, y, z, t) tmp = ((1.0 - z) * y) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(1.0 - z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - z\right) \cdot y - t
\end{array}
Initial program 91.0%
Taylor expanded in y around 0
+-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
Applied rewrites99.0%
Taylor expanded in x around 0
Applied rewrites62.9%
Taylor expanded in y around inf
Applied rewrites45.0%
Taylor expanded in y around inf
Applied rewrites45.0%
(FPCore (x y z t) :precision binary64 (- (* (- y) z) t))
double code(double x, double y, double z, double t) {
return (-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 = (-y * z) - t
end function
public static double code(double x, double y, double z, double t) {
return (-y * z) - t;
}
def code(x, y, z, t): return (-y * z) - t
function code(x, y, z, t) return Float64(Float64(Float64(-y) * z) - t) end
function tmp = code(x, y, z, t) tmp = (-y * z) - t; end
code[x_, y_, z_, t_] := N[(N[((-y) * z), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(-y\right) \cdot z - t
\end{array}
Initial program 91.0%
Taylor expanded in y around 0
+-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
Applied rewrites99.0%
Taylor expanded in z around inf
Applied rewrites44.7%
(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 91.0%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6435.9
Applied rewrites35.9%
herbie shell --seed 2024356
(FPCore (x y z t)
:name "Statistics.Distribution.Beta:$cdensity from math-functions-0.1.5.2"
:precision binary64
(- (+ (* (- x 1.0) (log y)) (* (- z 1.0) (log (- 1.0 y)))) t))