JuliaMath / HCubature.jl

pure-Julia multidimensional h-adaptive integration
Other
153 stars 25 forks source link

non rectangular integral #16

Closed hesampour closed 5 years ago

hesampour commented 5 years ago

how we can compute a non rectangular integral (which some boundaries of the integral is a variable not a static value) with this package: something like this: image

MasonProtter commented 5 years ago

I believe that needs to be done with nested one-dimensional integrals.

hesampour commented 5 years ago

@MasonProtter would you please explain more?

MasonProtter commented 5 years ago

Suppose I want to compute the integral:

image

I can't express this as a simple integral over some square domain (unless there is some clever change or basis allowed by F). Instead, one has to treat it as two nested integrals, ie:

hquadrature(u -> hquadrature(v -> F(u, v), u, t), 0, t)
stevengj commented 5 years ago

Don’t use nested 1d adaptive integrals. That is almost always suboptimal because the inner adaptation doesn’t know about the outer integral.

You can use HCubature via a change of variables. In your example above, just change variables in the inner integral from u to u=z*(t-v)+v where z goes from 0 to 1, with a Jacobian factor of t-v multiplying the integrand.