MathGroup Archive 2004

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

Search the Archive

Re: Conflict between Mathematica 4.1 and 5.01?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg46064] Re: Conflict between Mathematica 4.1 and 5.01?
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Wed, 4 Feb 2004 02:29:33 -0500 (EST)
  • Organization: The University of Western Australia
  • References: <bvpb3r$se2$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In article <bvpb3r$se2$1 at smc.vnet.net>, Hugh Walker <hwalker at gvtc.com> 
wrote:

There have been other related postings about this topic. Ensuring that e 
in pistol is numeric (so as to prevent premature evaluation of pistol by 
eigenValue) is required:

sol[V_, e_, {q_, qLeft_, qRight_}] :=
   First[psi /. NDSolve[{(-(1/2))*Derivative[2][psi][q] +
         V*psi[q] == e*psi[q], psi[qLeft] == 0,
       Derivative[1][psi][qLeft] == 1}, psi,
      {q, qLeft, qRight}]]

pistol[V_, e_?NumericQ, {q_, qLeft_, qRight_}] :=
   sol[V, e, {q, qLeft, qRight}][qRight]

eigenValue[V_, eStart_, {q_, qLeft_, qRight_}] :=
   e /. FindRoot[pistol[V, e, {q, qLeft, qRight}] == 0,
     {e, eStart, eStart + 0.01*Abs[eStart]}]

eigenValue[0.5*q^2, 0.4, {q, -4., 4.}]

Cheers,
Paul

> I run under Mac OS X 10.2.8 on an iMac.
> 
> The code below was extracted from a package I wrote some time ago using 
> Mathematica 4.1. Recently I upgraded to 5.01.
> 
> If I execute the last line in 4.1, everything works as intended. 
> However, the identical code executed in 5.01 results in numerous fatal 
> errors. I find nothing in the 5.01 documentation that indicates any 
> such incompatibility. My frustration has boiled over. When pasted in a 
> 4.1 notebook, this code works; but the same code bombs out when pasted 
> in a 5.01 notebook. Can anyone spot the cause of this very strange 
> behavior? Can anyone reproduce these results?
> 
> The job of the code snippets is to solve an eigenvalue problem by the 
> shooting method. The particular example here ought to produce the 
> ground state energy of the simple oscillator. Any comments would be 
> most welcome.
> 
> sol[V_, e_, {q_, qLeft_, qRight_}] :=
>    First[psi /. NDSolve[{(-(1/2))*Derivative[2][psi][q] +
>          V*psi[q] == e*psi[q], psi[qLeft] == 0,
>        Derivative[1][psi][qLeft] == 1}, psi,
>       {q, qLeft, qRight}]]
> 
> pistol[V_, e_, {q_, qLeft_, qRight_}] :=
>    sol[V, e, {q, qLeft, qRight}][qRight]
> 
> eigenValue[V_, eStart_, {q_, qLeft_, qRight_}] :=
>    e /. FindRoot[pistol[V, e, {q, qLeft, qRight}] == 0,
>      {e, eStart, eStart + 0.01*Abs[eStart]}]
> 
> eigenValue[0.5*q^2, 0.4, {q, -4., 4.}]
> 
> 
> ==========
> Hugh Walker
>

-- 
Paul Abbott                                   Phone: +61 8 9380 2734
School of Physics, M013                         Fax: +61 8 9380 1014
The University of Western Australia      (CRICOS Provider No 00126G)         
35 Stirling Highway
Crawley WA 6009                      mailto:paul at physics.uwa.edu.au 
AUSTRALIA                            http://physics.uwa.edu.au/~paul


  • Prev by Date: Re: How do I Copy an error message to a text document, as text?
  • Next by Date: Re: FactorTerms
  • Previous by thread: Conflict between Mathematica 4.1 and 5.01?
  • Next by thread: FactorTerms