I want to solve the radial part of Schrodinger equation by shooting method. In this method I set the initial value of energy and appropriate boundary conditions. By varying the value of energy the best wave function, which satisfies the boundary conditions, is found. My code is:
Now I want to make a loop to change the value of energy and again recalculate the wave function until the correct wave function is obtained. I used Do[expr,{i,imin,imax,di}] but it didnt work. Please guide me how to make a loop to change the energy and plot wave functions for each value of energy.
?again it doesn’t give the correct answer. it should be something like the attached file. one more thing is that this approach doesn’t give us the energy value for which the wave function has been plotted.
What should I do?
It would be easier to read your code if you put it into a “code sample” block, which is the first icon.
I suggest that you first test your solution[energy] function to see if it gives the correct result for the correct energy. Also note that the code I posted as an illustration can be split up to get the value found by FindRoot. Since there are multiple eigenvalues, you need to give FindRoot starting values near the correct result.
Thanks a million for all your hints and suggestions. I used ParametricNDSolve function and fortunately it worked. now I want to have legend on the graph to label wave function corresponding to each energy value. how should I do that? is that PlotLegend function?