Rational Least Squares Approximation
Compute least squares rational approximations \(R(x) = P(x)/Q(x)\) for continuous functions using a stable SVD-based solver. Visualize, assess errors, detect poles, and export.
The Rational Approximation Problem
Given \(f \in C[a,b]\), we seek a rational function \(R(x) = P(x)/Q(x)\) of type \([m/n]\) (numerator degree \(m\), denominator degree \(n\)) that minimises the discrete \(L^2\) error over sample points \(x_i \in [a,b]\):
Linearised SVD Solver
The problem is inherently nonlinear in the denominator coefficients. We linearise by multiplying through by \(Q(x_i)\) and fixing \(q_0=1\), yielding an overdetermined linear system:
This system is solved via full SVD with pseudoinverse — no normal equations are formed, preserving numerical stability. The condition number and effective rank are reported.
Pole Detection
Zeros of the denominator \(Q(x)\) inside \([a,b]\) are poles of \(R(x)\). The tool locates them via sign-change scanning and bisection refinement. If internal poles are found, plotting is disabled to avoid singularities.
Options
- Chebyshev sampling: Uses Chebyshev nodes instead of uniform points. Recommended for higher degrees to mitigate Runge-like effects.
- Tikhonov regularisation: Adds \(\lambda\|\mathbf{q}\|^2\) penalty on denominator coefficients to improve conditioning in near-degenerate cases.
Why Rational over Polynomial?
Rational approximations often converge much faster than polynomials for functions with poles, branch points, or steep gradients near \([a,b]\). They are the backbone of Padé approximation and are widely used for special functions (exponential, trigonometric, Bessel, etc.).
Export
After fitting, \(R(x)\) can be exported in LaTeX, Python, or MATLAB format. The plot (SVG) and data (CSV) are also downloadable.