series_functions¶
shortfx.fxNumeric.series_functions
¶
Series and summation formulas.
Provides arithmetic, geometric, harmonic, Taylor/Maclaurin, Fourier, and binomial series evaluations from Spiegel's Mathematical Handbook.
Functions¶
abel_sum(series: list[float], r: float = 0.99) -> float
¶
Compute the Abel sum of a series: Σ a_n r^n.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
series
|
list[float]
|
List of series terms a_n. |
required |
r
|
float
|
Value in [0, 1) (default 0.99). |
0.99
|
Returns:
| Type | Description |
|---|---|
float
|
Abel sum. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If series is not a list or r is not numeric. |
ValueError
|
If series is empty or r not in [0, 1). |
Usage Example
round(abel_sum([1, -1, 1, -1, 1, -1], 0.5), 4) 0.6562
Complexity: O(n)
Source code in shortfx/fxNumeric/series_functions.py
alternating_series_sum(f: Callable[[int], float], n: int) -> float
¶
Computes an alternating series sum_{k=0}^{n-1} (-1)^k f(k).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
Callable[[int], float]
|
Term function f(k). |
required |
n
|
int
|
Number of terms (>= 1). |
required |
Returns:
| Type | Description |
|---|---|
float
|
The alternating sum. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If n is not an integer. |
ValueError
|
If n < 1. |
Example
alternating_series_sum(lambda k: 1/(k+1), 4) 0.5833333333333333
Complexity: O(n)
Source code in shortfx/fxNumeric/series_functions.py
arithmetic_series_sum(a: float, d: float, n: int) -> float
¶
Computes the sum of an arithmetic series: a + (a+d) + ... + (a+(n-1)d).
S_n = n/2 * (2a + (n-1)d).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
First term. |
required |
d
|
float
|
Common difference. |
required |
n
|
int
|
Number of terms (>= 1). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Sum of the series. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If a or d are not numeric, or n is not an integer. |
ValueError
|
If n < 1. |
Example
arithmetic_series_sum(1, 2, 5) 25.0
Complexity: O(1)
Source code in shortfx/fxNumeric/series_functions.py
basel_series(terms: int = 1000) -> float
¶
Approximates pi^2/6 using the Basel series: sum 1/k^2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
terms
|
int
|
Number of terms (>= 1). |
1000
|
Returns:
| Type | Description |
|---|---|
float
|
Approximation of pi^2/6. |
Example
round(basel_series(10000), 4) 1.6449
Complexity: O(terms)
Source code in shortfx/fxNumeric/series_functions.py
bbp_pi_digit(n: int) -> float
¶
Compute π using the Bailey-Borwein-Plouffe formula (partial sum).
π = Σ_{k=0}^{n} (1/16^k)(4/(8k+1) - 2/(8k+4) - 1/(8k+5) - 1/(8k+6))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of terms (0-indexed). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Approximation of π. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If n is not an integer. |
ValueError
|
If n < 0. |
Usage Example
round(bbp_pi_digit(10), 10) 3.1415926536
Complexity: O(n)
Source code in shortfx/fxNumeric/series_functions.py
binomial_series(alpha: float, x: float, terms: int = 20) -> float
¶
Evaluates the generalized binomial series (1+x)^alpha for |x| < 1.
(1+x)^alpha = sum_{k=0}^{inf} C(alpha, k) x^k where C(alpha, k) is the generalized binomial coefficient.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alpha
|
float
|
Exponent (any real number). |
required |
x
|
float
|
Argument (|x| < 1 for convergence when alpha is not a non-negative integer). |
required |
terms
|
int
|
Number of series terms (>= 1). |
20
|
Returns:
| Type | Description |
|---|---|
float
|
Approximation of (1+x)^alpha. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If alpha or x are not numeric or terms is not an integer. |
ValueError
|
If |x| >= 1 and alpha is not a non-negative integer, or terms < 1. |
Example
round(binomial_series(0.5, 0.5, 30), 6) 1.224745
Complexity: O(terms)
Source code in shortfx/fxNumeric/series_functions.py
cesaro_sum(series: list[float]) -> float
¶
Compute the Cesàro sum of a series.
The Cesàro sum is the limit of the arithmetic means of partial sums.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
series
|
list[float]
|
List of series terms. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Cesàro sum (arithmetic mean of partial sums). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If series is not a list. |
ValueError
|
If series is empty. |
Usage Example
cesaro_sum([1, -1, 1, -1, 1, -1]) 0.5
Complexity: O(n)
Source code in shortfx/fxNumeric/series_functions.py
chudnovsky_pi(terms: int = 5) -> float
¶
Approximate π using the Chudnovsky algorithm.
Very fast convergence: ~14 digits per term.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
terms
|
int
|
Number of terms (default 5, gives ~70 digits). |
5
|
Returns:
| Type | Description |
|---|---|
float
|
Approximation of π. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If terms is not an integer. |
ValueError
|
If terms < 1. |
Usage Example
round(chudnovsky_pi(2), 10) 3.1415926536
Complexity: O(terms)
Source code in shortfx/fxNumeric/series_functions.py
convergent_sequence(f, x0: float, terms: int = 100) -> list[float]
¶
Generate a convergent sequence by repeated application x_{n+1} = f(x_n).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
Callable mapping float → float. |
required | |
x0
|
float
|
Initial value. |
required |
terms
|
int
|
Number of iterations (default 100). |
100
|
Returns:
| Type | Description |
|---|---|
list[float]
|
List of sequence values. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If x0 is not numeric or terms is not int. |
Usage Example
seq = convergent_sequence(lambda x: (x + 2/x)/2, 1.0, 10) round(seq[-1], 4) 1.4142
Complexity: O(terms)
Source code in shortfx/fxNumeric/series_functions.py
euler_maclaurin_sum(f, a: int, b: int, terms: int = 4) -> float
¶
Approximate Σ_{k=a}^{b} f(k) using the Euler-Maclaurin formula.
Uses the trapezoidal rule with Bernoulli number corrections. Only first few correction terms are applied.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
Callable accepting a numeric argument. |
required | |
a
|
int
|
Lower limit (integer). |
required |
b
|
int
|
Upper limit (integer). |
required |
terms
|
int
|
Number of Bernoulli correction terms (default 4). |
4
|
Returns:
| Type | Description |
|---|---|
float
|
Approximation of the sum. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If a or b is not int. |
ValueError
|
If a > b. |
Usage Example
round(euler_maclaurin_sum(lambda k: 1/k, 1, 100), 2) 4.68
Complexity: O(b - a)
Source code in shortfx/fxNumeric/series_functions.py
fourier_coefficients(f: Callable[[float], float], period: float, n_terms: int, n_points: int = 1000) -> Tuple[List[float], List[float]]
¶
Computes numerical Fourier series coefficients a_n and b_n.
f(x) ~ a_0/2 + sum_{n=1}^{N} [a_n cos(2pinx/T) + b_n sin(2pinx/T)]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
Callable[[float], float]
|
Periodic function to decompose. |
required |
period
|
float
|
Period T of the function. |
required |
n_terms
|
int
|
Number of Fourier terms (>= 1). |
required |
n_points
|
int
|
Integration sample points (>= 100). |
1000
|
Returns:
| Type | Description |
|---|---|
List[float]
|
Tuple (a_coeffs, b_coeffs) where a_coeffs[0] is a_0 and |
List[float]
|
b_coeffs[0] is always 0. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If period or n_terms are invalid. |
ValueError
|
If period <= 0 or n_terms < 1. |
Example
import math a, b = fourier_coefficients(math.sin, 2 * math.pi, 3) round(b[1], 2) 1.0
Complexity: O(n_terms * n_points)
Source code in shortfx/fxNumeric/series_functions.py
fourier_series_eval(a_coeffs: List[float], b_coeffs: List[float], period: float, x: float) -> float
¶
Evaluates a Fourier series at point x given its coefficients.
f(x) ~ a_0/2 + sum_{n=1}^{N} [a_n cos(2pinx/T) + b_n sin(2pinx/T)]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a_coeffs
|
List[float]
|
Cosine coefficients [a_0, a_1, ...]. |
required |
b_coeffs
|
List[float]
|
Sine coefficients [b_0, b_1, ...]. |
required |
period
|
float
|
Period T. |
required |
x
|
float
|
Evaluation point. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Approximated function value. |
Example
fourier_series_eval([0, 0], [0, 1], 2 * math.pi, math.pi / 2) 1.0
Complexity: O(n_terms)
Source code in shortfx/fxNumeric/series_functions.py
generalized_harmonic(n: int, s: float) -> float
¶
Computes the generalized harmonic number H_{n,s} = sum_{k=1}^{n} 1/k^s.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of terms (>= 1). |
required |
s
|
float
|
Exponent (> 0). |
required |
Returns:
| Type | Description |
|---|---|
float
|
H_{n,s}. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If n is not an integer or s is not numeric. |
ValueError
|
If n < 1 or s <= 0. |
Example
round(generalized_harmonic(10, 2), 6) 1.549768
Complexity: O(n)
Source code in shortfx/fxNumeric/series_functions.py
geometric_series_infinite(a: float, r: float) -> float
¶
Computes the sum of an infinite geometric series: a / (1 - r).
Converges only when |r| < 1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
First term. |
required |
r
|
float
|
Common ratio (|r| < 1). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Sum of the infinite series. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If a or r are not numeric. |
ValueError
|
If |r| >= 1. |
Example
geometric_series_infinite(1, 0.5) 2.0
Complexity: O(1)
Source code in shortfx/fxNumeric/series_functions.py
geometric_series_sum(a: float, r: float, n: int) -> float
¶
Computes the sum of a finite geometric series: a + ar + ar^2 + ... + ar^{n-1}.
S_n = a(1 - r^n) / (1 - r) when r != 1, or S_n = n*a when r == 1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
First term. |
required |
r
|
float
|
Common ratio. |
required |
n
|
int
|
Number of terms (>= 1). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Sum of the series. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If a or r are not numeric, or n is not an integer. |
ValueError
|
If n < 1. |
Example
geometric_series_sum(1, 0.5, 10) 1.998046875
Complexity: O(1)
Source code in shortfx/fxNumeric/series_functions.py
gregory_leibniz_pi(terms: int = 1000) -> float
¶
Approximate π using the Gregory-Leibniz series.
π/4 = 1 - 1/3 + 1/5 - 1/7 + ···
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
terms
|
int
|
Number of terms (default 1000). |
1000
|
Returns:
| Type | Description |
|---|---|
float
|
Approximation of π. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If terms is not an integer. |
ValueError
|
If terms < 1. |
Usage Example
round(gregory_leibniz_pi(10000), 3) 3.141
Complexity: O(terms)
Source code in shortfx/fxNumeric/series_functions.py
harmonic_series_partial(n: int) -> float
¶
Computes the n-th partial sum of the harmonic series H_n = sum_{k=1}^{n} 1/k.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of terms (>= 1). |
required |
Returns:
| Type | Description |
|---|---|
float
|
H_n. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If n is not an integer. |
ValueError
|
If n < 1. |
Example
round(harmonic_series_partial(10), 6) 2.928968
Complexity: O(n)
Source code in shortfx/fxNumeric/series_functions.py
leibniz_pi(terms: int = 1000) -> float
¶
Approximates pi/4 using the Leibniz formula: sum (-1)^k / (2k+1).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
terms
|
int
|
Number of terms (>= 1). |
1000
|
Returns:
| Type | Description |
|---|---|
float
|
Approximation of pi/4. |
Example
round(leibniz_pi(10000) * 4, 4) 3.1415
Complexity: O(terms)
Source code in shortfx/fxNumeric/series_functions.py
madhava_pi(terms: int = 50) -> float
¶
Approximate π using Madhava's series (predecessor to Gregory-Leibniz).
π = √12 Σ_{k=0}^{N} (-1)^k / ((2k+1)·3^k)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
terms
|
int
|
Number of terms (default 50). |
50
|
Returns:
| Type | Description |
|---|---|
float
|
Approximation of π. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If terms is not an integer. |
ValueError
|
If terms < 1. |
Usage Example
round(madhava_pi(20), 10) 3.1415926536
Complexity: O(terms)
Source code in shortfx/fxNumeric/series_functions.py
nilakantha_pi(terms: int = 1000) -> float
¶
Approximate π using the Nilakantha series.
π = 3 + 4/(2·3·4) - 4/(4·5·6) + 4/(6·7·8) - ···
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
terms
|
int
|
Number of terms (default 1000). |
1000
|
Returns:
| Type | Description |
|---|---|
float
|
Approximation of π. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If terms is not an integer. |
ValueError
|
If terms < 1. |
Usage Example
round(nilakantha_pi(100), 4) 3.1416
Complexity: O(terms)
Source code in shortfx/fxNumeric/series_functions.py
p_series_partial(n: int, p: float) -> float
¶
Computes the partial sum of the p-series sum_{k=1}^{n} 1/k^p.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of terms (>= 1). |
required |
p
|
float
|
Exponent. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Partial sum. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If n is not an integer or p is not numeric. |
ValueError
|
If n < 1. |
Example
round(p_series_partial(1000, 2), 4) 1.6439
Complexity: O(n)
Source code in shortfx/fxNumeric/series_functions.py
power_series_eval(coefficients: List[float], x: float) -> float
¶
Evaluates a power series sum_{k=0}^{n} a_k x^k using Horner's method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coefficients
|
List[float]
|
List of coefficients [a_0, a_1, ..., a_n]. |
required |
x
|
float
|
Evaluation point. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Value of the power series at x. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If coefficients is not a list or x is not numeric. |
ValueError
|
If coefficients is empty. |
Example
power_series_eval([1, 0, -0.5], 1.0) 0.5
Complexity: O(n)
Source code in shortfx/fxNumeric/series_functions.py
ramanujan_pi(terms: int = 10) -> float
¶
Approximate π using Ramanujan's series.
1/π = (2√2/9801) Σ (4k)!(1103+26390k)/((k!)⁴ 396^{4k})
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
terms
|
int
|
Number of terms (default 10). |
10
|
Returns:
| Type | Description |
|---|---|
float
|
Approximation of π. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If terms is not an integer. |
ValueError
|
If terms < 1. |
Usage Example
round(ramanujan_pi(2), 10) 3.1415926536
Complexity: O(terms)
Source code in shortfx/fxNumeric/series_functions.py
taylor_asin(x: float, terms: int = 50) -> float
¶
Approximates arcsin(x) via the Maclaurin series for |x| <= 1.
arcsin(x) = sum_{n=0}^{inf} (2n)! / (4^n (n!)^2 (2n+1)) x^{2n+1}.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Argument in [-1, 1]. |
required |
terms
|
int
|
Number of terms (>= 1). |
50
|
Returns:
| Type | Description |
|---|---|
float
|
Approximation of arcsin(x). |
Example
round(taylor_asin(0.5, 50), 6) 0.523599
Complexity: O(terms)
Source code in shortfx/fxNumeric/series_functions.py
taylor_atan(x: float, terms: int = 50) -> float
¶
Compute arctan(x) via Taylor/Maclaurin series.
For |x| ≤ 1: arctan(x) = Σ (-1)^n x^{2n+1}/(2n+1). For |x| > 1: uses identity arctan(x) = π/2 - arctan(1/x).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Input value. |
required |
terms
|
int
|
Number of series terms (default 50). |
50
|
Returns:
| Type | Description |
|---|---|
float
|
Approximation of arctan(x). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If x is not numeric. |
Usage Example
round(taylor_atan(1.0), 4) 0.7804
Complexity: O(terms)
Source code in shortfx/fxNumeric/series_functions.py
taylor_atanh(x: float, terms: int = 50) -> float
¶
Compute arctanh(x) via Taylor series for |x| < 1.
atanh(x) = Σ x^{2n+1}/(2n+1)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Input in (-1, 1). |
required |
terms
|
int
|
Number of series terms (default 50). |
50
|
Returns:
| Type | Description |
|---|---|
float
|
Approximation of atanh(x). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If x is not numeric. |
ValueError
|
If |x| ≥ 1. |
Usage Example
round(taylor_atanh(0.5), 4) 0.5493
Complexity: O(terms)
Source code in shortfx/fxNumeric/series_functions.py
taylor_cos(x: float, terms: int = 20) -> float
¶
Approximates cos(x) using the Maclaurin series.
cos(x) = sum_{n=0}^{inf} (-1)^n x^{2n} / (2n)!.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Argument in radians. |
required |
terms
|
int
|
Number of series terms (>= 1). |
20
|
Returns:
| Type | Description |
|---|---|
float
|
Approximation of cos(x). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If x is not numeric or terms is not an integer. |
ValueError
|
If terms < 1. |
Example
round(taylor_cos(0, 20), 10) 1.0
Complexity: O(terms)
Source code in shortfx/fxNumeric/series_functions.py
taylor_cosh(x: float, terms: int = 30) -> float
¶
Compute cosh(x) via Taylor series.
cosh(x) = Σ x^{2n}/(2n)!
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Input value. |
required |
terms
|
int
|
Number of series terms (default 30). |
30
|
Returns:
| Type | Description |
|---|---|
float
|
Approximation of cosh(x). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If x is not numeric. |
Usage Example
round(taylor_cosh(1.0), 4) 1.5431
Complexity: O(terms)
Source code in shortfx/fxNumeric/series_functions.py
taylor_exp(x: float, terms: int = 50) -> float
¶
Compute e^x via Taylor series.
e^x = Σ_{n=0}^{N} x^n/n!
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Input value. |
required |
terms
|
int
|
Number of terms (default 50). |
50
|
Returns:
| Type | Description |
|---|---|
float
|
Approximation of e^x. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If x is not numeric. |
Usage Example
round(taylor_exp(1.0), 4) 2.7183
Complexity: O(terms)
Source code in shortfx/fxNumeric/series_functions.py
taylor_ln1p(x: float, terms: int = 50) -> float
¶
Approximates ln(1+x) using the Maclaurin series for |x| <= 1.
ln(1+x) = x - x^2/2 + x^3/3 - ...
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Argument in (-1, 1]. |
required |
terms
|
int
|
Number of series terms (>= 1). |
50
|
Returns:
| Type | Description |
|---|---|
float
|
Approximation of ln(1+x). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If x is not numeric or terms is not an integer. |
ValueError
|
If x <= -1 or x > 1, or terms < 1. |
Example
round(taylor_ln1p(0.5, 50), 6) 0.405465
Complexity: O(terms)
Source code in shortfx/fxNumeric/series_functions.py
taylor_log1p(x: float, terms: int = 100) -> float
¶
Compute ln(1+x) via Taylor series for |x| ≤ 1.
ln(1+x) = Σ_{n=1}^{N} (-1)^{n+1} x^n/n
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Input value in (-1, 1]. |
required |
terms
|
int
|
Number of terms (default 100). |
100
|
Returns:
| Type | Description |
|---|---|
float
|
Approximation of ln(1+x). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If x is not numeric. |
ValueError
|
If x ≤ -1 or x > 1. |
Usage Example
round(taylor_log1p(0.5), 4) 0.4055
Complexity: O(terms)
Source code in shortfx/fxNumeric/series_functions.py
taylor_sin(x: float, terms: int = 20) -> float
¶
Approximates sin(x) using the Maclaurin series.
sin(x) = sum_{n=0}^{inf} (-1)^n x^{2n+1} / (2n+1)!.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Argument in radians. |
required |
terms
|
int
|
Number of series terms (>= 1). |
20
|
Returns:
| Type | Description |
|---|---|
float
|
Approximation of sin(x). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If x is not numeric or terms is not an integer. |
ValueError
|
If terms < 1. |
Example
round(taylor_sin(math.pi / 2, 20), 10) 1.0
Complexity: O(terms)
Source code in shortfx/fxNumeric/series_functions.py
taylor_sinh(x: float, terms: int = 30) -> float
¶
Compute sinh(x) via Taylor series.
sinh(x) = Σ x^{2n+1}/(2n+1)!
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Input value. |
required |
terms
|
int
|
Number of series terms (default 30). |
30
|
Returns:
| Type | Description |
|---|---|
float
|
Approximation of sinh(x). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If x is not numeric. |
Usage Example
round(taylor_sinh(1.0), 4) 1.1752
Complexity: O(terms)
Source code in shortfx/fxNumeric/series_functions.py
vieta_pi(terms: int = 30) -> float
¶
Approximate π using Vieta's infinite product.
2/π = √2/2 · √(2+√2)/2 · √(2+√(2+√2))/2 · ···
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
terms
|
int
|
Number of nested radicals (default 30). |
30
|
Returns:
| Type | Description |
|---|---|
float
|
Approximation of π. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If terms is not an integer. |
ValueError
|
If terms < 1. |
Usage Example
round(vieta_pi(20), 4) 3.1416
Complexity: O(terms)
Source code in shortfx/fxNumeric/series_functions.py
wallis_pi(terms: int = 1000) -> float
¶
Approximate π using Wallis' product.
π/2 = Π_{n=1}^{∞} (4n²)/(4n²-1)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
terms
|
int
|
Number of terms (default 1000). |
1000
|
Returns:
| Type | Description |
|---|---|
float
|
Approximation of π. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If terms is not an integer. |
ValueError
|
If terms < 1. |
Usage Example
round(wallis_pi(10000), 4) 3.1415
Complexity: O(terms)
Source code in shortfx/fxNumeric/series_functions.py
zeta_even(n: int) -> float
¶
Compute ζ(2n) = (-1)^{n+1} B_{2n} (2π)^{2n} / (2(2n)!).
Uses Bernoulli numbers for exact even-integer values of zeta.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Positive integer (computes ζ(2n)). |
required |
Returns:
| Type | Description |
|---|---|
float
|
ζ(2n). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If n is not an integer. |
ValueError
|
If n < 1. |
Usage Example
round(zeta_even(1), 4) 1.6449
Complexity: O(n²) for Bernoulli computation