
(FPCore (x y z t a b c i) :precision binary64 (+ (+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c))) (* y i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
}
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, a, b, c, i)
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), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
code = (((((x * log(y)) + z) + t) + a) + ((b - 0.5d0) * log(c))) + (y * i)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((((x * Math.log(y)) + z) + t) + a) + ((b - 0.5) * Math.log(c))) + (y * i);
}
def code(x, y, z, t, a, b, c, i): return (((((x * math.log(y)) + z) + t) + a) + ((b - 0.5) * math.log(c))) + (y * i)
function code(x, y, z, t, a, b, c, i) return Float64(Float64(Float64(Float64(Float64(Float64(x * log(y)) + z) + t) + a) + Float64(Float64(b - 0.5) * log(c))) + Float64(y * i)) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] + t), $MachinePrecision] + a), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b c i) :precision binary64 (+ (+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c))) (* y i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
}
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, a, b, c, i)
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), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
code = (((((x * log(y)) + z) + t) + a) + ((b - 0.5d0) * log(c))) + (y * i)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((((x * Math.log(y)) + z) + t) + a) + ((b - 0.5) * Math.log(c))) + (y * i);
}
def code(x, y, z, t, a, b, c, i): return (((((x * math.log(y)) + z) + t) + a) + ((b - 0.5) * math.log(c))) + (y * i)
function code(x, y, z, t, a, b, c, i) return Float64(Float64(Float64(Float64(Float64(Float64(x * log(y)) + z) + t) + a) + Float64(Float64(b - 0.5) * log(c))) + Float64(y * i)) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] + t), $MachinePrecision] + a), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i
\end{array}
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i) :precision binary64 (+ (+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c))) (* y i)))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
}
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
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, a, b, c, i)
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), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
code = (((((x * log(y)) + z) + t) + a) + ((b - 0.5d0) * log(c))) + (y * i)
end function
assert x < y && y < z && z < t && t < a && a < b && b < c && c < i;
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((((x * Math.log(y)) + z) + t) + a) + ((b - 0.5) * Math.log(c))) + (y * i);
}
[x, y, z, t, a, b, c, i] = sort([x, y, z, t, a, b, c, i]) def code(x, y, z, t, a, b, c, i): return (((((x * math.log(y)) + z) + t) + a) + ((b - 0.5) * math.log(c))) + (y * i)
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) return Float64(Float64(Float64(Float64(Float64(Float64(x * log(y)) + z) + t) + a) + Float64(Float64(b - 0.5) * log(c))) + Float64(y * i)) end
x, y, z, t, a, b, c, i = num2cell(sort([x, y, z, t, a, b, c, i])){:}
function tmp = code(x, y, z, t, a, b, c, i)
tmp = (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] + t), $MachinePrecision] + a), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i
\end{array}
Initial program 99.5%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(if (<= y 4e-14)
(+
(+ (+ (+ (* (fma x (/ (log y) z) 1.0) z) t) a) (* (- b 0.5) (log c)))
(* y i))
(*
(+
(fma
(* (- x) (/ (log y) y))
-1.0
(+ (+ (/ (fma (log c) (- b 0.5) z) y) (/ t y)) (/ a y)))
i)
y)))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (y <= 4e-14) {
tmp = ((((fma(x, (log(y) / z), 1.0) * z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
} else {
tmp = (fma((-x * (log(y) / y)), -1.0, (((fma(log(c), (b - 0.5), z) / y) + (t / y)) + (a / y))) + i) * y;
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (y <= 4e-14) tmp = Float64(Float64(Float64(Float64(Float64(fma(x, Float64(log(y) / z), 1.0) * z) + t) + a) + Float64(Float64(b - 0.5) * log(c))) + Float64(y * i)); else tmp = Float64(Float64(fma(Float64(Float64(-x) * Float64(log(y) / y)), -1.0, Float64(Float64(Float64(fma(log(c), Float64(b - 0.5), z) / y) + Float64(t / y)) + Float64(a / y))) + i) * y); end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[y, 4e-14], N[(N[(N[(N[(N[(N[(x * N[(N[Log[y], $MachinePrecision] / z), $MachinePrecision] + 1.0), $MachinePrecision] * z), $MachinePrecision] + t), $MachinePrecision] + a), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[((-x) * N[(N[Log[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] * -1.0 + N[(N[(N[(N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + z), $MachinePrecision] / y), $MachinePrecision] + N[(t / y), $MachinePrecision]), $MachinePrecision] + N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + i), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4 \cdot 10^{-14}:\\
\;\;\;\;\left(\left(\left(\mathsf{fma}\left(x, \frac{\log y}{z}, 1\right) \cdot z + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\left(-x\right) \cdot \frac{\log y}{y}, -1, \left(\frac{\mathsf{fma}\left(\log c, b - 0.5, z\right)}{y} + \frac{t}{y}\right) + \frac{a}{y}\right) + i\right) \cdot y\\
\end{array}
\end{array}
if y < 4e-14Initial program 99.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-log.f6493.5
Applied rewrites93.5%
if 4e-14 < y Initial program 99.1%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.7%
Final simplification96.8%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(if (<= y 9.5e-30)
(+
(+
(+ (+ (* (* (+ (pow x -1.0) (/ (log y) z)) x) z) t) a)
(* (- b 0.5) (log c)))
(* y i))
(*
(+
(fma
(* (- x) (/ (log y) y))
-1.0
(+ (+ (/ (fma (log c) (- b 0.5) z) y) (/ t y)) (/ a y)))
i)
y)))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (y <= 9.5e-30) {
tmp = ((((((pow(x, -1.0) + (log(y) / z)) * x) * z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
} else {
tmp = (fma((-x * (log(y) / y)), -1.0, (((fma(log(c), (b - 0.5), z) / y) + (t / y)) + (a / y))) + i) * y;
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (y <= 9.5e-30) tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64((x ^ -1.0) + Float64(log(y) / z)) * x) * z) + t) + a) + Float64(Float64(b - 0.5) * log(c))) + Float64(y * i)); else tmp = Float64(Float64(fma(Float64(Float64(-x) * Float64(log(y) / y)), -1.0, Float64(Float64(Float64(fma(log(c), Float64(b - 0.5), z) / y) + Float64(t / y)) + Float64(a / y))) + i) * y); end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[y, 9.5e-30], N[(N[(N[(N[(N[(N[(N[(N[Power[x, -1.0], $MachinePrecision] + N[(N[Log[y], $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * z), $MachinePrecision] + t), $MachinePrecision] + a), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[((-x) * N[(N[Log[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] * -1.0 + N[(N[(N[(N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + z), $MachinePrecision] / y), $MachinePrecision] + N[(t / y), $MachinePrecision]), $MachinePrecision] + N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + i), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9.5 \cdot 10^{-30}:\\
\;\;\;\;\left(\left(\left(\left(\left({x}^{-1} + \frac{\log y}{z}\right) \cdot x\right) \cdot z + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\left(-x\right) \cdot \frac{\log y}{y}, -1, \left(\frac{\mathsf{fma}\left(\log c, b - 0.5, z\right)}{y} + \frac{t}{y}\right) + \frac{a}{y}\right) + i\right) \cdot y\\
\end{array}
\end{array}
if y < 9.49999999999999939e-30Initial program 99.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-log.f6493.2
Applied rewrites93.2%
lift-fma.f64N/A
lift-/.f64N/A
lift-log.f64N/A
associate-*r/N/A
+-commutativeN/A
metadata-evalN/A
metadata-evalN/A
pow-plusN/A
inv-powN/A
associate-*r/N/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f64N/A
inv-powN/A
lower-pow.f64N/A
lift-log.f64N/A
lift-/.f6493.2
Applied rewrites93.2%
if 9.49999999999999939e-30 < y Initial program 99.2%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.7%
Final simplification96.8%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(if (<= z -1.45e-18)
(+
(* (- (/ (+ (+ a t) (fma (log c) (- b 0.5) (* (log y) x))) z) -1.0) z)
(* y i))
(+
(+ (* (- (/ (fma (log y) x (+ t z)) a) -1.0) a) (* (- b 0.5) (log c)))
(* y i))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (z <= -1.45e-18) {
tmp = (((((a + t) + fma(log(c), (b - 0.5), (log(y) * x))) / z) - -1.0) * z) + (y * i);
} else {
tmp = ((((fma(log(y), x, (t + z)) / a) - -1.0) * a) + ((b - 0.5) * log(c))) + (y * i);
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (z <= -1.45e-18) tmp = Float64(Float64(Float64(Float64(Float64(Float64(a + t) + fma(log(c), Float64(b - 0.5), Float64(log(y) * x))) / z) - -1.0) * z) + Float64(y * i)); else tmp = Float64(Float64(Float64(Float64(Float64(fma(log(y), x, Float64(t + z)) / a) - -1.0) * a) + Float64(Float64(b - 0.5) * log(c))) + Float64(y * i)); end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[z, -1.45e-18], N[(N[(N[(N[(N[(N[(a + t), $MachinePrecision] + N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] - -1.0), $MachinePrecision] * z), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[Log[y], $MachinePrecision] * x + N[(t + z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] - -1.0), $MachinePrecision] * a), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.45 \cdot 10^{-18}:\\
\;\;\;\;\left(\frac{\left(a + t\right) + \mathsf{fma}\left(\log c, b - 0.5, \log y \cdot x\right)}{z} - -1\right) \cdot z + y \cdot i\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\frac{\mathsf{fma}\left(\log y, x, t + z\right)}{a} - -1\right) \cdot a + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i\\
\end{array}
\end{array}
if z < -1.45e-18Initial program 99.9%
Taylor expanded in z around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.4%
if -1.45e-18 < z Initial program 99.3%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites83.0%
Final simplification86.7%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* (log y) x)) (t_2 (fma (log c) (- b 0.5) t_1)))
(if (<= z -3e-56)
(+ (* (- (/ (+ (+ a t) t_2) z) -1.0) z) (* y i))
(if (<= z 5.8e-146)
(+
(*
(fma (/ (+ (+ (+ (fma -0.5 (log c) t_1) z) t) a) b) -1.0 (- (log c)))
(- b))
(* y i))
(* (+ (+ 1.0 (/ a t)) (+ (fma i (/ y t) (/ t_2 t)) (/ z t))) t)))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = log(y) * x;
double t_2 = fma(log(c), (b - 0.5), t_1);
double tmp;
if (z <= -3e-56) {
tmp = (((((a + t) + t_2) / z) - -1.0) * z) + (y * i);
} else if (z <= 5.8e-146) {
tmp = (fma(((((fma(-0.5, log(c), t_1) + z) + t) + a) / b), -1.0, -log(c)) * -b) + (y * i);
} else {
tmp = ((1.0 + (a / t)) + (fma(i, (y / t), (t_2 / t)) + (z / t))) * t;
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) t_1 = Float64(log(y) * x) t_2 = fma(log(c), Float64(b - 0.5), t_1) tmp = 0.0 if (z <= -3e-56) tmp = Float64(Float64(Float64(Float64(Float64(Float64(a + t) + t_2) / z) - -1.0) * z) + Float64(y * i)); elseif (z <= 5.8e-146) tmp = Float64(Float64(fma(Float64(Float64(Float64(Float64(fma(-0.5, log(c), t_1) + z) + t) + a) / b), -1.0, Float64(-log(c))) * Float64(-b)) + Float64(y * i)); else tmp = Float64(Float64(Float64(1.0 + Float64(a / t)) + Float64(fma(i, Float64(y / t), Float64(t_2 / t)) + Float64(z / t))) * t); end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$2 = N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + t$95$1), $MachinePrecision]}, If[LessEqual[z, -3e-56], N[(N[(N[(N[(N[(N[(a + t), $MachinePrecision] + t$95$2), $MachinePrecision] / z), $MachinePrecision] - -1.0), $MachinePrecision] * z), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.8e-146], N[(N[(N[(N[(N[(N[(N[(N[(-0.5 * N[Log[c], $MachinePrecision] + t$95$1), $MachinePrecision] + z), $MachinePrecision] + t), $MachinePrecision] + a), $MachinePrecision] / b), $MachinePrecision] * -1.0 + (-N[Log[c], $MachinePrecision])), $MachinePrecision] * (-b)), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + N[(a / t), $MachinePrecision]), $MachinePrecision] + N[(N[(i * N[(y / t), $MachinePrecision] + N[(t$95$2 / t), $MachinePrecision]), $MachinePrecision] + N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]]]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
t_1 := \log y \cdot x\\
t_2 := \mathsf{fma}\left(\log c, b - 0.5, t\_1\right)\\
\mathbf{if}\;z \leq -3 \cdot 10^{-56}:\\
\;\;\;\;\left(\frac{\left(a + t\right) + t\_2}{z} - -1\right) \cdot z + y \cdot i\\
\mathbf{elif}\;z \leq 5.8 \cdot 10^{-146}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\left(\left(\mathsf{fma}\left(-0.5, \log c, t\_1\right) + z\right) + t\right) + a}{b}, -1, -\log c\right) \cdot \left(-b\right) + y \cdot i\\
\mathbf{else}:\\
\;\;\;\;\left(\left(1 + \frac{a}{t}\right) + \left(\mathsf{fma}\left(i, \frac{y}{t}, \frac{t\_2}{t}\right) + \frac{z}{t}\right)\right) \cdot t\\
\end{array}
\end{array}
if z < -2.99999999999999989e-56Initial program 99.9%
Taylor expanded in z around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.5%
if -2.99999999999999989e-56 < z < 5.80000000000000022e-146Initial program 99.9%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites76.2%
if 5.80000000000000022e-146 < z Initial program 98.8%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites72.1%
Final simplification80.2%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(if (<= y 1.8e-20)
(+
(* (- (/ (+ (+ a t) (fma (log c) (- b 0.5) (* (log y) x))) z) -1.0) z)
(* y i))
(*
(+
(fma
(* (- x) (/ (log y) y))
-1.0
(+ (+ (/ (fma (log c) (- b 0.5) z) y) (/ t y)) (/ a y)))
i)
y)))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (y <= 1.8e-20) {
tmp = (((((a + t) + fma(log(c), (b - 0.5), (log(y) * x))) / z) - -1.0) * z) + (y * i);
} else {
tmp = (fma((-x * (log(y) / y)), -1.0, (((fma(log(c), (b - 0.5), z) / y) + (t / y)) + (a / y))) + i) * y;
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (y <= 1.8e-20) tmp = Float64(Float64(Float64(Float64(Float64(Float64(a + t) + fma(log(c), Float64(b - 0.5), Float64(log(y) * x))) / z) - -1.0) * z) + Float64(y * i)); else tmp = Float64(Float64(fma(Float64(Float64(-x) * Float64(log(y) / y)), -1.0, Float64(Float64(Float64(fma(log(c), Float64(b - 0.5), z) / y) + Float64(t / y)) + Float64(a / y))) + i) * y); end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[y, 1.8e-20], N[(N[(N[(N[(N[(N[(a + t), $MachinePrecision] + N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] - -1.0), $MachinePrecision] * z), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[((-x) * N[(N[Log[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] * -1.0 + N[(N[(N[(N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + z), $MachinePrecision] / y), $MachinePrecision] + N[(t / y), $MachinePrecision]), $MachinePrecision] + N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + i), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.8 \cdot 10^{-20}:\\
\;\;\;\;\left(\frac{\left(a + t\right) + \mathsf{fma}\left(\log c, b - 0.5, \log y \cdot x\right)}{z} - -1\right) \cdot z + y \cdot i\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\left(-x\right) \cdot \frac{\log y}{y}, -1, \left(\frac{\mathsf{fma}\left(\log c, b - 0.5, z\right)}{y} + \frac{t}{y}\right) + \frac{a}{y}\right) + i\right) \cdot y\\
\end{array}
\end{array}
if y < 1.79999999999999987e-20Initial program 99.9%
Taylor expanded in z around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites67.3%
if 1.79999999999999987e-20 < y Initial program 99.1%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.7%
Final simplification84.5%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(if (<= y 1.86e-65)
(*
(+
(+ 1.0 (/ a t))
(+ (fma i (/ y t) (/ (fma (log c) (- b 0.5) (* (log y) x)) t)) (/ z t)))
t)
(*
(+
(fma
(* (- x) (/ (log y) y))
-1.0
(+ (+ (/ (fma (log c) (- b 0.5) z) y) (/ t y)) (/ a y)))
i)
y)))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (y <= 1.86e-65) {
tmp = ((1.0 + (a / t)) + (fma(i, (y / t), (fma(log(c), (b - 0.5), (log(y) * x)) / t)) + (z / t))) * t;
} else {
tmp = (fma((-x * (log(y) / y)), -1.0, (((fma(log(c), (b - 0.5), z) / y) + (t / y)) + (a / y))) + i) * y;
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (y <= 1.86e-65) tmp = Float64(Float64(Float64(1.0 + Float64(a / t)) + Float64(fma(i, Float64(y / t), Float64(fma(log(c), Float64(b - 0.5), Float64(log(y) * x)) / t)) + Float64(z / t))) * t); else tmp = Float64(Float64(fma(Float64(Float64(-x) * Float64(log(y) / y)), -1.0, Float64(Float64(Float64(fma(log(c), Float64(b - 0.5), z) / y) + Float64(t / y)) + Float64(a / y))) + i) * y); end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[y, 1.86e-65], N[(N[(N[(1.0 + N[(a / t), $MachinePrecision]), $MachinePrecision] + N[(N[(i * N[(y / t), $MachinePrecision] + N[(N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] + N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision], N[(N[(N[(N[((-x) * N[(N[Log[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] * -1.0 + N[(N[(N[(N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + z), $MachinePrecision] / y), $MachinePrecision] + N[(t / y), $MachinePrecision]), $MachinePrecision] + N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + i), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.86 \cdot 10^{-65}:\\
\;\;\;\;\left(\left(1 + \frac{a}{t}\right) + \left(\mathsf{fma}\left(i, \frac{y}{t}, \frac{\mathsf{fma}\left(\log c, b - 0.5, \log y \cdot x\right)}{t}\right) + \frac{z}{t}\right)\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\left(-x\right) \cdot \frac{\log y}{y}, -1, \left(\frac{\mathsf{fma}\left(\log c, b - 0.5, z\right)}{y} + \frac{t}{y}\right) + \frac{a}{y}\right) + i\right) \cdot y\\
\end{array}
\end{array}
if y < 1.86000000000000006e-65Initial program 99.9%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites78.5%
if 1.86000000000000006e-65 < y Initial program 99.2%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.6%
Final simplification90.3%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i) :precision binary64 (* (+ (+ 1.0 (/ a t)) (+ (fma i (/ y t) (/ (fma (log c) (- b 0.5) (* (log y) x)) t)) (/ z t))) t))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return ((1.0 + (a / t)) + (fma(i, (y / t), (fma(log(c), (b - 0.5), (log(y) * x)) / t)) + (z / t))) * t;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) return Float64(Float64(Float64(1.0 + Float64(a / t)) + Float64(fma(i, Float64(y / t), Float64(fma(log(c), Float64(b - 0.5), Float64(log(y) * x)) / t)) + Float64(z / t))) * t) end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(1.0 + N[(a / t), $MachinePrecision]), $MachinePrecision] + N[(N[(i * N[(y / t), $MachinePrecision] + N[(N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] + N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\left(\left(1 + \frac{a}{t}\right) + \left(\mathsf{fma}\left(i, \frac{y}{t}, \frac{\mathsf{fma}\left(\log c, b - 0.5, \log y \cdot x\right)}{t}\right) + \frac{z}{t}\right)\right) \cdot t
\end{array}
Initial program 99.5%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites74.6%
herbie shell --seed 2025059
(FPCore (x y z t a b c i)
:name "Numeric.SpecFunctions:logBeta from math-functions-0.1.5.2, B"
:precision binary64
(+ (+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c))) (* y i)))