thesnorlax
thesnorlax

Reputation: 91

How to get Matlab to integrate with respect to another function?

Say I want to find the value of a stieltjes integral f(x) dg(x) from a to b. In other words, integrate f(x) with respect to g(x). I know the variable and function values and I'm looking for a numerical result.

Is there a standard function in Matlab that does this? I've been calculating it somewhat manually by rectangle method, would any Matlab function be faster and/or more accurate?

I haven't had much experience with Matlab, and I can't find the solution in the documentation. Any help would be appreciated! :)

Upvotes: 1

Views: 1778

Answers (1)

Mohsen Nosratinia
Mohsen Nosratinia

Reputation: 9864

There is no function to support this but if you have the derivative of either functions you can use quad (or other members of quad family). If you have the derivative of g(x) then

integral(a,b) f(x) dg(x) = integral(a,b) f(x) g'(x) dx [[if g'(x) is bounded ]]

and if you have the derivative of f(x) you can use integration by parts to get

integral(a,b) f(x) g'(x) dx = f(b)g(b) - f(a)g(a) - integral(a,b) f'(x) g(x) dx

Upvotes: 1

Related Questions