# shooting method

**URL:** <https://community.wolfram.com/t/shooting-method/7640>\
**Category:** Questions\
**Tags:** physics\
**Created:** [January 10, 2016, 11:27am UTC](https://community.wolfram.com/t/shooting-method/7640 "2016-01-10T11:27:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sghayebph](https://avatars.discourse-cdn.com/v4/letter/s/c68b51/32.png) [@sghayebph](https://community.wolfram.com/u/sghayebph)\
**Post date:** [January 10, 2016, 11:27am UTC](https://community.wolfram.com/t/shooting-method/7640/1 "2016-01-10T11:27:18Z")

</div>

Hello everybody

I want to solve Schrodinger equation for a quantum dot by shooting method. My code is:

v[x\_] := If[0 \< x \< 0.5, 0, 50];  
energy = 6;  
xMax = 5;  
solution =  
NDSolve[{psi’‘[x] + (2/x) psi’[x] == -2 (energy - v[x]) psi[x],  
psi[xMax] == 0, psi’[xMax] == 0.001}, psi, {x, 0, xMax}];  
Plot[psi[x] /. solution, {x, 0, xMax}]

The plotted wave function is not the correct one. What is my mistake?

---

<div class="post-metadata">

**Author:** ![nma](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@nma](https://community.wolfram.com/u/nma)\
**Post date:** [January 10, 2016, 11:44am UTC](https://community.wolfram.com/t/shooting-method/7640/2 "2016-01-10T11:44:35Z")

</div>

> The plotted wave function is not the correct one

You did not tell the readers what the correct one should be? But this eliminates the warnings you were getting, may be it will get you started. I have no idea what the plot should look like, or if your equation and parameters are correct or not.

```
ClearAll[x, psi, v];
v[x_] := If[0 < x < 0.5, 0, 50];
energy = 6; xMax = 1;

solution = NDSolve[{psi''[x] + (2/x) psi'[x] == -2 (energy - v[x]) psi[x],psi[xMax] == 0, psi'[xMax] == 0.001},
  psi, {x, 0.00001, xMax}, Method -> "StiffnessSwitching"]
Plot[psi[x] /. solution, {x, 0.00001, xMax}]

```

---

<div class="post-metadata">

**Author:** ![fkampas](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/fkampas/32/41217_2.png) [@fkampas](https://community.wolfram.com/u/fkampas)\
**Post date:** [January 10, 2016, 1:54pm UTC](https://community.wolfram.com/t/shooting-method/7640/3 "2016-01-10T13:54:26Z")

</div>

I’ve found the quasi-linearization has better convergence for boundary value problems than the shooting method.

> **[Iterative Solution of Highly Nonlinear Differential Equations Using...](https://library.wolfram.com/infocenter/Conferences/368/)**
>
> These are just a few of the many interesting and important problems that were previously excluded from the teaching curriculum as being too difficult but that can now be solved with Mathematica in a simple and lucid manner accessible to students. The...

---

<div class="post-metadata">

**Author:** ![sghayebph](https://avatars.discourse-cdn.com/v4/letter/s/c68b51/32.png) [@sghayebph](https://community.wolfram.com/u/sghayebph)\
**Post date:** [January 10, 2016, 3:25pm UTC](https://community.wolfram.com/t/shooting-method/7640/4 "2016-01-10T15:25:00Z")

</div>

Thanks for your reply. it should be something like the wavefunction corresponding to n=1 in the attached figure.

---

<div class="post-metadata">

**Author:** ![sghayebph](https://avatars.discourse-cdn.com/v4/letter/s/c68b51/32.png) [@sghayebph](https://community.wolfram.com/u/sghayebph)\
**Post date:** [January 10, 2016, 3:28pm UTC](https://community.wolfram.com/t/shooting-method/7640/5 "2016-01-10T15:28:21Z")

</div>

Thanks for your suggestion. Unfortunately I have to use shooting method not other numerical methods.

---

<div class="post-metadata">

**Author:** ![fkampas](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/fkampas/32/41217_2.png) [@fkampas](https://community.wolfram.com/u/fkampas)\
**Post date:** [January 10, 2016, 4:00pm UTC](https://community.wolfram.com/t/shooting-method/7640/6 "2016-01-10T16:00:59Z")

</div>

I suspect the 2/x term, which is singular at the origin, is what’s causing problems.
