MathGroup Archive 2004

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

Search the Archive

Re: Problem with loops in Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg49757] Re: [mg49693] Problem with loops in Mathematica
  • From: DrBob <drbob at bigfoot.com>
  • Date: Fri, 30 Jul 2004 06:02:09 -0400 (EDT)
  • References: <200407291142.HAA10118@smc.vnet.net>
  • Reply-to: drbob at bigfoot.com
  • Sender: owner-wri-mathgroup at wolfram.com

Try

Table[Table[S u^j d^(n - j) p^j q^(n - j), {j, 0, n}], {n, 0, 5}]

or

Table[S u^j d^(# - j) p^j q^(# - j), {j, 0, #}] & /@ Range[0, 5]

or

f = Table[S u^j d^(# - j) p^j q^(# - j), {j, 0, #}] &;
Array[f[# - 1] &, {6}]

Bobby

On Thu, 29 Jul 2004 07:42:57 -0400 (EDT), Kristofer Eklundh <kristofer_eklundh at spray.se> wrote:

> Hi all,
>
> I am trying to work out the value of S at different nodes in a
> binomial tree, using the following formula:
>
> Table[S u^j d^(n - j) p^j q^(n - j), {j, 0, n}]
>
> I would like to loop this in some way so that I don't have to assign
> new values to n all the time (S, d, p, q are given). I have tried For
> and Do, but when i print the result, Mathematica produces n lists that
> are equal to the final value of n, and not for n=0,1,..., n-1.
>
> Anyone who could help me with this?
>
>
>



-- 
DrBob at bigfoot.com
www.eclecticdreams.net


  • Prev by Date: Re: pattern matching and droping elements from list of lists.
  • Next by Date: Re: Wolfram Technology Conference 2004: Call for Submissions
  • Previous by thread: Problem with loops in Mathematica
  • Next by thread: Re: Problem with loops in Mathematica