I am taking a computational linear algebra course and i got stuck during a homework problem concerning the computation of inner products. I am supposed to compute the inner product:$$\mathrm{a}_{\mathrm{k}}=\frac{\left(\mathrm{g}_{\mathrm{k}} \mid \mathrm{f}\right)}{\left(\mathrm{g}_{\mathrm{k}} \mid \mathrm{g}_{\mathrm{k}}\right)}$$ for several values of k.

The inner product is defined as $$(U \mid V)=\int_{-1}^{1} U(x) V(x) d x$$The function $$ f = f(x)=\frac{1}{1+25 x^{2}}$$ and $g_{k}$ are the Legendre polynomials in the interval [-1, 1].

Is there any built-in command in NumPy that could be useful? I tried symbolic manipulation using SymPy but it did not go well. After that, i wrote the basic loop together with the relevant matrices, but i still cannot compute those inner products.

Any help is appreciated. Thanks in advance!

  • $\begingroup$ You don't need anything symbolic for this; ultimately the integral are going to be done numerically, so it will boil down to evaluating a sum of elements of a vector. $\endgroup$ – Maxim Umansky Oct 25 '20 at 2:28
  • $\begingroup$ @MaximUmansky That is the integral of a rational function; it can be computed exactly, in principle. $\endgroup$ – Federico Poloni Oct 25 '20 at 7:15
  • $\begingroup$ Your f is Runge’s example, which Chebyshev polynomials were born to deal with. You could use Clenshaw-Curtis integration, which uses them. This is what ChebPy does: github.com/chebpy/chebpy $\endgroup$ – Amit Hochman Oct 25 '20 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.