Re: A Problem with x[i_]:=

*To*: mathgroup at smc.vnet.net*Subject*: [mg82983] Re: A Problem with x[i_]:=*From*: Szabolcs Horvát <szhorvat at gmail.com>*Date*: Tue, 6 Nov 2007 03:39:17 -0500 (EST)*References*: <fgmq4o$9tv$1@smc.vnet.net>

John wrote: > The assignment, x=N[Total[-2Log[((n)(pdpd)/v[I])^v[i]]],10], executes > for i=1,2,..,10, and I can make a list of the 10 outcomes by repeating > the assignment 10 times. > > I thought that the assignment, x[i_]:=N{Total[-2Log[((n)(pdpd)/ > v[i])^v[i]]],10], would make a list of the 10 outcomes, without the > necessity of manual repetitions, but Mathematica rejected it. > > The error message tells me that my assignment won't execute because > times is protected. > You have to clear x, Clear[x], before you can assign to x[i_]. E.g.\ if you do x = 2a and then try x[n_] = n^2 then Mathematica will interpret the second definition as (2a)[n_] = n^2, i.e.\ Times[2, a][n_] = n^2 To make a table with different values of a parameter, use Table. For example, Table[n^2, {n, 1, 10}] produces a table of squares. -- Szabolcs