Applications, Examples and Libraries

Share your work here


 

Solving a Numbrix Puzzle with Logic

Background

 

 

Parade magazine, a filler in the local Sunday newspaper, contains a Numbrix puzzle, the object of which is to find a serpentine path of consecutive integers, 1 through 81, through a nine by nine grid.  The puzzle typically specifies the content of every other border cell.

 

The Maple Logic  package has a procedure, Satisfy , that can be used to solve this puzzle.  Satisfy is a SAT-solver; given a boolean expression it attempts to find a set of equations of the form {x__1 = b__1, x__2 = b__2, () .. ()}, where x__i are the boolean variables in the given expression and b__i are boolean values (true or false) that satisfy the expression (cause it to evaluate true).

 

A general technique to solve this and other puzzles with Satisfy is to select boolean-values variables that encode the state of the puzzle (a trial solution, whether valid or not), generate a boolean-expression of these variables that is satisfied (true) if and only if the variables are given values that correspond to a solution, pass this expression to Satisfy, then translate the returned set of boolean values (if any) to the puzzle solution.

Setup

 

Assign a matrix that defines the grid and the initial position.  Use zeros to indicate the cells that need values. To make it easy to inspect the expressions, a small 2 x 3 matrix is used for this demo---a full size example is given at the end.

M := Matrix(2,3, {(1,1) = 1, (1,3) = 5});

Matrix(2, 3, {(1, 1) = 1, (1, 2) = 0, (1, 3) = 5, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0})

(2.1)

 

Extract the dimensions of the Matrix

(m,n) := upperbound(M);

2, 3

(2.2)

Boolean Variables

 

Let the boolean variable x[i,j,k] mean that cell (i,j) has value k. For example, x[2,3,6] is true when cell (2,3) contains 6, otherwise it is false. There are (m*n)^2 boolean variables.

Initial Position

 

The initial position can be expressed as the following and-clause.

initial := &and(seq(seq(ifelse(M[i,j] = 0, NULL, x[i,j,M[i,j]]), i = 1..m), j = 1..n));

`&and`(x[1, 1, 1], x[1, 3, 5])

(4.1)

Adjacent Cells

 

The requirement that an interior cell with value k is adjacent to the cell with value k+1 can be expressed as the implication
   

   x[i,j,k] &implies &or(x[i-1,j,k+1], x[i+1,j,k+1], x[i,j-1,k+1], x[i,j+1,k+1])

 

Extending this to handle all cells results in the following boolean expression.

adjacent := &and(seq(seq(seq(
         x[i,j,k] &implies &or(NULL
                               , ifelse(1<i, x[i-1, j, k+1], NULL)
                               , ifelse(i<m, x[i+1, j, k+1], NULL)
                               , ifelse(1<j, x[i, j-1, k+1], NULL)
                               , ifelse(j<n, x[i, j+1, k+1], NULL)
                               )
                            , i = 1..m)
                        , j = 1..n)
                    , k = 1 .. m*n-1));

`&and`(`&implies`(x[1, 1, 1], `&or`(x[2, 1, 2], x[1, 2, 2])), `&implies`(x[2, 1, 1], `&or`(x[1, 1, 2], x[2, 2, 2])), `&implies`(x[1, 2, 1], `&or`(x[2, 2, 2], x[1, 1, 2], x[1, 3, 2])), `&implies`(x[2, 2, 1], `&or`(x[1, 2, 2], x[2, 1, 2], x[2, 3, 2])), `&implies`(x[1, 3, 1], `&or`(x[2, 3, 2], x[1, 2, 2])), `&implies`(x[2, 3, 1], `&or`(x[1, 3, 2], x[2, 2, 2])), `&implies`(x[1, 1, 2], `&or`(x[2, 1, 3], x[1, 2, 3])), `&implies`(x[2, 1, 2], `&or`(x[1, 1, 3], x[2, 2, 3])), `&implies`(x[1, 2, 2], `&or`(x[2, 2, 3], x[1, 1, 3], x[1, 3, 3])), `&implies`(x[2, 2, 2], `&or`(x[1, 2, 3], x[2, 1, 3], x[2, 3, 3])), `&implies`(x[1, 3, 2], `&or`(x[2, 3, 3], x[1, 2, 3])), `&implies`(x[2, 3, 2], `&or`(x[1, 3, 3], x[2, 2, 3])), `&implies`(x[1, 1, 3], `&or`(x[2, 1, 4], x[1, 2, 4])), `&implies`(x[2, 1, 3], `&or`(x[1, 1, 4], x[2, 2, 4])), `&implies`(x[1, 2, 3], `&or`(x[2, 2, 4], x[1, 1, 4], x[1, 3, 4])), `&implies`(x[2, 2, 3], `&or`(x[1, 2, 4], x[2, 1, 4], x[2, 3, 4])), `&implies`(x[1, 3, 3], `&or`(x[2, 3, 4], x[1, 2, 4])), `&implies`(x[2, 3, 3], `&or`(x[1, 3, 4], x[2, 2, 4])), `&implies`(x[1, 1, 4], `&or`(x[2, 1, 5], x[1, 2, 5])), `&implies`(x[2, 1, 4], `&or`(x[1, 1, 5], x[2, 2, 5])), `&implies`(x[1, 2, 4], `&or`(x[2, 2, 5], x[1, 1, 5], x[1, 3, 5])), `&implies`(x[2, 2, 4], `&or`(x[1, 2, 5], x[2, 1, 5], x[2, 3, 5])), `&implies`(x[1, 3, 4], `&or`(x[2, 3, 5], x[1, 2, 5])), `&implies`(x[2, 3, 4], `&or`(x[1, 3, 5], x[2, 2, 5])), `&implies`(x[1, 1, 5], `&or`(x[2, 1, 6], x[1, 2, 6])), `&implies`(x[2, 1, 5], `&or`(x[1, 1, 6], x[2, 2, 6])), `&implies`(x[1, 2, 5], `&or`(x[2, 2, 6], x[1, 1, 6], x[1, 3, 6])), `&implies`(x[2, 2, 5], `&or`(x[1, 2, 6], x[2, 1, 6], x[2, 3, 6])), `&implies`(x[1, 3, 5], `&or`(x[2, 3, 6], x[1, 2, 6])), `&implies`(x[2, 3, 5], `&or`(x[1, 3, 6], x[2, 2, 6])))

(5.1)

 

All Values Used

 

The following expression is true when each integer k, from 1 to m*n, is assigned to one or more cells.

allvals := &and(seq(seq(&or(seq(x[i,j,k], k=1..m*n)), i=1..m), j=1..n));

`&and`(`&or`(x[1, 1, 1], x[1, 1, 2], x[1, 1, 3], x[1, 1, 4], x[1, 1, 5], x[1, 1, 6]), `&or`(x[2, 1, 1], x[2, 1, 2], x[2, 1, 3], x[2, 1, 4], x[2, 1, 5], x[2, 1, 6]), `&or`(x[1, 2, 1], x[1, 2, 2], x[1, 2, 3], x[1, 2, 4], x[1, 2, 5], x[1, 2, 6]), `&or`(x[2, 2, 1], x[2, 2, 2], x[2, 2, 3], x[2, 2, 4], x[2, 2, 5], x[2, 2, 6]), `&or`(x[1, 3, 1], x[1, 3, 2], x[1, 3, 3], x[1, 3, 4], x[1, 3, 5], x[1, 3, 6]), `&or`(x[2, 3, 1], x[2, 3, 2], x[2, 3, 3], x[2, 3, 4], x[2, 3, 5], x[2, 3, 6]))

(6.1)

Single Value

 

The following expression is satisfied when each cell has no more than one value.

 single := &not &or(seq(seq(seq(seq(x[i,j,k] &and x[i,j,kk], kk = k+1..m*n), k = 1..m*n-1), i = 1..m), j = 1..n));

`&not`(`&or`(`&and`(x[1, 1, 1], x[1, 1, 2]), `&and`(x[1, 1, 1], x[1, 1, 3]), `&and`(x[1, 1, 1], x[1, 1, 4]), `&and`(x[1, 1, 1], x[1, 1, 5]), `&and`(x[1, 1, 1], x[1, 1, 6]), `&and`(x[1, 1, 2], x[1, 1, 3]), `&and`(x[1, 1, 2], x[1, 1, 4]), `&and`(x[1, 1, 2], x[1, 1, 5]), `&and`(x[1, 1, 2], x[1, 1, 6]), `&and`(x[1, 1, 3], x[1, 1, 4]), `&and`(x[1, 1, 3], x[1, 1, 5]), `&and`(x[1, 1, 3], x[1, 1, 6]), `&and`(x[1, 1, 4], x[1, 1, 5]), `&and`(x[1, 1, 4], x[1, 1, 6]), `&and`(x[1, 1, 5], x[1, 1, 6]), `&and`(x[2, 1, 1], x[2, 1, 2]), `&and`(x[2, 1, 1], x[2, 1, 3]), `&and`(x[2, 1, 1], x[2, 1, 4]), `&and`(x[2, 1, 1], x[2, 1, 5]), `&and`(x[2, 1, 1], x[2, 1, 6]), `&and`(x[2, 1, 2], x[2, 1, 3]), `&and`(x[2, 1, 2], x[2, 1, 4]), `&and`(x[2, 1, 2], x[2, 1, 5]), `&and`(x[2, 1, 2], x[2, 1, 6]), `&and`(x[2, 1, 3], x[2, 1, 4]), `&and`(x[2, 1, 3], x[2, 1, 5]), `&and`(x[2, 1, 3], x[2, 1, 6]), `&and`(x[2, 1, 4], x[2, 1, 5]), `&and`(x[2, 1, 4], x[2, 1, 6]), `&and`(x[2, 1, 5], x[2, 1, 6]), `&and`(x[1, 2, 1], x[1, 2, 2]), `&and`(x[1, 2, 1], x[1, 2, 3]), `&and`(x[1, 2, 1], x[1, 2, 4]), `&and`(x[1, 2, 1], x[1, 2, 5]), `&and`(x[1, 2, 1], x[1, 2, 6]), `&and`(x[1, 2, 2], x[1, 2, 3]), `&and`(x[1, 2, 2], x[1, 2, 4]), `&and`(x[1, 2, 2], x[1, 2, 5]), `&and`(x[1, 2, 2], x[1, 2, 6]), `&and`(x[1, 2, 3], x[1, 2, 4]), `&and`(x[1, 2, 3], x[1, 2, 5]), `&and`(x[1, 2, 3], x[1, 2, 6]), `&and`(x[1, 2, 4], x[1, 2, 5]), `&and`(x[1, 2, 4], x[1, 2, 6]), `&and`(x[1, 2, 5], x[1, 2, 6]), `&and`(x[2, 2, 1], x[2, 2, 2]), `&and`(x[2, 2, 1], x[2, 2, 3]), `&and`(x[2, 2, 1], x[2, 2, 4]), `&and`(x[2, 2, 1], x[2, 2, 5]), `&and`(x[2, 2, 1], x[2, 2, 6]), `&and`(x[2, 2, 2], x[2, 2, 3]), `&and`(x[2, 2, 2], x[2, 2, 4]), `&and`(x[2, 2, 2], x[2, 2, 5]), `&and`(x[2, 2, 2], x[2, 2, 6]), `&and`(x[2, 2, 3], x[2, 2, 4]), `&and`(x[2, 2, 3], x[2, 2, 5]), `&and`(x[2, 2, 3], x[2, 2, 6]), `&and`(x[2, 2, 4], x[2, 2, 5]), `&and`(x[2, 2, 4], x[2, 2, 6]), `&and`(x[2, 2, 5], x[2, 2, 6]), `&and`(x[1, 3, 1], x[1, 3, 2]), `&and`(x[1, 3, 1], x[1, 3, 3]), `&and`(x[1, 3, 1], x[1, 3, 4]), `&and`(x[1, 3, 1], x[1, 3, 5]), `&and`(x[1, 3, 1], x[1, 3, 6]), `&and`(x[1, 3, 2], x[1, 3, 3]), `&and`(x[1, 3, 2], x[1, 3, 4]), `&and`(x[1, 3, 2], x[1, 3, 5]), `&and`(x[1, 3, 2], x[1, 3, 6]), `&and`(x[1, 3, 3], x[1, 3, 4]), `&and`(x[1, 3, 3], x[1, 3, 5]), `&and`(x[1, 3, 3], x[1, 3, 6]), `&and`(x[1, 3, 4], x[1, 3, 5]), `&and`(x[1, 3, 4], x[1, 3, 6]), `&and`(x[1, 3, 5], x[1, 3, 6]), `&and`(x[2, 3, 1], x[2, 3, 2]), `&and`(x[2, 3, 1], x[2, 3, 3]), `&and`(x[2, 3, 1], x[2, 3, 4]), `&and`(x[2, 3, 1], x[2, 3, 5]), `&and`(x[2, 3, 1], x[2, 3, 6]), `&and`(x[2, 3, 2], x[2, 3, 3]), `&and`(x[2, 3, 2], x[2, 3, 4]), `&and`(x[2, 3, 2], x[2, 3, 5]), `&and`(x[2, 3, 2], x[2, 3, 6]), `&and`(x[2, 3, 3], x[2, 3, 4]), `&and`(x[2, 3, 3], x[2, 3, 5]), `&and`(x[2, 3, 3], x[2, 3, 6]), `&and`(x[2, 3, 4], x[2, 3, 5]), `&and`(x[2, 3, 4], x[2, 3, 6]), `&and`(x[2, 3, 5], x[2, 3, 6])))

(7.1)

Solution

 

Combine the boolean expressions into a a single and-clause and pass it to Satisfy.

sol := Logic:-Satisfy(&and(initial, adjacent, allvals, single));

{x[1, 1, 1] = true, x[1, 1, 2] = false, x[1, 1, 3] = false, x[1, 1, 4] = false, x[1, 1, 5] = false, x[1, 1, 6] = false, x[1, 2, 1] = false, x[1, 2, 2] = false, x[1, 2, 3] = false, x[1, 2, 4] = false, x[1, 2, 5] = false, x[1, 2, 6] = true, x[1, 3, 1] = false, x[1, 3, 2] = false, x[1, 3, 3] = false, x[1, 3, 4] = false, x[1, 3, 5] = true, x[1, 3, 6] = false, x[2, 1, 1] = false, x[2, 1, 2] = true, x[2, 1, 3] = false, x[2, 1, 4] = false, x[2, 1, 5] = false, x[2, 1, 6] = false, x[2, 2, 1] = false, x[2, 2, 2] = false, x[2, 2, 3] = true, x[2, 2, 4] = false, x[2, 2, 5] = false, x[2, 2, 6] = false, x[2, 3, 1] = false, x[2, 3, 2] = false, x[2, 3, 3] = false, x[2, 3, 4] = true, x[2, 3, 5] = false, x[2, 3, 6] = false}

(8.1)

Select the equations whose right size is true

sol := select(rhs, sol);

{x[1, 1, 1] = true, x[1, 2, 6] = true, x[1, 3, 5] = true, x[2, 1, 2] = true, x[2, 2, 3] = true, x[2, 3, 4] = true}

(8.2)

Extract the lhs of the true equations

vars := map(lhs, sol);

{x[1, 1, 1], x[1, 2, 6], x[1, 3, 5], x[2, 1, 2], x[2, 2, 3], x[2, 3, 4]}

(8.3)

Extract the result from the indices of the vars and assign to a new Matrix

S := Matrix(m,n):

for v in vars do S[op(1..2,v)] := op(3,v); end do:

S;

Matrix(2, 3, {(1, 1) = 1, (1, 2) = 6, (1, 3) = 5, (2, 1) = 2, (2, 2) = 3, (2, 3) = 4})

(8.4)

Procedure

 

We can now combine the manual steps into a procedure that takes an initialized Matrix and fills in a solution.

Numbrix := proc( M :: ~Matrix, { inline :: truefalse := false } )

Example

 

Create the initial position for a 9 x 9 Numbrix and solve it.

P := Matrix(9, {(1,1)=11, (1,3)=7, (1,5)=3, (1,7)=81, (1,9)=77, (3,9)=75, (5,9)=65, (7,9)=55, (9,9)=53
               , (9,7)=47, (9,5)=41, (9,3)=39, (9,1)=37, (7,1)=21, (5,1)=17, (3,1)=13});

Matrix(9, 9, {(1, 1) = 11, (1, 2) = 0, (1, 3) = 7, (1, 4) = 0, (1, 5) = 3, (1, 6) = 0, (1, 7) = 81, (1, 8) = 0, (1, 9) = 77, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (2, 4) = 0, (2, 5) = 0, (2, 6) = 0, (2, 7) = 0, (2, 8) = 0, (2, 9) = 0, (3, 1) = 13, (3, 2) = 0, (3, 3) = 0, (3, 4) = 0, (3, 5) = 0, (3, 6) = 0, (3, 7) = 0, (3, 8) = 0, (3, 9) = 75, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = 0, (4, 5) = 0, (4, 6) = 0, (4, 7) = 0, (4, 8) = 0, (4, 9) = 0, (5, 1) = 17, (5, 2) = 0, (5, 3) = 0, (5, 4) = 0, (5, 5) = 0, (5, 6) = 0, (5, 7) = 0, (5, 8) = 0, (5, 9) = 65, (6, 1) = 0, (6, 2) = 0, (6, 3) = 0, (6, 4) = 0, (6, 5) = 0, (6, 6) = 0, (6, 7) = 0, (6, 8) = 0, (6, 9) = 0, (7, 1) = 21, (7, 2) = 0, (7, 3) = 0, (7, 4) = 0, (7, 5) = 0, (7, 6) = 0, (7, 7) = 0, (7, 8) = 0, (7, 9) = 55, (8, 1) = 0, (8, 2) = 0, (8, 3) = 0, (8, 4) = 0, (8, 5) = 0, (8, 6) = 0, (8, 7) = 0, (8, 8) = 0, (8, 9) = 0, (9, 1) = 37, (9, 2) = 0, (9, 3) = 39, (9, 4) = 0, (9, 5) = 41, (9, 6) = 0, (9, 7) = 47, (9, 8) = 0, (9, 9) = 53})

(10.1)

CodeTools:-Usage(Numbrix(P));

memory used=0.77GiB, alloc change=220.03MiB, cpu time=15.55s, real time=12.78s, gc time=3.85s

 

Matrix(9, 9, {(1, 1) = 11, (1, 2) = 10, (1, 3) = 7, (1, 4) = 81, (1, 5) = 3, (1, 6) = 4, (1, 7) = 81, (1, 8) = 78, (1, 9) = 77, (2, 1) = 12, (2, 2) = 9, (2, 3) = 8, (2, 4) = 7, (2, 5) = 6, (2, 6) = 5, (2, 7) = 80, (2, 8) = 79, (2, 9) = 76, (3, 1) = 13, (3, 2) = 14, (3, 3) = 27, (3, 4) = 28, (3, 5) = 71, (3, 6) = 72, (3, 7) = 73, (3, 8) = 74, (3, 9) = 75, (4, 1) = 16, (4, 2) = 15, (4, 3) = 26, (4, 4) = 29, (4, 5) = 70, (4, 6) = 69, (4, 7) = 68, (4, 8) = 67, (4, 9) = 66, (5, 1) = 17, (5, 2) = 18, (5, 3) = 25, (5, 4) = 30, (5, 5) = 61, (5, 6) = 62, (5, 7) = 63, (5, 8) = 64, (5, 9) = 65, (6, 1) = 20, (6, 2) = 19, (6, 3) = 24, (6, 4) = 31, (6, 5) = 60, (6, 6) = 59, (6, 7) = 58, (6, 8) = 57, (6, 9) = 56, (7, 1) = 21, (7, 2) = 22, (7, 3) = 23, (7, 4) = 32, (7, 5) = 43, (7, 6) = 44, (7, 7) = 49, (7, 8) = 50, (7, 9) = 55, (8, 1) = 36, (8, 2) = 35, (8, 3) = 34, (8, 4) = 33, (8, 5) = 42, (8, 6) = 45, (8, 7) = 48, (8, 8) = 51, (8, 9) = 54, (9, 1) = 37, (9, 2) = 38, (9, 3) = 39, (9, 4) = 40, (9, 5) = 41, (9, 6) = 46, (9, 7) = 47, (9, 8) = 52, (9, 9) = 53})

(10.2)

 

numbrix.mw

I describe here a finite difference scheme for solving the boundary value
problem for the heat equation

"(&PartialD; u)/(&PartialD; t)= ((&PartialD;)^)/((&PartialD;)^( )x^)(c(x)(&PartialD; u)/(&PartialD; x)) + f(x,t)   a<x<b,   t>0"

for the unknown temperature u(x, t)subject to the boundary conditions

u(a, t) = alpha(t), u(b, t) = beta(t), t > 0

and the initial condition

"u(x,0)=`u__0`(x),    a < x < b."

 

This finite difference scheme is designed expressly with the goal of avoiding

differentiating the conductivity c(x), therefore c(x) is allowed to be

nonsmooth or even discontinuous. A discontinuous c(x) is particularly
important in applications where the heat conduction takes place through layers
of distinct types of materials.

 

The animation below, extracted from the worksheet, demonstrates a solution 

corresponding to a discontinuous c(x).  The limit of that solution as time goes to

infinity, which may be calculated independently and exactly, is shown as a gray
line.

Download worksheet: heat-finite-difference.mw

 

 

 

 

Maple 2019 has a new add-on package Maple Quantum Chemistry Toolbox from RDMChem for computing the energies and properties of molecules.  As a member of the team at RDMChem that developed the package, I would like to tell the story of its origins and provide a brief demonstration of the package.  

 

Thinking about Quantum Chemistry at Harvard

 

The story of the Maple Quantum Chemistry Toolbox begins with my graduate studies in Chemical Physics at Harvard University in the late 1990s.  Even in 1998 programs for computing the energies and properties of molecules were extremely complicated and nonintuitive.  Many of the existing programs had begun in the 1970s on computers whose programs would be recorded on punchcards.

Fig. 1: Used Punchcard by Pete Birkinshaw from Manchester, UK CC BY 2.0

 

Even today some of these programs have remnants of their early versions such as input files that must start on the second column to account for the margin of the now non-existent punchcards.  As a student, I made a bound copy of one of these manuals at a local Kinkos photocopy shop and later found myself in Harvard Yard, thinking that there must be a better way to present quantum chemistry computations.  The idea for a Maple-like package for quantum chemistry was born in that moment.

 

At the same time I was learning about something called the two-electron reduced density matrix (2-RDM).  The basic variable in quantum chemistry is the wave function which is the probability amplitude for finding each of the electrons in a molecule.  Because electrons are indistinguishable with pairwise interactions, the wave function contains much more information than is needed for computing the energies and electronic properties of molecules.  The energies and properties of any molecule with any number of electrons can be expressed as a function of a 2 electron matrix, the 2-RDM [1-3].  A quantum chemistry based on the 2-RDM, it was known, would have potentially significant advantages over wave function calculations in terms of accuracy and computational cost, especially for molecules far from the mean-field limit.  A 2-RDM approach to quantum chemistry became the focus of my Ph.D. thesis.

 

Representing Many Electrons with Only Two Electrons

 

The idea of using the 2-RDM in quantum chemistry can be attributed to four scientists: two physicists Kodi Husimi and Joseph Mayer, a chemist Per-Olov Lowdin, and a mathematician John Coleman [1-3].  In the early 1940s Husimi first published the idea in a Japanese physics journal, but in the midst of World War II the paper was not widely disseminated in the West.  In the summer of 1951 John Coleman, which attending a physics conference at Chalk River, realized that the ground-state energy of any atom or molecule could be expressed as functional of the 2-RDM, and similar ideas later occurred to Per-Olov Lowdin and Joseph Mayer who published their ideas in Physical Review in 1955.  It was soon recognized that computing the ground-state energy of an atom or molecule with the 2-RDM was potentially difficult because not every two-electron density matrix corresponds to an N-electron density matrix or wave function.  The search for the appropriate constraints on the 2-RDM, known as N-representability conditions, became known as the N-representability problem [1-3].  

 

Beginning in the late 1990s and early 2000s, Carmela Valdemoro and Diego Alcoba at the Consejo Superior de Investigaciones Científicas (Madrid, Spain), Hiroshi Nakatsuji, Koji Yasuda, and Maho Nakata at Kyoto University (Kyoto, Japan), Jerome Percus and Bastiaan Braams at the Courant Institute (New York, USA), John Coleman and Robert Erdahl at Queens University (Kingston, Canada), and my research group and I at The University of Chicago (Chicago, USA) began to make significant progress in the computation of the 2-RDM without computing the many-electron wave function [1-3].  Further contributions were made by Eric Cances and Claude Le Bris at CERMICS, Ecole Nationale des Ponts et Chaussées (Marne-la-Vallée, France), Paul Ayers at McMaster University (Hamilton, Canada), and Dimitri Van Neck at the University of Ghent (Ghent, Belgium) and their research groups.  By 2014 several powerful 2-RDM methods had emerged for the computation of molecules.  The Army Research Office (ARO) issued a proposal call for a company to develop a modern, built-from-scratch package for quantum chemistry that would contain two newly developed 2-RDM-based methods from our group: the parametric 2-RDM method [1] and the variational 2-RDM method with a fast algorithm for solving the semidefinite program [4,5,6].   The company RDMChem LLC was founded to work with the ARO to develop such a package built around RDMs, and hence, the name of the company RDMChem was selected as a hybrid of the RDM abbreviation for Reduced Density Matrices and the Chem colloquialism for Chemistry.  To achieve a really new design for an electronic structure package with access to numeric and symbolic computations as well as advanced visualizations, the team at RDMChem and I developed a partnership with Maplesoft to build something new that became the Maple Quantum Chemistry Package (or Toolbox), which was released with Maple 2019 on Pi Day.

 

Maple Quantum Chemistry Toolbox

 The Maple Quantum Chemistry Toolbox provides a powerful, parallel platform for quantum chemistry calculations that is directly integrated into the Maple 2019 environment.  It is optimized for both cutting-edge research as well as chemistry education.  The Toolbox can be used from the worksheet, document, or command-line interfaces.  Plus there is a Maplet interface for rapid exploration of molecules and their properties.  Figure 2 shows the Maplet interface being applied to compute the ground-state energy of 1,3-dibromobenzene by density functional theory (DFT) in a 6-31g basis set.           

Fig. 2: Maplet interface to the Quantum Chemistry Toolbox 2019, showing a density functional theory (DFT) calculation         

After entering a name into the text box labeled Name, the user can click on: (1) the button Web to import the geometry from an online database containing more than 96 million molecules,  (2) the button File to read the geometry from a standard XYZ file, or (3) the button Input to enter the geometry.  As soon the geometry is entered, the Maplet displays a 3D picture of the molecule in the window on the right of the options.  Dropdown menus allow the user to select the basis set, the electronic structure method, and a boolean for geometry optimization.  The user can click on the Compute button to perform the computation.  When the quantum computation completes, the total energy appears in the box labeled Total Energy.  The dropdown menu Analyze contains a list of data tables, plots, and animations that can be selected and then displayed by clicking the Analyze button.  The Maplet interface contains nearly all of the options available in the worksheet interface.   The Help Pages of the Toolbox include extensive curricula and lessons that can be used in undergraduate, graduate, and even high school chemistry courses.  Next we look at some sample calculations in the worksheet interface.     

 

Reproducing an Early 2-RDM Calculation

 

One of the earliest variational calculations of the 2-RDM was performed in 1975 by Garrod, Mihailović,  and  Rosina [1-3].  They minimized the electronic ground state of the 4-electron atom beryllium as a functional of only two electrons, the 2-RDM.  They imposed semidefinite constraints on the particle-particle (D), hole-hole (Q), and particle-hole (G) metric matrices.  They solved the resulting optimization problem of minimizing the energy as a linear function of the 2-RDM subject to the semidefinite constraints, known as a semidefinite program, by a cutting-plane algorithm.  Due to limitations of the cutting-plane algorithm and computers circa 1975, the calculation was a difficult one, likely taking a significant amount of computer time and memory.

 

With the Quantum Chemistry Toolbox we can use the command Variational2RDM to reproduce the calculation on a Windows laptop.  First, in a Maple 2019 worksheet we load the commands of the Add-on Quantum Chemistry Toolbox:

with(QuantumChemistry);

[AOLabels, ActiveSpaceCI, ActiveSpaceSCF, AtomicData, BondAngles, BondDistances, Charges, ChargesPlot, CorrelationEnergy, CoupledCluster, DensityFunctional, DensityPlot3D, Dipole, DipolePlot, Energy, FullCI, GeometryOptimization, HartreeFock, Interactive, Isotopes, MOCoefficients, MODiagram, MOEnergies, MOIntegrals, MOOccupations, MOOccupationsPlot, MOSymmetries, MP2, MolecularData, MolecularGeometry, NuclearEnergy, NuclearGradient, Parametric2RDM, PlotMolecule, Populations, RDM1, RDM2, ReadXYZ, SaveXYZ, SearchBasisSets, SearchFunctionals, SkeletalStructure, Thermodynamics, Variational2RDM, VibrationalModeAnimation, VibrationalModes, Video]

(1.1)

Then we define the atom (or molecule) using a Maple list of lists that we assign to the variable atom:

atom := [["Be",0,0,0]];

[["Be", 0, 0, 0]]

(1.2)

 

We can then perform the variational 2-RDM method with the Variational2RDM command to compute the ground-state energy and properties of beryllium in a minimal basis set like the one used by Rosina and his collaborators.  By default the method uses the D, Q, and G N-representability conditions and the minimal "sto-3g" basis set.  The calculation, which completes in seconds, contains a wealth of information in the form of a convenient Maple table that we assign to the variable data.

data := Variational2RDM(atom);

table(%id = 18446744313704784158)

(1.3)

 

The table contains the total ground-state energy of the beryllium atom in the atomic unit of energy (hartrees)

data[e_tot];

HFloat(-14.40370016681039)

(1.4)

 

We also have the atomic orbitals (AOs) employed in the calculation

data[aolabels];

Vector(5, {(1) = "0 Be 1s", (2) = "0 Be 2s", (3) = "0 Be 2px", (4) = "0 Be 2py", (5) = "0 Be 2pz"})

(1.5)

 

as well as the Mulliken populations of these orbitals

data[populations];

Vector(5, {(1) = 1.9995807710723152, (2) = 1.7913484714571852, (3) = 0.6969023822632789e-1, (4) = 0.6969026475511847e-1, (5) = 0.6969029119010149e-1})

(1.6)

 

We see that 2 electrons are located in the 1s orbital, 1.8 electrons in the 2s orbital, and about 0.2 electrons in the 2p orbitals.  By default the calculation also returns the 1-RDM

data[rdm1];

Matrix(5, 5, {(1, 1) = 1.9999258249189755, (1, 2) = -0.37784860208539793e-2, (1, 3) = 0., (1, 4) = 0., (1, 5) = 0., (2, 1) = -0.37784860208539793e-2, (2, 2) = 1.7910034176105256, (2, 3) = 0., (2, 4) = 0., (2, 5) = 0., (3, 1) = 0., (3, 2) = 0., (3, 3) = 0.6969023822632789e-1, (3, 4) = 0., (3, 5) = 0., (4, 1) = 0., (4, 2) = 0., (4, 3) = 0., (4, 4) = 0.6969026475511847e-1, (4, 5) = 0., (5, 1) = 0., (5, 2) = 0., (5, 3) = 0., (5, 4) = 0., (5, 5) = 0.6969029119010149e-1})

(1.7)

 

The eigenvalues of the 1-RDM are the natural orbital occupations

LinearAlgebra:-Eigenvalues(data[rdm1]);

Vector(5, {(1) = 1.9999941387490443+0.*I, (2) = 1.7909351037804568+0.*I, (3) = 0.6969023822632789e-1+0.*I, (4) = 0.6969026475511847e-1+0.*I, (5) = 0.6969029119010149e-1+0.*I})

(1.8)

 

We can display the density of the 2s-like 2nd natural orbital using the DensityPlot3D command providing the atom, the data, and the orbitalindex keyword

DensityPlot3D(atom,data,orbitalindex=2);

 

 

Similarly,  using the DensityPlot3D command, we can readily display the 2p-like 3rd natural orbital

DensityPlot3D(atom,data,orbitalindex=3);

 

 

By using Maple keyword arguments in the Variational2RDM command, we can readily change the basis set, use point-group symmetry, add active orbitals with or without self-consistent-field, change the N-representability conditions, as well as explore many other options.  Having reenacted one of the first variational 2-RDM calculations ever, let's examine a more complicated molecule.

 

Explosive TNT

 

We consider the molecule TNT that is used as an explosive. Using the command MolecularGeometry, we can import the experimental geometry of TNT from the online PubChem database.

mol := MolecularGeometry("TNT");

[["O", .5454, -3.514, 0.12e-2], ["O", .5495, 3.5137, 0.8e-3], ["O", 2.4677, -2.4539, -0.5e-3], ["O", 2.4705, 2.4513, 0.3e-3], ["O", -3.5931, -1.0959, 0.4e-3], ["O", -3.5922, 1.0993, 0.6e-3], ["N", 1.2142, -2.454, 0.2e-3], ["N", 1.217, 2.4527, 0], ["N", -2.9846, 0.15e-2, 0.1e-3], ["C", 1.2253, -0.6e-3, -0.9e-3], ["C", .5271, -1.2082, -0.8e-3], ["C", .5284, 1.2078, -0.8e-3], ["C", -1.5646, 0.8e-3, -0.4e-3], ["C", -.8678, -1.2074, -0.6e-3], ["C", -.8666, 1.2084, -0.6e-3], ["C", 2.7239, -0.16e-2, 0.11e-2], ["H", -1.4159, -2.1468, -0.3e-3], ["H", -1.4137, 2.1483, -0.3e-3], ["H", 3.1226, .2418, -.9891], ["H", 3.0863, .6934, .7662], ["H", 3.3154, -.8111, .4109]]

(1.9)

 

The command PlotMolecule generates a 3D ball-and-stick plot of the molecule

PlotMolecule(mol);

 

 

We perform a variational calculation of the 2-RDM of TNT in an active space of 10 electrons and 10 orbitals by setting the keyword active to the list [10,10].  The keyword casscf is set to true to optimize the active orbitals during the calculation.  The keyword basis is used to set the basis set to a minimal basis set sto-3g for illustration.   

data := Variational2RDM(mol, active=[10,10], casscf=true, basis="sto-3g");

table(%id = 18446744493271367454)

(1.10)

 

The ground-state energy of TNT in hartrees is

data[e_tot];

HFloat(-868.8629631593426)

(1.11)

 

Unlike beryllium, the electric dipole moment of TNT in debyes is nonzero

data[dipole];

Vector(3, {(1) = .5158925019252739, (2) = -0.5985274393363119e-1, (3) = .1277528280025474})

(1.12)

 

We can easily visualize the dipole moment relative to the molecule's ball-and-stick model with the DipolePlot command

DipolePlot(mol,method=Variational2RDM, active=[10,10], casscf=true, basis="sto-3g");

 

 

The 1-RDM is returned by default

data[rdm1];

_rtable[18446744313709602566]

(1.13)

 

The natural molecular-orbital (MO) occupations are the eigenvalues of the 1-RDM

data[mo_occ];

_rtable[18446744313709600150]

(1.14)

 

All of the occupations can be viewed at once by converting the Vector to a list

convert(data[mo_occ], list);

[HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(2.0), HFloat(1.9110133620349001), HFloat(1.8984139688344246), HFloat(1.6231436866358906), HFloat(1.6158489471020905), HFloat(1.6145310163161273), HFloat(0.38920731792133734), HFloat(0.387039366894289), HFloat(0.37786347287813526), HFloat(0.09734187094597906), HFloat(0.08559699476985069), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0), HFloat(0.0)]

(1.15)

 

We can visualize these occupations with the MOOccupationsPlot command

MOOccupationsPlot(mol,method=Variational2RDM, active=[10,10], casscf=true, basis="sto-3g");

 

 

The occupations, we observe, show significant deviations from 0 and 2, indicating that the electrons have substantial correlation beyond the mean-field (Hartree-Fock) limit.  The blue lines indicate the first N/2 spatial orbitals where N is the total number of electrons while the red lines indicate the remaining spatial orbitals.  We can visualize the highest "occupied" molecular orbital (58) with the DensityPlot3D command

DensityPlot3D(mol,data, orbitalindex=58);

 

 

Similarly, we can visualize the lowest "unoccupied" molecular orbital (59) with the DensityPlot3D command

DensityPlot3D(mol,data, orbitalindex=59);

 

 

Comparison of orbitals 58 and 59 reveals an increase in the number of nodes (changes in the phase of the orbitals denoted by green and purple), which reflects an increase in the energy of the orbital.

 

Looking Ahead

 

The Maple Quantum Chemistry Toolbox 2019, an new Add-on for Maple 2019 from RDMChem, provides a easy-to-use, research-grade environment for the computation of the energies and properties of atoms and molecules.  In this blog we discussed its origins in graduate research at Harvard, its reproduction of an early 2-RDM calculation of beryllium, and its application to the explosive molecule TNT.  We have illustrated only some of the many features and electronic structure methods of the Maple Quantum Chemistry package.  There is much more chemistry and physics to explore.  Enjoy!    

 

Selected References

 

[1] D. A. Mazziotti, Chem. Rev. 112, 244 (2012). "Two-electron Reduced Density Matrix as the Basic Variable in Many-Electron Quantum Chemistry and Physics"

[2]  Reduced-Density-Matrix Mechanics: With Application to Many-Electron Atoms and Molecules (Adv. Chem. Phys.) ; D. A. Mazziotti, Ed.; Wiley: New York, 2007; Vol. 134.

[3] A. J. Coleman and V. I. Yukalov, Reduced Density Matrices: Coulson’s Challenge (Springer-Verlag,  New York, 2000).

[4] D. A. Mazziotti, Phys. Rev. Lett. 106, 083001 (2011). "Large-scale Semidefinite Programming for Many-electron Quantum Mechanics"

[5] A. W. Schlimgen, C. W. Heaps, and D. A. Mazziotti, J. Phys. Chem. Lett. 7, 627-631 (2016). "Entangled Electrons Foil Synthesis of Elusive Low-Valent Vanadium Oxo Complex"

[6] J. M. Montgomery and D. A. Mazziotti, J. Phys. Chem. A 122, 4988-4996 (2018). "Strong Electron Correlation in Nitrogenase Cofactor, FeMoco"

 

Download QCT2019_PrimesV17_05.05.19.mw

In this Post I derive the differential equations of motion of a homogeneous elliptic lamina of mass m and the major and minor axes of lengths of a and b which rolls without slipping along the horizontal x axis within the vertical xy plane.

If the initial angular velocity is large enough, the ellipse will roll forever and go to ±∞ in the x direction, otherwise it will just rock.

I have attached two files:

 rolling-ellipse.mw
        Worksheet to solve the differential equations and animate the motion

rolling-ellipse.pdf
         Documentation containing the derivation of the differential equations

And here are two animations extracted from the worksheet.

While googling around for Season 8 spoilers, I found data sets that can be used to create a character interaction network for the books in the A Song of Ice and Fire series, and the TV show they inspired, Game of Thrones.

The data sets are the work of Dr Andrew Beveridge, an associate professor at Macalaster College (check out his Network of Thrones blog).

You can create an undirected, weighted graph using this data and Maple's GraphTheory package.

Then, you can ask yourself really pressing questions like

  • Who is the most influential person in Westeros? How has their influence changed over each season (or indeed, book)?
  • How are Eddard Stark and Randyll Tarly connected?
  • What do eigenvectors have to do with the battle for the Iron Throne, anyway?

These two applications (one for the TV show, and another for the novels) have the answers, and more.

The graphs for the books tend to be more interesting than those for the TV show, simply because of the far broader range of characters and the intricacy of the interweaving plot lines.

Let’s look at some of the results.

This a small section of the character interaction network for the first book in the A Song of Ice and Fire series (this is the entire visualization - it's big, simply because of the shear number of characters)

The graph was generated by GraphTheory:-DrawGraph (with method = spring, which models the graph as a system of protons repelling each other, connected by springs).

The highlighted vertices are the most influential characters, as determined by their Eigenvector centrality (more on this later).

 

The importance of a vertex can be described by its centrality, of which there are several variants.

Eigenvector centrality, for example, is the dominant eigenvector of the adjacency matrix, and uses the number and importance of neighboring vertices to quantify influence.

This plot shows the 15 most influential characters in Season 7 of the TV show Game of Thrones. Jon Snow is the clear leader.

Here’s how the Eigenvector centrality of several characters change over the books in the A Song of Ice and Fire series.

A clique is a group of vertices that are all connected to every other vertex in the group. Here’s the largest clique in Season 7 of the TV show.

Game of Thrones has certainly motivated me to learn more about graph theory (yes, seriously, it has). It's such a wide, open field with many interesting real-world applications.

Enjoy tinkering!

Hi

The Physics Updates for Maple 2019 (current v.331 or higher) is already available for installation via MapleCloud. This version contains further improvements to the Maple 2019 capabilities for solving PDE & BC as well as to the tensor simplifier. To install these Updates,

  • Open Maple,
  • Click the MapleCloud icon in the upper-right corner to open the MapleCloud toolbar 
  • In the MapleCloud toolbar, open Packages
  • Find the Physics Updates package and click the install button, it is the last one under Actions
  • To check for new versions of Physics Updates, click the MapleCloud icon. If the Updates icon has a red dot, click it to install the new version

Note that the first time you install the Updates in Maple 2019 you need to install them from Packages, even if in your copy of Maple 2018 you had already installed these Updates.

Also, at this moment you cannot use the MapleCloud to install the Physics Updates for Maple 2018. So, to install the last version of the Updates for Maple 2018, open Maple 2018 and enter PackageTools:-Install("5137472255164416", version = 329, overwrite)

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

This application solves a set of compatible equations of two variables. It also graphs the intersection point of the variable "x" and "y". If we want to observe the intersection point closer we will use the zoom button that is activated when manipulating the graph. If we want to change the variable ("x" and "y") we enter the code of the button that solves and graphs. In spanish.

System_of_Equations_Determined_Compatible_2x2_and_3x3.mw

Lenin Araujo Castillo

Ambassador of Maple

It is my pleasure to announce the return of the Maple Conference! On October 15-17th, in Waterloo, Ontario, Canada, we will gather a group of Maple enthusiasts, product experts, and customers, to explore and celebrate the different aspects of Maple.

Specifically, this conference will be dedicated to exploring Maple’s impact on education, new symbolic computation algorithms and techniques, and the wide range of Maple applications. Attendees will have the opportunity to learn about the latest research, share experiences, and interact with Maple developers.

In preparation for the conference we are welcoming paper and extended abstract submissions. We are looking for presentations which fall into the broad categories of “Maple in Education”, “Algorithms and Software”, and “Applications of Maple” (a more extensive list of topics can be found here).

You can learn more about the event, plus find our call-for-papers and abstracts, here: https://www.maplesoft.com/mapleconference/

There have been several posts, over the years, related to visual cues about the values associated with particular 2D contours in a plot.

Some people ask or post about color-bars [1]. Some people ask or post about inlined labelling of the curves [1, 2, 3, 4, 5, 6, 7]. And some post about mouse popup/hover-over functionality [1]., which got added as general new 2D plot annotation functionality in Maple 2017 and is available for the plots:-contourplot command via its contourlabels option.

Another possibility consists of a legend for 2D contour plots, with distinct entries for each contour value. That is not currently available from the plots:-contourplot command as documented. This post is about obtaining such a legend.

Aside from the method used below, a similar effect may be possible (possibly with a little effort) using contour-plotting approaches based on individual plots:-implicitplot calls for each contour level. Eg. using Kitonum's procedure, or an undocumented, alternate internal driver for plots:-contourplot.

Since I like the functionality provided by the contourlabels option I thought that I'd highjack that (and the _HOVERCONTENT plotting substructure that plot-annotations now generate) and get a relatively convenient way to get a color-key via the 2D plotting legend.  This is not supposed to be super-efficient.

Here below are some examples. I hope that it illustrates some useful functionality that could be added to the contourplot command. It can also be used to get a color-key for use with densityplot.

restart;

contplot:=proc(ee, rng1, rng2)
  local clabels, clegend, i, ncrvs, newP, otherdat, others, tcrvs, tempP;
  (clegend,others):=selectremove(type,[_rest],identical(:-legend)=anything);
  (clabels,others):= selectremove(type,others,identical(:-contourlabels)=anything);
  if nops(clegend)>0 then
    tempP:=:-plots:-contourplot(ee,rng1,rng2,others[],
                                ':-contourlabels'=rhs(clegend[-1]));
    tempP:=subsindets(tempP,'specfunc(:-_HOVERCONTENT)',
                      u->`if`(has(u,"null"),NULL,':-LEGEND'(op(u))));
    if nops(clabels)>0 then
      newP:=plots:-contourplot(ee,rng1,rng2,others[],
                              ':-contourlabels'=rhs(clabels[-1]));
      tcrvs:=select(type,[op(tempP)],'specfunc(CURVES)');
      (ncrvs,otherdat):=selectremove(type,[op(newP)],'specfunc(CURVES)');
      return ':-PLOT'(seq(':-CURVES'(op(ncrvs[i]),op(indets(tcrvs[i],'specfunc(:-LEGEND)'))),
                          i=1..nops(ncrvs)),
                      op(otherdat));
    else
      return tempP;
    end if;
  elif nops(clabels)>0 then
    return plots:-contourplot(ee,rng1,rng2,others[],
                              ':-contourlabels'=rhs(clabels[-1]));
  else
    return plots:-contourplot(ee,rng1,rng2,others[]);
  end if;
end proc:
 

contplot(x^2+y^2, x=-2..2, y=-2..2,
      coloring=["Yellow","Blue"],
      contours = 9,
      size=[500,400],
      legendstyle = [location = right],
      legend=true,
      contourlabels=true,
      view=[-2.1..2.1,-2.1..2.1]
);

contplot(x^2+y^2, x=-2..2, y=-2..2,
      coloring=["Yellow","Blue"],
      contours = 17,
      size=[500,400],
      legendstyle = [location = right],
      legend=['contourvalue',$("null",7),'contourvalue',$("null",7),'contourvalue'],
      contourlabels=true,
      view=[-2.1..2.1,-2.1..2.1]
);

# Apparently legend items must be unique, to persist on document re-open.

contplot(x^2+y^2, x=-2..2, y=-2..2,
      coloring=["Yellow","Blue"],
      contours = 11,
      size=[500,400],
      legendstyle = [location = right],
      legend=['contourvalue',seq(cat($(` `,i)),i=2..5),
              'contourvalue',seq(cat($(` `,i)),i=6..9),
              'contourvalue'],
      contourlabels=true,
      view=[-2.1..2.1,-2.1..2.1]
);

contplot(x^2+y^2, x=-2..2, y=-2..2,
      coloring=["Green","Red"],
      contours = 8,
      size=[400,450],
      legend=true,
      contourlabels=true
);

contplot(x^2+y^2, x=-2..2, y=-2..2,
      coloring=["Yellow","Blue"],
      contours = 13,
      legend=['contourvalue',$("null",5),'contourvalue',$("null",5),'contourvalue'],
      contourlabels=true
);

(low,high,N):=0.1,7.6,23:
conts:=[seq(low..high*1.01, (high-low)/(N-1))]:
contplot(x^2+y^2, x=-2..2, y=-2..2,
      coloring=["Yellow","Blue"],
      contours = conts,
      legend=['contourvalue',$("null",floor((N-3)/2)),'contourvalue',$("null",ceil((N-3)/2)),'contourvalue'],
      contourlabels=true
);

plots:-display(
  subsindets(contplot((x^2+y^2)^(1/2), x=-2..2, y=-2..2,
                      coloring=["Yellow","Blue"],
                      contours = 7,
                      filledregions),
             specfunc(CURVES),u->NULL),
  contplot((x^2+y^2)^(1/2), x=-2..2, y=-2..2,
      coloring=["Yellow","Blue"],
      contours = 7, #grid=[50,50],
      thickness=0,
      legendstyle = [location=right],
      legend=true),
  size=[600,500],
  view=[-2.1..2.1,-2.1..2.1]
);

 

plots:-display(
  contplot(x^2+y^2, x=-2..2, y=-2..2,
      coloring=["Yellow","Blue"],
      contours = 5,
      thickness=0, filledregions),
  contplot(x^2+y^2, x=-2..2, y=-2..2,
      coloring=["Yellow","Blue"],
      contours = 5,
      thickness=3,
      legendstyle = [location=right],
      legend=typeset("<=",contourvalue)),
  size=[700,600],
  view=[-2.1..2.1,-2.1..2.1]
);

N:=11:
plots:-display(
  contplot(sin(x)*y, x=-2*Pi..2*Pi, y=-1..1,
      coloring=["Yellow","Blue"],
      contours = [seq(-1+(i-1)*(1-(-1))/(N-1),i=1..N)],
      thickness=3,
      legendstyle = [location=right],
      legend=true),
   plots:-densityplot(sin(x)*y, x=-2*Pi..2*Pi, y=-1..1,
      colorscheme=["zgradient",["Yellow","Blue"],colorspace="RGB"],
      grid=[100,100],
      style=surface, restricttoranges),
   plottools:-line([-2*Pi,-1],[-2*Pi,1],thickness=3,color=white),
   plottools:-line([2*Pi,-1],[2*Pi,1],thickness=3,color=white),
   plottools:-line([-2*Pi,1],[2*Pi,1],thickness=3,color=white),
   plottools:-line([-2*Pi,-1],[2*Pi,-1],thickness=3,color=white),
   size=[600,500]
);

N:=13:
plots:-display(
  contplot(sin(x)*y, x=-2*Pi..2*Pi, y=-1..1,
      coloring=["Yellow","Blue"],
      contours = [seq(-1+(i-1)*(1-(-1))/(N-1),i=1..N)],
      thickness=6,
      legendstyle = [location=right],
      legend=['contourvalue',seq(cat($(` `,i)),i=2..3),
              'contourvalue',seq(cat($(` `,i)),i=5..6),
              'contourvalue',seq(cat($(` `,i)),i=8..9),
              'contourvalue',seq(cat($(` `,i)),i=11..12),
              'contourvalue']),
   plots:-densityplot(sin(x)*y, x=-2*Pi..2*Pi, y=-1..1,
      colorscheme=["zgradient",["Yellow","Blue"],colorspace="RGB"],
      grid=[100,100],
      style=surface, restricttoranges),
   plottools:-line([-2*Pi,-1],[-2*Pi,1],thickness=6,color=white),
   plottools:-line([2*Pi,-1],[2*Pi,1],thickness=6,color=white),
   plottools:-line([-2*Pi,1],[2*Pi,1],thickness=6,color=white),
   plottools:-line([-2*Pi,-1],[2*Pi,-1],thickness=6,color=white),
  size=[600,500]
);

 

Download contour_legend_post.mw

 

 

 


A Complete Guide for performing Tensors computations using Physics

 

This is an old request, a complete guide for using Physics  to perform tensor computations. This guide, shown below with Sections closed, is linked at the end of this post as a pdf file with all the sections open, and also as a Maple worksheet that allows for reproducing its contents. Most of the computations shown are reproducible in Maple 2018.2.1, and a significant part also in previous releases, but to reproduce everything you need to have the Maplesoft Physics Updates version 283 or higher installed. Feedback one how to improve this presentation is welcome.

 

Physics  is a package developed by Maplesoft, an integral part of the Maple system. In addition to its commands for Quantum Mechanics, Classical Field Theory and General Relativity, Physics  includes 5 other subpackages, three of them also related to General Relativity: Tetrads , ThreePlusOne  and NumericalRelativity (work in progress), plus one to compute with Vectors  and another related to the Standard Model (this one too work in progress).

 

The presentation is organized as follows. Section I is complete regarding the functionality provided with the Physics package for computing with tensors  in Classical and Quantum Mechanics (so including Euclidean spaces), Electrodynamics and Special Relativity. The material of section I is also relevant in General Relativity, for which section II is all devoted to curved spacetimes. (The sub-section on the Newman-Penrose formalism needs to be filled with more material and a new section devoted to the EnergyMomentum tensor is appropriate. I will complete these two things as time permits.) Section III is about transformations of coordinates, relevant in general.

 

For an alphabetical list of the Physics commands with a brief one-line description and a link to the corresponding help page see Physics: Brief description of each command .

 

I. Spacetime and tensors in Physics

 

 

This section contains all what is necessary for working with tensors in Classical and Quantum Mechanics, Electrodynamics and Special Relativity. This material is also relevant for computing with tensors in General Relativity, for which there is a dedicated Section II. Curved spacetimes .

 

Default metric and signature, coordinate systems

   

Tensors, their definition, symmetries and operations

 

 

Physics comes with a set of predefined tensors, mainly the spacetime metric  g[mu, nu], the space metric  gamma[j, k], and all the standard tensors of  General Relativity. In addition, one of the strengths of Physics is that you can define tensors, in natural ways, by indicating a matrix or array with its components, or indicating any generic tensorial expression involving other tensors.

 

In Maple, tensor indices are letters, as when computing with paper and pencil, lowercase or upper case, latin or greek, entered using indexation, as in A[mu], and are displayed as subscripts as in A[mu]. Contravariant indices are entered preceding the letter with ~, as in A[`~&mu;`], and are displayed as superscripts as in A[`~mu`]. You can work with two or more kinds of indices at the same time, e.g., spacetime and space indices.

 

To input greek letters, you can spell them, as in mu for mu, or simpler: use the shortcuts for entering Greek characters . Right-click your input and choose Convert To → 2-D Math input to give to your input spelled tensorial expression a textbook high quality typesetting.

 

Not every indexed object or function is, however, automatically a tensor. You first need to define it as such using the Define  command. You can do that in two ways:

 

1. 

Passing the tensor being defined, say F[mu, nu], possibly indicating symmetries and/or antisymmetries for its indices.

2. 

Passing a tensorial equation where the left-hand side is the tensor being defined as in 1. and the right-hand side is a tensorial expression - or an Array or Matrix - such that the components of the tensor being defined are equal to the components of the tensorial expression.

 

After defining a tensor - say A[mu] or F[mu, nu]- you can perform the following operations on algebraic expressions involving them

 

• 

Automatic formatting of repeated indices, one covariant the other contravariant

• 

Automatic handling of collisions of repeated indices in products of tensors

• 

Simplify  products using Einstein's sum rule for repeated indices.

• 

SumOverRepeatedIndices  of the tensorial expression.

• 

Use TensorArray  to compute the expression's components

• 

TransformCoordinates .

 

If you define a tensor using a tensorial equation, in addition to the items above you can:

 

• 

Get each tensor component by indexing, say as in A[1] or A[`~1`]

• 

Get all the covariant and contravariant components by respectively using the shortcut notation A[] and "A[~]".

• 

Use any of the special indexing keywords valid for the pre-defined tensors of Physics; they are: definition, nonzero, and in the case of tensors of 2 indices also trace, and determinant.

• 

No need to specify the tensor dependency for differentiation purposes - it is inferred automatically from its definition.

• 

Redefine any particular tensor component using Library:-RedefineTensorComponent

• 

Minimizing the number of independent tensor components using Library:-MinimizeTensorComponent

• 

Compute the number of independent tensor components - relevant for tensors with several indices and different symmetries - using Library:-NumberOfTensorComponents .

 

The first two sections illustrate these two ways of defining a tensor and the features described. The next sections present the existing functionality of the Physics package to compute with tensors.

 

Defining a tensor passing the tensor itself

   

Defining a tensor passing a tensorial equation

   

Automatic formatting of repeated tensor indices and handling of their collisions in products

   

Tensor symmetries

   

Substituting tensors and tensor indices

   

Simplifying tensorial expressions

   

SumOverRepeatedIndices

   

Visualizing tensor components - Library:-TensorComponents and TensorArray

   

Modifying tensor components - Library:-RedefineTensorComponent

   

Enhancing the display of tensorial expressions involving tensor functions and derivatives using CompactDisplay

   

The LeviCivita tensor and KroneckerDelta

   

The 3D space metric and decomposing 4D tensors into their 3D space part and the rest

   

Total differentials, the d_[mu] and dAlembertian operators

   

Tensorial differential operators in algebraic expressions

   

Inert tensors

   

Functional differentiation of tensorial expressions with respect to tensor functions

   

The Pauli matrices and the spacetime Psigma[mu] 4-vector

   

The Dirac matrices and the spacetime Dgamma[mu] 4-vector

   

Quantum not-commutative operators using tensor notation

   

II. Curved spacetimes

 

 

Physics comes with a set of predefined tensors, mainly the spacetime metric  g[mu, nu], the space metric  gamma[j, k], and all the standard tensors of general relativity, respectively entered and displayed as: Einstein[mu,nu] = G[mu, nu],    Ricci[mu,nu]  = R[mu, nu], Riemann[alpha, beta, mu, nu]  = R[alpha, beta, mu, nu], Weyl[alpha, beta, mu, nu],  = C[alpha, beta, mu, nu], and the Christoffel symbols   Christoffel[alpha, mu, nu]  = GAMMA[alpha, mu, nu] and Christoffel[~alpha, mu, nu]  = "GAMMA[mu,nu]^(alpha)" respectively of first and second kinds. The Tetrads  and ThreePlusOne  subpackages have other predefined related tensors. This section is thus all about computing with tensors in General Relativity.

 

Loading metrics from the database of solutions to Einstein's equations

   

Setting the spacetime metric indicating the line element or a Matrix

   

Covariant differentiation: the D_[mu] operator and the Christoffel symbols

   

The Einstein, Ricci, Riemann and Weyl tensors of General Relativity

   

A conversion network for the tensors of General Relativity

   

Tetrads and the local system of references - the Newman-Penrose formalism

   

The ThreePlusOne package and the 3+1 splitting of Einstein's equations

   

III. Transformations of coordinates

   

See Also

 

Physics , Conventions used in the Physics package , Physics examples , Physics Updates

 


 

Download Tensors_-_A_Complete_Guide.mw, or the pdf version with sections open: Tensors_-_A_Complete_Guide.pdf

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

Recently, my research team at the University of Waterloo was approached by Mark Ideson, the skip for the Canadian Paralympic men’s curling team, about developing a curling end-effector, a device to give wheelchair curlers greater control over their shots. A gold medalist and multi-medal winner at the Paralympics, Mark has a passion to see wheelchair curling performance improve and entrusted us to assist him in this objective. We previously worked with Mark and his team on a research project to model the wheelchair curling shot and help optimize their performance on the ice. The end-effector project was the next step in our partnership.

The use of technology in the sports world is increasing rapidly, allowing us to better understand athletic performance. We are able to gather new types of data that, when coupled with advanced engineering tools, allow us to perform more in-depth analysis of the human body as it pertains to specific movements and tasks. As a result, we can refine motions and improve equipment to help athletes maximize their abilities and performance. As a professor of Systems Design Engineering at the University of Waterloo, I have overseen several studies on the motor function of Paralympic athletes. My team focuses on modelling the interactions between athletes and their equipment to maximize athletic performance, and we rely heavily on Maple and MapleSim in our research and project development.

The end-effector project was led by my UW students Borna Ghannadi and Conor Jansen. The objective was to design a device that attaches to the end of the curler’s stick and provides greater command over the stone by pulling it back prior to release.  Our team modeled the end effector in Maple and built an initial prototype, which has undergone several trials and adjustments since then. The device is now on its 7th iteration, which we felt appropriate to name the Mark 7, in recognition of Mark’s inspiration for the project. The device has been a challenge, but we have steadily made improvements with Mark’s input and it is close to being a finished product.

Currently, wheelchair curlers use a device that keeps the stone static before it’s thrown. Having the ability to pull back on the stone and break the friction prior to release will provide great benefit to the curlers. As a curler, if you can only push forward and the ice conditions aren’t perfect, you’re throwing at a different speed every time. If you can pull the stone back and then go forward, you’ve broken that friction and your shot is far more repeatable. This should make the game much more interesting.

For our team, the objective was to design a mechanism that not only allowed curlers to pull back on the stone, but also had a release option with no triggers on the curler’s hand. The device we developed screws on to the end of the curler’s stick, and is designed to rest firmly on the curling handle. Once the curler selects their shot, they can position the stone accordingly, slide the stone backward and then forward, and watch the device gently separate from the stone.

For our research, the increased speed and accuracy of MapleSim’s multibody dynamic simulations, made possible by the underlying symbolic modelling engine, Maple, allowed us to spend more time on system design and optimization. MapleSim combines principles of mechanics with linear graph theory to produce unified representations of the system topology and modelling coordinates. The system equations are automatically generated symbolically, which enables us to view and share the equations prior to a numerical solution of the highly-optimized simulation code.

The Mark 7 is an invention that could have significant ramifications in the curling world. Shooting accuracy across wheelchair curling is currently around 60-62%, and if new technology like the Mark 7 is adopted, that number could grow to 70 or 75%. Improved accuracy will make the game more enjoyable and competitive. Having the ability to pull back on the stone prior to release will eliminate some instability for the curlers, which can help level the playing field for everyone involved. Given the work we have been doing with Mark’s team on performance improvements, it was extremely satisfying for us to see them win the bronze medal in South Korea. We hope that our research and partnership with the team can produce gold medals in the years to come.

 

Throughout the course of a year, Maple users create wildly varying applications on all sorts of subjects. To mark the end of 2018, I thought I’d share some of the 2018 submissions to the Maple Application Center that I personally found particularly interesting.

Solving the 15-puzzle, by Curtis Bright. You know those puzzles where you have to move the pieces around inside a square to put them in order, and there’s only one free space to move into?  I’m not good at those puzzles, but it turns out Maple can help. This is one of collection of new, varied applications using Maple’s SAT solvers (if you want to solve the world’s hardest Sudoku, Maple’s SAT solvers can help with that, too).

Romeo y Julieta: Un clasico de las historias de amor... y de las ecuaciones diferenciales [Romeo and Juliet: A classic story of love..and differential equations], by Ranferi Gutierrez. This one made me laugh (and even more so once I put some of it in google translate, which is more than enough to let you appreciate the application even if you don’t speak Spanish). What’s not to like about modeling a high drama love story using DEs?

Prediction of malignant/benign of breast mass with DNN classifier, by Sophie Tan. Machine learning can save lives.

Hybrid Image of a Cat and a Dog, by Samir Khan. Signal processing can be more fun that I realized. This is one of those crazy optical illusions where the picture changes depending on how far away you are.

Beyond the 8 Queens Problem, by Yury Zavarovsky. In true mathematical fashion, why have 8 queens when you can have n?  (If you are interested in this problem, you can also see a different solution that uses SAT solvers.)

Gödel's Universe, by Frank Wang.  Can’t say I understood much of it, but it involves Gödel, Einstein, and Hawking, so I don’t need to understand it to find it interesting.


Overview of the Physics Updates

 

One of the problems pointed out several times about the Physics package documentation is that the information is scattered. There are the help pages for each Physics command, then there is that page on Physics conventions, one other with Examples in different areas of physics, one "What's new in Physics" page at each release with illustrations only shown there. Then there are a number of Mapleprimes post describing the Physics project and showing how to use the package to tackle different problems. We seldomly find the information we are looking for fast enough.

 

This post thus organizes and presents all those elusive links in one place. All the hyperlinks below are alive from within a Maple worksheet. A link to this page is also appearing in all the Physics help pages in the future Maple release. Comments on practical ways to improve this presentation of information are welcome.

Description

 

As part of its commitment to providing the best possible environment for algebraic computations in Physics, Maplesoft launched, during 2014, a Maple Physics: Research and Development website. That enabled users to ask questions, provide feedback and download updated versions of the Physics package, around the clock.

The "Physics Updates" include improvements, fixes, and the latest new developments, in the areas of Physics, Differential Equations and Mathematical Functions. Since Maple 2018, you can install/uninstall the "Physics Updates" directly from the MapleCloud .

Maplesoft incorporated the results of this accelerated exchange with people around the world into the successive versions of Maple. Below there are two sections

• 

The Updates of Physics, as  an organized collection of links per Maple release, where you can find a description with examples of the subjects developed in the Physics package, from 2012 till 2019.

• 

The Mapleprimes Physics posts, containing the most important posts describing the Physics project and showing the use of the package to tackle problems in General Relativity and Quantum Mechanics.

The update of Physics in Maple 2018 and back to Maple 16 (2012)

 

 

• 

Physics Updates during 2018

a. 

Tensor product of Quantum States using Dirac's Bra-Ket Notation

b. 

Coherent States in Quantum Mechanics

c. 

The Zassenhaus formula and the algebra of the Pauli matrices

d. 

Multivariable Taylor series of expressions involving anticommutative (Grassmannian) variables

e. 

New SortProducts command

f. 

A Complete Guide for Tensor computations using Physics

 

• 

Physics Maple 2018 updates

g. 

Automatic handling of collision of tensor indices in products

h. 

User defined algebraic differential operators

i. 

The Physics:-Cactus package for Numerical Relativity

j. 

Automatic setting of the EnergyMomentumTensor for metrics of the database of solutions to Einstein's equations

k. 

Minimize the number of tensor components according to its symmetries, relabel, redefine or count the number of independent tensor components

l. 

New functionality and display for inert names and inert tensors

m. 

Automatic setting of Dirac, Paul and Gell-Mann algebras

n. 

Simplification of products of Dirac matrices

o. 

New Physics:-Library commands to perform matrix operations in expressions involving spinors with omitted indices

p. 

Miscellaneous improvements

 

• 

Physics Maple 2017 updates

q. 

General Relativity: classification of solutions to Einstein's equations and the Tetrads package

r. 

The 3D metric and the ThreePlusOne (3 + 1) new Physics subpackage

s. 

Tensors in Special and General Relativity

t. 

The StandardModel new Physics subpackage

 

• 

Physics Maple 2016 updates

u. 

Completion of the Database of Solutions to Einstein's Equations

v. 

Operatorial Algebraic Expressions Involving the Differential Operators d_[mu], D_[mu] and Nabla

w. 

Factorization of Expressions Involving Noncommutative Operators

x. 

Tensors in Special and General Relativity

y. 

Vectors Package

z. 

New Physics:-Library commands

aa. 

Redesigned Functionality and Miscellaneous

 

• 

Physics Maple 2015 updates

ab. 

Simplification

ac. 

Tensors

ad. 

Tetrads in General Relativity

ae. 

More Metrics in the Database of Solutions to Einstein's Equations

af. 

Commutators, AntiCommutators, and Dirac notation in quantum mechanics

ag. 

New Assume command and new enhanced Mode: automaticsimplification

ah. 

Vectors Package

ai. 

New Physics:-Library commands

aj. 

Miscellaneous

 

• 

Physics Maple 18 updates

ak. 

Simplification

al. 

4-Vectors, Substituting Tensors

am. 

Functional Differentiation

an. 

More Metrics in the Database of Solutions to Einstein's Equations

ao. 

Commutators, AntiCommutators

ap. 

Expand and Combine

aq. 

New Enhanced Modes in Physics Setup

ar. 

Dagger

as. 

Vectors Package

at. 

New Physics:-Library commands

au. 

Miscellaneous

 

• 

Physics Maple 17 updates

av. 

Tensors and Relativity: ExteriorDerivative, Geodesics, KillingVectors, LieDerivative, LieBracket, Antisymmetrize and Symmetrize

aw. 

Dirac matrices, commutators, anticommutators, and algebras

ax. 

Vector Analysis

ay. 

A new Library of programming commands for Physics

 

• 

Physics Maple 16 updates

az. 

Tensors in Special and General Relativity: contravariant indices and new commands for all the General Relativity tensors

ba. 

New commands for working with expressions involving anticommutative variables and functions: Gtaylor, ToFieldComponents, ToSuperfields

bb. 

Vector Analysis: geometrical coordinates with funcional dependency

Mapleprimes Physics posts

 

 

1. 

The Physics project at Maplesoft

2. 

Mini-Course: Computer Algebra for Physicists

3. 

A Complete Guide for Tensor computations using Physics

4. 

Perimeter Institute-2015, Computer Algebra in Theoretical Physics (I)

5. 

IOP-2016, Computer Algebra in Theoretical Physics (II)

6. 

ACA-2017, Computer Algebra in Theoretical Physics (III) 

 

• 

General Relativity

 

7. 

General Relativity using Computer Algebra

8. 

Exact solutions to Einstein's equations 

9. 

Classification of solutions to Einstein's equations and the ThreePlusOne (3 + 1) package 

10. 

Tetrads and Weyl scalars in canonical form 

11. 

Equivalence problem in General Relativity 

12. 

Automatic handling of collision of tensor indices in products 

13. 

Minimize the number of tensor components according to its symmetries

• 

Quantum Mechanics

 

14. 

Quantum Commutation Rules Basics 

15. 

Quantum Mechanics: Schrödinger vs Heisenberg picture 

16. 

Quantization of the Lorentz Force 

17. 

Magnetic traps in cold-atom physics 

18. 

The hidden SO(4) symmetry of the hydrogen atom

19. 

(I) Ground state of a quantum system of identical boson particles 

20. 

(II) The Gross-Pitaevskii equation and Bogoliubov spectrum 

21. 

(III) The Landau criterion for Superfluidity 

22. 

Simplification of products of Dirac matrices

23. 

Algebra of Dirac matrices with an identity matrix on the right-hand side

24. 

Factorization with non-commutative variables

25. 

Tensor Products of Quantum State Spaces 

26. 

Coherent States in Quantum Mechanics 

27. 

The Zassenhaus formula and the Pauli matrices 

 

• 

Physics package generic functionality

 

28. 

Automatic simplification and a new Assume (as in "extended assuming")

29. 

Wirtinger derivatives and multi-index summation

See Also

 

Conventions used in the Physics package , Physics , Physics examples , A Complete Guide for Tensor computations using Physics


 

Download Physics-Updates.mw
 

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

The Zassenhaus formula and the algebra of the Pauli matrices

 

Edgardo S. Cheb-Terrab1 and Bryan C. Sanctuary2

(1) Maplesoft

(2) Department of Chemistry, McGill University, Montreal, Quebec, Canada

 

  


The implementation of the Pauli matrices and their algebra were reviewed during 2018, including the algebraic manipulation of nested commutators, resulting in faster computations using simpler and more flexible input. As it frequently happens, improvements of this type suddenly transform research problems presented in the literature as untractable in practice, into tractable.

  

As an illustration, we tackle below the derivation of the coefficients entering the Zassenhaus formula shown in section 4 of [1] for the Pauli matrices up to order 10 (results in the literature go up to order 5). The computation presented can be reused to compute these coefficients up to any desired higher-order (hardware limitations may apply). A number of examples which exploit this formula and its dual, the Baker-Campbell-Hausdorff formula, occur in connection with the Weyl prescription for converting a classical function to a quantum operator (see sec. 5 of [1]), as well as when solving the eigenvalue problem for classes of mathematical-physics partial differential equations [2].  
To reproduce the results below - a worksheet with this contents is linked at the end - you need to have your Maple 2018.2.1 updated with the 
Maplesoft Physics Updates version 280 or higher.

References

 
  

[1] R.M. Wilcox, "Exponential Operators and Parameter Differentiation in Quantum Physics", Journal of Mathematical Physics, V.8, 4, (1967.

  

[2] S. Steinberg, "Applications of the lie algebraic formulas of Baker, Campbell, Hausdorff, and Zassenhaus to the calculation of explicit solutions of partial differential equations", Journal of Differential Equations, V.26, 3, 1977.

  

[3] K. Huang, "Statistical Mechanics", John Wiley & Sons, Inc. 1963, p217, Eq.(10.60).

 

Formulation of the problem

The Zassenhaus formula expresses exp(lambda*(A+B)) as an infinite product of exponential operators involving nested commutators of increasing complexity

"(e)^(lambda (A+B))   =    (e)^(lambda A) * (e)^(lambda B) * (e)^(lambda^2 C[2]) * (e)^(lambda^3 C[3]) *  ...  "
                                                                       =   exp(lambda*A)*exp(lambda*B)*exp(-(1/2)*lambda^2*%Commutator(A, B))*exp((1/6)*lambda^3*(%Commutator(B, %Commutator(A, B))+2*%Commutator(A, %Commutator(A, B))))

Given A, B and their commutator E = %Commutator(A, B), if A and B commute with E, C[n] = 0 for n >= 3 and the Zassenhaus formula reduces to the product of the first three exponentials above. The interest here is in the general case, when %Commutator(A, E) <> 0 and %Commutator(B, E) <> 0, and the goal is to compute the Zassenhaus coefficients C[n]in terms of A, B for arbitrary finite n. Following [1], in that general case, differentiating the Zassenhaus formula with respect to lambda and multiplying from the right by exp(-lambda*(A+B)) one obtains

"A+B=A+(e)^(lambda A) B (e)^(-lambda A)+(e)^(lambda A)+(e)^(lambda B) 2 lambda C[2] (e)^(-lambda B) (e)^(-lambda A)+ ..."

This is an intricate formula, which however (see eq.(4.20) of [1]) can be represented in abstract form as

 

"0=((&sum;)(lambda^n)/(n!) {A^n,B})+2 lambda ((&sum;) (&sum;)(lambda^(n+m))/(n! m!) {A^m,B^n,C[2]})+3 lambda^2 ((&sum;) (&sum;) (&sum;)(lambda^(n+m+k))/(n! m! k!) {A^k,B^m,(C[2])^n,C[3]})+ ..."

from where an equation to be solved for each C[n] is obtained by equating to 0 the coefficient of lambda^(n-1). In this formula, the repeated commutator bracket is defined inductively in terms of the standard commutator %Commutator(A, B)by

{B, A^0} = B, {B, A^(n+1)} = %Commutator(A, {A^n, B^n})

{C[j], B^n, A^0} = {C[j], B^n}, {C[j], A^m, B^n} = %Commutator(A, {A^`-`(m, 1), B^n, C[j]^k})

and higher-order repeated-commutator brackets are similarly defined. For example, taking the coefficient of lambda and lambda^2 and respectively solving each of them for C[2] and C[3] one obtains

C[2] = -(1/2)*%Commutator(A, B)

C[3] = (1/6)*%Commutator(B, %Commutator(A, B))+(1/3)*%Commutator(B, %Commutator(A, B))

This method is used in [3] to treat quantum deviations from the classical limit of the partition function for both a Bose-Einstein and Fermi-Dirac gas. The complexity of the computation of C[n] grows rapidly and in the literature only the coefficients up to C[5] have been published. Taking advantage of developments in the Physics package during 2018, below we show the computation up to C[10] and provide a compact approach to compute them up to arbitrary finite order.

 

Computing up to C[10]

Set the signature of spacetime such that its space part is equal to +++ and use lowercaselatin letters to represent space indices. Set also A, B and C[n] to represent quantum operators

with(Physics)

Setup(op = {A, B, C}, signature = `+++-`, spaceindices = lowercaselatin)

`* Partial match of  '`*op*`' against keyword '`*quantumoperators*`' `

 

_______________________________________________________

 

[quantumoperators = {A, B, C}, signature = `+ + + -`, spaceindices = lowercaselatin]

(1)

To illustrate the computation up to C[10], a convenient example, where the commutator algebra is closed, consists of taking A and B as Pauli Matrices which, multiplied by the imaginary unit, form a basis for the `&sfr;&ufr;`(2)group, which in turn exponentiate to the relevant Special Unitary Group SU(2). The algebra for the Pauli matrices involves a commutator and an anticommutator

Library:-DefaultAlgebraRules(Psigma)

%Commutator(Physics:-Psigma[i], Physics:-Psigma[j]) = (2*I)*Physics:-LeviCivita[i, j, k]*Physics:-Psigma[k], %AntiCommutator(Physics:-Psigma[i], Physics:-Psigma[j]) = 2*Physics:-KroneckerDelta[i, j]

(2)

Assign now A and B to two Pauli matrices, for instance

A := Psigma[1]

Physics:-Psigma[1]

(3)

B := Psigma[3]

Physics:-Psigma[3]

(4)

Next, to extract the coefficient of lambda^n from

"0=((&sum;)(lambda^n)/(n!) {A^n,B})+2 lambda ((&sum;) (&sum;)(lambda^(n+m))/(n! m!) {A^m,B^n,C[2]})+3 lambda^2 ((&sum;) (&sum;) (&sum;)(lambda^(n+m+k))/(n! m! k!) {A^k,B^m,(C[2])^n,C[3]})+..."

to solve it for C[n+1] we note that each term has a factor lambda^m multiplying a sum, so we only need to take into account the first n+1 terms (sums) and in each sum replace infinity by the corresponding n-m. For example, given "C[2]=-1/2 `%Commutator`(A,B), "to compute C[3] we only need to compute these first three terms:

0 = Sum(lambda^n*{B, A^n}/factorial(n), n = 1 .. 2)+2*lambda*(Sum(Sum(lambda^(n+m)*{C[2], A^m, B^n}/(factorial(n)*factorial(m)), n = 0 .. 1), m = 0 .. 1))+3*lambda^2*(Sum(Sum(Sum(lambda^(n+m+k)*{C[3], A^k, B^m, C[2]^n}/(factorial(n)*factorial(m)*factorial(k)), n = 0 .. 0), m = 0 .. 0), k = 0 .. 0))

then solving for C[3] one gets C[3] = (1/3)*%Commutator(B, %Commutator(A, B))+(1/6)*%Commutator(A, %Commutator(A, B)).

Also, since to compute C[n] we only need the coefficient of lambda^(n-1), it is not necessary to compute all the terms of each multiple-sum. One way of restricting the multiple-sums to only one power of lambda consists of using multi-index summation, available in the Physics package (see Physics:-Library:-Add ). For that purpose, redefine sum to extend its functionality with multi-index summation

Setup(redefinesum = true)

[redefinesum = true]

(5)

Now we can represent the same computation of C[3] without multiple sums and without computing unnecessary terms as

0 = Sum(lambda^n*{B, A^n}/factorial(n), n = 1)+2*lambda*(Sum(lambda^(n+m)*{C[2], A^m, B^n}/(factorial(n)*factorial(m)), n+m = 1))+3*lambda^2*(Sum(lambda^(n+m+k)*{C[3], A^k, B^m, C[2]^n}/(factorial(n)*factorial(m)*factorial(k)), n+m+k = 0))

Finally, we need a computational representation for the repeated commutator bracket 

{B, A^0} = B, {B, A^(n+1)} = %Commutator(A, {A^n, B^n})

One way of representing this commutator bracket operation is defining a procedure, say F, with a cache to avoid recomputing lower order nested commutators, as follows

F := proc (A, B, n) options operator, arrow; if n::negint then 0 elif n = 0 then B elif n::posint then %Commutator(A, F(A, B, n-1)) else 'F(A, B, n)' end if end proc

proc (A, B, n) options operator, arrow; if n::negint then 0 elif n = 0 then B elif n::posint then %Commutator(A, F(A, B, n-1)) else 'F(A, B, n)' end if end proc

(6)

Cache(procedure = F)

 

For example,

F(A, B, 1)

%Commutator(Physics:-Psigma[1], Physics:-Psigma[3])

(7)

F(A, B, 2)

%Commutator(Physics:-Psigma[1], %Commutator(Physics:-Psigma[1], Physics:-Psigma[3]))

(8)

F(A, B, 3)

%Commutator(Physics:-Psigma[1], %Commutator(Physics:-Psigma[1], %Commutator(Physics:-Psigma[1], Physics:-Psigma[3])))

(9)

We can set now the value of C[2]

C[2] := -(1/2)*Commutator(A, B)

I*Physics:-Psigma[2]

(10)

and enter the formula that involves only multi-index summation

H := sum(lambda^n*F(A, B, n)/factorial(n), n = 2)+2*lambda*(sum(lambda^(n+m)*F(A, F(B, C[2], n), m)/(factorial(n)*factorial(m)), n+m = 1))+3*lambda^2*(sum(lambda^(n+m+k)*F(A, F(B, F(C[2], C[3], n), m), k)/(factorial(n)*factorial(m)*factorial(k)), n+m+k = 0))

(1/2)*lambda^2*%Commutator(Physics:-Psigma[1], %Commutator(Physics:-Psigma[1], Physics:-Psigma[3]))+2*lambda*(lambda*%Commutator(Physics:-Psigma[1], I*Physics:-Psigma[2])+lambda*%Commutator(Physics:-Psigma[3], I*Physics:-Psigma[2]))+3*lambda^2*C[3]

(11)

from where we compute C[3] by solving for it the coefficient of lambda^2, and since due to the mulit-index summation this expression already contains lambda^2 as a factor,

C[3] = Simplify(solve(H, C[3]))

C[3] = (2/3)*Physics:-Psigma[3]-(4/3)*Physics:-Psigma[1]

(12)

In order to generalize the formula for H for higher powers of lambda, the right-hand side of the multi-index summation limit can be expressed in terms of an abstract N, and H transformed into a mapping:

 

H := unapply(sum(lambda^n*F(A, B, n)/factorial(n), n = N)+2*lambda*(sum(lambda^(n+m)*F(A, F(B, C[2], n), m)/(factorial(n)*factorial(m)), n+m = N-1))+3*lambda^2*(sum(lambda^(n+m+k)*F(A, F(B, F(C[2], C[3], n), m), k)/(factorial(n)*factorial(m)*factorial(k)), n+m+k = N-2)), N)

proc (N) options operator, arrow; lambda^N*F(Physics:-Psigma[1], Physics:-Psigma[3], N)/factorial(N)+2*lambda*(sum(Physics:-`*`(Physics:-`^`(lambda, n+m), Physics:-`^`(Physics:-`*`(factorial(n), factorial(m)), -1), F(Physics:-Psigma[1], F(Physics:-Psigma[3], I*Physics:-Psigma[2], n), m)), n+m = N-1))+3*lambda^2*(sum(Physics:-`*`(Physics:-`^`(lambda, n+m+k), Physics:-`^`(Physics:-`*`(factorial(n), factorial(m), factorial(k)), -1), F(Physics:-Psigma[1], F(Physics:-Psigma[3], F(I*Physics:-Psigma[2], C[3], n), m), k)), n+m+k = N-2)) end proc

(13)

Now we have

H(0)

Physics:-Psigma[3]

(14)

H(1)

lambda*%Commutator(Physics:-Psigma[1], Physics:-Psigma[3])+(2*I)*lambda*Physics:-Psigma[2]

(15)

The following is already equal to (11)

H(2)

(1/2)*lambda^2*%Commutator(Physics:-Psigma[1], %Commutator(Physics:-Psigma[1], Physics:-Psigma[3]))+2*lambda*(lambda*%Commutator(Physics:-Psigma[1], I*Physics:-Psigma[2])+lambda*%Commutator(Physics:-Psigma[3], I*Physics:-Psigma[2]))+3*lambda^2*C[3]

(16)

In this way, we can reproduce the results published in the literature for the coefficients of Zassenhaus formula up to C[5] by adding two more multi-index sums to (13). Unassign C first

unassign(C)

H := unapply(sum(lambda^n*F(A, B, n)/factorial(n), n = N)+2*lambda*(sum(lambda^(n+m)*F(A, F(B, C[2], n), m)/(factorial(n)*factorial(m)), n+m = N-1))+3*lambda^2*(sum(lambda^(n+m+k)*F(A, F(B, F(C[2], C[3], n), m), k)/(factorial(n)*factorial(m)*factorial(k)), n+m+k = N-2))+4*lambda^3*(sum(lambda^(n+m+k+l)*F(A, F(B, F(C[2], F(C[3], C[4], n), m), k), l)/(factorial(n)*factorial(m)*factorial(k)*factorial(l)), n+m+k+l = N-3))+5*lambda^4*(sum(lambda^(n+m+k+l+p)*F(A, F(B, F(C[2], F(C[3], F(C[4], C[5], n), m), k), l), p)/(factorial(n)*factorial(m)*factorial(k)*factorial(l)*factorial(p)), n+m+k+l+p = N-4)), N)

We compute now up to C[5] in one go

for j to 4 do C[j+1] := Simplify(solve(H(j), C[j+1])) end do

I*Physics:-Psigma[2]

 

(2/3)*Physics:-Psigma[3]-(4/3)*Physics:-Psigma[1]

 

-((1/3)*I)*((3*I)*Physics:-Psigma[1]+(6*I)*Physics:-Psigma[3]-4*Physics:-Psigma[2])

 

-(8/9)*Physics:-Psigma[1]-(158/45)*Physics:-Psigma[3]-((16/3)*I)*Physics:-Psigma[2]

(17)

The nested-commutator expression solved in the last step for C[5] is

H(4)

(1/24)*lambda^4*%Commutator(Physics:-Psigma[1], %Commutator(Physics:-Psigma[1], %Commutator(Physics:-Psigma[1], %Commutator(Physics:-Psigma[1], Physics:-Psigma[3]))))+2*lambda*((1/6)*lambda^3*%Commutator(Physics:-Psigma[1], %Commutator(Physics:-Psigma[1], %Commutator(Physics:-Psigma[1], I*Physics:-Psigma[2])))+(1/2)*lambda^3*%Commutator(Physics:-Psigma[1], %Commutator(Physics:-Psigma[1], %Commutator(Physics:-Psigma[3], I*Physics:-Psigma[2])))+(1/2)*lambda^3*%Commutator(Physics:-Psigma[1], %Commutator(Physics:-Psigma[3], %Commutator(Physics:-Psigma[3], I*Physics:-Psigma[2])))+(1/6)*lambda^3*%Commutator(Physics:-Psigma[3], %Commutator(Physics:-Psigma[3], %Commutator(Physics:-Psigma[3], I*Physics:-Psigma[2]))))+3*lambda^2*((1/2)*lambda^2*%Commutator(Physics:-Psigma[1], %Commutator(Physics:-Psigma[1], (2/3)*Physics:-Psigma[3]-(4/3)*Physics:-Psigma[1]))+lambda^2*%Commutator(Physics:-Psigma[1], %Commutator(Physics:-Psigma[3], (2/3)*Physics:-Psigma[3]-(4/3)*Physics:-Psigma[1]))+(1/2)*lambda^2*%Commutator(Physics:-Psigma[3], %Commutator(Physics:-Psigma[3], (2/3)*Physics:-Psigma[3]-(4/3)*Physics:-Psigma[1]))+lambda^2*%Commutator(Physics:-Psigma[1], %Commutator(I*Physics:-Psigma[2], (2/3)*Physics:-Psigma[3]-(4/3)*Physics:-Psigma[1]))+lambda^2*%Commutator(Physics:-Psigma[3], %Commutator(I*Physics:-Psigma[2], (2/3)*Physics:-Psigma[3]-(4/3)*Physics:-Psigma[1]))+(1/2)*lambda^2*%Commutator(I*Physics:-Psigma[2], %Commutator(I*Physics:-Psigma[2], (2/3)*Physics:-Psigma[3]-(4/3)*Physics:-Psigma[1])))+4*lambda^3*(lambda*%Commutator(Physics:-Psigma[1], -((1/3)*I)*((3*I)*Physics:-Psigma[1]+(6*I)*Physics:-Psigma[3]-4*Physics:-Psigma[2]))+lambda*%Commutator(Physics:-Psigma[3], -((1/3)*I)*((3*I)*Physics:-Psigma[1]+(6*I)*Physics:-Psigma[3]-4*Physics:-Psigma[2]))+lambda*%Commutator(I*Physics:-Psigma[2], -((1/3)*I)*((3*I)*Physics:-Psigma[1]+(6*I)*Physics:-Psigma[3]-4*Physics:-Psigma[2]))+lambda*%Commutator((2/3)*Physics:-Psigma[3]-(4/3)*Physics:-Psigma[1], -((1/3)*I)*((3*I)*Physics:-Psigma[1]+(6*I)*Physics:-Psigma[3]-4*Physics:-Psigma[2])))+5*lambda^4*(-(8/9)*Physics:-Psigma[1]-(158/45)*Physics:-Psigma[3]-((16/3)*I)*Physics:-Psigma[2])

(18)

With everything understood, we want now to extend these results generalizing them into an approach to compute an arbitrarily large coefficient C[n], then use that generalization to compute all the Zassenhaus coefficients up to C[10]. To type the formula for H for higher powers of lambda is however prone to typographical mistakes. The following is a program, using the Maple programming language , that produces these formulas for an arbitrary integer power of lambda:

Formula := proc(A, B, C, Q)

 

This Formula program uses a sequence of summation indices with as much indices as the order of the coefficient C[n] we want to compute, in this case we need 10 of them

summation_indices := n, m, k, l, p, q, r, s, t, u

n, m, k, l, p, q, r, s, t, u

(19)

To avoid interference of the results computed in the loop (17), unassign C again

unassign(C)

 

Now the formulas typed by hand, used lines above to compute each of C[2], C[3] and C[5], are respectively constructed by the computer

Formula(A, B, C, 2)

sum(lambda^n*F(Physics:-Psigma[1], Physics:-Psigma[3], n)/factorial(n), n = N)+2*lambda*(sum(lambda^(n+m)*F(Physics:-Psigma[1], F(Physics:-Psigma[3], C[2], n), m)/(factorial(n)*factorial(m)), n+m = N-1))

(20)

Formula(A, B, C, 3)

sum(lambda^n*F(Physics:-Psigma[1], Physics:-Psigma[3], n)/factorial(n), n = N)+2*lambda*(sum(lambda^(n+m)*F(Physics:-Psigma[1], F(Physics:-Psigma[3], C[2], n), m)/(factorial(n)*factorial(m)), n+m = N-1))+3*lambda^2*(sum(lambda^(n+m+k)*F(Physics:-Psigma[1], F(Physics:-Psigma[3], F(C[2], C[3], n), m), k)/(factorial(n)*factorial(m)*factorial(k)), n+m+k = N-2))

(21)

Formula(A, B, C, 5)

sum(lambda^n*F(Physics:-Psigma[1], Physics:-Psigma[3], n)/factorial(n), n = N)+2*lambda*(sum(lambda^(n+m)*F(Physics:-Psigma[1], F(Physics:-Psigma[3], C[2], n), m)/(factorial(n)*factorial(m)), n+m = N-1))+3*lambda^2*(sum(lambda^(n+m+k)*F(Physics:-Psigma[1], F(Physics:-Psigma[3], F(C[2], C[3], n), m), k)/(factorial(n)*factorial(m)*factorial(k)), n+m+k = N-2))+4*lambda^3*(sum(lambda^(n+m+k+l)*F(Physics:-Psigma[1], F(Physics:-Psigma[3], F(C[2], F(C[3], C[4], n), m), k), l)/(factorial(n)*factorial(m)*factorial(k)*factorial(l)), n+m+k+l = N-3))+5*lambda^4*(sum(lambda^(n+m+k+l+p)*F(Physics:-Psigma[1], F(Physics:-Psigma[3], F(C[2], F(C[3], F(C[4], C[5], n), m), k), l), p)/(factorial(n)*factorial(l)*factorial(m)*factorial(k)*factorial(p)), n+m+k+l+p = N-4))

(22)

 

Construct then the formula for C[10] and make it be a mapping with respect to N, as done for C[5] after (16)

H := unapply(Formula(A, B, C, 10), N)

proc (N) options operator, arrow; sum(lambda^n*F(Physics:-Psigma[1], Physics:-Psigma[3], n)/factorial(n), n = N)+2*lambda*(sum(lambda^(n+m)*F(Physics:-Psigma[1], F(Physics:-Psigma[3], C[2], n), m)/(factorial(n)*factorial(m)), n+m = N-1))+3*lambda^2*(sum(lambda^(n+m+k)*F(Physics:-Psigma[1], F(Physics:-Psigma[3], F(C[2], C[3], n), m), k)/(factorial(n)*factorial(m)*factorial(k)), n+m+k = N-2))+4*lambda^3*(sum(lambda^(n+m+k+l)*F(Physics:-Psigma[1], F(Physics:-Psigma[3], F(C[2], F(C[3], C[4], n), m), k), l)/(factorial(n)*factorial(m)*factorial(k)*factorial(l)), n+m+k+l = N-3))+5*lambda^4*(sum(lambda^(n+m+k+l+p)*F(Physics:-Psigma[1], F(Physics:-Psigma[3], F(C[2], F(C[3], F(C[4], C[5], n), m), k), l), p)/(factorial(n)*factorial(l)*factorial(m)*factorial(k)*factorial(p)), n+m+k+l+p = N-4))+6*lambda^5*(sum(lambda^(n+m+k+l+p+q)*F(Physics:-Psigma[1], F(Physics:-Psigma[3], F(C[2], F(C[3], F(C[4], F(C[5], C[6], n), m), k), l), p), q)/(factorial(n)*factorial(l)*factorial(m)*factorial(p)*factorial(k)*factorial(q)), n+m+k+l+p+q = N-5))+7*lambda^6*(sum(lambda^(n+m+k+l+p+q+r)*F(Physics:-Psigma[1], F(Physics:-Psigma[3], F(C[2], F(C[3], F(C[4], F(C[5], F(C[6], C[7], n), m), k), l), p), q), r)/(factorial(n)*factorial(l)*factorial(m)*factorial(p)*factorial(q)*factorial(k)*factorial(r)), n+m+k+l+p+q+r = N-6))+8*lambda^7*(sum(lambda^(n+m+k+l+p+q+r+s)*F(Physics:-Psigma[1], F(Physics:-Psigma[3], F(C[2], F(C[3], F(C[4], F(C[5], F(C[6], F(C[7], C[8], n), m), k), l), p), q), r), s)/(factorial(n)*factorial(r)*factorial(l)*factorial(m)*factorial(p)*factorial(q)*factorial(k)*factorial(s)), n+m+k+l+p+q+r+s = N-7))+9*lambda^8*(sum(lambda^(n+m+k+l+p+q+r+s+t)*F(Physics:-Psigma[1], F(Physics:-Psigma[3], F(C[2], F(C[3], F(C[4], F(C[5], F(C[6], F(C[7], F(C[8], C[9], n), m), k), l), p), q), r), s), t)/(factorial(s)*factorial(n)*factorial(r)*factorial(l)*factorial(m)*factorial(p)*factorial(q)*factorial(k)*factorial(t)), n+m+k+l+p+q+r+s+t = N-8))+10*lambda^9*(sum(lambda^(n+m+k+l+p+q+r+s+t+u)*F(Physics:-Psigma[1], F(Physics:-Psigma[3], F(C[2], F(C[3], F(C[4], F(C[5], F(C[6], F(C[7], F(C[8], F(C[9], C[10], n), m), k), l), p), q), r), s), t), u)/(factorial(s)*factorial(n)*factorial(t)*factorial(r)*factorial(l)*factorial(m)*factorial(p)*factorial(q)*factorial(k)*factorial(u)), n+m+k+l+p+q+r+s+t+u = N-9)) end proc

(23)

Compute now the coefficients of the Zassenhaus formula up to C[10] all in one go

for j to 9 do C[j+1] := Simplify(solve(H(j), C[j+1])) end do

I*Physics:-Psigma[2]

 

(2/3)*Physics:-Psigma[3]-(4/3)*Physics:-Psigma[1]

 

-((1/3)*I)*((3*I)*Physics:-Psigma[1]+(6*I)*Physics:-Psigma[3]-4*Physics:-Psigma[2])

 

-(8/9)*Physics:-Psigma[1]-(158/45)*Physics:-Psigma[3]-((16/3)*I)*Physics:-Psigma[2]

 

(1030/81)*Physics:-Psigma[1]-(8/81)*Physics:-Psigma[3]+((1078/405)*I)*Physics:-Psigma[2]

 

((11792/243)*I)*Physics:-Psigma[2]+(358576/42525)*Physics:-Psigma[1]+(12952/135)*Physics:-Psigma[3]

 

(87277417/492075)*Physics:-Psigma[1]+(833718196/820125)*Physics:-Psigma[3]+((35837299048/17222625)*I)*Physics:-Psigma[2]

 

-((449018539801088/104627446875)*I)*Physics:-Psigma[2]-(263697596812424/996451875)*Physics:-Psigma[1]+(84178036928794306/2197176384375)*Physics:-Psigma[3]

 

(3226624781090887605597040906/21022858292748046875)*Physics:-Psigma[1]+(200495118165066770268119656/200217698026171875)*Physics:-Psigma[3]+((2185211616689851230363020476/4204571658549609375)*I)*Physics:-Psigma[2]

(24)

Notes: with the material above you can compute higher order values of C[n]. For that you need:

1. 

Unassign C as done above in two opportunities, to avoid interference of the results just computed.

2. 

Indicate more summation indices in the sequence summation_indices in (19), as many as the maximum value of n in C[n].

3. 

Have in mind that the growth in size and complexity is significant, with each C[n] taking significantly more time than the computation of all the previous ones.

4. 

Re-execute the input line (23) and the loop (24).

NULL


Download The_Zassenhause_formula_and_the_Pauli_Matrices.mw

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

Over the holidays I reconnected with an old friend and occasional
chess partner who, upon hearing I was getting soundly thrashed by run
of the mill engines, recommended checking out the ChessTempo site.  It
has online tools for training your chess tactics.  As you attempt to
solve chess problems your rating is computed depending on how well you
do.  The chess problems, too, are rated and adjusted as visitors
attempt them.  This should be familar to any chess or table-tennis
player.  Rather than the Elo rating system, the Glicko rating system is
used.

You have a choice of the relative difficulty of the problems.
After attempting a number of easy puzzles and seeing my rating slowly
climb, I wondered what was the most effective technique to raise my
rating (the classical blunder).  Attempting higher rated problems would lower my
solving rate, but this would be compensated by a smaller loss and
larger gain.  Assuming my actual playing strength is greater than my
current rating (a misconception common to us patzers), there should be a
rating that maximizes the rating gain per problem.

The following Maple module computes the expected rating change
using the Glicko system.

Glicko := module()

export DeltaRating
    ,  ExpectedDelta
    ,  Pwin
    ;

    # Return the change in rating for a loss and a win
    # for player 1 against player2
    DeltaRating := proc(r1,rd1,r2,rd2)
    local E, K, g, g2, idd, q;

        q := ln(10)/400;
        g := rd -> 1/sqrt(1 + 3*q^2*rd^2/Pi^2);
        g2 := g(rd2);
        E := 1/(1+10^(-g2*(r1-r2)/400));
        idd := q^2*(g2^2*E*(1-E));

        K := q/(1/rd1^2+idd)*g2;

        (K*(0-E), K*(1-E));

    end proc:

    # Compute the probability of a win
    # for a player with strength s1
    # vs a player with strength s2.

    Pwin := proc(s1, s2)
    local p;
        p := 10^((s1-s2)/400);
        p/(1+p);
    end proc:

    # Compute the expected rating change for
    # player with strength s1, rating r1 vs a player with true rating r2.
    # The optional rating deviations are rd1 and rd2.

    ExpectedDelta := proc(s1,r1,r2,rd1 := 35, rd2 := 35)
    local P, l, w;
        P := Pwin(s1,r2);
        (l,w) := DeltaRating(r1,rd1,r2,rd2);
        P*w + (1-P)*l;
    end proc:

end module:

Assume a player has a rating of 1500 but an actual playing strength of 1700.  Compute the expected rating change for a given puzzle rating, then plot it.  As expected the graph has a peak.

 

Ept := Glicko:-ExpectedDelta(1700,1500,r2):
plot(Ept,r2 = 1000...2000);

Compute the optimum problem rating

 

fsolve(diff(Ept,r2));

                     {r2 = 1599.350691}

As your rating improves, you'll want to adjust the rating of the problems (the site doesn't allow that fine tuning). Here we plot the optimum puzzle rating (r2) for a given player rating (r1), assuming the player's strength remains at 1700.

Ept := Glicko:-ExpectedDelta(1700, r1, r2):
dEpt := diff(Ept,r2):
r2vsr1 := r -> fsolve(eval(dEpt,r1=r)):
plot(r2vsr1, 1000..1680);

Here is a Maple worksheet with the code and computations.

Glicko.mw

Later

After pondering this, I realized there is a more useful way to present the results. The shape of the optimal curve is independent of the user's actual strength. Showing that is trivial, just substitute a symbolic value for the player's strength, offset the ratings from it, and verify that the result does not depend on the strength.

Ept := Glicko:-ExpectedDelta(S, S+r1, S+r2):
has(Ept, S);
                    false

Here's the general curve, shifted so the player's strength is 0, r1 and r2 are relative to that.

r2_r1 := r -> rhs(Optimization:-Maximize(eval(Ept,r1=r), r2=-500..0)[2][]):
p1 := plot(r2_r1, -500..0, 'numpoints'=30);

Compute and plot the expected points gained when playing the optimal partner and your rating is r-points higher than your strength.

EptMax := r -> eval(Ept, [r1=r, r2=r2_r1(r)]):
plot(EptMax, -200..200, 'numpoints'=30, 'labels' = ["r","Ept"]);

When your playing strength matches your rating, the optimal opponent has a relative rating of

r2_r1(0);
                       -269.86

The expected points you win is

evalf(EptMax(0));
                       0.00956
First 17 18 19 20 21 22 23 Last Page 19 of 71