How to integrate twice numerically
If you don't want to work too hard at this, I believe the
multidimensional software at
http://mathalacarte.com/cb/mom.fcg/ya63 may be what you are looking for.
It is I believe the most efficient software out there for
multidimensional integrals up to dimension 3 or 4 or so, and will let
you take advantage of some of the structure that is in your problem.
If you want to work a bit harder, you may save computing time by making
up a new function, say q(z) = \int_a^z f(t) dt. This could be done by
doing an indefinite integration. Ideally there would be quadrature
software for doing this, but I don't know of it. The ODE software at
http://mathalacarte.com/cb/mom.fcg/ya64 has provision for saving the
solution, and thus you could save the solution to y' = f(t) over the
interval [a, x] using this software and then use interpolation (provided
by this software) as the definition of q(z). The former approach would
require considerably less work on your part. If the second approach is
used, you can save a bit of work by skipping the evaluation of f(t)
after the corrected value is obtained.
If you actually want H(x) for a bunch of different x values which can be
obtained in sequential order, you may find it faster to use an ode
solver to get these once you have a q(z).
Unless you are doing a lot of these computations with functions f and g
that are expensive to compute the quadrature software is what I would
recommend. Also if f(t) is much more expensive to compute that g(z) (in
your first case) you would probably be ahead to use integration by parts
to make the inner integral be an integral of g.
Note, I am the vendor of this software and depending on your use, you
may be expected to pay for it if you use it. Details are on the site at
http://mathalacarte.com/.
Regards,
Fred
|