
(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]
\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t
Herbie found 10 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]
\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t
(FPCore (x y z t) :precision binary64 (- (fma y (fma (- z 1.0) (* -0.5 y) (- 1.0 z)) (* (log y) (- x 1.0))) t))
double code(double x, double y, double z, double t) {
return fma(y, fma((z - 1.0), (-0.5 * y), (1.0 - z)), (log(y) * (x - 1.0))) - t;
}
function code(x, y, z, t) return Float64(fma(y, fma(Float64(z - 1.0), Float64(-0.5 * y), Float64(1.0 - z)), Float64(log(y) * Float64(x - 1.0))) - t) end
code[x_, y_, z_, t_] := N[(N[(y * N[(N[(z - 1.0), $MachinePrecision] * N[(-0.5 * y), $MachinePrecision] + N[(1.0 - z), $MachinePrecision]), $MachinePrecision] + N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\mathsf{fma}\left(y, \mathsf{fma}\left(z - 1, -0.5 \cdot y, 1 - z\right), \log y \cdot \left(x - 1\right)\right) - t
Initial program 89.5%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6499.5%
Applied rewrites99.5%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
mul-1-negN/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6499.5%
Applied rewrites99.5%
(FPCore (x y z t) :precision binary64 (- (fma (- x 1.0) (log y) (* (* (- z 1.0) y) (fma -0.5 y -1.0))) t))
double code(double x, double y, double z, double t) {
return fma((x - 1.0), log(y), (((z - 1.0) * y) * fma(-0.5, y, -1.0))) - t;
}
function code(x, y, z, t) return Float64(fma(Float64(x - 1.0), log(y), Float64(Float64(Float64(z - 1.0) * y) * fma(-0.5, y, -1.0))) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(N[(N[(z - 1.0), $MachinePrecision] * y), $MachinePrecision] * N[(-0.5 * y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\mathsf{fma}\left(x - 1, \log y, \left(\left(z - 1\right) \cdot y\right) \cdot \mathsf{fma}\left(-0.5, y, -1\right)\right) - t
Initial program 89.5%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6499.5%
Applied rewrites99.5%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
mul-1-negN/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6499.5%
Applied rewrites99.5%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
remove-double-negN/A
mul-1-negN/A
*-commutativeN/A
lower-fma.f64N/A
mul-1-negN/A
remove-double-negN/A
lift-fma.f64N/A
distribute-lft-outN/A
associate-*r*N/A
lift--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lift--.f64N/A
distribute-rgt-neg-outN/A
lift--.f64N/A
mul-1-negN/A
*-commutativeN/A
Applied rewrites99.5%
(FPCore (x y z t) :precision binary64 (- (fma (- x 1.0) (log y) (* (- 1.0 z) y)) t))
double code(double x, double y, double z, double t) {
return fma((x - 1.0), log(y), ((1.0 - z) * y)) - t;
}
function code(x, y, z, t) return Float64(fma(Float64(x - 1.0), log(y), Float64(Float64(1.0 - z) * y)) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(N[(1.0 - z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\mathsf{fma}\left(x - 1, \log y, \left(1 - z\right) \cdot y\right) - t
Initial program 89.5%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6499.1%
Applied rewrites99.1%
lift-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6499.1%
Applied rewrites99.1%
(FPCore (x y z t) :precision binary64 (if (<= z -1.25e+271) (- (* (- z) y) t) (- (+ y (* (log y) (- x 1.0))) t)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.25e+271) {
tmp = (-z * y) - t;
} else {
tmp = (y + (log(y) * (x - 1.0))) - 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.25d+271)) then
tmp = (-z * y) - t
else
tmp = (y + (log(y) * (x - 1.0d0))) - t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.25e+271) {
tmp = (-z * y) - t;
} else {
tmp = (y + (Math.log(y) * (x - 1.0))) - t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.25e+271: tmp = (-z * y) - t else: tmp = (y + (math.log(y) * (x - 1.0))) - t return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.25e+271) tmp = Float64(Float64(Float64(-z) * y) - t); else tmp = Float64(Float64(y + Float64(log(y) * Float64(x - 1.0))) - t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -1.25e+271) tmp = (-z * y) - t; else tmp = (y + (log(y) * (x - 1.0))) - t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.25e+271], N[(N[((-z) * y), $MachinePrecision] - t), $MachinePrecision], N[(N[(y + N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;z \leq -1.25 \cdot 10^{+271}:\\
\;\;\;\;\left(-z\right) \cdot y - t\\
\mathbf{else}:\\
\;\;\;\;\left(y + \log y \cdot \left(x - 1\right)\right) - t\\
\end{array}
if z < -1.2500000000000001e271Initial program 89.5%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6499.1%
Applied rewrites99.1%
Taylor expanded in z around inf
lower-*.f64N/A
lower-*.f6445.9%
Applied rewrites45.9%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6445.9%
Applied rewrites45.9%
if -1.2500000000000001e271 < z Initial program 89.5%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6499.1%
Applied rewrites99.1%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6488.4%
Applied rewrites88.4%
(FPCore (x y z t) :precision binary64 (if (<= z -1.25e+271) (- (* (- z) y) t) (- (* (log y) (- x 1.0)) t)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.25e+271) {
tmp = (-z * y) - t;
} else {
tmp = (log(y) * (x - 1.0)) - 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.25d+271)) then
tmp = (-z * y) - t
else
tmp = (log(y) * (x - 1.0d0)) - t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.25e+271) {
tmp = (-z * y) - t;
} else {
tmp = (Math.log(y) * (x - 1.0)) - t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.25e+271: tmp = (-z * y) - t else: tmp = (math.log(y) * (x - 1.0)) - t return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.25e+271) tmp = Float64(Float64(Float64(-z) * y) - t); else tmp = Float64(Float64(log(y) * Float64(x - 1.0)) - t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -1.25e+271) tmp = (-z * y) - t; else tmp = (log(y) * (x - 1.0)) - t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.25e+271], N[(N[((-z) * y), $MachinePrecision] - t), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;z \leq -1.25 \cdot 10^{+271}:\\
\;\;\;\;\left(-z\right) \cdot y - t\\
\mathbf{else}:\\
\;\;\;\;\log y \cdot \left(x - 1\right) - t\\
\end{array}
if z < -1.2500000000000001e271Initial program 89.5%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6499.1%
Applied rewrites99.1%
Taylor expanded in z around inf
lower-*.f64N/A
lower-*.f6445.9%
Applied rewrites45.9%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6445.9%
Applied rewrites45.9%
if -1.2500000000000001e271 < z Initial program 89.5%
Taylor expanded in y around 0
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6488.3%
Applied rewrites88.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* x (log y)) t)))
(if (<= x -1e-14)
t_1
(if (<= x 0.85) (- (fma (log y) -1.0 y) t) t_1))))double code(double x, double y, double z, double t) {
double t_1 = (x * log(y)) - t;
double tmp;
if (x <= -1e-14) {
tmp = t_1;
} else if (x <= 0.85) {
tmp = fma(log(y), -1.0, y) - t;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(x * log(y)) - t) tmp = 0.0 if (x <= -1e-14) tmp = t_1; elseif (x <= 0.85) tmp = Float64(fma(log(y), -1.0, y) - t); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]}, If[LessEqual[x, -1e-14], t$95$1, If[LessEqual[x, 0.85], N[(N[(N[Log[y], $MachinePrecision] * -1.0 + y), $MachinePrecision] - t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := x \cdot \log y - t\\
\mathbf{if}\;x \leq -1 \cdot 10^{-14}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 0.85:\\
\;\;\;\;\mathsf{fma}\left(\log y, -1, y\right) - t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if x < -1e-14 or 0.84999999999999998 < x Initial program 89.5%
Taylor expanded in y around 0
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6488.3%
Applied rewrites88.3%
Taylor expanded in x around inf
lower-*.f64N/A
lower-log.f6470.0%
Applied rewrites70.0%
if -1e-14 < x < 0.84999999999999998Initial program 89.5%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6499.1%
Applied rewrites99.1%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6488.4%
Applied rewrites88.4%
Taylor expanded in x around 0
Applied rewrites53.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6453.7%
Applied rewrites53.7%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (- (* x (log y)) t))) (if (<= x -1e-14) t_1 (if (<= x 0.85) (- (* (log y) -1.0) t) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (x * log(y)) - t;
double tmp;
if (x <= -1e-14) {
tmp = t_1;
} else if (x <= 0.85) {
tmp = (log(y) * -1.0) - 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 = (x * log(y)) - t
if (x <= (-1d-14)) then
tmp = t_1
else if (x <= 0.85d0) then
tmp = (log(y) * (-1.0d0)) - 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 = (x * Math.log(y)) - t;
double tmp;
if (x <= -1e-14) {
tmp = t_1;
} else if (x <= 0.85) {
tmp = (Math.log(y) * -1.0) - t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (x * math.log(y)) - t tmp = 0 if x <= -1e-14: tmp = t_1 elif x <= 0.85: tmp = (math.log(y) * -1.0) - t else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x * log(y)) - t) tmp = 0.0 if (x <= -1e-14) tmp = t_1; elseif (x <= 0.85) tmp = Float64(Float64(log(y) * -1.0) - t); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x * log(y)) - t; tmp = 0.0; if (x <= -1e-14) tmp = t_1; elseif (x <= 0.85) tmp = (log(y) * -1.0) - t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]}, If[LessEqual[x, -1e-14], t$95$1, If[LessEqual[x, 0.85], N[(N[(N[Log[y], $MachinePrecision] * -1.0), $MachinePrecision] - t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := x \cdot \log y - t\\
\mathbf{if}\;x \leq -1 \cdot 10^{-14}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 0.85:\\
\;\;\;\;\log y \cdot -1 - t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if x < -1e-14 or 0.84999999999999998 < x Initial program 89.5%
Taylor expanded in y around 0
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6488.3%
Applied rewrites88.3%
Taylor expanded in x around inf
lower-*.f64N/A
lower-log.f6470.0%
Applied rewrites70.0%
if -1e-14 < x < 0.84999999999999998Initial program 89.5%
Taylor expanded in y around 0
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6488.3%
Applied rewrites88.3%
Taylor expanded in x around 0
Applied rewrites53.6%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (- (* x (log y)) t))) (if (<= x -5200.0) t_1 (if (<= x 0.76) (- (* (- z) y) t) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (x * log(y)) - t;
double tmp;
if (x <= -5200.0) {
tmp = t_1;
} else if (x <= 0.76) {
tmp = (-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 = (x * log(y)) - t
if (x <= (-5200.0d0)) then
tmp = t_1
else if (x <= 0.76d0) then
tmp = (-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 = (x * Math.log(y)) - t;
double tmp;
if (x <= -5200.0) {
tmp = t_1;
} else if (x <= 0.76) {
tmp = (-z * y) - t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (x * math.log(y)) - t tmp = 0 if x <= -5200.0: tmp = t_1 elif x <= 0.76: tmp = (-z * y) - t else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x * log(y)) - t) tmp = 0.0 if (x <= -5200.0) tmp = t_1; elseif (x <= 0.76) tmp = Float64(Float64(Float64(-z) * y) - t); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x * log(y)) - t; tmp = 0.0; if (x <= -5200.0) tmp = t_1; elseif (x <= 0.76) tmp = (-z * y) - t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]}, If[LessEqual[x, -5200.0], t$95$1, If[LessEqual[x, 0.76], N[(N[((-z) * y), $MachinePrecision] - t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := x \cdot \log y - t\\
\mathbf{if}\;x \leq -5200:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 0.76:\\
\;\;\;\;\left(-z\right) \cdot y - t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if x < -5200 or 0.76000000000000001 < x Initial program 89.5%
Taylor expanded in y around 0
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6488.3%
Applied rewrites88.3%
Taylor expanded in x around inf
lower-*.f64N/A
lower-log.f6470.0%
Applied rewrites70.0%
if -5200 < x < 0.76000000000000001Initial program 89.5%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6499.1%
Applied rewrites99.1%
Taylor expanded in z around inf
lower-*.f64N/A
lower-*.f6445.9%
Applied rewrites45.9%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6445.9%
Applied rewrites45.9%
(FPCore (x y z t) :precision binary64 (- (* (- z) y) t))
double code(double x, double y, double z, double t) {
return (-z * y) - t;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (-z * y) - t
end function
public static double code(double x, double y, double z, double t) {
return (-z * y) - t;
}
def code(x, y, z, t): return (-z * y) - t
function code(x, y, z, t) return Float64(Float64(Float64(-z) * y) - t) end
function tmp = code(x, y, z, t) tmp = (-z * y) - t; end
code[x_, y_, z_, t_] := N[(N[((-z) * y), $MachinePrecision] - t), $MachinePrecision]
\left(-z\right) \cdot y - t
Initial program 89.5%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6499.1%
Applied rewrites99.1%
Taylor expanded in z around inf
lower-*.f64N/A
lower-*.f6445.9%
Applied rewrites45.9%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6445.9%
Applied rewrites45.9%
(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)
-t
Initial program 89.5%
Taylor expanded in t around inf
lower-*.f6435.7%
Applied rewrites35.7%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6435.7%
Applied rewrites35.7%
herbie shell --seed 2025212
(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))