-
Notifications
You must be signed in to change notification settings - Fork 2
Description
The aim is to use Magnus expansion up to 4th order for non-stochastic. We need mu0 and mu1 line integrals and Lambda(f,g), Lambda(g,f) integrals.
mu0(f, t, h, method='gl7')
mu1(f, t, h, method='scipy')
nu(f, g, t, h, method='gl3') nu(g, f, t, h, method='gl3').
Guannan can you please correct if the above order is incorrect?
Doing so separately in different functions keeps us flexible, makes it easy to do unit testing etc. However, we can also make things more efficient by exposing the Gauss--Legendre knots explicitly, e.g. by creating a function quadweights which returns the knots and weights for GL quadrature (for example)
knots, weights = quadweights('gl7')
Then we sample f and g at these knots
fv = [f(t+k*h) for k in knots]
gv = [g(t+k*h) for k in knots]
Then passing fv instead of f,
mu0(fv, t, h, method='gl7')
f should no longer need to be sampled inside the method. The method should detect whether we are passing a function handle or a list of numbers.
We have discarded weights, which will be computed or used internally again (ideally not re-computed). Similarly for nu method. This way we sample each f at 7 GL knots and then pass them on to these functions.