Quasimatrices¶
A quasimatrix is an \(\infty \times n\) matrix whose columns are Chebfun objects defined on the same domain. This enables continuous analogues of linear algebra.
Creating a Quasimatrix¶
import numpy as np
from chebpy import Quasimatrix, chebfun
x = chebfun('x')
A = Quasimatrix([1, x, x**2, x**3, x**4, x**5])
QR Factorisation¶
The QR factorisation of a quasimatrix produces orthonormal columns (analogous to Legendre polynomials for the monomial basis):
Q, R = A.qr()
SVD¶
U, S, V = A.svd()
Least-Squares Approximation¶
Solve \(A c \approx f\) in the least-squares sense:
f = chebfun(lambda t: np.exp(t) * np.sin(6 * t), [-1, 1])
c = A.solve(f)
f_approx = A @ c # reconstruct as a Chebfun
Polynomial Fitting¶
The polyfit convenience function fits a polynomial of given degree:
from chebpy import polyfit
f = chebfun(lambda x: np.exp(x), [-1, 1])
p = polyfit(f, 5) # degree-5 polynomial least-squares fit
References¶
- L. N. Trefethen, Householder triangularization of a quasimatrix, IMA J. Numer. Anal., 30 (2010), pp. 887–897.
- Z. Battles and L. N. Trefethen, An extension of MATLAB to continuous functions and operators, SIAM J. Sci. Comput., 25 (2004), pp. 1743–1770.
- A. Townsend and L. N. Trefethen, Continuous analogues of matrix factorizations, Proc. Roy. Soc. A, 471 (2015), 20140585.