I've made a lot of progress on my problem the last few days thanks to all the help I've received on here. I think I'm upto the final step of greatly improving the performance of NIntegrate[..] on my setup.

I have an integral that looks like

$$\int^{x_f}_{x_i} \mathrm{d}x\, \exp{(ix)} \exp{(i\omega t(x))} \phi^*(x)$$

(* refers to complex conjugation).The $\exp{(ix)}$ is slowly oscillatory compared with everything else. The $x_i,x_f$ are negative; typical values might be $-115,-75$, the closer you get to $-4/3$ the more problematic things get, $x>x_h=-4/3$. Similarly the bigger $\omega$ gets the more oscillatory things are.

The function $t(x)$ is

$$t(x)=3x_h (x/x_h)^{1/3}+x-3x_h\text{arctanh}{\left((x_h/x)^{1/3}\right)}$$

and satisfies



$$\phi''(r)+\frac{2(r-1)}{r(r-2)} \phi'(r)+\left(\frac{\omega^2 r^2}{(r-2)^2}-\frac{2}{r(r-2)}\right)\phi(r)=0$$

where $r=2(x/x_h)^{2/3}$. So this can be transformed into an ODE in x.

Is it possible using this information to construct the "DifferentialMatrices" and "Kernel" of the LevinRule?

If this turns out not to be possible, is it possible to tell Mathematica to use LevinRule only in some finite range of integration where one of the above factors becomes non-oscillatory and I can lump it in the amplitude.

  • $\begingroup$ Clarifications: 1. Does phi^* refer to the complex conjugate? 2. Did you mean to write x_i, x_f not tau_i, tau_f? $\endgroup$ Oct 20, 2012 at 19:59
  • $\begingroup$ yes, complex conjugate (satisfying same ODE as \phi does), and yes I meant x_i,x_f sorry (edited). $\endgroup$
    – fpghost
    Oct 20, 2012 at 20:33
  • $\begingroup$ your differential equation does not specify $\phi$ unambiguously. We need boundary conditions as well for the integral to be defined(?) $\endgroup$
    – chris
    Oct 20, 2012 at 20:41
  • $\begingroup$ @chris the ICs for this $\phi$ are complicated, and would involve me giving a host a new definitions in the above. Do you really need them to deduce the LevinRule "DifferentialMatrices" and "Kernel" from the above? (I can put them in if so, but I think all you need to get these quantities is the ODE) $\endgroup$
    – fpghost
    Oct 21, 2012 at 8:23
  • $\begingroup$ I must wonder, have you by any chance already read the original papers by David Levin? $\endgroup$ Oct 21, 2012 at 10:16

1 Answer 1


How about this?

The $\phi$ ODE in terms of $x$ looks like


Let's write this as


which defines $f(x),g(x)$.

Now to construct Kernel and Differential Matrices

Make the choice:

$$w_1=\exp(i\omega t(x))\phi^*$$ $$w_2=w_1'=i\omega t' w_1+\exp{(i\omega t)}(\phi^{*})'$$

The second equation gives us something that will be useful later: $\exp(i\omega t) (\phi^*)'=w_2-i\omega t' w_1$

Then we automatically have components $A_{11}=0$, $A_{12}=1$ of the differential matrices the tricky part is getting the other two.

Now take the derivative of $w_2$ which is $w_1''$, using the useful relation I mentioned and the ODE in $\phi$, this can be shown to be

$$w_2=w_1[-i\omega t'(2i\omega t'-f)+i\omega t''-g-\omega^2 (t')^2]+w_2(2i\omega t'-f)$$

This gives us

$$A_{12}=[-i\omega t'(2i\omega t'-f)+i\omega t''-g-\omega^2 (t')^2]$$ $$A_{22}=(2i\omega t'-f)$$

Now all that is left is to simply sub into this $f(x),g(x),t'(x),t''(x)$ that we know from above.

Then the rules are specified as "Kernel->{w_1,w_2}", "DifferentialMatrices"->{{A_{11},A_{12}},{A_{21},A_{22}}.


Strangely this shows no time improvement (it actually takes a bit longer than default) although gives answer in agreement.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.