From: Bob Hanlon on 3 May 2010 06:11 Array[((-1)^(# + 1) (x)^#)/#! &, 3, 1] // Total x^3/6 - x^2/2 + x Plus @@ Array[((-1)^(# + 1) (x)^#)/#! &, 3, 1] x^3/6 - x^2/2 + x Sum[(-1)^(n + 1) x^n/n!, {n, 3}] x^3/6 - x^2/2 + x Series[1 - E^-x, {x, 0, 3}] // Normal x^3/6 - x^2/2 + x % == %% == %%% == %%%% True Bob Hanlon ---- davef <davidfrick2003(a)yahoo.com> wrote: ============= I want to evaluate a sum from a series I created using the Array function. For example; I specify Array[((-1)^(# + 1) (x)^#)/# ! &, 3, 1 ] which gives me the following 3 terms of output: {x, -(x^2/2), x^3/6} Can anyone tell if and how I can turn these 3 terms into a sum to be evaluated?
From: Laszlo Sturmann on 3 May 2010 06:12 davef wrote: > I want to evaluate a sum from a series I created using the Array > function. > > For example; I specify > > Array[((-1)^(# + 1) (x)^#)/# ! &, 3, 1 ] > > which gives me the following 3 terms of output: > > {x, -(x^2/2), x^3/6} > > Can anyone tell if and how I can turn these 3 terms into a sum to be > evaluated? > > > Apply[Plus, Array[((-1)^(# + 1) (x)^#)/#! &, 3, 1]] LS
From: Murray Eisenberg on 3 May 2010 06:11 Very simple: Apply[Plus, Array[((-1)^(# + 1) (x)^#)/# !&, 3, 1 ]] Or, using the prefix @@ abbreviation for Apply: Plus @@ Array[((-1)^(# + 1) (x)^#)/#! &, 3, 1] Or, with a newer specialized function in Mathematica: Total[Array[((-1)^(# + 1) (x)^#)/#! &, 3, 1]] Or: Total @ Array[((-1)^(# + 1) (x)^#)/#! &, 3, 1] On 5/2/2010 5:35 AM, davef wrote: > I want to evaluate a sum from a series I created using the Array > function. > > For example; I specify > > Array[((-1)^(# + 1) (x)^#)/# !&, 3, 1 ] > > which gives me the following 3 terms of output: > > {x, -(x^2/2), x^3/6} > > Can anyone tell if and how I can turn these 3 terms into a sum to be > evaluated? > -- Murray Eisenberg murray(a)math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305
|
Pages: 1 Prev: Function construction and also symmetric matrices Next: space between Output cels |