
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
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, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
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, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -0.002)
(- (pow (+ x 1.0) (/ 1.0 n)) t_0)
(if (<= (/ 1.0 n) 1e-15)
(-
(/ (fma (/ (pow (log1p x) 2.0) n) 0.5 (log1p x)) n)
(/ (fma (/ (pow (log x) 2.0) n) 0.5 (log x)) n))
(- (exp (* (log1p x) (pow n -1.0))) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -0.002) {
tmp = pow((x + 1.0), (1.0 / n)) - t_0;
} else if ((1.0 / n) <= 1e-15) {
tmp = (fma((pow(log1p(x), 2.0) / n), 0.5, log1p(x)) / n) - (fma((pow(log(x), 2.0) / n), 0.5, log(x)) / n);
} else {
tmp = exp((log1p(x) * pow(n, -1.0))) - t_0;
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -0.002) tmp = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0); elseif (Float64(1.0 / n) <= 1e-15) tmp = Float64(Float64(fma(Float64((log1p(x) ^ 2.0) / n), 0.5, log1p(x)) / n) - Float64(fma(Float64((log(x) ^ 2.0) / n), 0.5, log(x)) / n)); else tmp = Float64(exp(Float64(log1p(x) * (n ^ -1.0))) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.002], N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-15], N[(N[(N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / n), $MachinePrecision] * 0.5 + N[Log[1 + x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] - N[(N[(N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / n), $MachinePrecision] * 0.5 + N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] * N[Power[n, -1.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -0.002:\\
\;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-15}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n}, 0.5, \mathsf{log1p}\left(x\right)\right)}{n} - \frac{\mathsf{fma}\left(\frac{{\log x}^{2}}{n}, 0.5, \log x\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\mathsf{log1p}\left(x\right) \cdot {n}^{-1}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2e-3Initial program 99.5%
if -2e-3 < (/.f64 #s(literal 1 binary64) n) < 1.0000000000000001e-15Initial program 29.2%
Taylor expanded in n around inf
div-subN/A
lower--.f64N/A
Applied rewrites77.4%
if 1.0000000000000001e-15 < (/.f64 #s(literal 1 binary64) n) Initial program 51.1%
lift-+.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
+-commutativeN/A
lower-*.f64N/A
lower-log1p.f64N/A
inv-powN/A
lower-pow.f6494.5
Applied rewrites94.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- (exp (* (log1p x) (pow n -1.0))) (pow x (/ 1.0 n)))))
(if (<= (/ 1.0 n) -0.002)
t_0
(if (<= (/ 1.0 n) 1e-15)
(-
(/ (fma (/ (pow (log1p x) 2.0) n) 0.5 (log1p x)) n)
(/ (fma (/ (pow (log x) 2.0) n) 0.5 (log x)) n))
t_0))))
double code(double x, double n) {
double t_0 = exp((log1p(x) * pow(n, -1.0))) - pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -0.002) {
tmp = t_0;
} else if ((1.0 / n) <= 1e-15) {
tmp = (fma((pow(log1p(x), 2.0) / n), 0.5, log1p(x)) / n) - (fma((pow(log(x), 2.0) / n), 0.5, log(x)) / n);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, n) t_0 = Float64(exp(Float64(log1p(x) * (n ^ -1.0))) - (x ^ Float64(1.0 / n))) tmp = 0.0 if (Float64(1.0 / n) <= -0.002) tmp = t_0; elseif (Float64(1.0 / n) <= 1e-15) tmp = Float64(Float64(fma(Float64((log1p(x) ^ 2.0) / n), 0.5, log1p(x)) / n) - Float64(fma(Float64((log(x) ^ 2.0) / n), 0.5, log(x)) / n)); else tmp = t_0; end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] * N[Power[n, -1.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.002], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-15], N[(N[(N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / n), $MachinePrecision] * 0.5 + N[Log[1 + x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] - N[(N[(N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / n), $MachinePrecision] * 0.5 + N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\mathsf{log1p}\left(x\right) \cdot {n}^{-1}} - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -0.002:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-15}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n}, 0.5, \mathsf{log1p}\left(x\right)\right)}{n} - \frac{\mathsf{fma}\left(\frac{{\log x}^{2}}{n}, 0.5, \log x\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2e-3 or 1.0000000000000001e-15 < (/.f64 #s(literal 1 binary64) n) Initial program 82.6%
lift-+.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
+-commutativeN/A
lower-*.f64N/A
lower-log1p.f64N/A
inv-powN/A
lower-pow.f6497.7
Applied rewrites97.7%
if -2e-3 < (/.f64 #s(literal 1 binary64) n) < 1.0000000000000001e-15Initial program 29.2%
Taylor expanded in n around inf
div-subN/A
lower--.f64N/A
Applied rewrites77.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log1p x) n))
(t_1 (/ (log x) n))
(t_2 (* -1.0 (log x)))
(t_3 (exp t_1)))
(if (<= (/ 1.0 n) -5e-30)
(/ (pow (exp -1.0) (/ t_2 n)) (* n x))
(if (<= (/ 1.0 n) 4e-12)
(-
(/ (fma (/ (pow (log1p x) 2.0) n) 0.5 (log1p x)) n)
(/ (fma (/ (pow (log x) 2.0) n) 0.5 (log x)) n))
(if (<= (/ 1.0 n) 5e+173)
(/
(- (pow (exp 3.0) t_0) (exp (* t_1 3.0)))
(fma t_3 (exp t_0) (fma t_3 t_3 (exp (* t_0 2.0)))))
(*
-0.3333333333333333
(/
(- (* (* -3.0 (log1p x)) n) (* n (fma -2.0 (log x) t_2)))
(* n n))))))))
double code(double x, double n) {
double t_0 = log1p(x) / n;
double t_1 = log(x) / n;
double t_2 = -1.0 * log(x);
double t_3 = exp(t_1);
double tmp;
if ((1.0 / n) <= -5e-30) {
tmp = pow(exp(-1.0), (t_2 / n)) / (n * x);
} else if ((1.0 / n) <= 4e-12) {
tmp = (fma((pow(log1p(x), 2.0) / n), 0.5, log1p(x)) / n) - (fma((pow(log(x), 2.0) / n), 0.5, log(x)) / n);
} else if ((1.0 / n) <= 5e+173) {
tmp = (pow(exp(3.0), t_0) - exp((t_1 * 3.0))) / fma(t_3, exp(t_0), fma(t_3, t_3, exp((t_0 * 2.0))));
} else {
tmp = -0.3333333333333333 * ((((-3.0 * log1p(x)) * n) - (n * fma(-2.0, log(x), t_2))) / (n * n));
}
return tmp;
}
function code(x, n) t_0 = Float64(log1p(x) / n) t_1 = Float64(log(x) / n) t_2 = Float64(-1.0 * log(x)) t_3 = exp(t_1) tmp = 0.0 if (Float64(1.0 / n) <= -5e-30) tmp = Float64((exp(-1.0) ^ Float64(t_2 / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 4e-12) tmp = Float64(Float64(fma(Float64((log1p(x) ^ 2.0) / n), 0.5, log1p(x)) / n) - Float64(fma(Float64((log(x) ^ 2.0) / n), 0.5, log(x)) / n)); elseif (Float64(1.0 / n) <= 5e+173) tmp = Float64(Float64((exp(3.0) ^ t_0) - exp(Float64(t_1 * 3.0))) / fma(t_3, exp(t_0), fma(t_3, t_3, exp(Float64(t_0 * 2.0))))); else tmp = Float64(-0.3333333333333333 * Float64(Float64(Float64(Float64(-3.0 * log1p(x)) * n) - Float64(n * fma(-2.0, log(x), t_2))) / Float64(n * n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]}, Block[{t$95$2 = N[(-1.0 * N[Log[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Exp[t$95$1], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-30], N[(N[Power[N[Exp[-1.0], $MachinePrecision], N[(t$95$2 / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-12], N[(N[(N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / n), $MachinePrecision] * 0.5 + N[Log[1 + x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] - N[(N[(N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / n), $MachinePrecision] * 0.5 + N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+173], N[(N[(N[Power[N[Exp[3.0], $MachinePrecision], t$95$0], $MachinePrecision] - N[Exp[N[(t$95$1 * 3.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$3 * N[Exp[t$95$0], $MachinePrecision] + N[(t$95$3 * t$95$3 + N[Exp[N[(t$95$0 * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.3333333333333333 * N[(N[(N[(N[(-3.0 * N[Log[1 + x], $MachinePrecision]), $MachinePrecision] * n), $MachinePrecision] - N[(n * N[(-2.0 * N[Log[x], $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{log1p}\left(x\right)}{n}\\
t_1 := \frac{\log x}{n}\\
t_2 := -1 \cdot \log x\\
t_3 := e^{t\_1}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-30}:\\
\;\;\;\;\frac{{\left(e^{-1}\right)}^{\left(\frac{t\_2}{n}\right)}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-12}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n}, 0.5, \mathsf{log1p}\left(x\right)\right)}{n} - \frac{\mathsf{fma}\left(\frac{{\log x}^{2}}{n}, 0.5, \log x\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+173}:\\
\;\;\;\;\frac{{\left(e^{3}\right)}^{t\_0} - e^{t\_1 \cdot 3}}{\mathsf{fma}\left(t\_3, e^{t\_0}, \mathsf{fma}\left(t\_3, t\_3, e^{t\_0 \cdot 2}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{\left(-3 \cdot \mathsf{log1p}\left(x\right)\right) \cdot n - n \cdot \mathsf{fma}\left(-2, \log x, t\_2\right)}{n \cdot n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4.99999999999999972e-30Initial program 93.1%
Taylor expanded in x around inf
lower-/.f64N/A
exp-prodN/A
log-recN/A
mul-1-negN/A
lower-pow.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-*.f6495.6
Applied rewrites95.6%
if -4.99999999999999972e-30 < (/.f64 #s(literal 1 binary64) n) < 3.99999999999999992e-12Initial program 29.6%
Taylor expanded in n around inf
div-subN/A
lower--.f64N/A
Applied rewrites78.5%
if 3.99999999999999992e-12 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000034e173Initial program 70.3%
lift--.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
flip3--N/A
lower-/.f64N/A
Applied rewrites66.5%
Taylor expanded in n around 0
lower-/.f64N/A
Applied rewrites68.6%
if 5.00000000000000034e173 < (/.f64 #s(literal 1 binary64) n) Initial program 25.1%
lift--.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
flip3--N/A
lower-/.f64N/A
Applied rewrites20.8%
Taylor expanded in n around -inf
lower-*.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-log1p.f64N/A
lower-/.f64N/A
Applied rewrites8.5%
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-log1p.f64N/A
lift-/.f64N/A
lift-log.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-log.f64N/A
frac-subN/A
unpow2N/A
lower-/.f64N/A
Applied rewrites80.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (* -1.0 (log x))) (t_1 (/ (pow (exp -1.0) (/ t_0 n)) (* n x))))
(if (<= (/ 1.0 n) -5e-30)
t_1
(if (<= (/ 1.0 n) 1e-98)
(-
(/ (fma (/ (pow (log1p x) 2.0) n) 0.5 (log1p x)) n)
(/ (fma (/ (pow (log x) 2.0) n) 0.5 (log x)) n))
(if (<= (/ 1.0 n) 1e-67)
t_1
(*
-0.3333333333333333
(/
(- (* (* -3.0 (log1p x)) n) (* n (fma -2.0 (log x) t_0)))
(* n n))))))))
double code(double x, double n) {
double t_0 = -1.0 * log(x);
double t_1 = pow(exp(-1.0), (t_0 / n)) / (n * x);
double tmp;
if ((1.0 / n) <= -5e-30) {
tmp = t_1;
} else if ((1.0 / n) <= 1e-98) {
tmp = (fma((pow(log1p(x), 2.0) / n), 0.5, log1p(x)) / n) - (fma((pow(log(x), 2.0) / n), 0.5, log(x)) / n);
} else if ((1.0 / n) <= 1e-67) {
tmp = t_1;
} else {
tmp = -0.3333333333333333 * ((((-3.0 * log1p(x)) * n) - (n * fma(-2.0, log(x), t_0))) / (n * n));
}
return tmp;
}
function code(x, n) t_0 = Float64(-1.0 * log(x)) t_1 = Float64((exp(-1.0) ^ Float64(t_0 / n)) / Float64(n * x)) tmp = 0.0 if (Float64(1.0 / n) <= -5e-30) tmp = t_1; elseif (Float64(1.0 / n) <= 1e-98) tmp = Float64(Float64(fma(Float64((log1p(x) ^ 2.0) / n), 0.5, log1p(x)) / n) - Float64(fma(Float64((log(x) ^ 2.0) / n), 0.5, log(x)) / n)); elseif (Float64(1.0 / n) <= 1e-67) tmp = t_1; else tmp = Float64(-0.3333333333333333 * Float64(Float64(Float64(Float64(-3.0 * log1p(x)) * n) - Float64(n * fma(-2.0, log(x), t_0))) / Float64(n * n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(-1.0 * N[Log[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Exp[-1.0], $MachinePrecision], N[(t$95$0 / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-30], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-98], N[(N[(N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / n), $MachinePrecision] * 0.5 + N[Log[1 + x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] - N[(N[(N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / n), $MachinePrecision] * 0.5 + N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-67], t$95$1, N[(-0.3333333333333333 * N[(N[(N[(N[(-3.0 * N[Log[1 + x], $MachinePrecision]), $MachinePrecision] * n), $MachinePrecision] - N[(n * N[(-2.0 * N[Log[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 \cdot \log x\\
t_1 := \frac{{\left(e^{-1}\right)}^{\left(\frac{t\_0}{n}\right)}}{n \cdot x}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-30}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-98}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n}, 0.5, \mathsf{log1p}\left(x\right)\right)}{n} - \frac{\mathsf{fma}\left(\frac{{\log x}^{2}}{n}, 0.5, \log x\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-67}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{\left(-3 \cdot \mathsf{log1p}\left(x\right)\right) \cdot n - n \cdot \mathsf{fma}\left(-2, \log x, t\_0\right)}{n \cdot n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4.99999999999999972e-30 or 9.99999999999999939e-99 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999943e-68Initial program 87.9%
Taylor expanded in x around inf
lower-/.f64N/A
exp-prodN/A
log-recN/A
mul-1-negN/A
lower-pow.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-*.f6492.5
Applied rewrites92.5%
if -4.99999999999999972e-30 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999939e-99Initial program 32.4%
Taylor expanded in n around inf
div-subN/A
lower--.f64N/A
Applied rewrites81.5%
if 9.99999999999999943e-68 < (/.f64 #s(literal 1 binary64) n) Initial program 41.3%
lift--.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
flip3--N/A
lower-/.f64N/A
Applied rewrites38.2%
Taylor expanded in n around -inf
lower-*.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-log1p.f64N/A
lower-/.f64N/A
Applied rewrites20.4%
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-log1p.f64N/A
lift-/.f64N/A
lift-log.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-log.f64N/A
frac-subN/A
unpow2N/A
lower-/.f64N/A
Applied rewrites43.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow (log x) 3.0))
(t_1 (pow (* x x) -1.0))
(t_2 (/ (log x) (pow x 4.0)))
(t_3 (pow (log x) 2.0))
(t_4 (/ t_3 (pow x 4.0)))
(t_5 (/ (log x) (* x x)))
(t_6 (* (* x x) x))
(t_7 (/ (log x) t_6))
(t_8 (/ t_3 t_6))
(t_9 (pow t_6 -1.0))
(t_10 (/ (log x) x))
(t_11 (pow (pow x 4.0) -1.0))
(t_12 (/ t_3 (* x x))))
(if (<= (/ 1.0 n) -5e-30)
(/ (pow (exp -1.0) (/ (* -1.0 (log x)) n)) (* n x))
(if (<= (/ 1.0 n) 1e-98)
(-
(/ (fma (/ (pow (log1p x) 2.0) n) 0.5 (log1p x)) n)
(/ (fma (/ t_3 n) 0.5 (log x)) n))
(*
-1.0
(/
(fma
-1.0
(/
(-
(fma
-1.0
(/
(-
(fma
-1.0
(/
(fma
-0.25
t_2
(fma
-0.25
t_8
(fma
-0.08333333333333333
(/ t_0 (* x x))
(fma
-0.041666666666666664
(/ t_0 (pow x 4.0))
(fma
0.041666666666666664
t_11
(fma
0.05555555555555555
(pow t_10 3.0)
(+
(* 0.16666666666666666 t_7)
(fma
0.16666666666666666
(/ t_0 x)
(fma 0.22916666666666666 t_4 (* 0.25 t_12))))))))))
n)
(fma
-0.5
t_5
(fma
-0.5
(/ t_3 x)
(+
(* -0.4583333333333333 t_2)
(+
(* -0.16666666666666666 t_8)
(+
(* 0.125 t_4)
(fma 0.25 t_11 (fma 0.25 t_12 (* 0.5 t_7)))))))))
(* 0.16666666666666666 t_9))
n)
(fma
-0.5
t_5
(fma
-0.25
t_2
(fma
0.3333333333333333
t_7
(fma 0.4583333333333333 t_11 (fma 0.5 t_1 t_10))))))
(* 0.5 t_9))
n)
(+
(/ -1.0 x)
(-
(/ (fma 0.25 t_9 (* 0.5 (pow x -1.0))) x)
(/ (* 0.3333333333333333 t_1) x))))
n))))))
double code(double x, double n) {
double t_0 = pow(log(x), 3.0);
double t_1 = pow((x * x), -1.0);
double t_2 = log(x) / pow(x, 4.0);
double t_3 = pow(log(x), 2.0);
double t_4 = t_3 / pow(x, 4.0);
double t_5 = log(x) / (x * x);
double t_6 = (x * x) * x;
double t_7 = log(x) / t_6;
double t_8 = t_3 / t_6;
double t_9 = pow(t_6, -1.0);
double t_10 = log(x) / x;
double t_11 = pow(pow(x, 4.0), -1.0);
double t_12 = t_3 / (x * x);
double tmp;
if ((1.0 / n) <= -5e-30) {
tmp = pow(exp(-1.0), ((-1.0 * log(x)) / n)) / (n * x);
} else if ((1.0 / n) <= 1e-98) {
tmp = (fma((pow(log1p(x), 2.0) / n), 0.5, log1p(x)) / n) - (fma((t_3 / n), 0.5, log(x)) / n);
} else {
tmp = -1.0 * (fma(-1.0, ((fma(-1.0, ((fma(-1.0, (fma(-0.25, t_2, fma(-0.25, t_8, fma(-0.08333333333333333, (t_0 / (x * x)), fma(-0.041666666666666664, (t_0 / pow(x, 4.0)), fma(0.041666666666666664, t_11, fma(0.05555555555555555, pow(t_10, 3.0), ((0.16666666666666666 * t_7) + fma(0.16666666666666666, (t_0 / x), fma(0.22916666666666666, t_4, (0.25 * t_12)))))))))) / n), fma(-0.5, t_5, fma(-0.5, (t_3 / x), ((-0.4583333333333333 * t_2) + ((-0.16666666666666666 * t_8) + ((0.125 * t_4) + fma(0.25, t_11, fma(0.25, t_12, (0.5 * t_7))))))))) - (0.16666666666666666 * t_9)) / n), fma(-0.5, t_5, fma(-0.25, t_2, fma(0.3333333333333333, t_7, fma(0.4583333333333333, t_11, fma(0.5, t_1, t_10)))))) - (0.5 * t_9)) / n), ((-1.0 / x) + ((fma(0.25, t_9, (0.5 * pow(x, -1.0))) / x) - ((0.3333333333333333 * t_1) / x)))) / n);
}
return tmp;
}
function code(x, n) t_0 = log(x) ^ 3.0 t_1 = Float64(x * x) ^ -1.0 t_2 = Float64(log(x) / (x ^ 4.0)) t_3 = log(x) ^ 2.0 t_4 = Float64(t_3 / (x ^ 4.0)) t_5 = Float64(log(x) / Float64(x * x)) t_6 = Float64(Float64(x * x) * x) t_7 = Float64(log(x) / t_6) t_8 = Float64(t_3 / t_6) t_9 = t_6 ^ -1.0 t_10 = Float64(log(x) / x) t_11 = (x ^ 4.0) ^ -1.0 t_12 = Float64(t_3 / Float64(x * x)) tmp = 0.0 if (Float64(1.0 / n) <= -5e-30) tmp = Float64((exp(-1.0) ^ Float64(Float64(-1.0 * log(x)) / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 1e-98) tmp = Float64(Float64(fma(Float64((log1p(x) ^ 2.0) / n), 0.5, log1p(x)) / n) - Float64(fma(Float64(t_3 / n), 0.5, log(x)) / n)); else tmp = Float64(-1.0 * Float64(fma(-1.0, Float64(Float64(fma(-1.0, Float64(Float64(fma(-1.0, Float64(fma(-0.25, t_2, fma(-0.25, t_8, fma(-0.08333333333333333, Float64(t_0 / Float64(x * x)), fma(-0.041666666666666664, Float64(t_0 / (x ^ 4.0)), fma(0.041666666666666664, t_11, fma(0.05555555555555555, (t_10 ^ 3.0), Float64(Float64(0.16666666666666666 * t_7) + fma(0.16666666666666666, Float64(t_0 / x), fma(0.22916666666666666, t_4, Float64(0.25 * t_12)))))))))) / n), fma(-0.5, t_5, fma(-0.5, Float64(t_3 / x), Float64(Float64(-0.4583333333333333 * t_2) + Float64(Float64(-0.16666666666666666 * t_8) + Float64(Float64(0.125 * t_4) + fma(0.25, t_11, fma(0.25, t_12, Float64(0.5 * t_7))))))))) - Float64(0.16666666666666666 * t_9)) / n), fma(-0.5, t_5, fma(-0.25, t_2, fma(0.3333333333333333, t_7, fma(0.4583333333333333, t_11, fma(0.5, t_1, t_10)))))) - Float64(0.5 * t_9)) / n), Float64(Float64(-1.0 / x) + Float64(Float64(fma(0.25, t_9, Float64(0.5 * (x ^ -1.0))) / x) - Float64(Float64(0.3333333333333333 * t_1) / x)))) / n)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(x * x), $MachinePrecision], -1.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Log[x], $MachinePrecision] / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[Log[x], $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$7 = N[(N[Log[x], $MachinePrecision] / t$95$6), $MachinePrecision]}, Block[{t$95$8 = N[(t$95$3 / t$95$6), $MachinePrecision]}, Block[{t$95$9 = N[Power[t$95$6, -1.0], $MachinePrecision]}, Block[{t$95$10 = N[(N[Log[x], $MachinePrecision] / x), $MachinePrecision]}, Block[{t$95$11 = N[Power[N[Power[x, 4.0], $MachinePrecision], -1.0], $MachinePrecision]}, Block[{t$95$12 = N[(t$95$3 / N[(x * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-30], N[(N[Power[N[Exp[-1.0], $MachinePrecision], N[(N[(-1.0 * N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-98], N[(N[(N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / n), $MachinePrecision] * 0.5 + N[Log[1 + x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] - N[(N[(N[(t$95$3 / n), $MachinePrecision] * 0.5 + N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(N[(-1.0 * N[(N[(N[(-1.0 * N[(N[(N[(-1.0 * N[(N[(-0.25 * t$95$2 + N[(-0.25 * t$95$8 + N[(-0.08333333333333333 * N[(t$95$0 / N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(-0.041666666666666664 * N[(t$95$0 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(0.041666666666666664 * t$95$11 + N[(0.05555555555555555 * N[Power[t$95$10, 3.0], $MachinePrecision] + N[(N[(0.16666666666666666 * t$95$7), $MachinePrecision] + N[(0.16666666666666666 * N[(t$95$0 / x), $MachinePrecision] + N[(0.22916666666666666 * t$95$4 + N[(0.25 * t$95$12), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(-0.5 * t$95$5 + N[(-0.5 * N[(t$95$3 / x), $MachinePrecision] + N[(N[(-0.4583333333333333 * t$95$2), $MachinePrecision] + N[(N[(-0.16666666666666666 * t$95$8), $MachinePrecision] + N[(N[(0.125 * t$95$4), $MachinePrecision] + N[(0.25 * t$95$11 + N[(0.25 * t$95$12 + N[(0.5 * t$95$7), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.16666666666666666 * t$95$9), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(-0.5 * t$95$5 + N[(-0.25 * t$95$2 + N[(0.3333333333333333 * t$95$7 + N[(0.4583333333333333 * t$95$11 + N[(0.5 * t$95$1 + t$95$10), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 * t$95$9), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(N[(-1.0 / x), $MachinePrecision] + N[(N[(N[(0.25 * t$95$9 + N[(0.5 * N[Power[x, -1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - N[(N[(0.3333333333333333 * t$95$1), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\log x}^{3}\\
t_1 := {\left(x \cdot x\right)}^{-1}\\
t_2 := \frac{\log x}{{x}^{4}}\\
t_3 := {\log x}^{2}\\
t_4 := \frac{t\_3}{{x}^{4}}\\
t_5 := \frac{\log x}{x \cdot x}\\
t_6 := \left(x \cdot x\right) \cdot x\\
t_7 := \frac{\log x}{t\_6}\\
t_8 := \frac{t\_3}{t\_6}\\
t_9 := {t\_6}^{-1}\\
t_10 := \frac{\log x}{x}\\
t_11 := {\left({x}^{4}\right)}^{-1}\\
t_12 := \frac{t\_3}{x \cdot x}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-30}:\\
\;\;\;\;\frac{{\left(e^{-1}\right)}^{\left(\frac{-1 \cdot \log x}{n}\right)}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-98}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n}, 0.5, \mathsf{log1p}\left(x\right)\right)}{n} - \frac{\mathsf{fma}\left(\frac{t\_3}{n}, 0.5, \log x\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-0.25, t\_2, \mathsf{fma}\left(-0.25, t\_8, \mathsf{fma}\left(-0.08333333333333333, \frac{t\_0}{x \cdot x}, \mathsf{fma}\left(-0.041666666666666664, \frac{t\_0}{{x}^{4}}, \mathsf{fma}\left(0.041666666666666664, t\_11, \mathsf{fma}\left(0.05555555555555555, {t\_10}^{3}, 0.16666666666666666 \cdot t\_7 + \mathsf{fma}\left(0.16666666666666666, \frac{t\_0}{x}, \mathsf{fma}\left(0.22916666666666666, t\_4, 0.25 \cdot t\_12\right)\right)\right)\right)\right)\right)\right)\right)}{n}, \mathsf{fma}\left(-0.5, t\_5, \mathsf{fma}\left(-0.5, \frac{t\_3}{x}, -0.4583333333333333 \cdot t\_2 + \left(-0.16666666666666666 \cdot t\_8 + \left(0.125 \cdot t\_4 + \mathsf{fma}\left(0.25, t\_11, \mathsf{fma}\left(0.25, t\_12, 0.5 \cdot t\_7\right)\right)\right)\right)\right)\right)\right) - 0.16666666666666666 \cdot t\_9}{n}, \mathsf{fma}\left(-0.5, t\_5, \mathsf{fma}\left(-0.25, t\_2, \mathsf{fma}\left(0.3333333333333333, t\_7, \mathsf{fma}\left(0.4583333333333333, t\_11, \mathsf{fma}\left(0.5, t\_1, t\_10\right)\right)\right)\right)\right)\right) - 0.5 \cdot t\_9}{n}, \frac{-1}{x} + \left(\frac{\mathsf{fma}\left(0.25, t\_9, 0.5 \cdot {x}^{-1}\right)}{x} - \frac{0.3333333333333333 \cdot t\_1}{x}\right)\right)}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4.99999999999999972e-30Initial program 93.1%
Taylor expanded in x around inf
lower-/.f64N/A
exp-prodN/A
log-recN/A
mul-1-negN/A
lower-pow.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-*.f6495.6
Applied rewrites95.6%
if -4.99999999999999972e-30 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999939e-99Initial program 32.4%
Taylor expanded in n around inf
div-subN/A
lower--.f64N/A
Applied rewrites81.5%
if 9.99999999999999939e-99 < (/.f64 #s(literal 1 binary64) n) Initial program 39.0%
Taylor expanded in x around inf
Applied rewrites9.2%
Taylor expanded in n around -inf
Applied rewrites31.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (* 0.5 (pow x -1.0)))
(t_1 (* (* x x) x))
(t_2 (/ (log x) t_1))
(t_3 (pow (log x) 3.0))
(t_4 (/ (log x) (pow x 4.0)))
(t_5 (pow (pow x 4.0) -1.0))
(t_6 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
(t_7 (pow (* x x) -1.0))
(t_8 (* 0.3333333333333333 t_7))
(t_9 (pow (log x) 2.0))
(t_10 (/ t_9 (pow x 4.0)))
(t_11 (/ t_9 (* x x)))
(t_12 (/ (log x) (* x x)))
(t_13 (pow t_1 -1.0))
(t_14 (/ t_9 t_1))
(t_15 (/ (log x) x)))
(if (<= t_6 (- INFINITY))
(*
(/
(/
(+
(log x)
(fma
0.5
(/ (+ 1.0 (* -1.0 (log x))) x)
(fma
0.5
(/ (- (* 0.6666666666666666 (log x)) 1.0) (* x x))
(* n (- (+ 1.0 t_8) t_0)))))
x)
(* n (- n)))
-1.0)
(if (<= t_6 0.8227314594154127)
(-
(/ (fma (/ (pow (log1p x) 2.0) n) 0.5 (log1p x)) n)
(/ (fma (/ t_9 n) 0.5 (log x)) n))
(*
-1.0
(/
(fma
-1.0
(/
(-
(fma
-1.0
(/
(-
(fma
-1.0
(/
(fma
-0.25
t_4
(fma
-0.25
t_14
(fma
-0.08333333333333333
(/ t_3 (* x x))
(fma
-0.041666666666666664
(/ t_3 (pow x 4.0))
(fma
0.041666666666666664
t_5
(fma
0.05555555555555555
(pow t_15 3.0)
(+
(* 0.16666666666666666 t_2)
(fma
0.16666666666666666
(/ t_3 x)
(fma 0.22916666666666666 t_10 (* 0.25 t_11))))))))))
n)
(fma
-0.5
t_12
(fma
-0.5
(/ t_9 x)
(+
(* -0.4583333333333333 t_4)
(+
(* -0.16666666666666666 t_14)
(+
(* 0.125 t_10)
(fma 0.25 t_5 (fma 0.25 t_11 (* 0.5 t_2)))))))))
(* 0.16666666666666666 t_13))
n)
(fma
-0.5
t_12
(fma
-0.25
t_4
(fma
0.3333333333333333
t_2
(fma 0.4583333333333333 t_5 (fma 0.5 t_7 t_15))))))
(* 0.5 t_13))
n)
(+ (/ -1.0 x) (- (/ (fma 0.25 t_13 t_0) x) (/ t_8 x))))
n))))))
double code(double x, double n) {
double t_0 = 0.5 * pow(x, -1.0);
double t_1 = (x * x) * x;
double t_2 = log(x) / t_1;
double t_3 = pow(log(x), 3.0);
double t_4 = log(x) / pow(x, 4.0);
double t_5 = pow(pow(x, 4.0), -1.0);
double t_6 = pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
double t_7 = pow((x * x), -1.0);
double t_8 = 0.3333333333333333 * t_7;
double t_9 = pow(log(x), 2.0);
double t_10 = t_9 / pow(x, 4.0);
double t_11 = t_9 / (x * x);
double t_12 = log(x) / (x * x);
double t_13 = pow(t_1, -1.0);
double t_14 = t_9 / t_1;
double t_15 = log(x) / x;
double tmp;
if (t_6 <= -((double) INFINITY)) {
tmp = (((log(x) + fma(0.5, ((1.0 + (-1.0 * log(x))) / x), fma(0.5, (((0.6666666666666666 * log(x)) - 1.0) / (x * x)), (n * ((1.0 + t_8) - t_0))))) / x) / (n * -n)) * -1.0;
} else if (t_6 <= 0.8227314594154127) {
tmp = (fma((pow(log1p(x), 2.0) / n), 0.5, log1p(x)) / n) - (fma((t_9 / n), 0.5, log(x)) / n);
} else {
tmp = -1.0 * (fma(-1.0, ((fma(-1.0, ((fma(-1.0, (fma(-0.25, t_4, fma(-0.25, t_14, fma(-0.08333333333333333, (t_3 / (x * x)), fma(-0.041666666666666664, (t_3 / pow(x, 4.0)), fma(0.041666666666666664, t_5, fma(0.05555555555555555, pow(t_15, 3.0), ((0.16666666666666666 * t_2) + fma(0.16666666666666666, (t_3 / x), fma(0.22916666666666666, t_10, (0.25 * t_11)))))))))) / n), fma(-0.5, t_12, fma(-0.5, (t_9 / x), ((-0.4583333333333333 * t_4) + ((-0.16666666666666666 * t_14) + ((0.125 * t_10) + fma(0.25, t_5, fma(0.25, t_11, (0.5 * t_2))))))))) - (0.16666666666666666 * t_13)) / n), fma(-0.5, t_12, fma(-0.25, t_4, fma(0.3333333333333333, t_2, fma(0.4583333333333333, t_5, fma(0.5, t_7, t_15)))))) - (0.5 * t_13)) / n), ((-1.0 / x) + ((fma(0.25, t_13, t_0) / x) - (t_8 / x)))) / n);
}
return tmp;
}
function code(x, n) t_0 = Float64(0.5 * (x ^ -1.0)) t_1 = Float64(Float64(x * x) * x) t_2 = Float64(log(x) / t_1) t_3 = log(x) ^ 3.0 t_4 = Float64(log(x) / (x ^ 4.0)) t_5 = (x ^ 4.0) ^ -1.0 t_6 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) t_7 = Float64(x * x) ^ -1.0 t_8 = Float64(0.3333333333333333 * t_7) t_9 = log(x) ^ 2.0 t_10 = Float64(t_9 / (x ^ 4.0)) t_11 = Float64(t_9 / Float64(x * x)) t_12 = Float64(log(x) / Float64(x * x)) t_13 = t_1 ^ -1.0 t_14 = Float64(t_9 / t_1) t_15 = Float64(log(x) / x) tmp = 0.0 if (t_6 <= Float64(-Inf)) tmp = Float64(Float64(Float64(Float64(log(x) + fma(0.5, Float64(Float64(1.0 + Float64(-1.0 * log(x))) / x), fma(0.5, Float64(Float64(Float64(0.6666666666666666 * log(x)) - 1.0) / Float64(x * x)), Float64(n * Float64(Float64(1.0 + t_8) - t_0))))) / x) / Float64(n * Float64(-n))) * -1.0); elseif (t_6 <= 0.8227314594154127) tmp = Float64(Float64(fma(Float64((log1p(x) ^ 2.0) / n), 0.5, log1p(x)) / n) - Float64(fma(Float64(t_9 / n), 0.5, log(x)) / n)); else tmp = Float64(-1.0 * Float64(fma(-1.0, Float64(Float64(fma(-1.0, Float64(Float64(fma(-1.0, Float64(fma(-0.25, t_4, fma(-0.25, t_14, fma(-0.08333333333333333, Float64(t_3 / Float64(x * x)), fma(-0.041666666666666664, Float64(t_3 / (x ^ 4.0)), fma(0.041666666666666664, t_5, fma(0.05555555555555555, (t_15 ^ 3.0), Float64(Float64(0.16666666666666666 * t_2) + fma(0.16666666666666666, Float64(t_3 / x), fma(0.22916666666666666, t_10, Float64(0.25 * t_11)))))))))) / n), fma(-0.5, t_12, fma(-0.5, Float64(t_9 / x), Float64(Float64(-0.4583333333333333 * t_4) + Float64(Float64(-0.16666666666666666 * t_14) + Float64(Float64(0.125 * t_10) + fma(0.25, t_5, fma(0.25, t_11, Float64(0.5 * t_2))))))))) - Float64(0.16666666666666666 * t_13)) / n), fma(-0.5, t_12, fma(-0.25, t_4, fma(0.3333333333333333, t_2, fma(0.4583333333333333, t_5, fma(0.5, t_7, t_15)))))) - Float64(0.5 * t_13)) / n), Float64(Float64(-1.0 / x) + Float64(Float64(fma(0.25, t_13, t_0) / x) - Float64(t_8 / x)))) / n)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(0.5 * N[Power[x, -1.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$2 = N[(N[Log[x], $MachinePrecision] / t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]}, Block[{t$95$4 = N[(N[Log[x], $MachinePrecision] / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Power[N[Power[x, 4.0], $MachinePrecision], -1.0], $MachinePrecision]}, Block[{t$95$6 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$7 = N[Power[N[(x * x), $MachinePrecision], -1.0], $MachinePrecision]}, Block[{t$95$8 = N[(0.3333333333333333 * t$95$7), $MachinePrecision]}, Block[{t$95$9 = N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$10 = N[(t$95$9 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$11 = N[(t$95$9 / N[(x * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$12 = N[(N[Log[x], $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$13 = N[Power[t$95$1, -1.0], $MachinePrecision]}, Block[{t$95$14 = N[(t$95$9 / t$95$1), $MachinePrecision]}, Block[{t$95$15 = N[(N[Log[x], $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[t$95$6, (-Infinity)], N[(N[(N[(N[(N[Log[x], $MachinePrecision] + N[(0.5 * N[(N[(1.0 + N[(-1.0 * N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(0.5 * N[(N[(N[(0.6666666666666666 * N[Log[x], $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(n * N[(N[(1.0 + t$95$8), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / N[(n * (-n)), $MachinePrecision]), $MachinePrecision] * -1.0), $MachinePrecision], If[LessEqual[t$95$6, 0.8227314594154127], N[(N[(N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / n), $MachinePrecision] * 0.5 + N[Log[1 + x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] - N[(N[(N[(t$95$9 / n), $MachinePrecision] * 0.5 + N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(N[(-1.0 * N[(N[(N[(-1.0 * N[(N[(N[(-1.0 * N[(N[(-0.25 * t$95$4 + N[(-0.25 * t$95$14 + N[(-0.08333333333333333 * N[(t$95$3 / N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(-0.041666666666666664 * N[(t$95$3 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(0.041666666666666664 * t$95$5 + N[(0.05555555555555555 * N[Power[t$95$15, 3.0], $MachinePrecision] + N[(N[(0.16666666666666666 * t$95$2), $MachinePrecision] + N[(0.16666666666666666 * N[(t$95$3 / x), $MachinePrecision] + N[(0.22916666666666666 * t$95$10 + N[(0.25 * t$95$11), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(-0.5 * t$95$12 + N[(-0.5 * N[(t$95$9 / x), $MachinePrecision] + N[(N[(-0.4583333333333333 * t$95$4), $MachinePrecision] + N[(N[(-0.16666666666666666 * t$95$14), $MachinePrecision] + N[(N[(0.125 * t$95$10), $MachinePrecision] + N[(0.25 * t$95$5 + N[(0.25 * t$95$11 + N[(0.5 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.16666666666666666 * t$95$13), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(-0.5 * t$95$12 + N[(-0.25 * t$95$4 + N[(0.3333333333333333 * t$95$2 + N[(0.4583333333333333 * t$95$5 + N[(0.5 * t$95$7 + t$95$15), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 * t$95$13), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(N[(-1.0 / x), $MachinePrecision] + N[(N[(N[(0.25 * t$95$13 + t$95$0), $MachinePrecision] / x), $MachinePrecision] - N[(t$95$8 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot {x}^{-1}\\
t_1 := \left(x \cdot x\right) \cdot x\\
t_2 := \frac{\log x}{t\_1}\\
t_3 := {\log x}^{3}\\
t_4 := \frac{\log x}{{x}^{4}}\\
t_5 := {\left({x}^{4}\right)}^{-1}\\
t_6 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\
t_7 := {\left(x \cdot x\right)}^{-1}\\
t_8 := 0.3333333333333333 \cdot t\_7\\
t_9 := {\log x}^{2}\\
t_10 := \frac{t\_9}{{x}^{4}}\\
t_11 := \frac{t\_9}{x \cdot x}\\
t_12 := \frac{\log x}{x \cdot x}\\
t_13 := {t\_1}^{-1}\\
t_14 := \frac{t\_9}{t\_1}\\
t_15 := \frac{\log x}{x}\\
\mathbf{if}\;t\_6 \leq -\infty:\\
\;\;\;\;\frac{\frac{\log x + \mathsf{fma}\left(0.5, \frac{1 + -1 \cdot \log x}{x}, \mathsf{fma}\left(0.5, \frac{0.6666666666666666 \cdot \log x - 1}{x \cdot x}, n \cdot \left(\left(1 + t\_8\right) - t\_0\right)\right)\right)}{x}}{n \cdot \left(-n\right)} \cdot -1\\
\mathbf{elif}\;t\_6 \leq 0.8227314594154127:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n}, 0.5, \mathsf{log1p}\left(x\right)\right)}{n} - \frac{\mathsf{fma}\left(\frac{t\_9}{n}, 0.5, \log x\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-0.25, t\_4, \mathsf{fma}\left(-0.25, t\_14, \mathsf{fma}\left(-0.08333333333333333, \frac{t\_3}{x \cdot x}, \mathsf{fma}\left(-0.041666666666666664, \frac{t\_3}{{x}^{4}}, \mathsf{fma}\left(0.041666666666666664, t\_5, \mathsf{fma}\left(0.05555555555555555, {t\_15}^{3}, 0.16666666666666666 \cdot t\_2 + \mathsf{fma}\left(0.16666666666666666, \frac{t\_3}{x}, \mathsf{fma}\left(0.22916666666666666, t\_10, 0.25 \cdot t\_11\right)\right)\right)\right)\right)\right)\right)\right)}{n}, \mathsf{fma}\left(-0.5, t\_12, \mathsf{fma}\left(-0.5, \frac{t\_9}{x}, -0.4583333333333333 \cdot t\_4 + \left(-0.16666666666666666 \cdot t\_14 + \left(0.125 \cdot t\_10 + \mathsf{fma}\left(0.25, t\_5, \mathsf{fma}\left(0.25, t\_11, 0.5 \cdot t\_2\right)\right)\right)\right)\right)\right)\right) - 0.16666666666666666 \cdot t\_13}{n}, \mathsf{fma}\left(-0.5, t\_12, \mathsf{fma}\left(-0.25, t\_4, \mathsf{fma}\left(0.3333333333333333, t\_2, \mathsf{fma}\left(0.4583333333333333, t\_5, \mathsf{fma}\left(0.5, t\_7, t\_15\right)\right)\right)\right)\right)\right) - 0.5 \cdot t\_13}{n}, \frac{-1}{x} + \left(\frac{\mathsf{fma}\left(0.25, t\_13, t\_0\right)}{x} - \frac{t\_8}{x}\right)\right)}{n}\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < -inf.0Initial program 100.0%
Taylor expanded in n around -inf
Applied rewrites52.7%
Taylor expanded in x around inf
Applied rewrites91.4%
Taylor expanded in n around 0
lower-+.f64N/A
lift-log.f64N/A
lower-fma.f64N/A
Applied rewrites91.7%
if -inf.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < 0.8227314594154127Initial program 44.0%
Taylor expanded in n around inf
div-subN/A
lower--.f64N/A
Applied rewrites70.7%
if 0.8227314594154127 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) Initial program 52.2%
Taylor expanded in x around inf
Applied rewrites0.5%
Taylor expanded in n around -inf
Applied rewrites21.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow (log x) 3.0))
(t_1 (* n (- n)))
(t_2 (pow (log x) 2.0))
(t_3 (* (* x x) x))
(t_4 (/ (log x) t_3))
(t_5 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
(t_6 (pow (* x x) -1.0))
(t_7 (* 0.3333333333333333 t_6))
(t_8 (* 0.5 (pow x -1.0)))
(t_9 (/ t_2 (pow x 4.0)))
(t_10 (/ (log x) (pow x 4.0)))
(t_11 (pow (pow x 4.0) -1.0))
(t_12 (/ t_2 (* x x)))
(t_13 (/ (log x) (* x x)))
(t_14 (pow t_3 -1.0))
(t_15 (/ t_2 t_3))
(t_16 (/ (log x) x)))
(if (<= t_5 (- INFINITY))
(*
(/
(/
(+
(log x)
(fma
0.5
(/ (+ 1.0 (* -1.0 (log x))) x)
(fma
0.5
(/ (- (* 0.6666666666666666 (log x)) 1.0) (* x x))
(* n (- (+ 1.0 t_7) t_8)))))
x)
t_1)
-1.0)
(if (<= t_5 0.8227314594154127)
(*
(/
(-
(*
(fma
(- (* (/ (pow (log1p x) 2.0) n) 0.5) (* (/ t_2 n) 0.5))
-1.0
(* (log1p x) -1.0))
(- n))
(* n (log x)))
t_1)
-1.0)
(*
-1.0
(/
(fma
-1.0
(/
(-
(fma
-1.0
(/
(-
(fma
-1.0
(/
(fma
-0.25
t_10
(fma
-0.25
t_15
(fma
-0.08333333333333333
(/ t_0 (* x x))
(fma
-0.041666666666666664
(/ t_0 (pow x 4.0))
(fma
0.041666666666666664
t_11
(fma
0.05555555555555555
(pow t_16 3.0)
(+
(* 0.16666666666666666 t_4)
(fma
0.16666666666666666
(/ t_0 x)
(fma 0.22916666666666666 t_9 (* 0.25 t_12))))))))))
n)
(fma
-0.5
t_13
(fma
-0.5
(/ t_2 x)
(+
(* -0.4583333333333333 t_10)
(+
(* -0.16666666666666666 t_15)
(+
(* 0.125 t_9)
(fma 0.25 t_11 (fma 0.25 t_12 (* 0.5 t_4)))))))))
(* 0.16666666666666666 t_14))
n)
(fma
-0.5
t_13
(fma
-0.25
t_10
(fma
0.3333333333333333
t_4
(fma 0.4583333333333333 t_11 (fma 0.5 t_6 t_16))))))
(* 0.5 t_14))
n)
(+ (/ -1.0 x) (- (/ (fma 0.25 t_14 t_8) x) (/ t_7 x))))
n))))))
double code(double x, double n) {
double t_0 = pow(log(x), 3.0);
double t_1 = n * -n;
double t_2 = pow(log(x), 2.0);
double t_3 = (x * x) * x;
double t_4 = log(x) / t_3;
double t_5 = pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
double t_6 = pow((x * x), -1.0);
double t_7 = 0.3333333333333333 * t_6;
double t_8 = 0.5 * pow(x, -1.0);
double t_9 = t_2 / pow(x, 4.0);
double t_10 = log(x) / pow(x, 4.0);
double t_11 = pow(pow(x, 4.0), -1.0);
double t_12 = t_2 / (x * x);
double t_13 = log(x) / (x * x);
double t_14 = pow(t_3, -1.0);
double t_15 = t_2 / t_3;
double t_16 = log(x) / x;
double tmp;
if (t_5 <= -((double) INFINITY)) {
tmp = (((log(x) + fma(0.5, ((1.0 + (-1.0 * log(x))) / x), fma(0.5, (((0.6666666666666666 * log(x)) - 1.0) / (x * x)), (n * ((1.0 + t_7) - t_8))))) / x) / t_1) * -1.0;
} else if (t_5 <= 0.8227314594154127) {
tmp = (((fma((((pow(log1p(x), 2.0) / n) * 0.5) - ((t_2 / n) * 0.5)), -1.0, (log1p(x) * -1.0)) * -n) - (n * log(x))) / t_1) * -1.0;
} else {
tmp = -1.0 * (fma(-1.0, ((fma(-1.0, ((fma(-1.0, (fma(-0.25, t_10, fma(-0.25, t_15, fma(-0.08333333333333333, (t_0 / (x * x)), fma(-0.041666666666666664, (t_0 / pow(x, 4.0)), fma(0.041666666666666664, t_11, fma(0.05555555555555555, pow(t_16, 3.0), ((0.16666666666666666 * t_4) + fma(0.16666666666666666, (t_0 / x), fma(0.22916666666666666, t_9, (0.25 * t_12)))))))))) / n), fma(-0.5, t_13, fma(-0.5, (t_2 / x), ((-0.4583333333333333 * t_10) + ((-0.16666666666666666 * t_15) + ((0.125 * t_9) + fma(0.25, t_11, fma(0.25, t_12, (0.5 * t_4))))))))) - (0.16666666666666666 * t_14)) / n), fma(-0.5, t_13, fma(-0.25, t_10, fma(0.3333333333333333, t_4, fma(0.4583333333333333, t_11, fma(0.5, t_6, t_16)))))) - (0.5 * t_14)) / n), ((-1.0 / x) + ((fma(0.25, t_14, t_8) / x) - (t_7 / x)))) / n);
}
return tmp;
}
function code(x, n) t_0 = log(x) ^ 3.0 t_1 = Float64(n * Float64(-n)) t_2 = log(x) ^ 2.0 t_3 = Float64(Float64(x * x) * x) t_4 = Float64(log(x) / t_3) t_5 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) t_6 = Float64(x * x) ^ -1.0 t_7 = Float64(0.3333333333333333 * t_6) t_8 = Float64(0.5 * (x ^ -1.0)) t_9 = Float64(t_2 / (x ^ 4.0)) t_10 = Float64(log(x) / (x ^ 4.0)) t_11 = (x ^ 4.0) ^ -1.0 t_12 = Float64(t_2 / Float64(x * x)) t_13 = Float64(log(x) / Float64(x * x)) t_14 = t_3 ^ -1.0 t_15 = Float64(t_2 / t_3) t_16 = Float64(log(x) / x) tmp = 0.0 if (t_5 <= Float64(-Inf)) tmp = Float64(Float64(Float64(Float64(log(x) + fma(0.5, Float64(Float64(1.0 + Float64(-1.0 * log(x))) / x), fma(0.5, Float64(Float64(Float64(0.6666666666666666 * log(x)) - 1.0) / Float64(x * x)), Float64(n * Float64(Float64(1.0 + t_7) - t_8))))) / x) / t_1) * -1.0); elseif (t_5 <= 0.8227314594154127) tmp = Float64(Float64(Float64(Float64(fma(Float64(Float64(Float64((log1p(x) ^ 2.0) / n) * 0.5) - Float64(Float64(t_2 / n) * 0.5)), -1.0, Float64(log1p(x) * -1.0)) * Float64(-n)) - Float64(n * log(x))) / t_1) * -1.0); else tmp = Float64(-1.0 * Float64(fma(-1.0, Float64(Float64(fma(-1.0, Float64(Float64(fma(-1.0, Float64(fma(-0.25, t_10, fma(-0.25, t_15, fma(-0.08333333333333333, Float64(t_0 / Float64(x * x)), fma(-0.041666666666666664, Float64(t_0 / (x ^ 4.0)), fma(0.041666666666666664, t_11, fma(0.05555555555555555, (t_16 ^ 3.0), Float64(Float64(0.16666666666666666 * t_4) + fma(0.16666666666666666, Float64(t_0 / x), fma(0.22916666666666666, t_9, Float64(0.25 * t_12)))))))))) / n), fma(-0.5, t_13, fma(-0.5, Float64(t_2 / x), Float64(Float64(-0.4583333333333333 * t_10) + Float64(Float64(-0.16666666666666666 * t_15) + Float64(Float64(0.125 * t_9) + fma(0.25, t_11, fma(0.25, t_12, Float64(0.5 * t_4))))))))) - Float64(0.16666666666666666 * t_14)) / n), fma(-0.5, t_13, fma(-0.25, t_10, fma(0.3333333333333333, t_4, fma(0.4583333333333333, t_11, fma(0.5, t_6, t_16)))))) - Float64(0.5 * t_14)) / n), Float64(Float64(-1.0 / x) + Float64(Float64(fma(0.25, t_14, t_8) / x) - Float64(t_7 / x)))) / n)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]}, Block[{t$95$1 = N[(n * (-n)), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$4 = N[(N[Log[x], $MachinePrecision] / t$95$3), $MachinePrecision]}, Block[{t$95$5 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[Power[N[(x * x), $MachinePrecision], -1.0], $MachinePrecision]}, Block[{t$95$7 = N[(0.3333333333333333 * t$95$6), $MachinePrecision]}, Block[{t$95$8 = N[(0.5 * N[Power[x, -1.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$9 = N[(t$95$2 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$10 = N[(N[Log[x], $MachinePrecision] / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$11 = N[Power[N[Power[x, 4.0], $MachinePrecision], -1.0], $MachinePrecision]}, Block[{t$95$12 = N[(t$95$2 / N[(x * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$13 = N[(N[Log[x], $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$14 = N[Power[t$95$3, -1.0], $MachinePrecision]}, Block[{t$95$15 = N[(t$95$2 / t$95$3), $MachinePrecision]}, Block[{t$95$16 = N[(N[Log[x], $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[t$95$5, (-Infinity)], N[(N[(N[(N[(N[Log[x], $MachinePrecision] + N[(0.5 * N[(N[(1.0 + N[(-1.0 * N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(0.5 * N[(N[(N[(0.6666666666666666 * N[Log[x], $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(n * N[(N[(1.0 + t$95$7), $MachinePrecision] - t$95$8), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / t$95$1), $MachinePrecision] * -1.0), $MachinePrecision], If[LessEqual[t$95$5, 0.8227314594154127], N[(N[(N[(N[(N[(N[(N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / n), $MachinePrecision] * 0.5), $MachinePrecision] - N[(N[(t$95$2 / n), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] * -1.0 + N[(N[Log[1 + x], $MachinePrecision] * -1.0), $MachinePrecision]), $MachinePrecision] * (-n)), $MachinePrecision] - N[(n * N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision] * -1.0), $MachinePrecision], N[(-1.0 * N[(N[(-1.0 * N[(N[(N[(-1.0 * N[(N[(N[(-1.0 * N[(N[(-0.25 * t$95$10 + N[(-0.25 * t$95$15 + N[(-0.08333333333333333 * N[(t$95$0 / N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(-0.041666666666666664 * N[(t$95$0 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(0.041666666666666664 * t$95$11 + N[(0.05555555555555555 * N[Power[t$95$16, 3.0], $MachinePrecision] + N[(N[(0.16666666666666666 * t$95$4), $MachinePrecision] + N[(0.16666666666666666 * N[(t$95$0 / x), $MachinePrecision] + N[(0.22916666666666666 * t$95$9 + N[(0.25 * t$95$12), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(-0.5 * t$95$13 + N[(-0.5 * N[(t$95$2 / x), $MachinePrecision] + N[(N[(-0.4583333333333333 * t$95$10), $MachinePrecision] + N[(N[(-0.16666666666666666 * t$95$15), $MachinePrecision] + N[(N[(0.125 * t$95$9), $MachinePrecision] + N[(0.25 * t$95$11 + N[(0.25 * t$95$12 + N[(0.5 * t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.16666666666666666 * t$95$14), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(-0.5 * t$95$13 + N[(-0.25 * t$95$10 + N[(0.3333333333333333 * t$95$4 + N[(0.4583333333333333 * t$95$11 + N[(0.5 * t$95$6 + t$95$16), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 * t$95$14), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(N[(-1.0 / x), $MachinePrecision] + N[(N[(N[(0.25 * t$95$14 + t$95$8), $MachinePrecision] / x), $MachinePrecision] - N[(t$95$7 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\log x}^{3}\\
t_1 := n \cdot \left(-n\right)\\
t_2 := {\log x}^{2}\\
t_3 := \left(x \cdot x\right) \cdot x\\
t_4 := \frac{\log x}{t\_3}\\
t_5 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\
t_6 := {\left(x \cdot x\right)}^{-1}\\
t_7 := 0.3333333333333333 \cdot t\_6\\
t_8 := 0.5 \cdot {x}^{-1}\\
t_9 := \frac{t\_2}{{x}^{4}}\\
t_10 := \frac{\log x}{{x}^{4}}\\
t_11 := {\left({x}^{4}\right)}^{-1}\\
t_12 := \frac{t\_2}{x \cdot x}\\
t_13 := \frac{\log x}{x \cdot x}\\
t_14 := {t\_3}^{-1}\\
t_15 := \frac{t\_2}{t\_3}\\
t_16 := \frac{\log x}{x}\\
\mathbf{if}\;t\_5 \leq -\infty:\\
\;\;\;\;\frac{\frac{\log x + \mathsf{fma}\left(0.5, \frac{1 + -1 \cdot \log x}{x}, \mathsf{fma}\left(0.5, \frac{0.6666666666666666 \cdot \log x - 1}{x \cdot x}, n \cdot \left(\left(1 + t\_7\right) - t\_8\right)\right)\right)}{x}}{t\_1} \cdot -1\\
\mathbf{elif}\;t\_5 \leq 0.8227314594154127:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n} \cdot 0.5 - \frac{t\_2}{n} \cdot 0.5, -1, \mathsf{log1p}\left(x\right) \cdot -1\right) \cdot \left(-n\right) - n \cdot \log x}{t\_1} \cdot -1\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-0.25, t\_10, \mathsf{fma}\left(-0.25, t\_15, \mathsf{fma}\left(-0.08333333333333333, \frac{t\_0}{x \cdot x}, \mathsf{fma}\left(-0.041666666666666664, \frac{t\_0}{{x}^{4}}, \mathsf{fma}\left(0.041666666666666664, t\_11, \mathsf{fma}\left(0.05555555555555555, {t\_16}^{3}, 0.16666666666666666 \cdot t\_4 + \mathsf{fma}\left(0.16666666666666666, \frac{t\_0}{x}, \mathsf{fma}\left(0.22916666666666666, t\_9, 0.25 \cdot t\_12\right)\right)\right)\right)\right)\right)\right)\right)}{n}, \mathsf{fma}\left(-0.5, t\_13, \mathsf{fma}\left(-0.5, \frac{t\_2}{x}, -0.4583333333333333 \cdot t\_10 + \left(-0.16666666666666666 \cdot t\_15 + \left(0.125 \cdot t\_9 + \mathsf{fma}\left(0.25, t\_11, \mathsf{fma}\left(0.25, t\_12, 0.5 \cdot t\_4\right)\right)\right)\right)\right)\right)\right) - 0.16666666666666666 \cdot t\_14}{n}, \mathsf{fma}\left(-0.5, t\_13, \mathsf{fma}\left(-0.25, t\_10, \mathsf{fma}\left(0.3333333333333333, t\_4, \mathsf{fma}\left(0.4583333333333333, t\_11, \mathsf{fma}\left(0.5, t\_6, t\_16\right)\right)\right)\right)\right)\right) - 0.5 \cdot t\_14}{n}, \frac{-1}{x} + \left(\frac{\mathsf{fma}\left(0.25, t\_14, t\_8\right)}{x} - \frac{t\_7}{x}\right)\right)}{n}\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < -inf.0Initial program 100.0%
Taylor expanded in n around -inf
Applied rewrites52.7%
Taylor expanded in x around inf
Applied rewrites91.4%
Taylor expanded in n around 0
lower-+.f64N/A
lift-log.f64N/A
lower-fma.f64N/A
Applied rewrites91.7%
if -inf.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < 0.8227314594154127Initial program 44.0%
Taylor expanded in n around -inf
Applied rewrites52.1%
if 0.8227314594154127 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) Initial program 52.2%
Taylor expanded in x around inf
Applied rewrites0.5%
Taylor expanded in n around -inf
Applied rewrites21.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) x))
(t_1 (* (* x x) x))
(t_2 (/ (log x) t_1))
(t_3 (pow (log x) 3.0))
(t_4 (* 0.5 (pow x -1.0)))
(t_5 (/ (log x) (pow x 4.0)))
(t_6 (pow (pow x 4.0) -1.0))
(t_7 (pow (log x) 2.0))
(t_8 (/ t_7 t_1))
(t_9 (/ t_7 (* x x)))
(t_10 (/ (log x) (* x x)))
(t_11 (pow t_1 -1.0))
(t_12 (pow (* x x) -1.0))
(t_13 (* 0.3333333333333333 t_12))
(t_14 (/ t_7 (pow x 4.0))))
(if (<= (/ 1.0 n) -2e-143)
(*
(/
(/
(+
(log x)
(fma
0.5
(/ (+ 1.0 (* -1.0 (log x))) x)
(fma
0.5
(/ (- (* 0.6666666666666666 (log x)) 1.0) (* x x))
(* n (- (+ 1.0 t_13) t_4)))))
x)
(* n (- n)))
-1.0)
(*
-1.0
(/
(fma
-1.0
(/
(-
(fma
-1.0
(/
(-
(fma
-1.0
(/
(fma
-0.25
t_5
(fma
-0.25
t_8
(fma
-0.08333333333333333
(/ t_3 (* x x))
(fma
-0.041666666666666664
(/ t_3 (pow x 4.0))
(fma
0.041666666666666664
t_6
(fma
0.05555555555555555
(pow t_0 3.0)
(+
(* 0.16666666666666666 t_2)
(fma
0.16666666666666666
(/ t_3 x)
(fma 0.22916666666666666 t_14 (* 0.25 t_9))))))))))
n)
(fma
-0.5
t_10
(fma
-0.5
(/ t_7 x)
(+
(* -0.4583333333333333 t_5)
(+
(* -0.16666666666666666 t_8)
(+
(* 0.125 t_14)
(fma 0.25 t_6 (fma 0.25 t_9 (* 0.5 t_2)))))))))
(* 0.16666666666666666 t_11))
n)
(fma
-0.5
t_10
(fma
-0.25
t_5
(fma
0.3333333333333333
t_2
(fma 0.4583333333333333 t_6 (fma 0.5 t_12 t_0))))))
(* 0.5 t_11))
n)
(+ (/ -1.0 x) (- (/ (fma 0.25 t_11 t_4) x) (/ t_13 x))))
n)))))
double code(double x, double n) {
double t_0 = log(x) / x;
double t_1 = (x * x) * x;
double t_2 = log(x) / t_1;
double t_3 = pow(log(x), 3.0);
double t_4 = 0.5 * pow(x, -1.0);
double t_5 = log(x) / pow(x, 4.0);
double t_6 = pow(pow(x, 4.0), -1.0);
double t_7 = pow(log(x), 2.0);
double t_8 = t_7 / t_1;
double t_9 = t_7 / (x * x);
double t_10 = log(x) / (x * x);
double t_11 = pow(t_1, -1.0);
double t_12 = pow((x * x), -1.0);
double t_13 = 0.3333333333333333 * t_12;
double t_14 = t_7 / pow(x, 4.0);
double tmp;
if ((1.0 / n) <= -2e-143) {
tmp = (((log(x) + fma(0.5, ((1.0 + (-1.0 * log(x))) / x), fma(0.5, (((0.6666666666666666 * log(x)) - 1.0) / (x * x)), (n * ((1.0 + t_13) - t_4))))) / x) / (n * -n)) * -1.0;
} else {
tmp = -1.0 * (fma(-1.0, ((fma(-1.0, ((fma(-1.0, (fma(-0.25, t_5, fma(-0.25, t_8, fma(-0.08333333333333333, (t_3 / (x * x)), fma(-0.041666666666666664, (t_3 / pow(x, 4.0)), fma(0.041666666666666664, t_6, fma(0.05555555555555555, pow(t_0, 3.0), ((0.16666666666666666 * t_2) + fma(0.16666666666666666, (t_3 / x), fma(0.22916666666666666, t_14, (0.25 * t_9)))))))))) / n), fma(-0.5, t_10, fma(-0.5, (t_7 / x), ((-0.4583333333333333 * t_5) + ((-0.16666666666666666 * t_8) + ((0.125 * t_14) + fma(0.25, t_6, fma(0.25, t_9, (0.5 * t_2))))))))) - (0.16666666666666666 * t_11)) / n), fma(-0.5, t_10, fma(-0.25, t_5, fma(0.3333333333333333, t_2, fma(0.4583333333333333, t_6, fma(0.5, t_12, t_0)))))) - (0.5 * t_11)) / n), ((-1.0 / x) + ((fma(0.25, t_11, t_4) / x) - (t_13 / x)))) / n);
}
return tmp;
}
function code(x, n) t_0 = Float64(log(x) / x) t_1 = Float64(Float64(x * x) * x) t_2 = Float64(log(x) / t_1) t_3 = log(x) ^ 3.0 t_4 = Float64(0.5 * (x ^ -1.0)) t_5 = Float64(log(x) / (x ^ 4.0)) t_6 = (x ^ 4.0) ^ -1.0 t_7 = log(x) ^ 2.0 t_8 = Float64(t_7 / t_1) t_9 = Float64(t_7 / Float64(x * x)) t_10 = Float64(log(x) / Float64(x * x)) t_11 = t_1 ^ -1.0 t_12 = Float64(x * x) ^ -1.0 t_13 = Float64(0.3333333333333333 * t_12) t_14 = Float64(t_7 / (x ^ 4.0)) tmp = 0.0 if (Float64(1.0 / n) <= -2e-143) tmp = Float64(Float64(Float64(Float64(log(x) + fma(0.5, Float64(Float64(1.0 + Float64(-1.0 * log(x))) / x), fma(0.5, Float64(Float64(Float64(0.6666666666666666 * log(x)) - 1.0) / Float64(x * x)), Float64(n * Float64(Float64(1.0 + t_13) - t_4))))) / x) / Float64(n * Float64(-n))) * -1.0); else tmp = Float64(-1.0 * Float64(fma(-1.0, Float64(Float64(fma(-1.0, Float64(Float64(fma(-1.0, Float64(fma(-0.25, t_5, fma(-0.25, t_8, fma(-0.08333333333333333, Float64(t_3 / Float64(x * x)), fma(-0.041666666666666664, Float64(t_3 / (x ^ 4.0)), fma(0.041666666666666664, t_6, fma(0.05555555555555555, (t_0 ^ 3.0), Float64(Float64(0.16666666666666666 * t_2) + fma(0.16666666666666666, Float64(t_3 / x), fma(0.22916666666666666, t_14, Float64(0.25 * t_9)))))))))) / n), fma(-0.5, t_10, fma(-0.5, Float64(t_7 / x), Float64(Float64(-0.4583333333333333 * t_5) + Float64(Float64(-0.16666666666666666 * t_8) + Float64(Float64(0.125 * t_14) + fma(0.25, t_6, fma(0.25, t_9, Float64(0.5 * t_2))))))))) - Float64(0.16666666666666666 * t_11)) / n), fma(-0.5, t_10, fma(-0.25, t_5, fma(0.3333333333333333, t_2, fma(0.4583333333333333, t_6, fma(0.5, t_12, t_0)))))) - Float64(0.5 * t_11)) / n), Float64(Float64(-1.0 / x) + Float64(Float64(fma(0.25, t_11, t_4) / x) - Float64(t_13 / x)))) / n)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / x), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$2 = N[(N[Log[x], $MachinePrecision] / t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]}, Block[{t$95$4 = N[(0.5 * N[Power[x, -1.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[Log[x], $MachinePrecision] / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[Power[N[Power[x, 4.0], $MachinePrecision], -1.0], $MachinePrecision]}, Block[{t$95$7 = N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$8 = N[(t$95$7 / t$95$1), $MachinePrecision]}, Block[{t$95$9 = N[(t$95$7 / N[(x * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$10 = N[(N[Log[x], $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$11 = N[Power[t$95$1, -1.0], $MachinePrecision]}, Block[{t$95$12 = N[Power[N[(x * x), $MachinePrecision], -1.0], $MachinePrecision]}, Block[{t$95$13 = N[(0.3333333333333333 * t$95$12), $MachinePrecision]}, Block[{t$95$14 = N[(t$95$7 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-143], N[(N[(N[(N[(N[Log[x], $MachinePrecision] + N[(0.5 * N[(N[(1.0 + N[(-1.0 * N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(0.5 * N[(N[(N[(0.6666666666666666 * N[Log[x], $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(n * N[(N[(1.0 + t$95$13), $MachinePrecision] - t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / N[(n * (-n)), $MachinePrecision]), $MachinePrecision] * -1.0), $MachinePrecision], N[(-1.0 * N[(N[(-1.0 * N[(N[(N[(-1.0 * N[(N[(N[(-1.0 * N[(N[(-0.25 * t$95$5 + N[(-0.25 * t$95$8 + N[(-0.08333333333333333 * N[(t$95$3 / N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(-0.041666666666666664 * N[(t$95$3 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(0.041666666666666664 * t$95$6 + N[(0.05555555555555555 * N[Power[t$95$0, 3.0], $MachinePrecision] + N[(N[(0.16666666666666666 * t$95$2), $MachinePrecision] + N[(0.16666666666666666 * N[(t$95$3 / x), $MachinePrecision] + N[(0.22916666666666666 * t$95$14 + N[(0.25 * t$95$9), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(-0.5 * t$95$10 + N[(-0.5 * N[(t$95$7 / x), $MachinePrecision] + N[(N[(-0.4583333333333333 * t$95$5), $MachinePrecision] + N[(N[(-0.16666666666666666 * t$95$8), $MachinePrecision] + N[(N[(0.125 * t$95$14), $MachinePrecision] + N[(0.25 * t$95$6 + N[(0.25 * t$95$9 + N[(0.5 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.16666666666666666 * t$95$11), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(-0.5 * t$95$10 + N[(-0.25 * t$95$5 + N[(0.3333333333333333 * t$95$2 + N[(0.4583333333333333 * t$95$6 + N[(0.5 * t$95$12 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 * t$95$11), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(N[(-1.0 / x), $MachinePrecision] + N[(N[(N[(0.25 * t$95$11 + t$95$4), $MachinePrecision] / x), $MachinePrecision] - N[(t$95$13 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{x}\\
t_1 := \left(x \cdot x\right) \cdot x\\
t_2 := \frac{\log x}{t\_1}\\
t_3 := {\log x}^{3}\\
t_4 := 0.5 \cdot {x}^{-1}\\
t_5 := \frac{\log x}{{x}^{4}}\\
t_6 := {\left({x}^{4}\right)}^{-1}\\
t_7 := {\log x}^{2}\\
t_8 := \frac{t\_7}{t\_1}\\
t_9 := \frac{t\_7}{x \cdot x}\\
t_10 := \frac{\log x}{x \cdot x}\\
t_11 := {t\_1}^{-1}\\
t_12 := {\left(x \cdot x\right)}^{-1}\\
t_13 := 0.3333333333333333 \cdot t\_12\\
t_14 := \frac{t\_7}{{x}^{4}}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-143}:\\
\;\;\;\;\frac{\frac{\log x + \mathsf{fma}\left(0.5, \frac{1 + -1 \cdot \log x}{x}, \mathsf{fma}\left(0.5, \frac{0.6666666666666666 \cdot \log x - 1}{x \cdot x}, n \cdot \left(\left(1 + t\_13\right) - t\_4\right)\right)\right)}{x}}{n \cdot \left(-n\right)} \cdot -1\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-0.25, t\_5, \mathsf{fma}\left(-0.25, t\_8, \mathsf{fma}\left(-0.08333333333333333, \frac{t\_3}{x \cdot x}, \mathsf{fma}\left(-0.041666666666666664, \frac{t\_3}{{x}^{4}}, \mathsf{fma}\left(0.041666666666666664, t\_6, \mathsf{fma}\left(0.05555555555555555, {t\_0}^{3}, 0.16666666666666666 \cdot t\_2 + \mathsf{fma}\left(0.16666666666666666, \frac{t\_3}{x}, \mathsf{fma}\left(0.22916666666666666, t\_14, 0.25 \cdot t\_9\right)\right)\right)\right)\right)\right)\right)\right)}{n}, \mathsf{fma}\left(-0.5, t\_10, \mathsf{fma}\left(-0.5, \frac{t\_7}{x}, -0.4583333333333333 \cdot t\_5 + \left(-0.16666666666666666 \cdot t\_8 + \left(0.125 \cdot t\_14 + \mathsf{fma}\left(0.25, t\_6, \mathsf{fma}\left(0.25, t\_9, 0.5 \cdot t\_2\right)\right)\right)\right)\right)\right)\right) - 0.16666666666666666 \cdot t\_11}{n}, \mathsf{fma}\left(-0.5, t\_10, \mathsf{fma}\left(-0.25, t\_5, \mathsf{fma}\left(0.3333333333333333, t\_2, \mathsf{fma}\left(0.4583333333333333, t\_6, \mathsf{fma}\left(0.5, t\_12, t\_0\right)\right)\right)\right)\right)\right) - 0.5 \cdot t\_11}{n}, \frac{-1}{x} + \left(\frac{\mathsf{fma}\left(0.25, t\_11, t\_4\right)}{x} - \frac{t\_13}{x}\right)\right)}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.9999999999999999e-143Initial program 74.0%
Taylor expanded in n around -inf
Applied rewrites55.9%
Taylor expanded in x around inf
Applied rewrites47.1%
Taylor expanded in n around 0
lower-+.f64N/A
lift-log.f64N/A
lower-fma.f64N/A
Applied rewrites47.3%
if -1.9999999999999999e-143 < (/.f64 #s(literal 1 binary64) n) Initial program 38.3%
Taylor expanded in x around inf
Applied rewrites9.1%
Taylor expanded in n around -inf
Applied rewrites42.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow (log x) 2.0))
(t_1 (pow (log x) 3.0))
(t_2 (/ (log x) (pow x 4.0)))
(t_3 (/ t_0 (pow x 4.0)))
(t_4 (pow (* x x) -1.0))
(t_5 (pow (pow x 4.0) -1.0))
(t_6 (/ t_0 (* x x)))
(t_7 (* (* x x) x))
(t_8 (/ t_0 t_7))
(t_9 (pow t_7 -1.0))
(t_10 (/ (log x) t_7))
(t_11 (/ (log x) x))
(t_12 (/ (log x) (* x x))))
(*
-1.0
(/
(fma
-1.0
(/
(-
(fma
-1.0
(/
(-
(fma
-1.0
(/
(fma
-0.25
t_2
(fma
-0.25
t_8
(fma
-0.08333333333333333
(/ t_1 (* x x))
(fma
-0.041666666666666664
(/ t_1 (pow x 4.0))
(fma
0.041666666666666664
t_5
(fma
0.05555555555555555
(pow t_11 3.0)
(+
(* 0.16666666666666666 t_10)
(fma
0.16666666666666666
(/ t_1 x)
(fma 0.22916666666666666 t_3 (* 0.25 t_6))))))))))
n)
(fma
-0.5
t_12
(fma
-0.5
(/ t_0 x)
(+
(* -0.4583333333333333 t_2)
(+
(* -0.16666666666666666 t_8)
(+
(* 0.125 t_3)
(fma 0.25 t_5 (fma 0.25 t_6 (* 0.5 t_10)))))))))
(* 0.16666666666666666 t_9))
n)
(fma
-0.5
t_12
(fma
-0.25
t_2
(fma
0.3333333333333333
t_10
(fma 0.4583333333333333 t_5 (fma 0.5 t_4 t_11))))))
(* 0.5 t_9))
n)
(+
(/ -1.0 x)
(-
(/ (fma 0.25 t_9 (* 0.5 (pow x -1.0))) x)
(/ (* 0.3333333333333333 t_4) x))))
n))))
double code(double x, double n) {
double t_0 = pow(log(x), 2.0);
double t_1 = pow(log(x), 3.0);
double t_2 = log(x) / pow(x, 4.0);
double t_3 = t_0 / pow(x, 4.0);
double t_4 = pow((x * x), -1.0);
double t_5 = pow(pow(x, 4.0), -1.0);
double t_6 = t_0 / (x * x);
double t_7 = (x * x) * x;
double t_8 = t_0 / t_7;
double t_9 = pow(t_7, -1.0);
double t_10 = log(x) / t_7;
double t_11 = log(x) / x;
double t_12 = log(x) / (x * x);
return -1.0 * (fma(-1.0, ((fma(-1.0, ((fma(-1.0, (fma(-0.25, t_2, fma(-0.25, t_8, fma(-0.08333333333333333, (t_1 / (x * x)), fma(-0.041666666666666664, (t_1 / pow(x, 4.0)), fma(0.041666666666666664, t_5, fma(0.05555555555555555, pow(t_11, 3.0), ((0.16666666666666666 * t_10) + fma(0.16666666666666666, (t_1 / x), fma(0.22916666666666666, t_3, (0.25 * t_6)))))))))) / n), fma(-0.5, t_12, fma(-0.5, (t_0 / x), ((-0.4583333333333333 * t_2) + ((-0.16666666666666666 * t_8) + ((0.125 * t_3) + fma(0.25, t_5, fma(0.25, t_6, (0.5 * t_10))))))))) - (0.16666666666666666 * t_9)) / n), fma(-0.5, t_12, fma(-0.25, t_2, fma(0.3333333333333333, t_10, fma(0.4583333333333333, t_5, fma(0.5, t_4, t_11)))))) - (0.5 * t_9)) / n), ((-1.0 / x) + ((fma(0.25, t_9, (0.5 * pow(x, -1.0))) / x) - ((0.3333333333333333 * t_4) / x)))) / n);
}
function code(x, n) t_0 = log(x) ^ 2.0 t_1 = log(x) ^ 3.0 t_2 = Float64(log(x) / (x ^ 4.0)) t_3 = Float64(t_0 / (x ^ 4.0)) t_4 = Float64(x * x) ^ -1.0 t_5 = (x ^ 4.0) ^ -1.0 t_6 = Float64(t_0 / Float64(x * x)) t_7 = Float64(Float64(x * x) * x) t_8 = Float64(t_0 / t_7) t_9 = t_7 ^ -1.0 t_10 = Float64(log(x) / t_7) t_11 = Float64(log(x) / x) t_12 = Float64(log(x) / Float64(x * x)) return Float64(-1.0 * Float64(fma(-1.0, Float64(Float64(fma(-1.0, Float64(Float64(fma(-1.0, Float64(fma(-0.25, t_2, fma(-0.25, t_8, fma(-0.08333333333333333, Float64(t_1 / Float64(x * x)), fma(-0.041666666666666664, Float64(t_1 / (x ^ 4.0)), fma(0.041666666666666664, t_5, fma(0.05555555555555555, (t_11 ^ 3.0), Float64(Float64(0.16666666666666666 * t_10) + fma(0.16666666666666666, Float64(t_1 / x), fma(0.22916666666666666, t_3, Float64(0.25 * t_6)))))))))) / n), fma(-0.5, t_12, fma(-0.5, Float64(t_0 / x), Float64(Float64(-0.4583333333333333 * t_2) + Float64(Float64(-0.16666666666666666 * t_8) + Float64(Float64(0.125 * t_3) + fma(0.25, t_5, fma(0.25, t_6, Float64(0.5 * t_10))))))))) - Float64(0.16666666666666666 * t_9)) / n), fma(-0.5, t_12, fma(-0.25, t_2, fma(0.3333333333333333, t_10, fma(0.4583333333333333, t_5, fma(0.5, t_4, t_11)))))) - Float64(0.5 * t_9)) / n), Float64(Float64(-1.0 / x) + Float64(Float64(fma(0.25, t_9, Float64(0.5 * (x ^ -1.0))) / x) - Float64(Float64(0.3333333333333333 * t_4) / x)))) / n)) end
code[x_, n_] := Block[{t$95$0 = N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Log[x], $MachinePrecision] / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Power[N[(x * x), $MachinePrecision], -1.0], $MachinePrecision]}, Block[{t$95$5 = N[Power[N[Power[x, 4.0], $MachinePrecision], -1.0], $MachinePrecision]}, Block[{t$95$6 = N[(t$95$0 / N[(x * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$7 = N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$8 = N[(t$95$0 / t$95$7), $MachinePrecision]}, Block[{t$95$9 = N[Power[t$95$7, -1.0], $MachinePrecision]}, Block[{t$95$10 = N[(N[Log[x], $MachinePrecision] / t$95$7), $MachinePrecision]}, Block[{t$95$11 = N[(N[Log[x], $MachinePrecision] / x), $MachinePrecision]}, Block[{t$95$12 = N[(N[Log[x], $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]}, N[(-1.0 * N[(N[(-1.0 * N[(N[(N[(-1.0 * N[(N[(N[(-1.0 * N[(N[(-0.25 * t$95$2 + N[(-0.25 * t$95$8 + N[(-0.08333333333333333 * N[(t$95$1 / N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(-0.041666666666666664 * N[(t$95$1 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(0.041666666666666664 * t$95$5 + N[(0.05555555555555555 * N[Power[t$95$11, 3.0], $MachinePrecision] + N[(N[(0.16666666666666666 * t$95$10), $MachinePrecision] + N[(0.16666666666666666 * N[(t$95$1 / x), $MachinePrecision] + N[(0.22916666666666666 * t$95$3 + N[(0.25 * t$95$6), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(-0.5 * t$95$12 + N[(-0.5 * N[(t$95$0 / x), $MachinePrecision] + N[(N[(-0.4583333333333333 * t$95$2), $MachinePrecision] + N[(N[(-0.16666666666666666 * t$95$8), $MachinePrecision] + N[(N[(0.125 * t$95$3), $MachinePrecision] + N[(0.25 * t$95$5 + N[(0.25 * t$95$6 + N[(0.5 * t$95$10), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.16666666666666666 * t$95$9), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(-0.5 * t$95$12 + N[(-0.25 * t$95$2 + N[(0.3333333333333333 * t$95$10 + N[(0.4583333333333333 * t$95$5 + N[(0.5 * t$95$4 + t$95$11), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 * t$95$9), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(N[(-1.0 / x), $MachinePrecision] + N[(N[(N[(0.25 * t$95$9 + N[(0.5 * N[Power[x, -1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - N[(N[(0.3333333333333333 * t$95$4), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\log x}^{2}\\
t_1 := {\log x}^{3}\\
t_2 := \frac{\log x}{{x}^{4}}\\
t_3 := \frac{t\_0}{{x}^{4}}\\
t_4 := {\left(x \cdot x\right)}^{-1}\\
t_5 := {\left({x}^{4}\right)}^{-1}\\
t_6 := \frac{t\_0}{x \cdot x}\\
t_7 := \left(x \cdot x\right) \cdot x\\
t_8 := \frac{t\_0}{t\_7}\\
t_9 := {t\_7}^{-1}\\
t_10 := \frac{\log x}{t\_7}\\
t_11 := \frac{\log x}{x}\\
t_12 := \frac{\log x}{x \cdot x}\\
-1 \cdot \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-0.25, t\_2, \mathsf{fma}\left(-0.25, t\_8, \mathsf{fma}\left(-0.08333333333333333, \frac{t\_1}{x \cdot x}, \mathsf{fma}\left(-0.041666666666666664, \frac{t\_1}{{x}^{4}}, \mathsf{fma}\left(0.041666666666666664, t\_5, \mathsf{fma}\left(0.05555555555555555, {t\_11}^{3}, 0.16666666666666666 \cdot t\_10 + \mathsf{fma}\left(0.16666666666666666, \frac{t\_1}{x}, \mathsf{fma}\left(0.22916666666666666, t\_3, 0.25 \cdot t\_6\right)\right)\right)\right)\right)\right)\right)\right)}{n}, \mathsf{fma}\left(-0.5, t\_12, \mathsf{fma}\left(-0.5, \frac{t\_0}{x}, -0.4583333333333333 \cdot t\_2 + \left(-0.16666666666666666 \cdot t\_8 + \left(0.125 \cdot t\_3 + \mathsf{fma}\left(0.25, t\_5, \mathsf{fma}\left(0.25, t\_6, 0.5 \cdot t\_10\right)\right)\right)\right)\right)\right)\right) - 0.16666666666666666 \cdot t\_9}{n}, \mathsf{fma}\left(-0.5, t\_12, \mathsf{fma}\left(-0.25, t\_2, \mathsf{fma}\left(0.3333333333333333, t\_10, \mathsf{fma}\left(0.4583333333333333, t\_5, \mathsf{fma}\left(0.5, t\_4, t\_11\right)\right)\right)\right)\right)\right) - 0.5 \cdot t\_9}{n}, \frac{-1}{x} + \left(\frac{\mathsf{fma}\left(0.25, t\_9, 0.5 \cdot {x}^{-1}\right)}{x} - \frac{0.3333333333333333 \cdot t\_4}{x}\right)\right)}{n}
\end{array}
\end{array}
Initial program 53.6%
Taylor expanded in x around inf
Applied rewrites11.9%
Taylor expanded in n around -inf
Applied rewrites30.8%
herbie shell --seed 2025093
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))