Lesson 7 of 18

p-Series

p-Series

A p-series has the form:

sum_{k=1}^{infty} rac{1}{k^p} = 1 + rac{1}{2^p} + rac{1}{3^p} + cdots

Convergence Test

The p-series converges if and only if p>1p > 1.

ppSeriesConverges?Limit
11harmonic sum1/ksum 1/kNoinftyinfty
22Basel sum1/k2sum 1/k^2Yespi2/6approx1.6449pi^2/6 approx 1.6449
33Apéry sum1/k3sum 1/k^3Yesapprox1.2021approx 1.2021
44sum1/k4sum 1/k^4Yespi4/90approx1.0823pi^4/90 approx 1.0823

Why p=1 Diverges

Group the harmonic series:

ight) + left( rac{1}{5}+cdots+ rac{1}{8} ight) + cdots$$ Each group sums to at least $ rac{1}{2}$, so the total diverges. ### Why p=2 Converges The Basel problem — Euler showed the sum equals $ rac{pi^2}{6}$ using the factorization of $ rac{sin(x)}{x}$. Numerically, the partial sums converge slowly: $S_{1000} approx 1.6439$, approaching $1.6449$. ### Your Task Implement `double p_series(int p, int n)` that computes $sum_{k=1}^n rac{1}{k^p}$. Use a loop to compute $k^p$ without `math.h`.
TCC compiler loading...
Loading...
Click "Run" to execute your code.