Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #13652

Re: how to set initial values to symbolic variable array?

From Murray Eisenberg <murray@math.umass.edu>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: how to set initial values to symbolic variable array?
Date 2013-03-01 02:24 +0000
Message-ID <kgp3hd$ct2$1@smc.vnet.net> (permalink)
References <20130228044555.115C46877@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


Not clear why you're calling f a function, or why you "manually" add the four elements of the array. To answer your question:

  arr = Array[a, 4];
  f = Total[arr];
  f /. a[_] -> 1

 
On Feb 27, 2013, at 11:45 PM, Jon <devout1977@gmail.com> wrote:

>
> Dear All,
>
> Suppose I defined a symbolic variable array as
>
> Array[a,4]
>
> and defined a function as
>
> f = a[1] + a[2] + a[3] + a[4]
>
> I need to evaluate the value of f in the following way,
>
> f/.{a[1]->1,a[2]->1, ...}
>
> but specify each element of the array one by one is very troublesome, and I
> wonder whether there is something like a group definition like
>
> f/.{a[1:4]->1}
>
> to define the four variables at the same time with the same value.
>
> Thanks for your help,
>
> Sincerely,
> John
>

---
Murray Eisenberg                                    murray@math.umass.edu
Mathematics & Statistics Dept.      
Lederle Graduate Research Tower            phone 413 549-1020 (H)
University of Massachusetts                               413 545-2838 (W)
710 North Pleasant Street                         fax   413 545-1801
Amherst, MA 01003-9305





Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: how to set initial values to symbolic variable array? Murray Eisenberg <murray@math.umass.edu> - 2013-03-01 02:24 +0000

csiph-web