# Problem with integration for WKB approximation

1. Apr 29, 2010

### magimbu

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):

int(function*cos(int(function2,rprime,r,r2)),r,r1,r2)

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!
JN

Last edited: Apr 29, 2010
2. Apr 29, 2010

### magimbu

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:

% 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);
i=1;
% 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;
i=i+1;
end
valor = valores;

end