wolfram-mathematicaroot-finding

Root finding with quadrature


I have a problem with root finding and am having difficulty in getting it to work in this instance.

Some complicated function I need.

f[x_, lambda_, alpha_, beta_, mu_] = 
   Module[{gamma}, 
     gamma = Sqrt[alpha^2 - beta^2]; 
     (gamma^(2*lambda)/((2*alpha)^(lambda - 1/2)*Sqrt[Pi]*Gamma[lambda]))*
      Abs[x - mu]^(lambda - 1/2)*
      BesselK[lambda - 1/2, alpha Abs[x - mu]] E^(beta (x - mu))
   ];

A function I want to find the root of is defined as the integral of this function so I use quadrature:

F[x_, lambda_, alpha_, beta_, mu_] := 
    NIntegrate[f[t, lambda, alpha, beta, mu], {t, 0, x}]; 

Now the problem, mathematica has difficulty solving the roots of this equation,

Q[u_, lambda_, alpha_, beta_, mu_] := 
    x /. FindRoot[F[x, lambda, alpha, beta, mu] == u, {x, 1}]

Does anybody know why? The integral is defined at all points in R. f here is a density function and F its CDF.

Thanks for reading.


Solution

  • Try using := instead of = in the definition of f and see if that helps.

    Incidentally when you use this SetDelayed syntax, you don't need semicolons to suppress output, because it doesn't immediately create output.

    Here is some sample output, courtesy of belisarius and WReach:

    enter image description here