MathGroup Archive 2008

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

Search the Archive

Re: DO loop

  • To: mathgroup at smc.vnet.net
  • Subject: [mg91298] Re: DO loop
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Thu, 14 Aug 2008 06:59:38 -0400 (EDT)
  • References: <g7uo2f$5uj$1@smc.vnet.net>

Hi,

since you where not so kind to provide a working example here is
one
a) define the potential:

V[eps_, sigma_][r_] := With[{x = sigma/r}, 4*eps*(x^12 - x^6)]

b) compute the radii

LJRadii[eps_, sigma_][e_] :=
  Select[r /. Solve[V[eps, sigma][r] == e, r],
   FreeQ[#, _Complex] && # > 0 &]

c) define a integral condition

BohrSommerfeld[eps_, sigma_, m_: 1, hbar_: 1][e_, n_Integer] /;
   e < 0 :=
  Module[{r1, r2, r},
   {r1, r2} = LJRadii[eps, sigma][e];
   NIntegrate[
    Sqrt[2]*Sqrt[m*(hbar*n + (4*eps*sigma^6*(r^6 - sigma^6))/r^12)],
    {r, r1, r2}]
   ]

d) and now, comes the "DO loop", that compute the function
for energy values between [-0.9,-0.01] in steps of 0.0125

BohrSommerfeld[1, 1][#, 0] & /@ Table[e, {e, -0.9, -0.01, 0.0125}]

Ooops ! there is no "DO loop", let try a version with out
stuff like "&" and "/@"

Table[BohrSommerfeld[1, 1][e, 0],{e, -0.9, -0.01, 0.0125}]

Now lets make a matrix

Table[BohrSommerfeld[1, 1][e, n], {e, -0.9, -0.01, 0.0125}, {n, 0, 4}]

and there is again no  "DO loop"  and I never found out for what a
"DO loop" is good for in Mathematica. I had times where I forgot
the syntax, that can be found by typing

?Do

Regards
   Jens




maria wrote:
> Dear all,
> 
> I am new with mathematica and I have the following problem:
> I want  to repeat a procedure that involves a two main functions for a
> precise number of times. Which would be the format of a do loop in
> mathematica in order to calculate them and write the results of each
> iteration to a matrix?
> In order to be more exact I want to solve the following :
> 
> I have a function........
> 
> Vz[r_]=1/r
> intE = EA + e
> ........................which I solve and the real solutions are the
> intergartion limits at  the intergral that follows
> Solve[Vz[r] == intE, r]
> 
> olok = NIntegrate[f1[r], {r, Ra, Rb}] // N;
> 
> I would like to repeat this procure for several e values and write a
> matrix.
> I future I  would like to include a second function in the do loop
> which is also a function of e.
> 
> Thank you in advance.
> 
> Greetings
> Maria
> 


  • Prev by Date: Re: Re: More Inquiries
  • Next by Date: Re: minimize with complex numbers
  • Previous by thread: Re: DO loop
  • Next by thread: debugging code that contains compile