Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Problem with integration for WKB approximation

  1. Apr 29, 2010 #1
    problem with integration for WKB approximation in MATLAB

    hi all,
    i have been having troubles with getting matlab to solve the following problem (the language is not the matlab one, the functions are not solvable by the symbolic integration and i was trying to get one of the quad functions to do it)(r1,r2 are numbers):


    As you can see the problem is that inside the cosinues there is an integral that goes from r ( variable of the first integral) to r2, so i can t solve it numerically, because i need it in function of r in order to perform the big integral.

    I thought a couple integral function would exist but i am not able to find any ( the doublequad only works if its only one function integreded twice).

    I hope what i wrote cna be understood, and appreciate your help and time!
    Last edited: Apr 29, 2010
  2. jcsd
  3. Apr 29, 2010 #2
    hi all,
    i found the answer a couple hours ago, even if accuracy hasn t been the best, it is just now a matter of choosing the right integration algorithm withim matlab.
    I have until now write it using quad, basically the principle is that every time the outside integration wants to evaluate the function at a certain point, i evaluate the inner integral starting at that point. i m posting my solution so maybe it can help somebody else, thanks for looking at my post. so the code looks like this:

    solutionTest= quad((@integrand2),r1,r2)

    % then here is integrand 2, the letters are global constants

    function valor = integrand2(r)

    % here i have to see how many steps there are and for each of those i do
    % the numerical integration inside
    steps1 = size(r);
    steps = steps1(1,2);
    % and for each step i perform the integration

    while i <steps+1

    valores(i) = 1./(((Q-calculateVTotal1(r(i))).*2*reducedMass/(hbar^2)).^(1/2))*cos( quad((@integrand1),r(i),r2)).^2;
    valor = valores;

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook