๐ข Sequences & Series
Infinite sequences and series allow us to approximate complex functions using simple polynomials. This is the foundation of many numerical algorithms.
๐ข 1. Sequences
A sequence is an ordered list of numbers {anโ}.
- Convergence: A sequence {anโ} converges to L if limnโโโanโ=L.
- Divergence: If the limit doesnโt exist or is infinite.
Common Sequences
- Arithmetic: anโ=a1โ+(nโ1)d.
- Geometric: anโ=a1โrnโ1 (converges if โฃrโฃ<1 to 0).
๐ก 2. Infinite Series
An infinite series is the sum of a sequence: โn=1โโanโ.
Geometric Series
โn=0โโarn converges if and only if โฃrโฃ<1. Sum=1โraโ
Divergence Test
If limnโโโanโ๎ =0, then the series โanโ must diverge.
๐ด 3. Tests for Convergence
To determine if a series converges without finding its sum:
- Integral Test: Compare the series to โซ1โโf(x)dx.
- P-Series Test: โnp1โ converges if p>1.
- Comparison Test: Compare with a known convergent/divergent series.
- Ratio Test: limnโโโโฃanโan+1โโโฃ=L. Converges if L<1, diverges if L>1.
- Alternating Series Test: For sums like โ(โ1)nbnโ.
๐ฏ 4. Power Series and Taylor Series
A Power Series is a function of the form f(x)=โn=0โโcnโ(xโa)n.
Taylor and Maclaurin Series
A Taylor Series represents a function f(x) as an infinite sum of its derivatives at a point a: f(x)=โn=0โโn!f(n)(a)โ(xโa)n
If a=0, it is called a Maclaurin Series: f(x)=f(0)+fโฒ(0)x+2!fโฒโฒ(0)โx2+โฆ
Common Maclaurin Series
- ex=โn!xnโ=1+x+2!x2โ+โฆ
- sin(x)=โ(โ1)n(2n+1)!x2n+1โ=xโ3!x3โ+โฆ
- cos(x)=โ(โ1)n(2n)!x2nโ=1โ2!x2โ+โฆ
๐ก Practical Example: Calculating Pi with a Series
The Gregory-Leibniz series for ฯ/4: 4ฯโ=1โ31โ+51โโ71โ+โฏ=โn=0โโ2n+1(โ1)nโ
def estimate_pi(n_terms):
pi_over_4 = 0
for n in range(n_terms):
pi_over_4 += ((-1)**n) / (2*n + 1)
return pi_over_4 * 4
# More terms = more precision
print(f"PI (10 terms): {estimate_pi(10)}")
print(f"PI (10,000 terms): {estimate_pi(10000)}")
๐ Key Takeaways
- Sequences are lists, series are sums.
- Convergence tests tell us if an infinite sum is finite.
- Taylor Series allow us to approximate any โwell-behavedโ function with a polynomial.