
(FPCore (x y z)
:precision binary64
(+
(+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
(/
(+
(* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
0.083333333333333)
x)))
double code(double x, double y, double z) {
return ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((((x - 0.5d0) * log(x)) - x) + 0.91893853320467d0) + ((((((y + 0.0007936500793651d0) * z) - 0.0027777777777778d0) * z) + 0.083333333333333d0) / x)
end function
public static double code(double x, double y, double z) {
return ((((x - 0.5) * Math.log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
}
def code(x, y, z): return ((((x - 0.5) * math.log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + 0.91893853320467) + Float64(Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)) end
function tmp = code(x, y, z) tmp = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x); end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z)
:precision binary64
(+
(+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
(/
(+
(* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
0.083333333333333)
x)))
double code(double x, double y, double z) {
return ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((((x - 0.5d0) * log(x)) - x) + 0.91893853320467d0) + ((((((y + 0.0007936500793651d0) * z) - 0.0027777777777778d0) * z) + 0.083333333333333d0) / x)
end function
public static double code(double x, double y, double z) {
return ((((x - 0.5) * Math.log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
}
def code(x, y, z): return ((((x - 0.5) * math.log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + 0.91893853320467) + Float64(Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)) end
function tmp = code(x, y, z) tmp = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x); end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\end{array}
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (log x) (- x 0.5))))
(if (<= x 1.2e-5)
(-
(+
(+
(/
(fma
(- (* (+ y 0.0007936500793651) z) 0.0027777777777778)
z
0.083333333333333)
x)
t_0)
0.91893853320467)
x)
(-
(+
(fma (/ (- (* (+ 0.0007936500793651 y) z) 0.0027777777777778) x) z t_0)
0.91893853320467)
x))))
double code(double x, double y, double z) {
double t_0 = log(x) * (x - 0.5);
double tmp;
if (x <= 1.2e-5) {
tmp = (((fma((((y + 0.0007936500793651) * z) - 0.0027777777777778), z, 0.083333333333333) / x) + t_0) + 0.91893853320467) - x;
} else {
tmp = (fma(((((0.0007936500793651 + y) * z) - 0.0027777777777778) / x), z, t_0) + 0.91893853320467) - x;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(log(x) * Float64(x - 0.5)) tmp = 0.0 if (x <= 1.2e-5) tmp = Float64(Float64(Float64(Float64(fma(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778), z, 0.083333333333333) / x) + t_0) + 0.91893853320467) - x); else tmp = Float64(Float64(fma(Float64(Float64(Float64(Float64(0.0007936500793651 + y) * z) - 0.0027777777777778) / x), z, t_0) + 0.91893853320467) - x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] * N[(x - 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.2e-5], N[(N[(N[(N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision] + t$95$0), $MachinePrecision] + 0.91893853320467), $MachinePrecision] - x), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] / x), $MachinePrecision] * z + t$95$0), $MachinePrecision] + 0.91893853320467), $MachinePrecision] - x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log x \cdot \left(x - 0.5\right)\\
\mathbf{if}\;x \leq 1.2 \cdot 10^{-5}:\\
\;\;\;\;\left(\left(\frac{\mathsf{fma}\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778, z, 0.083333333333333\right)}{x} + t\_0\right) + 0.91893853320467\right) - x\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\frac{\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778}{x}, z, t\_0\right) + 0.91893853320467\right) - x\\
\end{array}
\end{array}
if x < 1.2e-5Initial program 99.7%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
div-addN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
Applied rewrites97.4%
Taylor expanded in z around 0
Applied rewrites99.7%
if 1.2e-5 < x Initial program 90.3%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
div-addN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
Applied rewrites99.5%
Taylor expanded in z around 0
Applied rewrites90.3%
Applied rewrites99.5%
Taylor expanded in x around inf
Applied rewrites99.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0
(+
(+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
(/
(+
(* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
0.083333333333333)
x))))
(if (or (<= t_0 -2e+66) (not (<= t_0 4e+307)))
(*
(*
(/
(fma
(/ (- 0.0027777777777778 (/ 0.083333333333333 z)) z)
-1.0
(+ 0.0007936500793651 y))
x)
z)
z)
(-
(fma (log x) (- x 0.5) (+ (/ 0.083333333333333 x) 0.91893853320467))
x))))
double code(double x, double y, double z) {
double t_0 = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
double tmp;
if ((t_0 <= -2e+66) || !(t_0 <= 4e+307)) {
tmp = ((fma(((0.0027777777777778 - (0.083333333333333 / z)) / z), -1.0, (0.0007936500793651 + y)) / x) * z) * z;
} else {
tmp = fma(log(x), (x - 0.5), ((0.083333333333333 / x) + 0.91893853320467)) - x;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + 0.91893853320467) + Float64(Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)) tmp = 0.0 if ((t_0 <= -2e+66) || !(t_0 <= 4e+307)) tmp = Float64(Float64(Float64(fma(Float64(Float64(0.0027777777777778 - Float64(0.083333333333333 / z)) / z), -1.0, Float64(0.0007936500793651 + y)) / x) * z) * z); else tmp = Float64(fma(log(x), Float64(x - 0.5), Float64(Float64(0.083333333333333 / x) + 0.91893853320467)) - x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -2e+66], N[Not[LessEqual[t$95$0, 4e+307]], $MachinePrecision]], N[(N[(N[(N[(N[(N[(0.0027777777777778 - N[(0.083333333333333 / z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] * -1.0 + N[(0.0007936500793651 + y), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] * z), $MachinePrecision] * z), $MachinePrecision], N[(N[(N[Log[x], $MachinePrecision] * N[(x - 0.5), $MachinePrecision] + N[(N[(0.083333333333333 / x), $MachinePrecision] + 0.91893853320467), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+66} \lor \neg \left(t\_0 \leq 4 \cdot 10^{+307}\right):\\
\;\;\;\;\left(\frac{\mathsf{fma}\left(\frac{0.0027777777777778 - \frac{0.083333333333333}{z}}{z}, -1, 0.0007936500793651 + y\right)}{x} \cdot z\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \frac{0.083333333333333}{x} + 0.91893853320467\right) - x\\
\end{array}
\end{array}
if (+.f64 (+.f64 (-.f64 (*.f64 (-.f64 x #s(literal 1/2 binary64)) (log.f64 x)) x) #s(literal 91893853320467/100000000000000 binary64)) (/.f64 (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) #s(literal 83333333333333/1000000000000000 binary64)) x)) < -1.99999999999999989e66 or 3.99999999999999994e307 < (+.f64 (+.f64 (-.f64 (*.f64 (-.f64 x #s(literal 1/2 binary64)) (log.f64 x)) x) #s(literal 91893853320467/100000000000000 binary64)) (/.f64 (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) #s(literal 83333333333333/1000000000000000 binary64)) x)) Initial program 88.2%
Taylor expanded in z around -inf
Applied rewrites88.2%
Taylor expanded in x around 0
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lift-/.f64N/A
lift--.f6485.9
Applied rewrites85.9%
Taylor expanded in x around 0
lower-/.f64N/A
associate-+r+N/A
lower-+.f64N/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lift-/.f64N/A
lift--.f6486.8
Applied rewrites86.8%
Applied rewrites92.2%
if -1.99999999999999989e66 < (+.f64 (+.f64 (-.f64 (*.f64 (-.f64 x #s(literal 1/2 binary64)) (log.f64 x)) x) #s(literal 91893853320467/100000000000000 binary64)) (/.f64 (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) #s(literal 83333333333333/1000000000000000 binary64)) x)) < 3.99999999999999994e307Initial program 99.4%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
div-addN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
Applied rewrites97.6%
Taylor expanded in z around 0
Applied rewrites99.4%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r/N/A
metadata-evalN/A
+-commutativeN/A
associate-+l+N/A
metadata-evalN/A
associate-*r/N/A
+-commutativeN/A
associate-*r/N/A
metadata-evalN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f64N/A
metadata-evalN/A
associate-*r/N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites90.4%
Final simplification91.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0
(+
(+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
(/
(+
(* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
0.083333333333333)
x))))
(if (or (<= t_0 -2e+66) (not (<= t_0 4e+307)))
(*
(*
(/
(fma
(/ (- 0.0027777777777778 (/ 0.083333333333333 z)) z)
-1.0
(+ 0.0007936500793651 y))
x)
z)
z)
(+
(fma (log x) (- x 0.5) (/ 0.083333333333333 x))
(- 0.91893853320467 x)))))
double code(double x, double y, double z) {
double t_0 = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
double tmp;
if ((t_0 <= -2e+66) || !(t_0 <= 4e+307)) {
tmp = ((fma(((0.0027777777777778 - (0.083333333333333 / z)) / z), -1.0, (0.0007936500793651 + y)) / x) * z) * z;
} else {
tmp = fma(log(x), (x - 0.5), (0.083333333333333 / x)) + (0.91893853320467 - x);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + 0.91893853320467) + Float64(Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)) tmp = 0.0 if ((t_0 <= -2e+66) || !(t_0 <= 4e+307)) tmp = Float64(Float64(Float64(fma(Float64(Float64(0.0027777777777778 - Float64(0.083333333333333 / z)) / z), -1.0, Float64(0.0007936500793651 + y)) / x) * z) * z); else tmp = Float64(fma(log(x), Float64(x - 0.5), Float64(0.083333333333333 / x)) + Float64(0.91893853320467 - x)); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -2e+66], N[Not[LessEqual[t$95$0, 4e+307]], $MachinePrecision]], N[(N[(N[(N[(N[(N[(0.0027777777777778 - N[(0.083333333333333 / z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] * -1.0 + N[(0.0007936500793651 + y), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] * z), $MachinePrecision] * z), $MachinePrecision], N[(N[(N[Log[x], $MachinePrecision] * N[(x - 0.5), $MachinePrecision] + N[(0.083333333333333 / x), $MachinePrecision]), $MachinePrecision] + N[(0.91893853320467 - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+66} \lor \neg \left(t\_0 \leq 4 \cdot 10^{+307}\right):\\
\;\;\;\;\left(\frac{\mathsf{fma}\left(\frac{0.0027777777777778 - \frac{0.083333333333333}{z}}{z}, -1, 0.0007936500793651 + y\right)}{x} \cdot z\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \frac{0.083333333333333}{x}\right) + \left(0.91893853320467 - x\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (-.f64 (*.f64 (-.f64 x #s(literal 1/2 binary64)) (log.f64 x)) x) #s(literal 91893853320467/100000000000000 binary64)) (/.f64 (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) #s(literal 83333333333333/1000000000000000 binary64)) x)) < -1.99999999999999989e66 or 3.99999999999999994e307 < (+.f64 (+.f64 (-.f64 (*.f64 (-.f64 x #s(literal 1/2 binary64)) (log.f64 x)) x) #s(literal 91893853320467/100000000000000 binary64)) (/.f64 (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) #s(literal 83333333333333/1000000000000000 binary64)) x)) Initial program 88.2%
Taylor expanded in z around -inf
Applied rewrites88.2%
Taylor expanded in x around 0
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lift-/.f64N/A
lift--.f6485.9
Applied rewrites85.9%
Taylor expanded in x around 0
lower-/.f64N/A
associate-+r+N/A
lower-+.f64N/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lift-/.f64N/A
lift--.f6486.8
Applied rewrites86.8%
Applied rewrites92.2%
if -1.99999999999999989e66 < (+.f64 (+.f64 (-.f64 (*.f64 (-.f64 x #s(literal 1/2 binary64)) (log.f64 x)) x) #s(literal 91893853320467/100000000000000 binary64)) (/.f64 (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) #s(literal 83333333333333/1000000000000000 binary64)) x)) < 3.99999999999999994e307Initial program 99.4%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
div-addN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
Applied rewrites97.6%
Taylor expanded in z around 0
associate-*r/N/A
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
div-addN/A
Applied rewrites90.4%
Final simplification91.1%
(FPCore (x y z)
:precision binary64
(-
(+
(fma
(/ (- (* (+ 0.0007936500793651 y) z) 0.0027777777777778) x)
z
(* (log x) (- x 0.5)))
(+ (/ 0.083333333333333 x) 0.91893853320467))
x))
double code(double x, double y, double z) {
return (fma(((((0.0007936500793651 + y) * z) - 0.0027777777777778) / x), z, (log(x) * (x - 0.5))) + ((0.083333333333333 / x) + 0.91893853320467)) - x;
}
function code(x, y, z) return Float64(Float64(fma(Float64(Float64(Float64(Float64(0.0007936500793651 + y) * z) - 0.0027777777777778) / x), z, Float64(log(x) * Float64(x - 0.5))) + Float64(Float64(0.083333333333333 / x) + 0.91893853320467)) - x) end
code[x_, y_, z_] := N[(N[(N[(N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] / x), $MachinePrecision] * z + N[(N[Log[x], $MachinePrecision] * N[(x - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(0.083333333333333 / x), $MachinePrecision] + 0.91893853320467), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}
\\
\left(\mathsf{fma}\left(\frac{\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778}{x}, z, \log x \cdot \left(x - 0.5\right)\right) + \left(\frac{0.083333333333333}{x} + 0.91893853320467\right)\right) - x
\end{array}
Initial program 94.8%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
div-addN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
Applied rewrites98.5%
Taylor expanded in z around 0
Applied rewrites94.8%
Applied rewrites98.5%
(FPCore (x y z)
:precision binary64
(if (<= x 1.2e-5)
(-
(+
(/
(fma
(- (* (+ 0.0007936500793651 y) z) 0.0027777777777778)
z
0.083333333333333)
x)
0.91893853320467)
x)
(if (<= x 1.4e+198)
(+
(+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
(* (* z z) (/ (+ 0.0007936500793651 y) x)))
(* (- (log x) 1.0) x))))
double code(double x, double y, double z) {
double tmp;
if (x <= 1.2e-5) {
tmp = ((fma((((0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x) + 0.91893853320467) - x;
} else if (x <= 1.4e+198) {
tmp = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((z * z) * ((0.0007936500793651 + y) / x));
} else {
tmp = (log(x) - 1.0) * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 1.2e-5) tmp = Float64(Float64(Float64(fma(Float64(Float64(Float64(0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x) + 0.91893853320467) - x); elseif (x <= 1.4e+198) tmp = Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + 0.91893853320467) + Float64(Float64(z * z) * Float64(Float64(0.0007936500793651 + y) / x))); else tmp = Float64(Float64(log(x) - 1.0) * x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 1.2e-5], N[(N[(N[(N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] - x), $MachinePrecision], If[LessEqual[x, 1.4e+198], N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(z * z), $MachinePrecision] * N[(N[(0.0007936500793651 + y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[x], $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.2 \cdot 10^{-5}:\\
\;\;\;\;\left(\frac{\mathsf{fma}\left(\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778, z, 0.083333333333333\right)}{x} + 0.91893853320467\right) - x\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+198}:\\
\;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(z \cdot z\right) \cdot \frac{0.0007936500793651 + y}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(\log x - 1\right) \cdot x\\
\end{array}
\end{array}
if x < 1.2e-5Initial program 99.7%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
div-addN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
Applied rewrites97.4%
Taylor expanded in z around 0
Applied rewrites99.7%
Taylor expanded in x around 0
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
lower-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-fma.f6499.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.0
Applied rewrites99.0%
if 1.2e-5 < x < 1.4e198Initial program 95.3%
Taylor expanded in z around inf
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f6496.4
Applied rewrites96.4%
if 1.4e198 < x Initial program 80.9%
Taylor expanded in x around inf
*-commutativeN/A
log-pow-revN/A
inv-powN/A
pow-powN/A
metadata-evalN/A
unpow1N/A
lower-*.f64N/A
lower--.f64N/A
lift-log.f6496.8
Applied rewrites96.8%
(FPCore (x y z)
:precision binary64
(if (<= x 1.2e-5)
(-
(+
(/
(fma
(- (* (+ 0.0007936500793651 y) z) 0.0027777777777778)
z
0.083333333333333)
x)
0.91893853320467)
x)
(if (<= x 1.4e+198)
(+
(+ (- (* x (log x)) x) 0.91893853320467)
(* (/ (+ 0.0007936500793651 y) x) (* z z)))
(* (- (log x) 1.0) x))))
double code(double x, double y, double z) {
double tmp;
if (x <= 1.2e-5) {
tmp = ((fma((((0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x) + 0.91893853320467) - x;
} else if (x <= 1.4e+198) {
tmp = (((x * log(x)) - x) + 0.91893853320467) + (((0.0007936500793651 + y) / x) * (z * z));
} else {
tmp = (log(x) - 1.0) * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 1.2e-5) tmp = Float64(Float64(Float64(fma(Float64(Float64(Float64(0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x) + 0.91893853320467) - x); elseif (x <= 1.4e+198) tmp = Float64(Float64(Float64(Float64(x * log(x)) - x) + 0.91893853320467) + Float64(Float64(Float64(0.0007936500793651 + y) / x) * Float64(z * z))); else tmp = Float64(Float64(log(x) - 1.0) * x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 1.2e-5], N[(N[(N[(N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] - x), $MachinePrecision], If[LessEqual[x, 1.4e+198], N[(N[(N[(N[(x * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] / x), $MachinePrecision] * N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[x], $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.2 \cdot 10^{-5}:\\
\;\;\;\;\left(\frac{\mathsf{fma}\left(\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778, z, 0.083333333333333\right)}{x} + 0.91893853320467\right) - x\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+198}:\\
\;\;\;\;\left(\left(x \cdot \log x - x\right) + 0.91893853320467\right) + \frac{0.0007936500793651 + y}{x} \cdot \left(z \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\log x - 1\right) \cdot x\\
\end{array}
\end{array}
if x < 1.2e-5Initial program 99.7%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
div-addN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
Applied rewrites97.4%
Taylor expanded in z around 0
Applied rewrites99.7%
Taylor expanded in x around 0
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
lower-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-fma.f6499.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.0
Applied rewrites99.0%
if 1.2e-5 < x < 1.4e198Initial program 95.3%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6480.9
Applied rewrites80.9%
Taylor expanded in x around inf
Applied rewrites80.5%
Taylor expanded in z around inf
associate-/l*N/A
div-addN/A
metadata-evalN/A
associate-*r/N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
lower-/.f64N/A
lift-+.f64N/A
pow2N/A
lift-*.f6495.9
Applied rewrites95.9%
if 1.4e198 < x Initial program 80.9%
Taylor expanded in x around inf
*-commutativeN/A
log-pow-revN/A
inv-powN/A
pow-powN/A
metadata-evalN/A
unpow1N/A
lower-*.f64N/A
lower--.f64N/A
lift-log.f6496.8
Applied rewrites96.8%
(FPCore (x y z)
:precision binary64
(if (<= x 3.3e+25)
(/
(fma
(- (* (+ 0.0007936500793651 y) z) 0.0027777777777778)
z
0.083333333333333)
x)
(if (<= x 2.05e+195)
(- (+ (+ (/ (* (* z z) y) x) (* (log x) (- x 0.5))) 0.91893853320467) x)
(* (- (log x) 1.0) x))))
double code(double x, double y, double z) {
double tmp;
if (x <= 3.3e+25) {
tmp = fma((((0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x;
} else if (x <= 2.05e+195) {
tmp = (((((z * z) * y) / x) + (log(x) * (x - 0.5))) + 0.91893853320467) - x;
} else {
tmp = (log(x) - 1.0) * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 3.3e+25) tmp = Float64(fma(Float64(Float64(Float64(0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x); elseif (x <= 2.05e+195) tmp = Float64(Float64(Float64(Float64(Float64(Float64(z * z) * y) / x) + Float64(log(x) * Float64(x - 0.5))) + 0.91893853320467) - x); else tmp = Float64(Float64(log(x) - 1.0) * x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 3.3e+25], N[(N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 2.05e+195], N[(N[(N[(N[(N[(N[(z * z), $MachinePrecision] * y), $MachinePrecision] / x), $MachinePrecision] + N[(N[Log[x], $MachinePrecision] * N[(x - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 0.91893853320467), $MachinePrecision] - x), $MachinePrecision], N[(N[(N[Log[x], $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.3 \cdot 10^{+25}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778, z, 0.083333333333333\right)}{x}\\
\mathbf{elif}\;x \leq 2.05 \cdot 10^{+195}:\\
\;\;\;\;\left(\left(\frac{\left(z \cdot z\right) \cdot y}{x} + \log x \cdot \left(x - 0.5\right)\right) + 0.91893853320467\right) - x\\
\mathbf{else}:\\
\;\;\;\;\left(\log x - 1\right) \cdot x\\
\end{array}
\end{array}
if x < 3.3000000000000001e25Initial program 99.1%
Taylor expanded in x around 0
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
lower-/.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift--.f6495.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6495.6
Applied rewrites95.6%
if 3.3000000000000001e25 < x < 2.05e195Initial program 95.5%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
div-addN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
Applied rewrites99.5%
Taylor expanded in z around 0
Applied rewrites95.5%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6485.9
Applied rewrites85.9%
if 2.05e195 < x Initial program 80.9%
Taylor expanded in x around inf
*-commutativeN/A
log-pow-revN/A
inv-powN/A
pow-powN/A
metadata-evalN/A
unpow1N/A
lower-*.f64N/A
lower--.f64N/A
lift-log.f6496.8
Applied rewrites96.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* (+ 0.0007936500793651 y) z) 0.0027777777777778)))
(if (<= x 1.2e-5)
(- (+ (/ (fma t_0 z 0.083333333333333) x) 0.91893853320467) x)
(- (+ (fma (/ t_0 x) z (* (log x) (- x 0.5))) 0.91893853320467) x))))
double code(double x, double y, double z) {
double t_0 = ((0.0007936500793651 + y) * z) - 0.0027777777777778;
double tmp;
if (x <= 1.2e-5) {
tmp = ((fma(t_0, z, 0.083333333333333) / x) + 0.91893853320467) - x;
} else {
tmp = (fma((t_0 / x), z, (log(x) * (x - 0.5))) + 0.91893853320467) - x;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(Float64(0.0007936500793651 + y) * z) - 0.0027777777777778) tmp = 0.0 if (x <= 1.2e-5) tmp = Float64(Float64(Float64(fma(t_0, z, 0.083333333333333) / x) + 0.91893853320467) - x); else tmp = Float64(Float64(fma(Float64(t_0 / x), z, Float64(log(x) * Float64(x - 0.5))) + 0.91893853320467) - x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]}, If[LessEqual[x, 1.2e-5], N[(N[(N[(N[(t$95$0 * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] - x), $MachinePrecision], N[(N[(N[(N[(t$95$0 / x), $MachinePrecision] * z + N[(N[Log[x], $MachinePrecision] * N[(x - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 0.91893853320467), $MachinePrecision] - x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778\\
\mathbf{if}\;x \leq 1.2 \cdot 10^{-5}:\\
\;\;\;\;\left(\frac{\mathsf{fma}\left(t\_0, z, 0.083333333333333\right)}{x} + 0.91893853320467\right) - x\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\frac{t\_0}{x}, z, \log x \cdot \left(x - 0.5\right)\right) + 0.91893853320467\right) - x\\
\end{array}
\end{array}
if x < 1.2e-5Initial program 99.7%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
div-addN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
Applied rewrites97.4%
Taylor expanded in z around 0
Applied rewrites99.7%
Taylor expanded in x around 0
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
lower-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-fma.f6499.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.0
Applied rewrites99.0%
if 1.2e-5 < x Initial program 90.3%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
div-addN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
Applied rewrites99.5%
Taylor expanded in z around 0
Applied rewrites90.3%
Applied rewrites99.5%
Taylor expanded in x around inf
Applied rewrites99.5%
(FPCore (x y z)
:precision binary64
(if (<= x 3.3e+25)
(/
(fma
(- (* (+ 0.0007936500793651 y) z) 0.0027777777777778)
z
0.083333333333333)
x)
(if (<= x 2.05e+195)
(+ (+ (- (* x (log x)) x) 0.91893853320467) (/ (* (* z z) y) x))
(* (- (log x) 1.0) x))))
double code(double x, double y, double z) {
double tmp;
if (x <= 3.3e+25) {
tmp = fma((((0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x;
} else if (x <= 2.05e+195) {
tmp = (((x * log(x)) - x) + 0.91893853320467) + (((z * z) * y) / x);
} else {
tmp = (log(x) - 1.0) * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 3.3e+25) tmp = Float64(fma(Float64(Float64(Float64(0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x); elseif (x <= 2.05e+195) tmp = Float64(Float64(Float64(Float64(x * log(x)) - x) + 0.91893853320467) + Float64(Float64(Float64(z * z) * y) / x)); else tmp = Float64(Float64(log(x) - 1.0) * x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 3.3e+25], N[(N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 2.05e+195], N[(N[(N[(N[(x * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(N[(z * z), $MachinePrecision] * y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[x], $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.3 \cdot 10^{+25}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778, z, 0.083333333333333\right)}{x}\\
\mathbf{elif}\;x \leq 2.05 \cdot 10^{+195}:\\
\;\;\;\;\left(\left(x \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(z \cdot z\right) \cdot y}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(\log x - 1\right) \cdot x\\
\end{array}
\end{array}
if x < 3.3000000000000001e25Initial program 99.1%
Taylor expanded in x around 0
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
lower-/.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift--.f6495.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6495.6
Applied rewrites95.6%
if 3.3000000000000001e25 < x < 2.05e195Initial program 95.5%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6485.9
Applied rewrites85.9%
Taylor expanded in x around inf
Applied rewrites85.9%
if 2.05e195 < x Initial program 80.9%
Taylor expanded in x around inf
*-commutativeN/A
log-pow-revN/A
inv-powN/A
pow-powN/A
metadata-evalN/A
unpow1N/A
lower-*.f64N/A
lower--.f64N/A
lift-log.f6496.8
Applied rewrites96.8%
(FPCore (x y z)
:precision binary64
(if (<= x 1.15e+88)
(/
(fma
(- (* (+ 0.0007936500793651 y) z) 0.0027777777777778)
z
0.083333333333333)
x)
(* (- (log x) 1.0) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= 1.15e+88) {
tmp = fma((((0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x;
} else {
tmp = (log(x) - 1.0) * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 1.15e+88) tmp = Float64(fma(Float64(Float64(Float64(0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x); else tmp = Float64(Float64(log(x) - 1.0) * x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 1.15e+88], N[(N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[Log[x], $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.15 \cdot 10^{+88}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778, z, 0.083333333333333\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(\log x - 1\right) \cdot x\\
\end{array}
\end{array}
if x < 1.1500000000000001e88Initial program 99.1%
Taylor expanded in x around 0
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
lower-/.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift--.f6491.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6491.7
Applied rewrites91.7%
if 1.1500000000000001e88 < x Initial program 87.8%
Taylor expanded in x around inf
*-commutativeN/A
log-pow-revN/A
inv-powN/A
pow-powN/A
metadata-evalN/A
unpow1N/A
lower-*.f64N/A
lower--.f64N/A
lift-log.f6483.7
Applied rewrites83.7%
(FPCore (x y z)
:precision binary64
(if (<= x 6e+15)
(/
(fma
(- (* (+ 0.0007936500793651 y) z) 0.0027777777777778)
z
0.083333333333333)
x)
(*
(*
(/
(fma
(/ (- 0.0027777777777778 (/ 0.083333333333333 z)) z)
-1.0
(+ 0.0007936500793651 y))
x)
z)
z)))
double code(double x, double y, double z) {
double tmp;
if (x <= 6e+15) {
tmp = fma((((0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x;
} else {
tmp = ((fma(((0.0027777777777778 - (0.083333333333333 / z)) / z), -1.0, (0.0007936500793651 + y)) / x) * z) * z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 6e+15) tmp = Float64(fma(Float64(Float64(Float64(0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x); else tmp = Float64(Float64(Float64(fma(Float64(Float64(0.0027777777777778 - Float64(0.083333333333333 / z)) / z), -1.0, Float64(0.0007936500793651 + y)) / x) * z) * z); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 6e+15], N[(N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[(N[(N[(N[(0.0027777777777778 - N[(0.083333333333333 / z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] * -1.0 + N[(0.0007936500793651 + y), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] * z), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6 \cdot 10^{+15}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778, z, 0.083333333333333\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\mathsf{fma}\left(\frac{0.0027777777777778 - \frac{0.083333333333333}{z}}{z}, -1, 0.0007936500793651 + y\right)}{x} \cdot z\right) \cdot z\\
\end{array}
\end{array}
if x < 6e15Initial program 99.7%
Taylor expanded in x around 0
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
lower-/.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift--.f6496.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6496.7
Applied rewrites96.7%
if 6e15 < x Initial program 89.6%
Taylor expanded in z around -inf
Applied rewrites51.9%
Taylor expanded in x around 0
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lift-/.f64N/A
lift--.f6425.6
Applied rewrites25.6%
Taylor expanded in x around 0
lower-/.f64N/A
associate-+r+N/A
lower-+.f64N/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lift-/.f64N/A
lift--.f6425.3
Applied rewrites25.3%
Applied rewrites31.0%
(FPCore (x y z) :precision binary64 (/ (fma (- (* (+ 0.0007936500793651 y) z) 0.0027777777777778) z 0.083333333333333) x))
double code(double x, double y, double z) {
return fma((((0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x;
}
function code(x, y, z) return Float64(fma(Float64(Float64(Float64(0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x) end
code[x_, y_, z_] := N[(N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778, z, 0.083333333333333\right)}{x}
\end{array}
Initial program 94.8%
Taylor expanded in x around 0
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
lower-/.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift--.f6462.3
lift-+.f64N/A
+-commutativeN/A
lower-+.f6462.3
Applied rewrites62.3%
(FPCore (x y z) :precision binary64 (* (/ (+ y 0.0007936500793651) x) (* z z)))
double code(double x, double y, double z) {
return ((y + 0.0007936500793651) / x) * (z * z);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((y + 0.0007936500793651d0) / x) * (z * z)
end function
public static double code(double x, double y, double z) {
return ((y + 0.0007936500793651) / x) * (z * z);
}
def code(x, y, z): return ((y + 0.0007936500793651) / x) * (z * z)
function code(x, y, z) return Float64(Float64(Float64(y + 0.0007936500793651) / x) * Float64(z * z)) end
function tmp = code(x, y, z) tmp = ((y + 0.0007936500793651) / x) * (z * z); end
code[x_, y_, z_] := N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] / x), $MachinePrecision] * N[(z * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{y + 0.0007936500793651}{x} \cdot \left(z \cdot z\right)
\end{array}
Initial program 94.8%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
div-addN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
Applied rewrites98.5%
Taylor expanded in z around inf
associate-*r/N/A
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
div-addN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites41.6%
(FPCore (x y z) :precision binary64 (* y (* z (/ z x))))
double code(double x, double y, double z) {
return y * (z * (z / x));
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y * (z * (z / x))
end function
public static double code(double x, double y, double z) {
return y * (z * (z / x));
}
def code(x, y, z): return y * (z * (z / x))
function code(x, y, z) return Float64(y * Float64(z * Float64(z / x))) end
function tmp = code(x, y, z) tmp = y * (z * (z / x)); end
code[x_, y_, z_] := N[(y * N[(z * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \left(z \cdot \frac{z}{x}\right)
\end{array}
Initial program 94.8%
Taylor expanded in y around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6427.3
Applied rewrites27.3%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6428.5
Applied rewrites28.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6428.5
Applied rewrites28.5%
(FPCore (x y z) :precision binary64 (+ (+ (+ (* (- x 0.5) (log x)) (- 0.91893853320467 x)) (/ 0.083333333333333 x)) (* (/ z x) (- (* z (+ y 0.0007936500793651)) 0.0027777777777778))))
double code(double x, double y, double z) {
return ((((x - 0.5) * log(x)) + (0.91893853320467 - x)) + (0.083333333333333 / x)) + ((z / x) * ((z * (y + 0.0007936500793651)) - 0.0027777777777778));
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((((x - 0.5d0) * log(x)) + (0.91893853320467d0 - x)) + (0.083333333333333d0 / x)) + ((z / x) * ((z * (y + 0.0007936500793651d0)) - 0.0027777777777778d0))
end function
public static double code(double x, double y, double z) {
return ((((x - 0.5) * Math.log(x)) + (0.91893853320467 - x)) + (0.083333333333333 / x)) + ((z / x) * ((z * (y + 0.0007936500793651)) - 0.0027777777777778));
}
def code(x, y, z): return ((((x - 0.5) * math.log(x)) + (0.91893853320467 - x)) + (0.083333333333333 / x)) + ((z / x) * ((z * (y + 0.0007936500793651)) - 0.0027777777777778))
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) + Float64(0.91893853320467 - x)) + Float64(0.083333333333333 / x)) + Float64(Float64(z / x) * Float64(Float64(z * Float64(y + 0.0007936500793651)) - 0.0027777777777778))) end
function tmp = code(x, y, z) tmp = ((((x - 0.5) * log(x)) + (0.91893853320467 - x)) + (0.083333333333333 / x)) + ((z / x) * ((z * (y + 0.0007936500793651)) - 0.0027777777777778)); end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] + N[(0.91893853320467 - x), $MachinePrecision]), $MachinePrecision] + N[(0.083333333333333 / x), $MachinePrecision]), $MachinePrecision] + N[(N[(z / x), $MachinePrecision] * N[(N[(z * N[(y + 0.0007936500793651), $MachinePrecision]), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(x - 0.5\right) \cdot \log x + \left(0.91893853320467 - x\right)\right) + \frac{0.083333333333333}{x}\right) + \frac{z}{x} \cdot \left(z \cdot \left(y + 0.0007936500793651\right) - 0.0027777777777778\right)
\end{array}
herbie shell --seed 2025032
(FPCore (x y z)
:name "Numeric.SpecFunctions:$slogFactorial from math-functions-0.1.5.2, B"
:precision binary64
:alt
(! :herbie-platform default (+ (+ (+ (* (- x 1/2) (log x)) (- 91893853320467/100000000000000 x)) (/ 83333333333333/1000000000000000 x)) (* (/ z x) (- (* z (+ y 7936500793651/10000000000000000)) 13888888888889/5000000000000000))))
(+ (+ (- (* (- x 0.5) (log x)) x) 0.91893853320467) (/ (+ (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z) 0.083333333333333) x)))