Physics updates and multi-index summation

December 05 2013 ecterrab 1169

2

Hi,
Relevant developments in Physics happened during the last month and a 1/2, some of them of interest beyond the use of this package. Among the most exciting things I can mention:

  1. The redefinition of the derivative rule for the complex components (abs, argument, conjugate, Im, Re, signum) together with the introduction of Wirtinger calculus, as an user-option to work with complex variables. In other words: it is now possible to compute taking z and its conjugate as independent variables and in equal footing.
  2. Introduction of textbook mathematical display for all the inert functions of the mathematical language, also for unknown functions f(x).
  3. New options in Physics:-Setup to indicate that some mathematical objects are real (different from assume(x, real), while integrated with `is` and `coulditbe`).
  4. A rather large number of micro developments advancing the integration of Physics with simplify, expand and combine.
  5. Another large number of micro developments for quantum mechanics.
  6. New options in Physics:-Setup to redefine sum as Physics:-Library:-Add, and with that have access to multiindex summation directly from sum, for instance as in sum(f(i, j), i + j <= n), including related typesetting copy & paste.

As usual the latest version of the package is available for download in the Maplesoft Physics: Research & Development webpage  and in the zip there is a worksheet illustrating all these developments. Below I'm copying the section related to the new redefinesum option of Physics:-Setup and multiindex summation.

Thanks to everyone who provided feedback, it has been of great value and at the root of this new round of developments.

December 4

 
• 

New option in Setup: redefinesum, so that the sum command is redefined in such a way that
    a) the sum arguments are processed in a way avoiding premature evaluation and related unexpected results or error interruptions
    b) the sum command includes new functionality present in Physics:-Library:-Add to perform sum over integer values of many indices, as in

"(&sum;)S(i,j)"     or  "(&sum;)S(i,j)" 

restart; with(Physics); Setup(notation = true)

`* Partial match of  'notation' against keyword 'mathematicalnotation'`

 

[mathematicalnotation = true]

(1.1)

New option: redefine sum so that its arguments are processed by the more modern Physics:-Library:-Add and so that it can perform multiindice summation.

 

Example:

By default, the sum command is not redefined, so the value of redefinesum is

Setup(redefinesum)

[redefinesum = false]

(1.2)

Consider this multiindex summation functionality of the Physics:-Library:-Add command

Library:-Add(f[i, j], 1 <= i+j and i+j <= n)

Physics:-Library:-Add(f[i, j], i+j <= n, lowerbound = 1)

(1.3)

For instance, for n = 2,

eval(Physics[Library]:-Add(f[i, j], i+j <= n, lowerbound = 1), n = 2)

f[0, 1]+f[1, 0]+f[0, 2]+f[1, 1]+f[2, 0]

(1.4)

This functionality can be plugged directly into the sum command. For that purpose, set redefinesum to true

Setup(redefinesum = true)

[redefinesum = true]

(1.5)

You can now compute directly with sum. The left-hand side is inert while the right-hand side is computed

(%sum = sum)(f[i, j], i+j <= 2)

%sum(f[i, j], i+j <= 2) = f[0, 0]+f[0, 1]+f[1, 0]+f[0, 2]+f[1, 1]+f[2, 0]

(1.6)

(%sum = sum)(f[i, j], 1 <= i+j and i+j <= 2)

%sum(f[i, j], 1 <= i+j and i+j <= 2) = f[0, 1]+f[1, 0]+f[0, 2]+f[1, 1]+f[2, 0]

(1.7)

value(%sum(f[i, j], 1 <= i+j and i+j <= 2) = f[0, 1]+f[1, 0]+f[0, 2]+f[1, 1]+f[2, 0])

f[0, 1]+f[1, 0]+f[0, 2]+f[1, 1]+f[2, 0] = f[0, 1]+f[1, 0]+f[0, 2]+f[1, 1]+f[2, 0]

(1.8)

The formula for the integer power of a sum

(a+b+c)^n = sum(factorial(n)*a^p*b^q*c^r/(factorial(p)*factorial(q)*factorial(r)), p+q+r = n)

(a+b+c)^n = sum(Physics:-`*`(Physics:-`*`(Physics:-`*`(Physics:-`*`(factorial(n), Physics:-`*`(1, Physics:-`^`(Physics:-`*`(Physics:-`*`(factorial(p), factorial(q)), factorial(r)), -1))), Physics:-`^`(a, p)), Physics:-`^`(b, q)), Physics:-`^`(c, r)), p+q+r = n)

(1.9)

eval((a+b+c)^n = sum(Physics[`*`](Physics[`*`](Physics[`*`](Physics[`*`](factorial(n), Physics[`*`](1, Physics[`^`](Physics[`*`](Physics[`*`](factorial(p), factorial(q)), factorial(r)), -1))), Physics[`^`](a, p)), Physics[`^`](b, q)), Physics[`^`](c, r)), p+q+r = n), n = 2)

(a+b+c)^2 = a^2+2*a*b+2*a*c+b^2+2*b*c+c^2

(1.10)

eval((a+b+c)^n = sum(Physics[`*`](Physics[`*`](Physics[`*`](Physics[`*`](factorial(n), Physics[`*`](1, Physics[`^`](Physics[`*`](Physics[`*`](factorial(p), factorial(q)), factorial(r)), -1))), Physics[`^`](a, p)), Physics[`^`](b, q)), Physics[`^`](c, r)), p+q+r = n), n = 3)

(a+b+c)^3 = a^3+3*a^2*b+3*a^2*c+3*a*b^2+6*a*b*c+3*a*c^2+b^3+3*b^2*c+3*b*c^2+c^3

(1.11)

Verify whether this equation is true

(`@`(evalb, expand))((a+b+c)^3 = a^3+3*a^2*b+3*a^2*c+3*a*b^2+6*a*b*c+3*a*c^2+b^3+3*b^2*c+3*b*c^2+c^3)

true

(1.12)

Besides this new functionality, the redefined sum does a more modern handling of its arguments, consider a typical problem posted in Maple primes

a := 1; b := 2; j := 3

1

 

2

 

3

(1.13)

In the following summation, j is a dummy summation index, so the value just assigned, j := 3, is not expected to interfer with the summation. This is the case with the redefined sum

sum(f(j), j = a .. b)

f(1)+f(2)

(1.14)

while without redefining sum the input above is interrupted with an error message. Likely, in this other case also reported in Mapleprimes

g := proc (j) options operator, arrow; if j::odd then G[j] else 0 end if end proc

proc (j) options operator, arrow; if j::odd then G[j] else 0 end if end proc

(1.15)

the following two summations can be performed after having redefining sum:

sum(g(i), i = 1 .. f)

sum(g(i), i = 1 .. f)

(1.16)

For the summation above, without redefining sum, it returns 0 instead of unevaluated, because of a premature evaluation of the function g(i) with an unassigned index i before performing the summation. Returning unevaluated as (1.16) permits evaluate the sum at a latter moment, for instance attributing a value to f

eval(sum(g(i), i = 1 .. f), f = 3)

G[1]+G[3]

(1.17)

And this other sum where f is given from the begining also returns 0 without redefining sum

sum(g(i), i = 1 .. 3)

G[1]+G[3]

(1.18)

Problems like this other one reported in Mapleprimes here also get resolved with this redefinition of sum.

 

 

Download sum_in_physics.mw

Edgardo S. Cheb-Terrab
Physics, Maplesoft

 

Please Wait...