MathGroup Archive 2008

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

Search the Archive

Re: Re: Re: Need Help

  • To: mathgroup at smc.vnet.net
  • Subject: [mg94725] Re: [mg94652] Re: [mg94637] Re: Need Help
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Sun, 21 Dec 2008 05:54:59 -0500 (EST)
  • References: <200812181222.HAA00451@smc.vnet.net>
  • Reply-to: drmajorbob at longhorns.com

The 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 Fri, 19 Dec 2008 06:22:39 -0600, Oyedeji, Kale <koyedeji at morehouse.edu>
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.
>
> 'Kale
>
>
>
>
> 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}]
>
> -----Original Message-----
> From: Bill Rowe [mailto:readnews at sbcglobal.net]
> Sent: 18 December 2008 07:22
> To: mathgroup at smc.vnet.net
> Subject: [mg94652] [mg94637] Re: Need Help
>
> On 12/17/08 at 6:33 AM, koyedeji at morehouse.edu (Oyedeji, Kale) wrote:
>
>> Thannks Daniel for your advice. I changed Evaluate to RSolve but
>> still got the same result. What I wanted was a calculation of S[k]
>> and R[k] for every k. I wanted a random number generated for each k.
>> I expect S[1]= some number, R[1]= some number for each k.
>
>> Thanks also for calling my attention to CopyAs.Plain Text.
>
>> 'Kale
>
>> With[{B=8,f=3x10^-5},
>> sol=RSolve[{S[k+1]==R[k]*B*Table[Random[],{10000}]-f*S[k]*R[k],R[k=
> +1
>> ]==f*S[k]*R[k], S[0]==3400, R[0]==9}, {S,R}, {k,0,10000}]]
>
> It is still unclear as to what you are trying to accomplish
> here. RSolve is meant to solve a recurrence relationship. That
> is find a set of rules relate the n+1th member of a sequence to
> some number of previous sequence values that can reproduce the
> sequence. That is RSolve is trying to find rules of the form
>
> f[n+1] == a g[n] + b h[n-1] + ...
>
> I don't see how you can expect to find any consistent set of
> rules if you substitute random integers for the arguments. So,
> what is it you are trying to accomplish here?
>
>
>



-- 
DrMajorBob at longhorns.com


  • References:
  • Prev by Date: Re: Debugging Mathematica
  • Next by Date: Re: Need Help
  • Previous by thread: Re: Need Help
  • Next by thread: Re: Need Help