
(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));
}
real(8) function code(x, n)
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}
Sampling outcomes in binary64 precision:
Herbie found 13 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));
}
real(8) function code(x, n)
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))) (t_1 (- (pow (+ x 1.0) (/ 1.0 n)) t_0)))
(if (<= t_1 (- INFINITY))
(- 1.0 t_0)
(if (<= t_1 0.0) (/ (log (/ x (+ x 1.0))) (- n)) (- (exp (/ x n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = 1.0 - t_0;
} else if (t_1 <= 0.0) {
tmp = log((x / (x + 1.0))) / -n;
} else {
tmp = exp((x / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = Math.pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = 1.0 - t_0;
} else if (t_1 <= 0.0) {
tmp = Math.log((x / (x + 1.0))) / -n;
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.pow((x + 1.0), (1.0 / n)) - t_0 tmp = 0 if t_1 <= -math.inf: tmp = 1.0 - t_0 elif t_1 <= 0.0: tmp = math.log((x / (x + 1.0))) / -n else: tmp = math.exp((x / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(1.0 - t_0); elseif (t_1 <= 0.0) tmp = Float64(log(Float64(x / Float64(x + 1.0))) / Float64(-n)); else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = ((x + 1.0) ^ (1.0 / n)) - t_0; tmp = 0.0; if (t_1 <= -Inf) tmp = 1.0 - t_0; elseif (t_1 <= 0.0) tmp = log((x / (x + 1.0))) / -n; else tmp = exp((x / n)) - t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\log \left(\frac{x}{x + 1}\right)}{-n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < -inf.0Initial program 100.0%
Taylor expanded in x around 0 100.0%
*-rgt-identity100.0%
associate-/l*100.0%
exp-to-pow100.0%
Simplified100.0%
if -inf.0 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < 0.0Initial program 40.3%
Taylor expanded in n around inf 79.4%
log1p-define79.4%
Simplified79.4%
log1p-undefine79.4%
diff-log79.6%
Applied egg-rr79.6%
clear-num79.6%
log-rec79.6%
Applied egg-rr79.6%
if 0.0 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) Initial program 51.3%
Taylor expanded in n around 0 51.3%
log1p-define97.4%
*-rgt-identity97.4%
associate-/l*97.4%
exp-to-pow97.4%
Simplified97.4%
Taylor expanded in x around 0 97.4%
Final simplification84.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n))))
(t_1 (/ (log (/ (+ x 1.0) x)) n))
(t_2 (/ 0.3333333333333333 (* n (pow x 3.0)))))
(if (<= (/ 1.0 n) -5e+37)
t_2
(if (<= (/ 1.0 n) -500000000.0)
t_0
(if (<= (/ 1.0 n) -5e-59)
t_1
(if (<= (/ 1.0 n) -1e-119)
(/ (- (/ 1.0 x) (/ 0.5 (* x x))) n)
(if (<= (/ 1.0 n) 0.001)
t_1
(if (<= (/ 1.0 n) 1e+199) t_0 t_2))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double t_1 = log(((x + 1.0) / x)) / n;
double t_2 = 0.3333333333333333 / (n * pow(x, 3.0));
double tmp;
if ((1.0 / n) <= -5e+37) {
tmp = t_2;
} else if ((1.0 / n) <= -500000000.0) {
tmp = t_0;
} else if ((1.0 / n) <= -5e-59) {
tmp = t_1;
} else if ((1.0 / n) <= -1e-119) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else if ((1.0 / n) <= 0.001) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+199) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
t_1 = log(((x + 1.0d0) / x)) / n
t_2 = 0.3333333333333333d0 / (n * (x ** 3.0d0))
if ((1.0d0 / n) <= (-5d+37)) then
tmp = t_2
else if ((1.0d0 / n) <= (-500000000.0d0)) then
tmp = t_0
else if ((1.0d0 / n) <= (-5d-59)) then
tmp = t_1
else if ((1.0d0 / n) <= (-1d-119)) then
tmp = ((1.0d0 / x) - (0.5d0 / (x * x))) / n
else if ((1.0d0 / n) <= 0.001d0) then
tmp = t_1
else if ((1.0d0 / n) <= 1d+199) then
tmp = t_0
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double t_1 = Math.log(((x + 1.0) / x)) / n;
double t_2 = 0.3333333333333333 / (n * Math.pow(x, 3.0));
double tmp;
if ((1.0 / n) <= -5e+37) {
tmp = t_2;
} else if ((1.0 / n) <= -500000000.0) {
tmp = t_0;
} else if ((1.0 / n) <= -5e-59) {
tmp = t_1;
} else if ((1.0 / n) <= -1e-119) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else if ((1.0 / n) <= 0.001) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+199) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) t_1 = math.log(((x + 1.0) / x)) / n t_2 = 0.3333333333333333 / (n * math.pow(x, 3.0)) tmp = 0 if (1.0 / n) <= -5e+37: tmp = t_2 elif (1.0 / n) <= -500000000.0: tmp = t_0 elif (1.0 / n) <= -5e-59: tmp = t_1 elif (1.0 / n) <= -1e-119: tmp = ((1.0 / x) - (0.5 / (x * x))) / n elif (1.0 / n) <= 0.001: tmp = t_1 elif (1.0 / n) <= 1e+199: tmp = t_0 else: tmp = t_2 return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) t_1 = Float64(log(Float64(Float64(x + 1.0) / x)) / n) t_2 = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0))) tmp = 0.0 if (Float64(1.0 / n) <= -5e+37) tmp = t_2; elseif (Float64(1.0 / n) <= -500000000.0) tmp = t_0; elseif (Float64(1.0 / n) <= -5e-59) tmp = t_1; elseif (Float64(1.0 / n) <= -1e-119) tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x))) / n); elseif (Float64(1.0 / n) <= 0.001) tmp = t_1; elseif (Float64(1.0 / n) <= 1e+199) tmp = t_0; else tmp = t_2; end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); t_1 = log(((x + 1.0) / x)) / n; t_2 = 0.3333333333333333 / (n * (x ^ 3.0)); tmp = 0.0; if ((1.0 / n) <= -5e+37) tmp = t_2; elseif ((1.0 / n) <= -500000000.0) tmp = t_0; elseif ((1.0 / n) <= -5e-59) tmp = t_1; elseif ((1.0 / n) <= -1e-119) tmp = ((1.0 / x) - (0.5 / (x * x))) / n; elseif ((1.0 / n) <= 0.001) tmp = t_1; elseif ((1.0 / n) <= 1e+199) tmp = t_0; else tmp = t_2; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, Block[{t$95$2 = N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+37], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], -500000000.0], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-59], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-119], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.001], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+199], t$95$0, t$95$2]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
t_2 := \frac{0.3333333333333333}{n \cdot {x}^{3}}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+37}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\frac{1}{n} \leq -500000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-59}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-119}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.001:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+199}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 1 n) < -4.99999999999999989e37 or 1.0000000000000001e199 < (/.f64 1 n) Initial program 83.0%
Taylor expanded in n around inf 48.6%
log1p-define48.6%
Simplified48.6%
Taylor expanded in x around inf 27.9%
associate--l+27.9%
associate-*r/27.9%
metadata-eval27.9%
associate-*r/29.7%
metadata-eval29.7%
Simplified29.7%
Taylor expanded in x around 0 73.1%
if -4.99999999999999989e37 < (/.f64 1 n) < -5e8 or 1e-3 < (/.f64 1 n) < 1.0000000000000001e199Initial program 74.8%
Taylor expanded in x around 0 69.3%
*-rgt-identity69.3%
associate-/l*69.3%
exp-to-pow69.3%
Simplified69.3%
if -5e8 < (/.f64 1 n) < -5.0000000000000001e-59 or -1.00000000000000001e-119 < (/.f64 1 n) < 1e-3Initial program 32.9%
Taylor expanded in n around inf 79.5%
log1p-define79.5%
Simplified79.5%
log1p-undefine79.5%
diff-log79.6%
Applied egg-rr79.6%
if -5.0000000000000001e-59 < (/.f64 1 n) < -1.00000000000000001e-119Initial program 12.8%
Taylor expanded in n around inf 42.4%
log1p-define42.4%
Simplified42.4%
Taylor expanded in x around inf 71.4%
associate-*r/71.4%
metadata-eval71.4%
Simplified71.4%
unpow271.4%
Applied egg-rr71.4%
Final simplification76.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (log (/ x (+ x 1.0))) (- n))))
(if (<= (/ 1.0 n) -1e-10)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) -5e-59)
t_1
(if (<= (/ 1.0 n) -1e-119)
(/ (- (/ 1.0 x) (/ 0.5 (* x x))) n)
(if (<= (/ 1.0 n) 0.001)
t_1
(if (<= (/ 1.0 n) 1.03e+214)
(- (+ 1.0 (/ x n)) t_0)
(/ 0.3333333333333333 (* n (pow x 3.0))))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = log((x / (x + 1.0))) / -n;
double tmp;
if ((1.0 / n) <= -1e-10) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= -5e-59) {
tmp = t_1;
} else if ((1.0 / n) <= -1e-119) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else if ((1.0 / n) <= 0.001) {
tmp = t_1;
} else if ((1.0 / n) <= 1.03e+214) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 0.3333333333333333 / (n * pow(x, 3.0));
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = log((x / (x + 1.0d0))) / -n
if ((1.0d0 / n) <= (-1d-10)) then
tmp = t_0 / (x * n)
else if ((1.0d0 / n) <= (-5d-59)) then
tmp = t_1
else if ((1.0d0 / n) <= (-1d-119)) then
tmp = ((1.0d0 / x) - (0.5d0 / (x * x))) / n
else if ((1.0d0 / n) <= 0.001d0) then
tmp = t_1
else if ((1.0d0 / n) <= 1.03d+214) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = 0.3333333333333333d0 / (n * (x ** 3.0d0))
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = Math.log((x / (x + 1.0))) / -n;
double tmp;
if ((1.0 / n) <= -1e-10) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= -5e-59) {
tmp = t_1;
} else if ((1.0 / n) <= -1e-119) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else if ((1.0 / n) <= 0.001) {
tmp = t_1;
} else if ((1.0 / n) <= 1.03e+214) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.log((x / (x + 1.0))) / -n tmp = 0 if (1.0 / n) <= -1e-10: tmp = t_0 / (x * n) elif (1.0 / n) <= -5e-59: tmp = t_1 elif (1.0 / n) <= -1e-119: tmp = ((1.0 / x) - (0.5 / (x * x))) / n elif (1.0 / n) <= 0.001: tmp = t_1 elif (1.0 / n) <= 1.03e+214: tmp = (1.0 + (x / n)) - t_0 else: tmp = 0.3333333333333333 / (n * math.pow(x, 3.0)) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(log(Float64(x / Float64(x + 1.0))) / Float64(-n)) tmp = 0.0 if (Float64(1.0 / n) <= -1e-10) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= -5e-59) tmp = t_1; elseif (Float64(1.0 / n) <= -1e-119) tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x))) / n); elseif (Float64(1.0 / n) <= 0.001) tmp = t_1; elseif (Float64(1.0 / n) <= 1.03e+214) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0))); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = log((x / (x + 1.0))) / -n; tmp = 0.0; if ((1.0 / n) <= -1e-10) tmp = t_0 / (x * n); elseif ((1.0 / n) <= -5e-59) tmp = t_1; elseif ((1.0 / n) <= -1e-119) tmp = ((1.0 / x) - (0.5 / (x * x))) / n; elseif ((1.0 / n) <= 0.001) tmp = t_1; elseif ((1.0 / n) <= 1.03e+214) tmp = (1.0 + (x / n)) - t_0; else tmp = 0.3333333333333333 / (n * (x ^ 3.0)); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-10], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-59], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-119], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.001], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1.03e+214], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log \left(\frac{x}{x + 1}\right)}{-n}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-10}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-59}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-119}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.001:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 1.03 \cdot 10^{+214}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -1.00000000000000004e-10Initial program 96.8%
Taylor expanded in x around inf 100.0%
log-rec100.0%
mul-1-neg100.0%
associate-*r/100.0%
associate-*r*100.0%
metadata-eval100.0%
*-commutative100.0%
associate-/l*100.0%
exp-to-pow100.0%
*-commutative100.0%
Simplified100.0%
if -1.00000000000000004e-10 < (/.f64 1 n) < -5.0000000000000001e-59 or -1.00000000000000001e-119 < (/.f64 1 n) < 1e-3Initial program 31.4%
Taylor expanded in n around inf 79.9%
log1p-define79.9%
Simplified79.9%
log1p-undefine79.9%
diff-log80.1%
Applied egg-rr80.1%
clear-num80.1%
log-rec80.1%
Applied egg-rr80.1%
if -5.0000000000000001e-59 < (/.f64 1 n) < -1.00000000000000001e-119Initial program 12.8%
Taylor expanded in n around inf 42.4%
log1p-define42.4%
Simplified42.4%
Taylor expanded in x around inf 71.4%
associate-*r/71.4%
metadata-eval71.4%
Simplified71.4%
unpow271.4%
Applied egg-rr71.4%
if 1e-3 < (/.f64 1 n) < 1.03e214Initial program 63.8%
Taylor expanded in x around 0 61.9%
if 1.03e214 < (/.f64 1 n) Initial program 20.7%
Taylor expanded in n around inf 6.6%
log1p-define6.6%
Simplified6.6%
Taylor expanded in x around inf 46.4%
associate--l+46.4%
associate-*r/46.4%
metadata-eval46.4%
associate-*r/46.4%
metadata-eval46.4%
Simplified46.4%
Taylor expanded in x around 0 74.2%
Final simplification82.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0)))
(t_1 (pow x (/ 1.0 n)))
(t_2 (/ (log t_0) (- n))))
(if (<= (/ 1.0 n) -1e-10)
(/ t_1 (* x n))
(if (<= (/ 1.0 n) -5e-59)
t_2
(if (<= (/ 1.0 n) -1e-119)
(/ (- (/ 1.0 x) (/ 0.5 (* x x))) n)
(if (<= (/ 1.0 n) 0.001)
t_2
(if (<= (/ 1.0 n) 1.03e+214)
(- (+ 1.0 (/ x n)) t_1)
(/ (log1p (+ t_0 -1.0)) (- n)))))))))
double code(double x, double n) {
double t_0 = x / (x + 1.0);
double t_1 = pow(x, (1.0 / n));
double t_2 = log(t_0) / -n;
double tmp;
if ((1.0 / n) <= -1e-10) {
tmp = t_1 / (x * n);
} else if ((1.0 / n) <= -5e-59) {
tmp = t_2;
} else if ((1.0 / n) <= -1e-119) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else if ((1.0 / n) <= 0.001) {
tmp = t_2;
} else if ((1.0 / n) <= 1.03e+214) {
tmp = (1.0 + (x / n)) - t_1;
} else {
tmp = log1p((t_0 + -1.0)) / -n;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = x / (x + 1.0);
double t_1 = Math.pow(x, (1.0 / n));
double t_2 = Math.log(t_0) / -n;
double tmp;
if ((1.0 / n) <= -1e-10) {
tmp = t_1 / (x * n);
} else if ((1.0 / n) <= -5e-59) {
tmp = t_2;
} else if ((1.0 / n) <= -1e-119) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else if ((1.0 / n) <= 0.001) {
tmp = t_2;
} else if ((1.0 / n) <= 1.03e+214) {
tmp = (1.0 + (x / n)) - t_1;
} else {
tmp = Math.log1p((t_0 + -1.0)) / -n;
}
return tmp;
}
def code(x, n): t_0 = x / (x + 1.0) t_1 = math.pow(x, (1.0 / n)) t_2 = math.log(t_0) / -n tmp = 0 if (1.0 / n) <= -1e-10: tmp = t_1 / (x * n) elif (1.0 / n) <= -5e-59: tmp = t_2 elif (1.0 / n) <= -1e-119: tmp = ((1.0 / x) - (0.5 / (x * x))) / n elif (1.0 / n) <= 0.001: tmp = t_2 elif (1.0 / n) <= 1.03e+214: tmp = (1.0 + (x / n)) - t_1 else: tmp = math.log1p((t_0 + -1.0)) / -n return tmp
function code(x, n) t_0 = Float64(x / Float64(x + 1.0)) t_1 = x ^ Float64(1.0 / n) t_2 = Float64(log(t_0) / Float64(-n)) tmp = 0.0 if (Float64(1.0 / n) <= -1e-10) tmp = Float64(t_1 / Float64(x * n)); elseif (Float64(1.0 / n) <= -5e-59) tmp = t_2; elseif (Float64(1.0 / n) <= -1e-119) tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x))) / n); elseif (Float64(1.0 / n) <= 0.001) tmp = t_2; elseif (Float64(1.0 / n) <= 1.03e+214) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_1); else tmp = Float64(log1p(Float64(t_0 + -1.0)) / Float64(-n)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Log[t$95$0], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-10], N[(t$95$1 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-59], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-119], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.001], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1.03e+214], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], N[(N[Log[1 + N[(t$95$0 + -1.0), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
t_2 := \frac{\log t\_0}{-n}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-10}:\\
\;\;\;\;\frac{t\_1}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-59}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-119}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.001:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\frac{1}{n} \leq 1.03 \cdot 10^{+214}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(t\_0 + -1\right)}{-n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -1.00000000000000004e-10Initial program 96.8%
Taylor expanded in x around inf 100.0%
log-rec100.0%
mul-1-neg100.0%
associate-*r/100.0%
associate-*r*100.0%
metadata-eval100.0%
*-commutative100.0%
associate-/l*100.0%
exp-to-pow100.0%
*-commutative100.0%
Simplified100.0%
if -1.00000000000000004e-10 < (/.f64 1 n) < -5.0000000000000001e-59 or -1.00000000000000001e-119 < (/.f64 1 n) < 1e-3Initial program 31.4%
Taylor expanded in n around inf 79.9%
log1p-define79.9%
Simplified79.9%
log1p-undefine79.9%
diff-log80.1%
Applied egg-rr80.1%
clear-num80.1%
log-rec80.1%
Applied egg-rr80.1%
if -5.0000000000000001e-59 < (/.f64 1 n) < -1.00000000000000001e-119Initial program 12.8%
Taylor expanded in n around inf 42.4%
log1p-define42.4%
Simplified42.4%
Taylor expanded in x around inf 71.4%
associate-*r/71.4%
metadata-eval71.4%
Simplified71.4%
unpow271.4%
Applied egg-rr71.4%
if 1e-3 < (/.f64 1 n) < 1.03e214Initial program 63.8%
Taylor expanded in x around 0 61.9%
if 1.03e214 < (/.f64 1 n) Initial program 20.7%
Taylor expanded in n around inf 6.6%
log1p-define6.6%
Simplified6.6%
log1p-undefine6.6%
diff-log6.6%
Applied egg-rr6.6%
clear-num6.6%
log-rec6.6%
Applied egg-rr6.6%
log1p-expm1-u82.4%
expm1-undefine82.4%
add-exp-log82.4%
+-commutative82.4%
Applied egg-rr82.4%
Final simplification82.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (log (/ x (+ x 1.0))) (- n))))
(if (<= (/ 1.0 n) -1e-10)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) -5e-59)
t_1
(if (<= (/ 1.0 n) -1e-119)
(/ (- (/ 1.0 x) (/ 0.5 (* x x))) n)
(if (<= (/ 1.0 n) 0.001)
t_1
(if (<= (/ 1.0 n) 1e+199)
(- 1.0 t_0)
(/ 0.3333333333333333 (* n (pow x 3.0))))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = log((x / (x + 1.0))) / -n;
double tmp;
if ((1.0 / n) <= -1e-10) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= -5e-59) {
tmp = t_1;
} else if ((1.0 / n) <= -1e-119) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else if ((1.0 / n) <= 0.001) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+199) {
tmp = 1.0 - t_0;
} else {
tmp = 0.3333333333333333 / (n * pow(x, 3.0));
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = log((x / (x + 1.0d0))) / -n
if ((1.0d0 / n) <= (-1d-10)) then
tmp = t_0 / (x * n)
else if ((1.0d0 / n) <= (-5d-59)) then
tmp = t_1
else if ((1.0d0 / n) <= (-1d-119)) then
tmp = ((1.0d0 / x) - (0.5d0 / (x * x))) / n
else if ((1.0d0 / n) <= 0.001d0) then
tmp = t_1
else if ((1.0d0 / n) <= 1d+199) then
tmp = 1.0d0 - t_0
else
tmp = 0.3333333333333333d0 / (n * (x ** 3.0d0))
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = Math.log((x / (x + 1.0))) / -n;
double tmp;
if ((1.0 / n) <= -1e-10) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= -5e-59) {
tmp = t_1;
} else if ((1.0 / n) <= -1e-119) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else if ((1.0 / n) <= 0.001) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+199) {
tmp = 1.0 - t_0;
} else {
tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.log((x / (x + 1.0))) / -n tmp = 0 if (1.0 / n) <= -1e-10: tmp = t_0 / (x * n) elif (1.0 / n) <= -5e-59: tmp = t_1 elif (1.0 / n) <= -1e-119: tmp = ((1.0 / x) - (0.5 / (x * x))) / n elif (1.0 / n) <= 0.001: tmp = t_1 elif (1.0 / n) <= 1e+199: tmp = 1.0 - t_0 else: tmp = 0.3333333333333333 / (n * math.pow(x, 3.0)) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(log(Float64(x / Float64(x + 1.0))) / Float64(-n)) tmp = 0.0 if (Float64(1.0 / n) <= -1e-10) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= -5e-59) tmp = t_1; elseif (Float64(1.0 / n) <= -1e-119) tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x))) / n); elseif (Float64(1.0 / n) <= 0.001) tmp = t_1; elseif (Float64(1.0 / n) <= 1e+199) tmp = Float64(1.0 - t_0); else tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0))); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = log((x / (x + 1.0))) / -n; tmp = 0.0; if ((1.0 / n) <= -1e-10) tmp = t_0 / (x * n); elseif ((1.0 / n) <= -5e-59) tmp = t_1; elseif ((1.0 / n) <= -1e-119) tmp = ((1.0 / x) - (0.5 / (x * x))) / n; elseif ((1.0 / n) <= 0.001) tmp = t_1; elseif ((1.0 / n) <= 1e+199) tmp = 1.0 - t_0; else tmp = 0.3333333333333333 / (n * (x ^ 3.0)); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-10], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-59], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-119], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.001], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+199], N[(1.0 - t$95$0), $MachinePrecision], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log \left(\frac{x}{x + 1}\right)}{-n}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-10}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-59}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-119}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 0.001:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+199}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -1.00000000000000004e-10Initial program 96.8%
Taylor expanded in x around inf 100.0%
log-rec100.0%
mul-1-neg100.0%
associate-*r/100.0%
associate-*r*100.0%
metadata-eval100.0%
*-commutative100.0%
associate-/l*100.0%
exp-to-pow100.0%
*-commutative100.0%
Simplified100.0%
if -1.00000000000000004e-10 < (/.f64 1 n) < -5.0000000000000001e-59 or -1.00000000000000001e-119 < (/.f64 1 n) < 1e-3Initial program 31.4%
Taylor expanded in n around inf 79.9%
log1p-define79.9%
Simplified79.9%
log1p-undefine79.9%
diff-log80.1%
Applied egg-rr80.1%
clear-num80.1%
log-rec80.1%
Applied egg-rr80.1%
if -5.0000000000000001e-59 < (/.f64 1 n) < -1.00000000000000001e-119Initial program 12.8%
Taylor expanded in n around inf 42.4%
log1p-define42.4%
Simplified42.4%
Taylor expanded in x around inf 71.4%
associate-*r/71.4%
metadata-eval71.4%
Simplified71.4%
unpow271.4%
Applied egg-rr71.4%
if 1e-3 < (/.f64 1 n) < 1.0000000000000001e199Initial program 64.7%
Taylor expanded in x around 0 60.9%
*-rgt-identity60.9%
associate-/l*60.9%
exp-to-pow60.9%
Simplified60.9%
if 1.0000000000000001e199 < (/.f64 1 n) Initial program 25.5%
Taylor expanded in n around inf 6.3%
log1p-define6.3%
Simplified6.3%
Taylor expanded in x around inf 47.0%
associate--l+47.0%
associate-*r/47.0%
metadata-eval47.0%
associate-*r/47.0%
metadata-eval47.0%
Simplified47.0%
Taylor expanded in x around 0 70.8%
Final simplification82.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log (/ x (+ x 1.0))) (- n))) (t_1 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= n -1.7e+124)
(/ (log (/ (+ x 1.0) x)) n)
(if (<= n -3.7e+58)
(/ (- (/ 1.0 x) (/ 0.5 (* x x))) n)
(if (<= n -3.8e-9)
t_0
(if (<= n -2e-38)
t_1
(if (<= n 9.7e-215)
(/ 0.3333333333333333 (* n (pow x 3.0)))
(if (<= n 1400.0) t_1 t_0))))))))
double code(double x, double n) {
double t_0 = log((x / (x + 1.0))) / -n;
double t_1 = 1.0 - pow(x, (1.0 / n));
double tmp;
if (n <= -1.7e+124) {
tmp = log(((x + 1.0) / x)) / n;
} else if (n <= -3.7e+58) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else if (n <= -3.8e-9) {
tmp = t_0;
} else if (n <= -2e-38) {
tmp = t_1;
} else if (n <= 9.7e-215) {
tmp = 0.3333333333333333 / (n * pow(x, 3.0));
} else if (n <= 1400.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = log((x / (x + 1.0d0))) / -n
t_1 = 1.0d0 - (x ** (1.0d0 / n))
if (n <= (-1.7d+124)) then
tmp = log(((x + 1.0d0) / x)) / n
else if (n <= (-3.7d+58)) then
tmp = ((1.0d0 / x) - (0.5d0 / (x * x))) / n
else if (n <= (-3.8d-9)) then
tmp = t_0
else if (n <= (-2d-38)) then
tmp = t_1
else if (n <= 9.7d-215) then
tmp = 0.3333333333333333d0 / (n * (x ** 3.0d0))
else if (n <= 1400.0d0) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log((x / (x + 1.0))) / -n;
double t_1 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if (n <= -1.7e+124) {
tmp = Math.log(((x + 1.0) / x)) / n;
} else if (n <= -3.7e+58) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else if (n <= -3.8e-9) {
tmp = t_0;
} else if (n <= -2e-38) {
tmp = t_1;
} else if (n <= 9.7e-215) {
tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
} else if (n <= 1400.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, n): t_0 = math.log((x / (x + 1.0))) / -n t_1 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if n <= -1.7e+124: tmp = math.log(((x + 1.0) / x)) / n elif n <= -3.7e+58: tmp = ((1.0 / x) - (0.5 / (x * x))) / n elif n <= -3.8e-9: tmp = t_0 elif n <= -2e-38: tmp = t_1 elif n <= 9.7e-215: tmp = 0.3333333333333333 / (n * math.pow(x, 3.0)) elif n <= 1400.0: tmp = t_1 else: tmp = t_0 return tmp
function code(x, n) t_0 = Float64(log(Float64(x / Float64(x + 1.0))) / Float64(-n)) t_1 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (n <= -1.7e+124) tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n); elseif (n <= -3.7e+58) tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x))) / n); elseif (n <= -3.8e-9) tmp = t_0; elseif (n <= -2e-38) tmp = t_1; elseif (n <= 9.7e-215) tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0))); elseif (n <= 1400.0) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, n) t_0 = log((x / (x + 1.0))) / -n; t_1 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if (n <= -1.7e+124) tmp = log(((x + 1.0) / x)) / n; elseif (n <= -3.7e+58) tmp = ((1.0 / x) - (0.5 / (x * x))) / n; elseif (n <= -3.8e-9) tmp = t_0; elseif (n <= -2e-38) tmp = t_1; elseif (n <= 9.7e-215) tmp = 0.3333333333333333 / (n * (x ^ 3.0)); elseif (n <= 1400.0) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -1.7e+124], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[n, -3.7e+58], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[n, -3.8e-9], t$95$0, If[LessEqual[n, -2e-38], t$95$1, If[LessEqual[n, 9.7e-215], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1400.0], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log \left(\frac{x}{x + 1}\right)}{-n}\\
t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;n \leq -1.7 \cdot 10^{+124}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{elif}\;n \leq -3.7 \cdot 10^{+58}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\
\mathbf{elif}\;n \leq -3.8 \cdot 10^{-9}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq -2 \cdot 10^{-38}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;n \leq 9.7 \cdot 10^{-215}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\
\mathbf{elif}\;n \leq 1400:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -1.7e124Initial program 41.3%
Taylor expanded in n around inf 89.1%
log1p-define89.1%
Simplified89.1%
log1p-undefine89.1%
diff-log89.4%
Applied egg-rr89.4%
if -1.7e124 < n < -3.7000000000000002e58Initial program 23.7%
Taylor expanded in n around inf 49.6%
log1p-define49.6%
Simplified49.6%
Taylor expanded in x around inf 75.0%
associate-*r/75.0%
metadata-eval75.0%
Simplified75.0%
unpow275.0%
Applied egg-rr75.0%
if -3.7000000000000002e58 < n < -3.80000000000000011e-9 or 1400 < n Initial program 27.3%
Taylor expanded in n around inf 74.3%
log1p-define74.3%
Simplified74.3%
log1p-undefine74.3%
diff-log74.4%
Applied egg-rr74.4%
clear-num74.4%
log-rec74.4%
Applied egg-rr74.4%
if -3.80000000000000011e-9 < n < -1.9999999999999999e-38 or 9.7000000000000001e-215 < n < 1400Initial program 73.6%
Taylor expanded in x around 0 68.3%
*-rgt-identity68.3%
associate-/l*68.3%
exp-to-pow68.3%
Simplified68.3%
if -1.9999999999999999e-38 < n < 9.7000000000000001e-215Initial program 84.1%
Taylor expanded in n around inf 50.2%
log1p-define50.2%
Simplified50.2%
Taylor expanded in x around inf 27.1%
associate--l+27.1%
associate-*r/27.1%
metadata-eval27.1%
associate-*r/28.9%
metadata-eval28.9%
Simplified28.9%
Taylor expanded in x around 0 73.8%
Final simplification76.3%
(FPCore (x n)
:precision binary64
(if (<= x 7.2e-242)
(/ (log x) (- n))
(if (<= x 1.45e-202)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 0.96)
(/ (- x (log x)) n)
(if (<= x 1.3e+185) (/ (- (/ 1.0 x) (/ 0.5 (* x x))) n) (/ 0.0 n))))))
double code(double x, double n) {
double tmp;
if (x <= 7.2e-242) {
tmp = log(x) / -n;
} else if (x <= 1.45e-202) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 0.96) {
tmp = (x - log(x)) / n;
} else if (x <= 1.3e+185) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 7.2d-242) then
tmp = log(x) / -n
else if (x <= 1.45d-202) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 0.96d0) then
tmp = (x - log(x)) / n
else if (x <= 1.3d+185) then
tmp = ((1.0d0 / x) - (0.5d0 / (x * x))) / n
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 7.2e-242) {
tmp = Math.log(x) / -n;
} else if (x <= 1.45e-202) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 0.96) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 1.3e+185) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 7.2e-242: tmp = math.log(x) / -n elif x <= 1.45e-202: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 0.96: tmp = (x - math.log(x)) / n elif x <= 1.3e+185: tmp = ((1.0 / x) - (0.5 / (x * x))) / n else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 7.2e-242) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 1.45e-202) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 0.96) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 1.3e+185) tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x))) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 7.2e-242) tmp = log(x) / -n; elseif (x <= 1.45e-202) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 0.96) tmp = (x - log(x)) / n; elseif (x <= 1.3e+185) tmp = ((1.0 / x) - (0.5 / (x * x))) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 7.2e-242], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 1.45e-202], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.96], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 1.3e+185], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 7.2 \cdot 10^{-242}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-202}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 0.96:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{+185}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 7.20000000000000028e-242Initial program 35.9%
Taylor expanded in n around inf 69.0%
log1p-define69.0%
Simplified69.0%
Taylor expanded in x around 0 69.0%
neg-mul-169.0%
Simplified69.0%
if 7.20000000000000028e-242 < x < 1.44999999999999994e-202Initial program 61.3%
Taylor expanded in x around 0 61.3%
*-rgt-identity61.3%
associate-/l*61.3%
exp-to-pow61.3%
Simplified61.3%
if 1.44999999999999994e-202 < x < 0.95999999999999996Initial program 32.5%
Taylor expanded in n around inf 57.4%
log1p-define57.4%
Simplified57.4%
Taylor expanded in x around 0 56.8%
neg-mul-156.8%
sub-neg56.8%
Simplified56.8%
if 0.95999999999999996 < x < 1.3e185Initial program 46.6%
Taylor expanded in n around inf 51.6%
log1p-define51.6%
Simplified51.6%
Taylor expanded in x around inf 71.4%
associate-*r/71.4%
metadata-eval71.4%
Simplified71.4%
unpow271.4%
Applied egg-rr71.4%
if 1.3e185 < x Initial program 86.1%
Taylor expanded in n around inf 86.1%
log1p-define86.1%
Simplified86.1%
log1p-undefine86.1%
diff-log86.1%
Applied egg-rr86.1%
Taylor expanded in x around inf 86.1%
Final simplification67.6%
(FPCore (x n) :precision binary64 (if (<= x 0.96) (/ (- x (log x)) n) (if (<= x 1.9e+185) (/ (- (/ 1.0 x) (/ 0.5 (* x x))) n) (/ 0.0 n))))
double code(double x, double n) {
double tmp;
if (x <= 0.96) {
tmp = (x - log(x)) / n;
} else if (x <= 1.9e+185) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.96d0) then
tmp = (x - log(x)) / n
else if (x <= 1.9d+185) then
tmp = ((1.0d0 / x) - (0.5d0 / (x * x))) / n
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.96) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 1.9e+185) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.96: tmp = (x - math.log(x)) / n elif x <= 1.9e+185: tmp = ((1.0 / x) - (0.5 / (x * x))) / n else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 0.96) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 1.9e+185) tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x))) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.96) tmp = (x - log(x)) / n; elseif (x <= 1.9e+185) tmp = ((1.0 / x) - (0.5 / (x * x))) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.96], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 1.9e+185], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.96:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{+185}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 0.95999999999999996Initial program 37.6%
Taylor expanded in n around inf 57.0%
log1p-define57.0%
Simplified57.0%
Taylor expanded in x around 0 56.5%
neg-mul-156.5%
sub-neg56.5%
Simplified56.5%
if 0.95999999999999996 < x < 1.8999999999999999e185Initial program 46.6%
Taylor expanded in n around inf 51.6%
log1p-define51.6%
Simplified51.6%
Taylor expanded in x around inf 71.4%
associate-*r/71.4%
metadata-eval71.4%
Simplified71.4%
unpow271.4%
Applied egg-rr71.4%
if 1.8999999999999999e185 < x Initial program 86.1%
Taylor expanded in n around inf 86.1%
log1p-define86.1%
Simplified86.1%
log1p-undefine86.1%
diff-log86.1%
Applied egg-rr86.1%
Taylor expanded in x around inf 86.1%
Final simplification65.7%
(FPCore (x n) :precision binary64 (if (<= x 0.68) (/ (log x) (- n)) (if (<= x 1.05e+185) (/ (- (/ 1.0 x) (/ 0.5 (* x x))) n) (/ 0.0 n))))
double code(double x, double n) {
double tmp;
if (x <= 0.68) {
tmp = log(x) / -n;
} else if (x <= 1.05e+185) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.68d0) then
tmp = log(x) / -n
else if (x <= 1.05d+185) then
tmp = ((1.0d0 / x) - (0.5d0 / (x * x))) / n
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.68) {
tmp = Math.log(x) / -n;
} else if (x <= 1.05e+185) {
tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.68: tmp = math.log(x) / -n elif x <= 1.05e+185: tmp = ((1.0 / x) - (0.5 / (x * x))) / n else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 0.68) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 1.05e+185) tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x))) / n); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.68) tmp = log(x) / -n; elseif (x <= 1.05e+185) tmp = ((1.0 / x) - (0.5 / (x * x))) / n; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.68], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 1.05e+185], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.68:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{+185}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 0.680000000000000049Initial program 37.6%
Taylor expanded in n around inf 57.0%
log1p-define57.0%
Simplified57.0%
Taylor expanded in x around 0 55.4%
neg-mul-155.4%
Simplified55.4%
if 0.680000000000000049 < x < 1.05e185Initial program 46.6%
Taylor expanded in n around inf 51.6%
log1p-define51.6%
Simplified51.6%
Taylor expanded in x around inf 71.4%
associate-*r/71.4%
metadata-eval71.4%
Simplified71.4%
unpow271.4%
Applied egg-rr71.4%
if 1.05e185 < x Initial program 86.1%
Taylor expanded in n around inf 86.1%
log1p-define86.1%
Simplified86.1%
log1p-undefine86.1%
diff-log86.1%
Applied egg-rr86.1%
Taylor expanded in x around inf 86.1%
Final simplification65.1%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) -5.0) (/ 0.0 n) (/ (/ 1.0 x) n)))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5.0) {
tmp = 0.0 / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((1.0d0 / n) <= (-5.0d0)) then
tmp = 0.0d0 / n
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -5.0) {
tmp = 0.0 / n;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -5.0: tmp = 0.0 / n else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -5.0) tmp = Float64(0.0 / n); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -5.0) tmp = 0.0 / n; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -5.0], N[(0.0 / n), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5:\\
\;\;\;\;\frac{0}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5Initial program 100.0%
Taylor expanded in n around inf 55.5%
log1p-define55.5%
Simplified55.5%
log1p-undefine55.5%
diff-log55.5%
Applied egg-rr55.5%
Taylor expanded in x around inf 50.8%
if -5 < (/.f64 1 n) Initial program 33.6%
Taylor expanded in n around inf 62.4%
log1p-define62.4%
Simplified62.4%
Taylor expanded in x around inf 46.3%
Final simplification47.3%
(FPCore (x n) :precision binary64 (/ 1.0 (* x n)))
double code(double x, double n) {
return 1.0 / (x * n);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (x * n)
end function
public static double code(double x, double n) {
return 1.0 / (x * n);
}
def code(x, n): return 1.0 / (x * n)
function code(x, n) return Float64(1.0 / Float64(x * n)) end
function tmp = code(x, n) tmp = 1.0 / (x * n); end
code[x_, n_] := N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot n}
\end{array}
Initial program 48.7%
Taylor expanded in n around inf 60.8%
log1p-define60.8%
Simplified60.8%
Taylor expanded in x around inf 41.2%
*-commutative41.2%
Simplified41.2%
Final simplification41.2%
(FPCore (x n) :precision binary64 (/ (/ 1.0 x) n))
double code(double x, double n) {
return (1.0 / x) / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / x) / n
end function
public static double code(double x, double n) {
return (1.0 / x) / n;
}
def code(x, n): return (1.0 / x) / n
function code(x, n) return Float64(Float64(1.0 / x) / n) end
function tmp = code(x, n) tmp = (1.0 / x) / n; end
code[x_, n_] := N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{n}
\end{array}
Initial program 48.7%
Taylor expanded in n around inf 60.8%
log1p-define60.8%
Simplified60.8%
Taylor expanded in x around inf 41.7%
Final simplification41.7%
(FPCore (x n) :precision binary64 (/ x n))
double code(double x, double n) {
return x / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = x / n
end function
public static double code(double x, double n) {
return x / n;
}
def code(x, n): return x / n
function code(x, n) return Float64(x / n) end
function tmp = code(x, n) tmp = x / n; end
code[x_, n_] := N[(x / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{n}
\end{array}
Initial program 48.7%
Taylor expanded in x around 0 29.3%
Taylor expanded in x around inf 4.8%
Final simplification4.8%
herbie shell --seed 2024046
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))