MathGroup Archive 2008

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

Search the Archive

Re: Need Help

  • To: mathgroup at smc.vnet.net
  • Subject: [mg94726] Re: Need Help
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Sun, 21 Dec 2008 05:55:12 -0500 (EST)
  • References: <200812181222.HAA00451@smc.vnet.net> <gig3m7$2ee$1@smc.vnet.net>
  • Reply-to: drmajorbob at longhorns.com

I told you the source of the error before, and I've sent that e-mail a  
second time.

But here it is again:

The (posted) code works fine here, and should work fine in v5, v6, or v7  
equally, at any machine.

The error message indicates, however, that this is NOT the code you ran.  
Instead it might have been something like

B = 8.;
f = 3. 10^-5;
n = 10;
S[0] = 3400;
R[0] = 9;
Do[
   S[k + 1] = R[k]*B Random[] - f*S[k]*R[k],
   R[k + 1] = f*S[k]*R[k];
   , {k, 0, 10}]

which does produce the error you've described. The difference is a comma  
where the first semicolon should be.

The second semicolon inside Do, meanwhile, is superfluous, so the code  
could be

B = 8.;
f = 3. 10^-5;
n = 10;
S[0] = 3400;
R[0] = 9;
Do[S[k + 1] = R[k]*B Random[] - f*S[k]*R[k];
  R[k + 1] = f*S[k]*R[k], {k, 0, 10}]

or better yet,

Clear[s, r]
b = 8.;
f = 3. 10^-5;
n = 10;
s[0] = 3400;
r[0] = 9;
s[k_] := r[k - 1]*b Random[] - f*s[k - 1]*r[k - 1]
r[k_] := r[k] = f*s[k - 1]*r[k - 1]

r /@ Range[10]

{0.918, 0.00165976, 3.28952*10^-8, 2.50056*10^-15, 1.73884*10^-26,
  1.69476*10^-45, 1.99353*10^-75, 2.14779*10^-124, 1.16712*10^-203,
  3.134039192015273*10^-331}

s /@ Range[10]

{5.24239, 7.1013, 0.00960136, 6.17858*10^-8, 1.3811*10^-14,
  4.54394*10^-26, 6.23853*10^-45, 1.38576*10^-74, 1.69909*10^-123,
  6.33387*10^-203}

Bobby

On Sat, 20 Dec 2008 09:33:25 -0600, Oyedeji, Kale <koyedeji at morehouse.edu>  
wrote:

> For a novice like me, it will help if Bobby tells me the source of the
> error.
>
> Thanks.
>
> 'Kale
>
> -----Original Message-----
> From: DrMajorBob [mailto:btreat1 at austin.rr.com]
> Sent: 20 December 2008 09:50
> To: Oyedeji, Kale; Jean-Marc Gulliet; mathgroup at smc.vnet.net
> Cc: dh; Bill Rowe
> Subject: Re: Need Help
>
> Wrong. That's NOT the source of the error, and the semicolon has ZERO
> effect there.
>
> Bobby
>
> On Sat, 20 Dec 2008 00:50:24 -0600, Oyedeji, Kale
> <koyedeji at morehouse.edu>
> wrote:
>
>> I thank Jean-Marc, Daniel, Bob, and Bill for all your assistance. All
>
>> your suggestions worked perfectly. It  took me a while to see the
> source
>> of the error was in not placing a semi-colon before the comma in R[k +
>
>> 1] = f*S[k]*R[k];,
>>
>> Thank you all for your time.
>>
>> 'Kale
>>
>> -----Original Message-----
>> From: Jean-Marc Gulliet [mailto:jeanmarc.gulliet at gmail.com]
>> Sent: Saturday, December 20, 2008 1:03 AM
>> To: Oyedeji, Kale; mathgroup at smc.vnet.net
>> Subject: Re: Need Help
>>
>> Oyedeji, Kale wrote:
>>
>>> Bill, thanks for your comment. I have two iterative implicit
> functions
>>> S[k] and R[k] for which I plotted these functions versus k. But now
>>> wants to see the effect of including a random function in the
> expression
>>> for S[k]. Daniel made suggestion that seem to work except that I was
>>> getting  some error message from his suggestion shown below. The
> error
>>> message is Do::itform: Argument R[k+1]=f S[k] R[k] at position 2 does
>>> not have the correct form for an iterator. >>. Will someone please
> help
>>> out. I spent hours in the Help pages of Mathematica, ver 6 without
>>> success. I am afraid to load ver 7 as of now.
>>
>> <snip>
>>
>> Kale,
>>
>> I have tried the code you posted and haven't get any error or warning
>> messages (Mathematica 6.0.3 on 64-bit Mac OS X 10.5.6). However, both
>> sequences converge swiftly towards zero.
>>
>> B = 8.;
>>
>> f = 3. 10^-5;
>>
>> n = 10;
>>
>> S[0] = 3400;
>>
>> R[0] = 9;
>>
>> Do[S[k + 1] = R[k]*B Random[] - f*S[k]*R[k];
>>   R[k + 1] = f*S[k]*R[k];, {k, 0, 10}]
>>
>> ?S
>>
>> Global`S
>>
>> S[0]=3400
>>
>> S[1]=50.7733
>>
>> S[2]=3.17097
>>
>> S[3]=0.00512872
>>
>> S[4]=7.01914*10^-7
>>
>> S[5]=1.56343*10^-13
>>
>> S[6]=1.15181*10^-24
>>
>> S[7]=5.86043*10^-42
>>
>> S[8]=9.93852*10^-71
>>
>> S[9]=3.9327*10^-116
>>
>> S[10]=1.48464*10^-190
>>
>> S[11]=7.525530556855338*10^-311
>>
>>
>> ?R
>>
>> Global`R
>>
>> R[0]=9
>>
>> R[1]=0.918
>>
>> R[2]=0.0013983
>>
>> R[3]=1.33019*10^-7
>>
>> R[4]=2.04665*10^-14
>>
>> R[5]=4.30971*10^-25
>>
>> R[6]=2.02138*10^-42
>>
>> R[7]=6.98472*10^-71
>>
>> R[8]=1.228*10^-116
>>
>> R[9]=3.66136*10^-191
>>
>> R[10]=4.319715040784381*10^-311
>>
>> R[11]=1.923966547814739*10^-505
>>
>>
>> Regards,
>> -- Jean-Marc
>
>
>



-- 
DrMajorBob at longhorns.com


  • References:
  • Prev by Date: Re: Re: Re: Need Help
  • Next by Date: Re: Decimals from the "Get Coordinates" Tool
  • Previous by thread: Re: Re: Re: Need Help
  • Next by thread: Re: Need Help