Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

RE: Sums and Products: Compact Notation and Differentiation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg23947] RE: [mg23901] Sums and Products: Compact Notation and Differentiation
  • From: "David Park" <djmp at earthlink.net>
  • Date: Fri, 16 Jun 2000 00:57:35 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

> -----Original Message-----
> From: Justus Piater [mailto:piater at cs.umass.edu]
To: mathgroup at smc.vnet.net
> Hi,
>
> I am relatively new to Mathematica (Version 3.0), and have been able
> to get sensible results using expressions involving Sum and Product
> symbols only if the summation/multiplication ranges are given by
> constants. I have the following specific problems:
>
> 1. When I have Mathematica operate on a formula involving Sum and
>    Product symbols with constant ranges, it always displays the result
>    in expanded form, without these symbols, even though it often seems
>    easily possible and much more compact to use Sums and Products. Is
>    is possible to have Mathematica retain the convenient notation, and
>    prevent it from expanding the terms?
>
> 2. I can't get Mathematica to give me simple derivatives of
>    expressions involving Sums and Products, unless the ranges are
>    known to Mathematica so it can expand them. For example, I would
>    like to type:
>
>        D[Sum[Subscript[a,i]x^i,{i,n}],x]
>
>    and get as output some rendering of:
>
>        Sum[i Subscript[a,i]x^(i-1),{i,n}]
>
>    Is this really not possible?
>
> Thanks,
> Justus
>
> --
> Justus Piater              Laboratory for Perceptual Robotics   U of Mass
> www.cs.umass.edu/~piater       Computer Vision Laboratory         Amherst
>
>

Justus,

This looks like a good place for rule-based programming. You can define a
set of rules which carry out the desired operations. In the following rules
HoldPattern is necessary on the left hand side of the rules - otherwise
Mathematica tries to evaluate the pattern Sum. The first rule does your last
example. The second rule combines two sums. The third rule changes the index
range. You can define other rules for other tasks. I changed the form of the
iterator to allow flexibility for the third rule.

s1 = Sum[Subscript[a, i]x^i, {i, 1, n}];
s2 = Sum[Subscript[b, i]x^(2i), {i, 1, n}];

rule1 = HoldPattern[Sum[term_, range_]] :> Sum[Evaluate[D[term, x]], range];
rule2 = HoldPattern[Sum[term1_, range_] + Sum[term2_, range_]] :>
      Sum[term1 + term2, range];
rule3 = HoldPattern[Sum[term_, {i_, 1, n_}]] :>
      Sum[Evaluate[term /. i -> i + 1], {i, 0, n - 1}];

s1 /. rule1
Sum[i*x^(-1 + i)*Subscript[a, i], {i, 1, n}]

s1 + s2 /. rule2
Sum[Subscript[a, i]*x^i + Subscript[b, i]*x^(2*i), {i, 1, n}]

s1 /. rule3
Sum[x^(1 + i)*Subscript[a, 1 + i], {i, 0, n - 1}]

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/



  • Prev by Date: Re: rounding off numbers
  • Next by Date: Re: Functional Expression Meaning (was:A Functional Expression Trick)
  • Previous by thread: Re: Sums and Products: Compact Notation and Differentiation
  • Next by thread: To color surfaces using z values with ContourPlot3D