MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Q: Combining NDSolve with FindRoot

  • To: mathgroup at
  • Subject: [mg13382] Re: Q: Combining NDSolve with FindRoot
  • From: Paul Abbott <paul at>
  • Date: Thu, 23 Jul 1998 03:32:30 -0400
  • Organization: University of Western Australia
  • References: <6okkoi$>
  • Sender: owner-wri-mathgroup at

[Contact the author to obtain the notebook or go to -

Anil Trivedi wrote:

> 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,..?

See the attached Notebook (taken from an exam question from my
computational physics course here at UWA) which addresses a similar
> Focussing on the first eigenvalue e = 0.5, let us try to (i) solve the
> equation with NDSolve,

BTW, here is one way of doing this (assuming that you already know the

	NDSolve[{y''[x] + (1 - x^2)*y[x] == 0, y[0] == 1, y'[0] == 0}, 	
		y[x], {x, -5, 5}]; 

Plot and compare with the exact solution:

	Plot[Evaluate[{HermiteH[0, x]/E^(x^2/2), y[x] /. First[%]}], 
		{x, -5, 5}, PlotStyle -> {Hue[1/3], Hue[1]}]; 

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

Basically, I think that you would need to use a series solution method,
after factoring off the appropriate asymptotic form, to compute the
eigenvalue in this way.  Alternatively, the Notebook demonstrates a
general matrix method for the approximate determination of the

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

The matrix method with an n x n matrix yields the first n eigenvalues.


Paul Abbott                                   Phone: +61-8-9380-2734
Department of Physics                           Fax: +61-8-9380-1014
The University of Western Australia            Nedlands WA  6907       
mailto:paul at  AUSTRALIA                   

            God IS a weakly left-handed dice player

  • Prev by Date: Re: Conditions on patterns in Flat functions
  • Next by Date: $BatchOutput
  • Previous by thread: Q: Combining NDSolve with FindRoot
  • Next by thread: Mandelbrot