Q: Combining NDSolve with FindRoot

*To*: mathgroup at smc.vnet.net*Subject*: [mg13282] Q: Combining NDSolve with FindRoot*From*: trivedi at yukawa.uchicago.edu (Anil Trivedi)*Date*: Fri, 17 Jul 1998 03:18:32 -0400*Organization*: University of Chicago*Sender*: owner-wri-mathgroup at wolfram.com

I am new to mathematica and would appreciate any help with a conceptual obstacle I am encountering. Trying to learn mathematica, I thought I would verify the following. The "harmonic oscillator" equation: y''[x] + (2e-x^2) * y[x] =0, y[0]=1, y'[0]=0 has solutions which vanish for large x only if e is one of the eigenvalues e= 0.5, 2.5, 4.5, 6.5, etc.. How can I generate this series, or the exact function e[n] = 2n+1/2 where n=0,1,2,..? Focussing on the first eigenvalue e = 0.5, let us try to (i) solve the equation with NDSolve, (ii) evaluate the soln at some large x = L, (iii) call the resulting function z[e], and (iv) use FindRoot to solve z[e]=0, with a good intitial guess like 0.45. :) This plan sounds nice but here are the obstacles: 1. NDSolve needs numerical coefficients. How to use it with a parameter like e? 2. How to use FindRoot with an implit function like z[e] above? All examples I have seen are with an explicit function. 3. If I want to specify the accuracy of the answer (say 6 decimal places), where do I do it? In FindRoot, NDSolve, or both? 3. Assuming I can do this for one eigenvalue, what is the best "mathematica way" of iterating the procedure to obtain the first N eigenvalues? (I doubt it is Do loop, but I don't know what it is.) Thanks, Anil Trivedi