Re: Modifying equations

*To*: mathgroup at smc.vnet.net*Subject*: [mg59164] Re: Modifying equations*From*: dh <dh at metrohm.ch>*Date*: Sun, 31 Jul 2005 01:30:39 -0400 (EDT)*References*: <dcf38r$lfr$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Hi Kalle, see below. sincerely Daniel Kalle Rutanen wrote: > Hello > > My intention is to write a mathematical paper which derives results step by > step. So here is my first question: > > Given the equations > eqn1 = a == b > eqn2 = c == d > > How can I combine these to form (for example) > a + c == b + d ? you must thread Plus over the head Equal: Thread[Plus[eqn1, eqn2], Equal] > > I tried the obvious eqn1 + eqn2, but that does not seem to work... > > Second question: > > Given this: > Sum[a_i, {i, 0, n}] + Sum[b_i, {i, 0, n}] > How can I make Mathematica combine the sums giving: > Sum[a_i + b_i, {i, 0, n}] ? this can be done e.g. by a rule: r = HoldPattern[Sum[f1_, {i, 0, n}] + Sum[f2_, {i, 0, n}]] :> Sum[f1 + f2, {i, 0, n}]; The HoldPattern is needed because f1 and f2 do not explicitely mention i and Mathematica would otherwise take f1 and f2 as independent of i. Application of this rule gives the result you want: Sum[a[i], {i, 0, n}] + Sum[b[i], {i, 0, n}] /. r note that your example a_i and b_i is WRONG. Either you can define a and b as functions od i and would write a[i] and b[i] or you take it as arrays: a[[i]], b[[i]] > > Thanks. > >