Featured Posts

For the past thirty years, I have used several mathematical packages for problem solving and graphing. It all started with spreadsheet software that really helped speedup calculations compared to calculators. As many people do, once I had one tool I then started looking for another that would offer even more capabilities and features. I tested several of the very early math software but none really did all that I wanted until I came across Maple while I was working at SPAR Aerospace in Canada. For me, the rest is history. As long as I had a copy of Maple, it was all that I needed.

On occasions when I did not have a copy of this amazing software, I resorted to spreadsheets once more to complete fairly large and complex projects involving large databases and large numbers of calculations, especially when performing What-If scenarios. One distinct disadvantage of using a spreadsheet was the cryptic form of equation writing. I had to divide one long equation into several sections in different cells and then add them all up, which clearly is not good for documentation of the calculations. It is also very confusing for other engineers to know what that equation is or what it does. The development of the full engineering spreadsheet took months to complete, debug and verify. During this process, when I had errors, it was often very difficult to track exactly where the problem was, making the debugging process time consuming and sometimes very frustrating.

Having worked with Maple before, I remembered how easy it was to enter equations in a very familiar, readable math format. The real power of this software is that it allows you to write the equation(s) anyway you like and solve for any given parameter, unlike spreadsheets where you have to solve the problem first, by hand, for the parameter you want and then get the spreadsheet to calculate the value. I remember one time a few years ago when I wrote nine or ten simultaneous differential equations all in symbolic form and asked Maple to calculate certain parameters in a fully symbolic form. To my utmost disbelief, the answer came back within few minutes. With results in hand, I was able to quickly finish my research, and the results were published at PCIM Europe 2005 in “Distributed Gate ESR and its Effect on Shoot Through Performance at the Die Level”. I would never have gotten the results I needed if I was using a spreadsheet.

Even with much simpler systems of equations, finding solutions with a paper and pencil was never an easy task for me. It took a very long time, and even then there was no guarantee that I did not make copying errors, accidentally leave out a term, or make a calculation error. After I found the correct solution, I then had the problem of plotting the results, which I often needed in 3-D. Plotting allowed much deeper insights into the interdependency of all the parameters and made it easy for me to concentrate on the important ones without wasting any time. I was very happy when I could pass all these tasks onto Maple, which could do them much faster and more reliably then I ever could. Maple is a software that allows me to go beyond routine engineering calculations and gives me the tools to reach levels of insight and understanding that were completely out of reach of the average engineer until a few years ago.

For the record, I have no business affiliations with Maplesoft. I’m writing this article because Maple makes such a difference in my work that I feel it is important to share my experiences so other engineers can get the same benefits.

 

Symbolic sequences enter in various formulations in mathematics. This post is about a related new subpackage, Sequences, within the MathematicalFunctions package, available for download in Maplesoft's R&D page for Mathematical Functions and Differential Equations (currently bundled with updates to the Physics package).

 

Perhaps the most typical cases of symbolic sequences are:

 

1) A sequence of numbers - say from n to m - frequently displayed as

n, `...`, m

 

2) A sequence of one object, say a, repeated say p times, frequently displayed as

 "((a,`...`,a))"

3) A more general sequence, as in 1), but of different objects and not necessarily numbers, frequently displayed as

a[n], `...`, a[m]

or likewise a sequence of functions

f(n), `...`, f(m)

In all these cases, of course, none of n, m, or p are known: they are just symbols, or algebraic expressions, representing integer values.

 

These most typical cases of symbolic sequences have been implemented in Maple since day 1 using the `$` operator. Cases 1), 2) and 3) above are respectively entered as `$`(n .. m), `$`(a, p), and `$`(a[i], i = n .. m) or "`$`(f(i), i = n .. m)." To have computer algebra representations for all these symbolic sequences is something wonderful, I would say unique in Maple.

Until recently, however, the typesetting of these symbolic sequences was frankly poor, input like `$`(a[i], i = n .. m) or ``$\``(a, p) just being echoed in the display. More relevant: too little could be done with these objects; the rest of Maple didn't know how to add, multiply, differentiate or map an operation over the elements of the sequence, nor for instance count the sequence's number of elements.

 

All this has now been implemented.  What follows is a brief illustration.

restart

First of all, now these three types of sequences have textbook-like typesetting:

`$`(n .. m)

`$`(n .. m)

(1)

`$`(a, p)

`$`(a, p)

(2)

For the above, a$p works the same way

`$`(a[i], i = n .. m)

`$`(a[i], i = n .. m)

(3)

Moreover, this now permits textbook display of mathematical functions that depend on sequences of paramateters, for example:

hypergeom([`$`(a[i], i = 1 .. p)], [`$`(b[i], i = 1 .. q)], z)

hypergeom([`$`(a[i], i = 1 .. p)], [`$`(b[i], i = 1 .. q)], z)

(4)

IncompleteBellB(n, k, `$`(factorial(j), j = 1 .. n-k+1))

IncompleteBellB(n, k, `$`(factorial(j), j = 1 .. n-k+1))

(5)

More interestingly, these new developments now permit differentiating these functions even when their arguments are symbolic sequences, and displaying the result as in textbooks, with copy and paste working properly, for instance

(%diff = diff)(hypergeom([`$`(a[i], i = 1 .. p)], [`$`(b[i], i = 1 .. q)], z), z)

%diff(hypergeom([`$`(a[i], i = 1 .. p)], [`$`(b[i], i = 1 .. q)], z), z) = (product(a[i], i = 1 .. p))*hypergeom([`$`(a[i]+1, i = 1 .. p)], [`$`(b[i]+1, i = 1 .. q)], z)/(product(b[i], i = 1 .. q))

(6)

It is very interesting how much this enhances the representation capabilities; to mention but one, this makes 100% possible the implementation of the Faa-di-Bruno  formula for the nth symbolic derivative of composite functions (more on this in a post to follow this one).

But the bread-and-butter first: the new package for handling sequences is

with(MathematicalFunctions:-Sequences)

[Add, Differentiate, Map, Multiply, Nops]

(7)

The five commands that got loaded do what their name tells. Consider for instance the first kind of sequences mentione above, i.e

`$`(n .. m)

`$`(n .. m)

(8)

Check what is behind this nice typesetting

lprint(`$`(n .. m))

`$`(n .. m)

 

All OK. How many operands (an abstract version of Maple's nops  command):

Nops(`$`(n .. m))

m-n+1

(9)

That was easy, ok. Add the sequence

Add(`$`(n .. m))

(1/2)*(m-n+1)*(n+m)

(10)

Multiply the sequence

Multiply(`$`(n .. m))

factorial(m)/factorial(n-1)

(11)

Map an operation over the elements of the sequence

Map(f, `$`(n .. m))

`$`(f(j), j = n .. m)

(12)

lprint(`$`(f(j), j = n .. m))

`$`(f(j), j = n .. m)

 

Map works as map, i.e. you can map extra arguments as well

MathematicalFunctions:-Sequences:-Map(Int, `$`(n .. m), x)

`$`(Int(j, x), j = n .. m)

(13)

All this works the same way with symbolic sequences of forms "((a,`...`,a))" , and a[n], `...`, a[m]. For example:

`$`(a, p)

`$`(a, p)

(14)

lprint(`$`(a, p))

`$`(a, p)

 

MathematicalFunctions:-Sequences:-Nops(`$`(a, p))

p

(15)

Add(`$`(a, p))

a*p

(16)

Multiply(`$`(a, p))

a^p

(17)

Differentation also works

Differentiate(`$`(a, p), a)

`$`(1, p)

(18)

MathematicalFunctions:-Sequences:-Map(f, `$`(a, p))

`$`(f(a), p)

(19)

MathematicalFunctions:-Sequences:-Differentiate(`$`(f(a), p), a)

`$`(diff(f(a), a), p)

(20)

For a symbolic sequence of type 3)

`$`(a[i], i = n .. m)

`$`(a[i], i = n .. m)

(21)

MathematicalFunctions:-Sequences:-Nops(`$`(a[i], i = n .. m))

m-n+1

(22)

Add(`$`(a[i], i = n .. m))

sum(a[i], i = n .. m)

(23)

Multiply(`$`(a[i], i = n .. m))

product(a[i], i = n .. m)

(24)

The following is nontrivial: differentiating the sequence a[n], `...`, a[m], with respect to a[k] should return 1 when n = k (i.e the running index has the value k), and 0 otherwise, and the same regarding m and k. That is how it works now:

Differentiate(`$`(a[i], i = n .. m), a[k])

`$`(piecewise(k = i, 1, 0), i = n .. m)

(25)

lprint(`$`(piecewise(k = i, 1, 0), i = n .. m))

`$`(piecewise(k = i, 1, 0), i = n .. m)

 

MathematicalFunctions:-Sequences:-Map(f, `$`(a[i], i = n .. m))

`$`(f(a[i]), i = n .. m)

(26)

Differentiate(`$`(f(a[i]), i = n .. m), a[k])

`$`((diff(f(a[i]), a[i]))*piecewise(k = i, 1, 0), i = n .. m)

(27)

lprint(`$`((diff(f(a[i]), a[i]))*piecewise(k = i, 1, 0), i = n .. m))

`$`((diff(f(a[i]), a[i]))*piecewise(k = i, 1, 0), i = n .. m)

 

 

And that is it. Summarizing: in addition to the former implementation of symbolic sequences, we now have textbook-like typesetting for them, and more important: Add, Multiply, Differentiate, Map and Nops. :)

 

The first large application we have been working on taking advantage of this is symbolic differentiation, with very nice results; I will see to summarize them in a post to follow in a couple of days.

 

Download MathematicalFunctionsSequences.mw

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft


MaplePrimes Questions Recent Unanswered Maple MapleSim Maple T.A.