
(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 22 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
(-
(+
(* (- x 1.0) (log y))
(*
(- z 1.0)
(-
(* (- (* (- (* (* y y) -0.3333333333333333) 0.5) (* y y)) 1.0) (* y y))
(log1p y))))
t))
double code(double x, double y, double z, double t) {
return (((x - 1.0) * log(y)) + ((z - 1.0) * (((((((y * y) * -0.3333333333333333) - 0.5) * (y * y)) - 1.0) * (y * y)) - log1p(y)))) - t;
}
public static double code(double x, double y, double z, double t) {
return (((x - 1.0) * Math.log(y)) + ((z - 1.0) * (((((((y * y) * -0.3333333333333333) - 0.5) * (y * y)) - 1.0) * (y * y)) - Math.log1p(y)))) - t;
}
def code(x, y, z, t): return (((x - 1.0) * math.log(y)) + ((z - 1.0) * (((((((y * y) * -0.3333333333333333) - 0.5) * (y * y)) - 1.0) * (y * y)) - math.log1p(y)))) - t
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x - 1.0) * log(y)) + Float64(Float64(z - 1.0) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(y * y) * -0.3333333333333333) - 0.5) * Float64(y * y)) - 1.0) * Float64(y * y)) - log1p(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[(N[(N[(N[(N[(N[(N[(y * y), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] - 0.5), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision] - N[Log[1 + y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \left(\left(\left(\left(y \cdot y\right) \cdot -0.3333333333333333 - 0.5\right) \cdot \left(y \cdot y\right) - 1\right) \cdot \left(y \cdot y\right) - \mathsf{log1p}\left(y\right)\right)\right) - t
\end{array}
Initial program 91.1%
lift--.f64N/A
lift-log.f64N/A
flip--N/A
log-divN/A
lower--.f64N/A
lower-log.f64N/A
metadata-evalN/A
unpow2N/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
lower-log1p.f6499.7
Applied rewrites99.7%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.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 -5000000.0) (not (<= t_1 1000.0)))
(- (fma (- y) z (* (log y) x)) t)
(- (fma (- y) (- z 1.0) (- (log 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 <= -5000000.0) || !(t_1 <= 1000.0)) {
tmp = fma(-y, z, (log(y) * x)) - t;
} else {
tmp = fma(-y, (z - 1.0), -log(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 <= -5000000.0) || !(t_1 <= 1000.0)) tmp = Float64(fma(Float64(-y), z, Float64(log(y) * x)) - t); else tmp = Float64(fma(Float64(-y), Float64(z - 1.0), Float64(-log(y))) - t); end return 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, -5000000.0], N[Not[LessEqual[t$95$1, 1000.0]], $MachinePrecision]], N[(N[((-y) * z + N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[((-y) * N[(z - 1.0), $MachinePrecision] + (-N[Log[y], $MachinePrecision])), $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 -5000000 \lor \neg \left(t\_1 \leq 1000\right):\\
\;\;\;\;\mathsf{fma}\left(-y, z, \log y \cdot x\right) - t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, z - 1, -\log y\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)))) < -5e6 or 1e3 < (+.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 95.3%
Taylor expanded in y around 0
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6498.7
Applied rewrites98.7%
Taylor expanded in z around inf
Applied rewrites98.7%
Taylor expanded in x around inf
Applied rewrites97.4%
if -5e6 < (+.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)))) < 1e3Initial program 86.6%
Taylor expanded in y around 0
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
+-commutativeN/A
mul-1-negN/A
distribute-lft-neg-outN/A
lower-fma.f64N/A
lift-neg.f64N/A
lift--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-log.f6499.6
Applied rewrites99.6%
Final simplification98.4%
(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 -5000000.0) (not (<= t_1 1000.0)))
(- (* (log y) x) t)
(- (fma (log y) -1.0 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 <= -5000000.0) || !(t_1 <= 1000.0)) {
tmp = (log(y) * x) - t;
} else {
tmp = fma(log(y), -1.0, 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 <= -5000000.0) || !(t_1 <= 1000.0)) tmp = Float64(Float64(log(y) * x) - t); else tmp = Float64(fma(log(y), -1.0, y) - t); end return 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, -5000000.0], N[Not[LessEqual[t$95$1, 1000.0]], $MachinePrecision]], N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - t), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * -1.0 + 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 -5000000 \lor \neg \left(t\_1 \leq 1000\right):\\
\;\;\;\;\log y \cdot x - t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -1, y\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)))) < -5e6 or 1e3 < (+.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 95.3%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lift-log.f6492.6
Applied rewrites92.6%
if -5e6 < (+.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)))) < 1e3Initial program 86.6%
Taylor expanded in y around 0
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f64100.0
Applied rewrites100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f6486.6
Applied rewrites86.6%
Taylor expanded in x around 0
Applied rewrites86.2%
Final simplification89.5%
(FPCore (x y z t) :precision binary64 (- (+ (* (- x 1.0) (log y)) (* (- z 1.0) (- (* (- (* (* y y) -0.5) 1.0) (* y y)) (log1p y)))) t))
double code(double x, double y, double z, double t) {
return (((x - 1.0) * log(y)) + ((z - 1.0) * (((((y * y) * -0.5) - 1.0) * (y * y)) - log1p(y)))) - t;
}
public static double code(double x, double y, double z, double t) {
return (((x - 1.0) * Math.log(y)) + ((z - 1.0) * (((((y * y) * -0.5) - 1.0) * (y * y)) - Math.log1p(y)))) - t;
}
def code(x, y, z, t): return (((x - 1.0) * math.log(y)) + ((z - 1.0) * (((((y * y) * -0.5) - 1.0) * (y * y)) - math.log1p(y)))) - t
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x - 1.0) * log(y)) + Float64(Float64(z - 1.0) * Float64(Float64(Float64(Float64(Float64(y * y) * -0.5) - 1.0) * Float64(y * y)) - log1p(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[(N[(N[(N[(N[(y * y), $MachinePrecision] * -0.5), $MachinePrecision] - 1.0), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision] - N[Log[1 + y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \left(\left(\left(y \cdot y\right) \cdot -0.5 - 1\right) \cdot \left(y \cdot y\right) - \mathsf{log1p}\left(y\right)\right)\right) - t
\end{array}
Initial program 91.1%
lift--.f64N/A
lift-log.f64N/A
flip--N/A
log-divN/A
lower--.f64N/A
lower-log.f64N/A
metadata-evalN/A
unpow2N/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
lower-log1p.f6499.7
Applied rewrites99.7%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6499.7
Applied rewrites99.7%
(FPCore (x y z t) :precision binary64 (- (+ (* (- x 1.0) (log y)) (* (- z 1.0) (- (* (* (- y) y) y) (log1p (fma y y y))))) t))
double code(double x, double y, double z, double t) {
return (((x - 1.0) * log(y)) + ((z - 1.0) * (((-y * y) * y) - log1p(fma(y, y, y))))) - t;
}
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x - 1.0) * log(y)) + Float64(Float64(z - 1.0) * Float64(Float64(Float64(Float64(-y) * y) * y) - log1p(fma(y, y, 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[(N[(N[((-y) * y), $MachinePrecision] * y), $MachinePrecision] - N[Log[1 + N[(y * y + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \left(\left(\left(-y\right) \cdot y\right) \cdot y - \mathsf{log1p}\left(\mathsf{fma}\left(y, y, y\right)\right)\right)\right) - t
\end{array}
Initial program 91.1%
lift--.f64N/A
lift-log.f64N/A
flip3--N/A
log-divN/A
lower--.f64N/A
lower-log.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-pow.f64N/A
metadata-evalN/A
lower-log1p.f64N/A
lower-fma.f64N/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f64N/A
lift-pow.f6499.7
Applied rewrites99.7%
lift-pow.f64N/A
unpow3N/A
pow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f6499.7
Applied rewrites99.7%
Final simplification99.7%
(FPCore (x y z t)
:precision binary64
(fma
(- x 1.0)
(log y)
(-
(*
(-
(* (- (* (- (* (* y y) -0.3333333333333333) 0.5) (* y y)) 1.0) (* y y))
(* (fma (- (* (fma -0.25 y 0.3333333333333333) y) 0.5) y 1.0) y))
(- z 1.0))
t)))
double code(double x, double y, double z, double t) {
return fma((x - 1.0), log(y), (((((((((y * y) * -0.3333333333333333) - 0.5) * (y * y)) - 1.0) * (y * y)) - (fma(((fma(-0.25, y, 0.3333333333333333) * y) - 0.5), y, 1.0) * y)) * (z - 1.0)) - t));
}
function code(x, y, z, t) return fma(Float64(x - 1.0), log(y), Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(y * y) * -0.3333333333333333) - 0.5) * Float64(y * y)) - 1.0) * Float64(y * y)) - Float64(fma(Float64(Float64(fma(-0.25, y, 0.3333333333333333) * y) - 0.5), y, 1.0) * y)) * Float64(z - 1.0)) - t)) end
code[x_, y_, z_, t_] := N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(N[(N[(N[(N[(N[(N[(N[(N[(y * y), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] - 0.5), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[(N[(-0.25 * y + 0.3333333333333333), $MachinePrecision] * y), $MachinePrecision] - 0.5), $MachinePrecision] * y + 1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] * N[(z - 1.0), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x - 1, \log y, \left(\left(\left(\left(y \cdot y\right) \cdot -0.3333333333333333 - 0.5\right) \cdot \left(y \cdot y\right) - 1\right) \cdot \left(y \cdot y\right) - \mathsf{fma}\left(\mathsf{fma}\left(-0.25, y, 0.3333333333333333\right) \cdot y - 0.5, y, 1\right) \cdot y\right) \cdot \left(z - 1\right) - t\right)
\end{array}
Initial program 91.1%
lift--.f64N/A
lift-log.f64N/A
flip--N/A
log-divN/A
lower--.f64N/A
lower-log.f64N/A
metadata-evalN/A
unpow2N/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
lower-log1p.f6499.7
Applied rewrites99.7%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6499.8
Applied rewrites99.8%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6499.7
Applied rewrites99.7%
lift--.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-log.f64N/A
Applied rewrites99.7%
(FPCore (x y z t)
:precision binary64
(-
(+
(* (- x 1.0) (log y))
(*
(- z 1.0)
(* (- (* (- (* (- (* -0.25 y) 0.3333333333333333) y) 0.5) y) 1.0) y)))
t))
double code(double x, double y, double z, double t) {
return (((x - 1.0) * log(y)) + ((z - 1.0) * (((((((-0.25 * y) - 0.3333333333333333) * y) - 0.5) * y) - 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) * ((((((((-0.25d0) * y) - 0.3333333333333333d0) * y) - 0.5d0) * y) - 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) * (((((((-0.25 * y) - 0.3333333333333333) * y) - 0.5) * y) - 1.0) * y))) - t;
}
def code(x, y, z, t): return (((x - 1.0) * math.log(y)) + ((z - 1.0) * (((((((-0.25 * y) - 0.3333333333333333) * y) - 0.5) * y) - 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) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.25 * y) - 0.3333333333333333) * y) - 0.5) * y) - 1.0) * y))) - t) end
function tmp = code(x, y, z, t) tmp = (((x - 1.0) * log(y)) + ((z - 1.0) * (((((((-0.25 * y) - 0.3333333333333333) * y) - 0.5) * y) - 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[(N[(N[(N[(N[(N[(N[(-0.25 * y), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * y), $MachinePrecision] - 0.5), $MachinePrecision] * y), $MachinePrecision] - 1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \left(\left(\left(\left(-0.25 \cdot y - 0.3333333333333333\right) \cdot y - 0.5\right) \cdot y - 1\right) \cdot y\right)\right) - t
\end{array}
Initial program 91.1%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6499.7
Applied rewrites99.7%
(FPCore (x y z t) :precision binary64 (- (fma (fma (* (- (* -0.3333333333333333 y) 0.5) z) y (- (- z 1.0))) y (* (log y) (- x 1.0))) t))
double code(double x, double y, double z, double t) {
return fma(fma((((-0.3333333333333333 * y) - 0.5) * z), y, -(z - 1.0)), y, (log(y) * (x - 1.0))) - t;
}
function code(x, y, z, t) return Float64(fma(fma(Float64(Float64(Float64(-0.3333333333333333 * y) - 0.5) * z), y, Float64(-Float64(z - 1.0))), y, Float64(log(y) * Float64(x - 1.0))) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(N[(N[(N[(-0.3333333333333333 * y), $MachinePrecision] - 0.5), $MachinePrecision] * z), $MachinePrecision] * y + (-N[(z - 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(\mathsf{fma}\left(\left(-0.3333333333333333 \cdot y - 0.5\right) \cdot z, y, -\left(z - 1\right)\right), y, \log y \cdot \left(x - 1\right)\right) - t
\end{array}
Initial program 91.1%
Taylor expanded in y around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6499.6
Applied rewrites99.6%
(FPCore (x y z t) :precision binary64 (- (fma (fma (* -0.5 y) (- z 1.0) (- (- z 1.0))) y (* (log y) (- x 1.0))) t))
double code(double x, double y, double z, double t) {
return fma(fma((-0.5 * y), (z - 1.0), -(z - 1.0)), y, (log(y) * (x - 1.0))) - t;
}
function code(x, y, z, t) return Float64(fma(fma(Float64(-0.5 * y), Float64(z - 1.0), Float64(-Float64(z - 1.0))), y, Float64(log(y) * Float64(x - 1.0))) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(N[(-0.5 * y), $MachinePrecision] * N[(z - 1.0), $MachinePrecision] + (-N[(z - 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(\mathsf{fma}\left(-0.5 \cdot y, z - 1, -\left(z - 1\right)\right), y, \log y \cdot \left(x - 1\right)\right) - t
\end{array}
Initial program 91.1%
Taylor expanded in y around 0
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6499.5
Applied rewrites99.5%
(FPCore (x y z t) :precision binary64 (- (+ (* (- x 1.0) (log y)) (* (- z 1.0) (* (- (* -0.5 y) 1.0) y))) t))
double code(double x, double y, double z, double t) {
return (((x - 1.0) * log(y)) + ((z - 1.0) * (((-0.5 * y) - 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) * ((((-0.5d0) * y) - 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) * (((-0.5 * y) - 1.0) * y))) - t;
}
def code(x, y, z, t): return (((x - 1.0) * math.log(y)) + ((z - 1.0) * (((-0.5 * y) - 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) * Float64(Float64(Float64(-0.5 * y) - 1.0) * y))) - t) end
function tmp = code(x, y, z, t) tmp = (((x - 1.0) * log(y)) + ((z - 1.0) * (((-0.5 * y) - 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[(N[(N[(-0.5 * y), $MachinePrecision] - 1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \left(\left(-0.5 \cdot y - 1\right) \cdot y\right)\right) - t
\end{array}
Initial program 91.1%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6499.4
Applied rewrites99.4%
(FPCore (x y z t) :precision binary64 (if (or (<= x -3.1e-6) (not (<= x 1.7e-10))) (- (* (log y) (- x 1.0)) t) (- (fma (- y) (- z 1.0) (- (log y))) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -3.1e-6) || !(x <= 1.7e-10)) {
tmp = (log(y) * (x - 1.0)) - t;
} else {
tmp = fma(-y, (z - 1.0), -log(y)) - t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((x <= -3.1e-6) || !(x <= 1.7e-10)) tmp = Float64(Float64(log(y) * Float64(x - 1.0)) - t); else tmp = Float64(fma(Float64(-y), Float64(z - 1.0), Float64(-log(y))) - t); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -3.1e-6], N[Not[LessEqual[x, 1.7e-10]], $MachinePrecision]], N[(N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[((-y) * N[(z - 1.0), $MachinePrecision] + (-N[Log[y], $MachinePrecision])), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.1 \cdot 10^{-6} \lor \neg \left(x \leq 1.7 \cdot 10^{-10}\right):\\
\;\;\;\;\log y \cdot \left(x - 1\right) - t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, z - 1, -\log y\right) - t\\
\end{array}
\end{array}
if x < -3.1e-6 or 1.70000000000000007e-10 < x Initial program 95.6%
Taylor expanded in y around 0
lower-*.f64N/A
lift-log.f64N/A
lift--.f6494.7
Applied rewrites94.7%
if -3.1e-6 < x < 1.70000000000000007e-10Initial program 86.1%
Taylor expanded in y around 0
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6499.5
Applied rewrites99.5%
Taylor expanded in x around 0
+-commutativeN/A
mul-1-negN/A
distribute-lft-neg-outN/A
lower-fma.f64N/A
lift-neg.f64N/A
lift--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-log.f6499.5
Applied rewrites99.5%
Final simplification97.0%
(FPCore (x y z t) :precision binary64 (- (fma (- y) (- z 1.0) (* (log y) (- x 1.0))) t))
double code(double x, double y, double z, double t) {
return fma(-y, (z - 1.0), (log(y) * (x - 1.0))) - t;
}
function code(x, y, z, t) return Float64(fma(Float64(-y), Float64(z - 1.0), Float64(log(y) * Float64(x - 1.0))) - t) end
code[x_, y_, z_, t_] := N[(N[((-y) * N[(z - 1.0), $MachinePrecision] + N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-y, z - 1, \log y \cdot \left(x - 1\right)\right) - t
\end{array}
Initial program 91.1%
Taylor expanded in y around 0
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6499.3
Applied rewrites99.3%
(FPCore (x y z t) :precision binary64 (if (or (<= x -2.9e-58) (not (<= x 0.00106))) (- (* (log y) x) t) (- (fma (- y) z y) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -2.9e-58) || !(x <= 0.00106)) {
tmp = (log(y) * x) - t;
} else {
tmp = fma(-y, z, y) - t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((x <= -2.9e-58) || !(x <= 0.00106)) tmp = Float64(Float64(log(y) * x) - t); else tmp = Float64(fma(Float64(-y), z, y) - t); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -2.9e-58], N[Not[LessEqual[x, 0.00106]], $MachinePrecision]], N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - t), $MachinePrecision], N[(N[((-y) * z + y), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.9 \cdot 10^{-58} \lor \neg \left(x \leq 0.00106\right):\\
\;\;\;\;\log y \cdot x - t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, z, y\right) - t\\
\end{array}
\end{array}
if x < -2.8999999999999999e-58 or 0.00105999999999999996 < x Initial program 95.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lift-log.f6491.8
Applied rewrites91.8%
if -2.8999999999999999e-58 < x < 0.00105999999999999996Initial program 85.3%
Taylor expanded in y around 0
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6499.4
Applied rewrites99.4%
Taylor expanded in y around inf
mul-1-negN/A
distribute-lft-neg-outN/A
lower-*.f64N/A
lift-neg.f64N/A
lift--.f6454.2
Applied rewrites54.2%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lift-neg.f6454.2
Applied rewrites54.2%
Final simplification75.1%
(FPCore (x y z t) :precision binary64 (- (fma (- y) z (* (log y) (- x 1.0))) t))
double code(double x, double y, double z, double t) {
return fma(-y, z, (log(y) * (x - 1.0))) - t;
}
function code(x, y, z, t) return Float64(fma(Float64(-y), z, Float64(log(y) * Float64(x - 1.0))) - t) end
code[x_, y_, z_, t_] := N[(N[((-y) * z + N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-y, z, \log y \cdot \left(x - 1\right)\right) - t
\end{array}
Initial program 91.1%
Taylor expanded in y around 0
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6499.3
Applied rewrites99.3%
Taylor expanded in z around inf
Applied rewrites99.0%
(FPCore (x y z t) :precision binary64 (if (or (<= x -5e+110) (not (<= x 12000000000000.0))) (* (log y) x) (- (* (- y) (* (fma (fma 0.3333333333333333 y 0.5) y 1.0) z)) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -5e+110) || !(x <= 12000000000000.0)) {
tmp = log(y) * x;
} else {
tmp = (-y * (fma(fma(0.3333333333333333, y, 0.5), y, 1.0) * z)) - t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((x <= -5e+110) || !(x <= 12000000000000.0)) tmp = Float64(log(y) * x); else tmp = Float64(Float64(Float64(-y) * Float64(fma(fma(0.3333333333333333, y, 0.5), y, 1.0) * z)) - t); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -5e+110], N[Not[LessEqual[x, 12000000000000.0]], $MachinePrecision]], N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision], N[(N[((-y) * N[(N[(N[(0.3333333333333333 * y + 0.5), $MachinePrecision] * y + 1.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{+110} \lor \neg \left(x \leq 12000000000000\right):\\
\;\;\;\;\log y \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(-y\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, y, 0.5\right), y, 1\right) \cdot z\right) - t\\
\end{array}
\end{array}
if x < -4.99999999999999978e110 or 1.2e13 < x Initial program 96.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lift-log.f6479.4
Applied rewrites79.4%
if -4.99999999999999978e110 < x < 1.2e13Initial program 87.5%
Taylor expanded in y around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.8%
Taylor expanded in z around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lift-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6456.1
Applied rewrites56.1%
Final simplification65.4%
(FPCore (x y z t) :precision binary64 (- (fma (log y) (- x 1.0) y) t))
double code(double x, double y, double z, double t) {
return fma(log(y), (x - 1.0), y) - t;
}
function code(x, y, z, t) return Float64(fma(log(y), Float64(x - 1.0), y) - t) end
code[x_, y_, z_, t_] := N[(N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision] + y), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\log y, x - 1, y\right) - t
\end{array}
Initial program 91.1%
Taylor expanded in y around 0
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6499.3
Applied rewrites99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f6490.3
Applied rewrites90.3%
(FPCore (x y z t) :precision binary64 (- (* (log y) (- x 1.0)) t))
double code(double x, double y, double z, double t) {
return (log(y) * (x - 1.0)) - 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 = (log(y) * (x - 1.0d0)) - t
end function
public static double code(double x, double y, double z, double t) {
return (Math.log(y) * (x - 1.0)) - t;
}
def code(x, y, z, t): return (math.log(y) * (x - 1.0)) - t
function code(x, y, z, t) return Float64(Float64(log(y) * Float64(x - 1.0)) - t) end
function tmp = code(x, y, z, t) tmp = (log(y) * (x - 1.0)) - t; end
code[x_, y_, z_, t_] := N[(N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\log y \cdot \left(x - 1\right) - t
\end{array}
Initial program 91.1%
Taylor expanded in y around 0
lower-*.f64N/A
lift-log.f64N/A
lift--.f6490.1
Applied rewrites90.1%
(FPCore (x y z t) :precision binary64 (- (* (- y) (* (fma (fma 0.3333333333333333 y 0.5) y 1.0) z)) t))
double code(double x, double y, double z, double t) {
return (-y * (fma(fma(0.3333333333333333, y, 0.5), y, 1.0) * z)) - t;
}
function code(x, y, z, t) return Float64(Float64(Float64(-y) * Float64(fma(fma(0.3333333333333333, y, 0.5), y, 1.0) * z)) - t) end
code[x_, y_, z_, t_] := N[(N[((-y) * N[(N[(N[(0.3333333333333333 * y + 0.5), $MachinePrecision] * y + 1.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(-y\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, y, 0.5\right), y, 1\right) \cdot z\right) - t
\end{array}
Initial program 91.1%
Taylor expanded in y around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.6%
Taylor expanded in z around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lift-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6441.8
Applied rewrites41.8%
(FPCore (x y z t) :precision binary64 (- (fma (- y) z y) t))
double code(double x, double y, double z, double t) {
return fma(-y, z, y) - t;
}
function code(x, y, z, t) return Float64(fma(Float64(-y), z, y) - t) end
code[x_, y_, z_, t_] := N[(N[((-y) * z + y), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-y, z, y\right) - t
\end{array}
Initial program 91.1%
Taylor expanded in y around 0
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6499.3
Applied rewrites99.3%
Taylor expanded in y around inf
mul-1-negN/A
distribute-lft-neg-outN/A
lower-*.f64N/A
lift-neg.f64N/A
lift--.f6441.7
Applied rewrites41.7%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lift-neg.f6441.7
Applied rewrites41.7%
(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.1%
Taylor expanded in y around 0
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6499.3
Applied rewrites99.3%
Taylor expanded in z around inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lift-neg.f6441.6
Applied rewrites41.6%
(FPCore (x y z t) :precision binary64 (- y t))
double code(double x, double y, double z, double t) {
return 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 = y - t
end function
public static double code(double x, double y, double z, double t) {
return y - t;
}
def code(x, y, z, t): return y - t
function code(x, y, z, t) return Float64(y - t) end
function tmp = code(x, y, z, t) tmp = y - t; end
code[x_, y_, z_, t_] := N[(y - t), $MachinePrecision]
\begin{array}{l}
\\
y - t
\end{array}
Initial program 91.1%
Taylor expanded in y around 0
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6499.3
Applied rewrites99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f6490.3
Applied rewrites90.3%
Taylor expanded in y around inf
Applied rewrites33.3%
(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.1%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6433.1
Applied rewrites33.1%
herbie shell --seed 2025043
(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))