Homepage › Solution manuals › Sheldon Axler › Linear Algebra Done Right › Exercise 6.C.13
Exercise 6.C.13
Answers
Proof. In this Exercise, I used the SymPy package from Python to calculate the integrals necessary for the Gram-Schmidt Procedure on the basis of and to compute the polynomial with the formula in 6.55 (i). I found the following
which, if you assume , is exactly what appers in 6.60. Here is the code used:
from sympy import * x = Symbol(’x’) def inner_product(f, g): return integrate(f*g, (x, -pi, pi)) def gs_procedure(basis): orthonormal_basis = [] for j, v_j in enumerate(basis): e_j = v_j - sum(map(lambda e_k: inner_product(v_j, e_k) * e_k, orthonormal_basis[:j - 1])) e_j = e_j / sqrt(inner_product(e_j, e_j)) orthonormal_basis.append(e_j) return orthonormal_basis def project(func, orthonormal_basis): return sum(map(lambda e_j: inner_product(func, e_j) * e_j, orthonormal_basis)) orthonormal_basis = gs_procedure([1, x, x**2, x**3, x**4, x**5]) approx_sin = project(sin(x), orthonormal_basis) p = collect(expand(approx_sin), x) print(latex(p))□