1

I have to integrate expression f(x) * g(x) for many different functions f but just one g.

I want to integrate it as sum of weighted values of f(x) * g(x) instead of calculating the table. Note that in Python I may write:

sum(w[i] * f(x[i]) * g(x[i]) for i in range(2 ** k + 1))

as:

wg = [w[i] * g(x[i]) for i in range(2 ** k + 1)]
sum(wg[i] * f(x[i]) for i in range(2 ** k + 1))

where w[i] are weights of function values used by the Romberg method which may be calculated like:

import numpy as np
from scipy.integrate import romb

w = romb(np.eye(2 ** k + 1))

Is such implementation of Romberg method safe?

(The question has been also asked at CS: https://scicomp.stackexchange.com/questions/35469/is-romberg-integration-method-implemented-as-weighted-function-values-numericall)

abukaj
  • 2,582
  • 1
  • 22
  • 45
  • 2
    Consider posting at [Computational Science SE](https://scicomp.stackexchange.com/) if you don't get enough attention here. If you decide to proceed, please, delete this post or at least cross-link them. – Anton Menshov Jul 02 '20 at 02:34
  • @AntonMenshov cross-linked – abukaj Jul 02 '20 at 08:40

0 Answers0