Items tagged with physics

Hi there,

I have a big polynomial expression involving powers of x and y, that comes from expanding a function in powers of x and y in polynomial form (I use series(convert(series(a,x=0,10),polynom),y=0,10) ). I want to multiply each of the terms by the factorial of the power of x and y it has. How can I do this?
I tried using Physics[Coefficient](a,x) but I get the error: it cannot compute the degree of the expression.
I tried using a double for with a double coeff to get each of the coefficients and the maybe be able to multiply them but I get the error "unable to compute coeff".

Is it because as expanding the series I have the term +O(y^11) that it cannot compute it?

I managed to substitute the x terms using subs(x^3=3!*x^3,x^5=5!*x^5,a). Obviously this is not very efficient since I need to write the substitution for each term, and since the ploynom is grouped in powers of y, this does not work for y (neither does algusbs).

[Edit 2]:

an example of it would be:

restart; z:=1/2*log((1+y+x)/(1+y-x)): a:=diff(z,x)*h: i:=int(series(convert(series(a,x=0,12),polynom),y=0,12),x);
with result 
i := -(1/6)*x^3-(1/8)*x^5-(11/112)*x^7-(31/384)*x^9-(193/2816)*x^11+(x+(2/3)*x^3+(7/10)*x^5+(41/56)*x^7+(109/144)*x^9+(1093/1408)*x^11)*y

And I want the coefficients for each x and y power to be multiplied by the factorial of those powers.


Thank you!

I am trying to solve a system of equations of motion of gravitational field and in this way, I deal with a second order differential equation containing Dirac delta function as follows:

Eq9 := -(l[f]^2/l[g]^2+2)*(diff(G(r, t), r, r)-2*(diff(G(r, t), r))/r)+l[f]^2*(diff(F(r, t), r, r)-2*(diff(F(r, t), r))/r)/l[g]^2+2*l[f]^2*(m^2*l[f]^2-3)*(G(r, t)/r^2-F(r, t)/r^2)/l[g]^2 = l[g]*E*exp(Pi*t*l[f]^2*(1-2*kappa)/l[g]^2)*Dirac(t)*Dirac(r)*Dirac(z)


Eq10 := diff(G(r, t), r, r)-2*(diff(G(r, t), r))/r-2*kappa*(diff(F(r, t), r, r)-2*(diff(F(r, t), r))/r)-(2*(m^2*l[f]^2-3))*(G(r, t)/r^2-F(r, t)/r^2) = l[g]*E*exp(Pi*t*l[f]^2*(1-2*kappa)/l[g]^2)*Dirac(t)*Dirac(r)*Dirac(z)

 want to solve these equations with MAPLE software symbolically.
Can anyone guide me in this way, please?

The material below was presented in the "Semantic Representation of Mathematical Knowledge Workshop", February 3-5, 2016 at the Fields Institute, University of Toronto. It shows the approach I used for “digitizing mathematical knowledge" regarding Differential Equations, Special Functions and Solutions to Einstein's equations. While for these areas using databases of information helps (for example textbooks frequently contain these sort of databases), these are areas that, at the same time, are very suitable for using algorithmic mathematical approaches, that result in much richer mathematics than what can be hard-coded into a database. The material also focuses on an interesting cherry-picked collection of Maple functionality, that I think is beautiful, not well know, and seldom focused inter-related as here.



Digitizing of special functions,

differential equations,

and solutions to Einstein’s equations

within a computer algebra system


Edgardo S. Cheb-Terrab

Physics, Differential Equations and Mathematical Functions, Maplesoft

Editor, Computer Physics Communications



Digitizing (old paradigm)



Big amounts of knowledge available to everybody in local machines or through the internet


Take advantage of basic computer functionality, like searching and editing



Digitizing (new paradigm)


By digitizing mathematical knowledge inside appropriate computational contexts that understand about the topics, one can use the digitized knowledge to automatically generate more and higher level knowledge




1) how to identify, test and organize the key blocks of information,


2) how to access it: the interface,


3) how to mathematically process it to automatically obtain more information on demand





                                           Three examples

Mathematical Functions


"Mathematical functions, are defined by algebraic expressions. So consider algebraic expressions in general ..."

The FunctionAdvisor (basic)


"Supporting information on definitions, identities, possible simplifications, integral forms, different types of series expansions, and mathematical properties in general"



General description





Differential equation representation for generic nonlinear algebraic expressions - their use


"Compute differential polynomial forms for arbitrary systems of non-polynomial equations ..."

The Differential Equations representing arbitrary algebraic expresssions


Deriving knowledge: ODE solving methods


Extending the mathematical language to include the inverse functions


Solving non-polynomial algebraic equations by solving polynomial differential equations





Branch Cuts of algebraic expressions


"Algebraically compute, and visualize, the branch cuts of arbitrary mathematical expressions"






Algebraic expresssions in terms of specified functions


"A conversion network for arbitrary mathematical expressions, to rewrite them in terms of different functions in flexible ways"



General description





Symbolic differentiation of algebraic expressions


"Perform symbolic differentiation by combining different algebraic techniques, including functions of symbolic sequences and Faà di Bruno's formula"






Ordinary Differential Equations


"Beyond the concept of a database, classify an arbitrary ODE and suggest solution methods for it"

General description







Exact Solutions to Einstein's equations



Lambda*g[mu, nu]+G[mu, nu] = 8*Pi*T[mu, nu]


"The authors of "Exact solutions toEinstein's equations" reviewed more than 4,000 papers containing solutions to Einstein’s equations in the general relativity literature, organized the whole material into chapters according to the physical properties of these solutions. These solutions are key in the area of general relativity, are now all digitized and become alive in a worksheet"

The ability to search the database according to the physical properties of the solutions, their classification, or just by parts of keywords (old paradigm) changes the game.

More important, within a computer algebra system this knowledge becomes alive (new paradigm).


The solutions are turned active by a simple call to one commend, called the g_  spacetime metric.


Everything else gets automatically derived and set on the fly ( Christoffel symbols  , Ricci  and Riemann  tensors orthonormal and null tetrads , etc.)


Almost all of the mathematical operations one can perform on these solutions are implemented as commands in the Physics  and DifferentialGeometry  packages.


All the mathematics within the Maple library are instantly ready to work with these solutions and derived mathematical objects.


Finally, in the Maple PDEtools package , we have all the mathematical tools to tackle the equivalence problem around these solutions.






Download:,    Digitizing_Mathematical_Information.pdf

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

This presentation is on an undergrad intermediate Quantum Mechanics topic. Tackling the problem within a computer algebra worksheet in the way shown below is actually the novelty, using the Physics package to formulate the problem with quantum operators and related algebra rules in tensor notation.


Quantization of the Lorentz Force


Pascal Szriftgiser1 and Edgardo S. Cheb-Terrab2 

(1) Laboratoire PhLAM, UMR CNRS 8523, Université Lille 1, F-59655, France

(2) Maplesoft


We consider the case of a quantum, non-relativistic, particle with mass m and charge q evolving under the action of an arbitrary time-independent magnetic field "B=Curl(A(x,y,z)), "where `#mover(mi("A",mathcolor = "olive"),mo("→"))` is the vector potential. The Hamiltonian for this system is

H = (`#mover(mi("p",mathcolor = "olive"),mo("→"))`-q*`#mover(mi("A",mathcolor = "olive"),mo("→"))`(X))^2/(2*m)

where `#mover(mi("p",mathcolor = "olive"),mo("→"))` is the momentum of the particle, and the force acting in this particle, also called the Lorentz force, is given by


`#mover(mi("F",mathcolor = "olive"),mo("→"))` = m*(diff(v(t), t))


where `#mover(mi("v",mathcolor = "olive"),mo("→"))` is the quantized velocity of the particle, and all of  H, `#mover(mi("p",mathcolor = "olive"),mo("→"))`, `#mover(mi("v",mathcolor = "olive"),mo("→"))`, `#mover(mi("B",mathcolor = "olive"),mo("→"))`, `#mover(mi("A",mathcolor = "olive"),mo("→"))` and `#mover(mi("F",mathcolor = "olive"),mo("→"))` are Hermitian quantum operators representing observable quantities.


In the classic (non-quantum) case, `#mover(mi("F"),mo("→"))` for such a particle in the absence of electrical field is given by


`#mover(mi("F"),mo("→"))` = `&x`(q*`#mover(mi("v"),mo("→"))`, `#mover(mi("B"),mo("→"))`) ,


Problem: Departing from the Hamiltonian, show that in the quantum case the Lorentz force is given by [1]


`#mover(mi("F",mathcolor = "olive"),mo("→"))` = (1/2)*q*(`&x`(`#mover(mi("v",mathcolor = "olive"),mo("→"))`, `#mover(mi("B",mathcolor = "olive"),mo("→"))`)-`&x`(`#mover(mi("B",mathcolor = "olive"),mo("→"))`, `#mover(mi("v",mathcolor = "olive"),mo("→"))`))


[1] Photons et atomes, Introduction à l'électrodynamique quantique, p. 179, Claude Cohen-Tannoudji, Jacques Dupont-Roc et Gilbert Grynberg - EDP Sciences janvier 1987.




We choose to tackle the problem in Heisenberg's picture of quantum mechanices, where the state of a system is static and only the quantum operators evolve in time according to


diff(O(t), t) = I*Physics:-Commutator(H, O(t))/`ℏ`


Also, the algebraic manipulations are simpler using tensor abstract notation instead of the standard 3D vector notation. We then start setting the framework for the problem, a system of coordinates X, indicating the dimension of the tensor space to be 3 and the metric Euclidean, and that we will use lowercaselatin letters to represent tensor indices. In addition, not necessary but for convenience, we set the lowercase latin i to represent the imaginary unit and we request automaticsimplification so that the output of everything comes automatically simplified in size.


restart; with(Physics); interface(imaginaryunit = i)

Setup(mathematicalnotation = true, automaticsimplification = true, coordinates = X, dimension = 3, metric = Euclidean, spacetimeindices = lowercaselatin, quiet)

[automaticsimplification = true, coordinatesystems = {X}, dimension = 3, mathematicalnotation = true, metric = {(1, 1) = 1, (2, 2) = 1, (3, 3) = 1}, spacetimeindices = lowercaselatin]



Next we indicate the letters we will use to represent the quantum operators with which we will work, and also the standard commutation rules between position and momentum, always the starting point when dealing with quantum mechanics problems


Setup(quantumoperators = {F}, hermitianoperators = {A, B, H, p, r, v, x}, realobjects = {`ℏ`, m, q}, algebrarules = {%Commutator(p[k], p[n]) = 0, %Commutator(x[k], p[l]) = I*`ℏ`*KroneckerDelta[k, l], %Commutator(x[k], x[l]) = 0})

[algebrarules = {%Commutator(p[k], p[n]) = 0, %Commutator(x[k], p[l]) = I*`ℏ`*Physics:-KroneckerDelta[k, l], %Commutator(x[k], x[l]) = 0}, hermitianoperators = {A, B, H, p, r, v, x}, quantumoperators = {A, B, F, H, p, r, v, x}, realobjects = {`ℏ`, m, q, x1, x2, x3, %dAlembertian, Physics:-dAlembertian}]



Note that we start not indicating F as Hermitian, in order to arrive at that result. The quantum operators A, B, and F are explicit functions of X, so to avoid redundant display of this functionality on the screen we use


CompactDisplay((A, B, F)(X))

A(x1, x2, x3)*`will now be displayed as`*A


B(x1, x2, x3)*`will now be displayed as`*B


F(x1, x2, x3)*`will now be displayed as`*F


Define now as tensors the quantum operators that we will use with tensorial notation (recalling: for these, Einstein's sum rule for repeated indices will be automatically applied when simplifying)


Define(x, p, v, A, B, F, quiet)

{A, B, F, p, v, x, Physics:-Dgamma[a], Physics:-Psigma[a], Physics:-d_[a], Physics:-g_[a, b], Physics:-KroneckerDelta[a, b], Physics:-LeviCivita[a, b, c], Physics:-SpaceTimeVector[a](X)}


The Hamiltonian,

H = (`#mover(mi("p",mathcolor = "olive"),mo("→"))`-q*`#mover(mi("A",mathcolor = "olive"),mo("→"))`(X))^2/(2*m)

in tensorial notation, is given by

H = (p[n]-q*A[n](X))^2/(2*m)

H = (1/2)*Physics:-`^`(p[n]-q*A[n](X), 2)/m


Generally speaking to arrive at  ```#mover(mi("F",mathcolor = "olive"),mo("→"))` = (1/2)*q*(`&x`(`#mover(mi("v",mathcolor = "olive"),mo("→"))`, `#mover(mi("B",mathcolor = "olive"),mo("→"))`)-`&x`(`#mover(mi("B",mathcolor = "olive"),mo("→"))`, `#mover(mi("v",mathcolor = "olive"),mo("→"))`)) what we now need to do is

1) Express this Hamiltonian (5) in terms of the velocity


And, recalling that, in Heisenberg's picture, quantum operators evolve in time according to

diff(O(t), t) = I*Physics:-Commutator(H, O(t))/`ℏ`


2) Take the commutator of H with the velocity itself to obtain its time derivative and, from `#mover(mi("F",mathcolor = "olive"),mo("→"))` = m*(diff(v(t), t)) , that commutator is already the force up to some constant factors.


To get in contact with the basic commutation rules between position and momentum behind quantum phenomena, the quantized velocity itself can be computed as the time derivative of the position operator, i.e as the commutator of x[k] with H

I*Commutator(H = (1/2)*Physics[`^`](p[n]-q*A[n](X), 2)/m, x[k])/`ℏ`

I*Physics:-Commutator(H, x[k])/`ℏ` = (1/2)*(I*q^2*Physics:-AntiCommutator(A[n](X), Physics:-Commutator(A[n](X), x[k]))-I*q*Physics:-AntiCommutator(p[n], Physics:-Commutator(A[n](X), x[k]))-2*(q*A[n](X)-p[n])*Physics:-KroneckerDelta[k, n]*`ℏ`)/(`ℏ`*m)


This expression for the velocity, that involves commutators between the potential A[n](X), the position x[k] and the momentum p[n], can be simplified taking into account the basic quantum algebra rules between position and momentum. We assume that A[n](X)(X) can be decomposed into a formal power series (possibly infinite) of the x[k], hence all the A[n](X) commute between themselves as well as with all the x[k]


{%Commutator(A[k](X), x[l]) = 0, %Commutator(A[k](X), A[l](X)) = 0}

{%Commutator(A[k](X), x[l]) = 0, %Commutator(A[k](X), A[l](X)) = 0}


(Note: in some cases, this is not true, but those cases are beyond the scope of this worksheet.)


Add these rules to the algebra rules already set so that they are all taken into account when simplifying things


Setup(algebrarules = {%Commutator(A[k](X), x[l]) = 0, %Commutator(A[k](X), A[l](X)) = 0})

[algebrarules = {%Commutator(p[k], p[n]) = 0, %Commutator(x[k], p[l]) = I*`ℏ`*Physics:-KroneckerDelta[k, l], %Commutator(x[k], x[l]) = 0, %Commutator(A[k](X), x[l]) = 0, %Commutator(A[k](X), A[l](X)) = 0}]


Simplify(I*Physics[Commutator](H, x[k])/`ℏ` = (1/2)*(I*q^2*Physics[AntiCommutator](A[n](X), Physics[Commutator](A[n](X), x[k]))-I*q*Physics[AntiCommutator](p[n], Physics[Commutator](A[n](X), x[k]))-2*(q*A[n](X)-p[n])*Physics[KroneckerDelta][k, n]*`ℏ`)/(`ℏ`*m))

I*Physics:-Commutator(H, x[k])/`ℏ` = (-A[k](X)*q+p[k])/m


The right-hand side of (9) is then the kth component of the velocity tensor quantum operator, the relationship is the same as in the classical case

v[k] = rhs(I*Physics[Commutator](H, x[k])/`ℏ` = (-A[k](X)*q+p[k])/m)

v[k] = (-A[k](X)*q+p[k])/m


and with this the Hamiltonian (5) can now be rewritten in term of the velocity completing step 1)

simplify(H = (1/2)*Physics[`^`](p[n]-q*A[n](X), 2)/m, {SubstituteTensorIndices(k = n, (rhs = lhs)(v[k] = (-A[k](X)*q+p[k])/m))})

H = (1/2)*m*Physics:-`^`(v[n], 2)


For step 2), to compute

 `#mover(mi("F",mathcolor = "olive"),mo("→"))` = m*(diff(v(t), t)) and m*(diff(v(t), t)) = I*m*Physics:-Commutator(H, v(t)[k])/`ℏ` 


we need the commutator between the different components of the quantized velocity which, contrary to what happens in the classical case, do not commute. For this purpose, take the commutator between (10) with itself after replacing the free index

Commutator(v[k] = (-A[k](X)*q+p[k])/m, SubstituteTensorIndices(k = n, v[k] = (-A[k](X)*q+p[k])/m))

Physics:-Commutator(v[k], v[n]) = -q*(Physics:-Commutator(A[k](X), p[n])+Physics:-Commutator(p[k], A[n](X)))/m^2


To simplify (12), we use the fact that if f  is a commutative mapping that can be decomposed into a formal power series in all the complex plan (which is assumed to be the case for all A[n](X)(X)), then

Physics:-Commutator(p[k], f(x, y, z)) = -I*`ℏ`*`∂`[k](f(x, y, z))

where p[k]"=-i `ℏ` `∂`[k] " is the momentum operator along the x[k] axis. This relation reads in tensor notation:

Commutator(p[k], A[n](X)) = -I*`ℏ`*d_[k](A[n](X))

Physics:-Commutator(p[k], A[n](X)) = -I*`ℏ`*Physics:-d_[k](A[n](X), [X])


Add this rule to the rules previously set in order to automatically take it into account in (12)

Setup(Physics[Commutator](p[k], A[n](X)) = -I*`ℏ`*Physics[d_][k](A[n](X), [X]))

[algebrarules = {%Commutator(p[k], p[n]) = 0, %Commutator(p[k], A[n](X)) = -I*`ℏ`*Physics:-d_[k](A[n](X), [X]), %Commutator(x[k], p[l]) = I*`ℏ`*Physics:-KroneckerDelta[k, l], %Commutator(x[k], x[l]) = 0, %Commutator(A[k](X), x[l]) = 0, %Commutator(A[k](X), A[l](X)) = 0}]


Physics[Commutator](v[k], v[n]) = -q*(Physics[Commutator](A[k](X), p[n])+Physics[Commutator](p[k], A[n](X)))/m^2

Physics:-Commutator(v[k], v[n]) = -I*q*`ℏ`*(Physics:-d_[n](A[k](X), [X])-Physics:-d_[k](A[n](X), [X]))/m^2


Also add this other rule so that it is taken into account automatically

Setup(Physics[Commutator](v[k], v[n]) = -I*q*`ℏ`*(Physics[d_][n](A[k](X), [X])-Physics[d_][k](A[n](X), [X]))/m^2)

[algebrarules = {%Commutator(p[k], p[n]) = 0, %Commutator(p[k], A[n](X)) = -I*`ℏ`*Physics:-d_[k](A[n](X), [X]), %Commutator(v[k], v[n]) = -I*q*`ℏ`*(Physics:-d_[n](A[k](X), [X])-Physics:-d_[k](A[n](X), [X]))/m^2, %Commutator(x[k], p[l]) = I*`ℏ`*Physics:-KroneckerDelta[k, l], %Commutator(x[k], x[l]) = 0, %Commutator(A[k](X), x[l]) = 0, %Commutator(A[k](X), A[l](X)) = 0}]


Recalling now the expression of the Hamiltonian (11) as a function of the velocity, one can compute the components of the force operator  "()Component(v*B,k)=m (v[k])=(i m [H,v[k]][-])/`ℏ`"

F[k](X) = I*m*%Commutator(rhs(H = (1/2)*m*Physics[`^`](v[n], 2)), v[k])/`ℏ`

F[k](X) = I*m*%Commutator((1/2)*m*Physics:-`^`(v[n], 2), v[k])/`ℏ`


Simplify this expression for the quantized force taking the quantum algebra rules (16) into account

Simplify(F[k](X) = I*m*%Commutator((1/2)*m*Physics[`^`](v[n], 2), v[k])/`ℏ`)

F[k](X) = (1/2)*q*(-Physics:-`*`(Physics:-d_[n](A[k](X), [X]), v[n])+Physics:-`*`(Physics:-d_[k](A[n](X), [X]), v[n])-Physics:-`*`(v[n], Physics:-d_[n](A[k](X), [X]))+Physics:-`*`(v[n], Physics:-d_[k](A[n](X), [X])))


It is not difficult to verify that this is the antisymmetrized vector product `&x`(`#mover(mi("v",mathcolor = "olive"),mo("→"))`, `#mover(mi("B",mathcolor = "olive"),mo("→"))`). Departing from `#mover(mi("B",mathcolor = "olive"),mo("→"))` = `&x`(VectorCalculus[Nabla], `#mover(mi("A",mathcolor = "olive"),mo("→"))`) expressed using tensor notation,

B[c](X) = LeviCivita[c, n, m]*d_[n](A[m](X))

B[c](X) = -Physics:-LeviCivita[c, m, n]*Physics:-d_[n](A[m](X), [X])


and taking into acount that

 Component(`&x`(`#mover(mi("v",mathcolor = "olive"),mo("→"))`, `#mover(mi("B",mathcolor = "olive"),mo("→"))`), k) = `ε`[b, c, k]*v[b]*B[c](X) 

multiply both sides of (19) by `ε`[b, c, k]*v[b], getting

LeviCivita[k, b, c]*v[b]*(B[c](X) = -Physics[LeviCivita][c, m, n]*Physics[d_][n](A[m](X), [X]))

Physics:-LeviCivita[b, c, k]*Physics:-`*`(v[b], B[c](X)) = -Physics:-LeviCivita[b, c, k]*Physics:-LeviCivita[c, m, n]*Physics:-`*`(v[b], Physics:-d_[n](A[m](X), [X]))


Simplify(Physics[LeviCivita][b, c, k]*Physics[`*`](v[b], B[c](X)) = -Physics[LeviCivita][b, c, k]*Physics[LeviCivita][c, m, n]*Physics[`*`](v[b], Physics[d_][n](A[m](X), [X])))

Physics:-LeviCivita[b, c, k]*Physics:-`*`(v[b], B[c](X)) = Physics:-`*`(v[m], Physics:-d_[k](A[m](X), [X]))-Physics:-`*`(v[n], Physics:-d_[n](A[k](X), [X]))


Finally, replacing the repeated index m by n 

SubstituteTensorIndices(m = n, Physics[LeviCivita][b, c, k]*Physics[`*`](v[b], B[c](X)) = Physics[`*`](v[m], Physics[d_][k](A[m](X), [X]))-Physics[`*`](v[n], Physics[d_][n](A[k](X), [X])))

Physics:-LeviCivita[b, c, k]*Physics:-`*`(v[b], B[c](X)) = Physics:-`*`(v[n], Physics:-d_[k](A[n](X), [X]))-Physics:-`*`(v[n], Physics:-d_[n](A[k](X), [X]))


Likewise, for

 Component(`&x`(`#mover(mi("v",mathcolor = "olive"),mo("→"))`, `#mover(mi("B",mathcolor = "olive"),mo("→"))`), k) = `ε`[b, c, k]*B[b]*B[c](X) 

multiplying (19), this time from the right instead of from the left, we get

Simplify(((B[c](X) = -Physics[LeviCivita][c, m, n]*Physics[d_][n](A[m](X), [X]))*LeviCivita[k, b, c])*v[b])

Physics:-LeviCivita[b, c, k]*Physics:-`*`(B[c](X), v[b]) = Physics:-`*`(Physics:-d_[k](A[m](X), [X]), v[m])-Physics:-`*`(Physics:-d_[n](A[k](X), [X]), v[n])


SubstituteTensorIndices(m = n, Physics[LeviCivita][b, c, k]*Physics[`*`](B[c](X), v[b]) = Physics[`*`](Physics[d_][k](A[m](X), [X]), v[m])-Physics[`*`](Physics[d_][n](A[k](X), [X]), v[n]))

Physics:-LeviCivita[b, c, k]*Physics:-`*`(B[c](X), v[b]) = Physics:-`*`(Physics:-d_[k](A[n](X), [X]), v[n])-Physics:-`*`(Physics:-d_[n](A[k](X), [X]), v[n])


Simplifying now the expression (18) for the quantized force taking into account (22) and (24) we get

simplify(F[k](X) = (1/2)*q*(-Physics[`*`](Physics[d_][n](A[k](X), [X]), v[n])+Physics[`*`](Physics[d_][k](A[n](X), [X]), v[n])-Physics[`*`](v[n], Physics[d_][n](A[k](X), [X]))+Physics[`*`](v[n], Physics[d_][k](A[n](X), [X]))), {(rhs = lhs)(Physics[LeviCivita][b, c, k]*Physics[`*`](v[b], B[c](X)) = Physics[`*`](v[n], Physics[d_][k](A[n](X), [X]))-Physics[`*`](v[n], Physics[d_][n](A[k](X), [X]))), (rhs = lhs)(Physics[LeviCivita][b, c, k]*Physics[`*`](B[c](X), v[b]) = Physics[`*`](Physics[d_][k](A[n](X), [X]), v[n])-Physics[`*`](Physics[d_][n](A[k](X), [X]), v[n]))})

F[k](X) = (1/2)*q*Physics:-LeviCivita[b, c, k]*(Physics:-`*`(v[b], B[c](X))+Physics:-`*`(B[c](X), v[b]))



`#mover(mi("F",mathcolor = "olive"),mo("→"))` = (1/2)*q*(`&x`(`#mover(mi("v",mathcolor = "olive"),mo("→"))`, `#mover(mi("B",mathcolor = "olive"),mo("→"))`)-`&x`(`#mover(mi("B",mathcolor = "olive"),mo("→"))`, `#mover(mi("v",mathcolor = "olive"),mo("→"))`))

in tensor notation. Finally, we note that this operator is Hermitian as expected

(F[k](X) = (1/2)*q*Physics[LeviCivita][b, c, k]*(Physics[`*`](v[b], B[c](X))+Physics[`*`](B[c](X), v[b])))-Dagger(F[k](X) = (1/2)*q*Physics[LeviCivita][b, c, k]*(Physics[`*`](v[b], B[c](X))+Physics[`*`](B[c](X), v[b])))

F[k](X)-Physics:-Dagger(F[k](X)) = 0


Download:,   Quantization_of_the_Lorentz_force.pdf

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

hi every one, i want to get derivative with sacalar function psi, first time ordinary derivative and second time covariant derivative , how should i write that ?!

hi every one ! i want to use Assume option to simplify some expression ! but it is not working ! what should i do !?

i have assume that ( a+b+c=0) and i want maple returns me exp(a+b+c) =1 ! but it does not ! what should i do !?





  is assumed to be: 0










The presentation below is on undergrad Quantum Mechanics. Tackling this topic within a computer algebra worksheet in the way it's done below, however, is an exciting novelty and illustrates well the level of abstraction that is now possible using the Physics package.


Quantum Mechanics: Schrödinger vs Heisenberg picture

Pascal Szriftgiser1 and Edgardo S. Cheb-Terrab2 

(1) Laboratoire PhLAM, UMR CNRS 8523, Université Lille 1, F-59655, France

(2) Maplesoft


Within the Schrödinger picture of Quantum Mechanics, the time evolution of the state of a system, represented by a Ket "| psi(t) >", is determined by Schrödinger's equation:

I*`ℏ`*(diff(Ket(psi, t), t)) = H*Ket(psi, t)

where H, the Hamiltonian, as well as the quantum operators O__S representing observable quantities, are all time-independent.


Within the Heisenberg picture, a Ket Ket(psi, 0) representing the state of the system does not evolve with time, but the operators O__H(t)representing observable quantities, and through them the Hamiltonian H, do.


Problem: Departing from Schrödinger's equation,


a) Show that the expected value of a physical observable in Schrödinger's and Heisenberg's representations is the same, i.e. that

Bra(psi, t)*O__S*Ket(psi, t) = Bra(psi, 0)*O__H(t)*Ket(psi, 0)


b) Show that the evolution equation of an observable O__H in Heisenberg's picture, equivalent to Schrödinger's equation,  is given by:

diff(O__H(t), t) = (-I*Physics:-Commutator(O__H(t), H))*(1/`ℏ`)

where in the right-hand-side we see the commutator of O__H with the Hamiltonian of the system.

Solution: Let O__S and O__H respectively be operators representing one and the same observable quantity in Schrödinger's and Heisenberg's pictures, and H be the operator representing the Hamiltonian of a physical system. All of these operators are Hermitian. So we start by setting up the framework for this problem accordingly, including that the time t and Planck's constant are real. To automatically combine powers of the same base (happening frequently in what follows) we also set combinepowersofsamebase = true. The following input/output was obtained using the latest Physics update (Aug/31/2016) distributed on the Maplesoft R&D Physics webpage.


Physics:-Setup(hermitianoperators = {H, O__H, O__S}, realobjects = {`ℏ`, t}, combinepowersofsamebase = true, mathematicalnotation = true)

[combinepowersofsamebase = true, hermitianoperators = {H, O__H, O__S}, mathematicalnotation = true, realobjects = {`ℏ`, t}]


Let's consider Schrödinger's equation

I*`ℏ`*(diff(Ket(psi, t), t)) = H*Ket(psi, t)

I*`ℏ`*(diff(Physics:-Ket(psi, t), t)) = Physics:-`*`(H, Physics:-Ket(psi, t))


Now, H is time-independent, so (2) can be formally solved: psi(t) is obtained from the solution psi(0) at time t = 0, as follows:

T := exp(-I*H*t/`ℏ`)



Ket(psi, t) = T*Ket(psi, 0)

Physics:-Ket(psi, t) = Physics:-`*`(exp(-I*t*H/`ℏ`), Physics:-Ket(psi, 0))


To check that (4) is a solution of (2), substitute it in (2):

eval(I*`ℏ`*(diff(Physics[Ket](psi, t), t)) = Physics[`*`](H, Physics[Ket](psi, t)), Physics[Ket](psi, t) = Physics[`*`](exp(-I*H*t/`ℏ`), Physics[Ket](psi, 0)))

Physics:-`*`(H, exp(-I*t*H/`ℏ`), Physics:-Ket(psi, 0)) = Physics:-`*`(H, exp(-I*t*H/`ℏ`), Physics:-Ket(psi, 0))


Next, to relate the Schrödinger and Heisenberg representations of an Hermitian operator O representing an observable physical quantity, recall that the value expected for this quantity at time t during a measurement is given by the mean value of the corresponding operator (i.e., bracketing it with the state of the system Ket(psi, t)).

So let O__S be an observable in the Schrödinger picture: its mean value is obtained by bracketing the operator with equation (4):

Dagger(Ket(psi, t) = Physics[`*`](exp(-I*H*t/`ℏ`), Ket(psi, 0)))*O__S*(Ket(psi, t) = Physics[`*`](exp(-I*H*t/`ℏ`), Ket(psi, 0)))

Physics:-`*`(Physics:-Bra(psi, t), O__S, Physics:-Ket(psi, t)) = Physics:-`*`(Physics:-Bra(psi, 0), exp(I*t*H/`ℏ`), O__S, exp(-I*t*H/`ℏ`), Physics:-Ket(psi, 0))


The composed operator within the bracket on the right-hand-side is the operator O in Heisenberg's picture, O__H(t)

Dagger(T)*O__S*T = O__H(t)

Physics:-`*`(exp(I*t*H/`ℏ`), O__S, exp(-I*t*H/`ℏ`)) = O__H(t)


Analogously, inverting this equation,

(T*(Physics[`*`](exp(I*H*t/`ℏ`), O__S, exp(-I*H*t/`ℏ`)) = O__H(t)))*Dagger(T)

O__S = Physics:-`*`(exp(-I*t*H/`ℏ`), O__H(t), exp(I*t*H/`ℏ`))


As an aside to the problem, we note from these two equations, and since the operator T = exp((-I*H*t)*(1/`ℏ`)) is unitary (because H is Hermitian), that the switch between Schrödinger's and Heisenberg's pictures is accomplished through a unitary transformation.


Inserting now this value of O__S from (8) in the right-hand-side of (6), we get the answer to item a)

lhs(Physics[`*`](Bra(psi, t), O__S, Ket(psi, t)) = Physics[`*`](Bra(psi, 0), exp(I*H*t/`ℏ`), O__S, exp(-I*H*t/`ℏ`), Ket(psi, 0))) = eval(rhs(Physics[`*`](Bra(psi, t), O__S, Ket(psi, t)) = Physics[`*`](Bra(psi, 0), exp(I*H*t/`ℏ`), O__S, exp(-I*H*t/`ℏ`), Ket(psi, 0))), O__S = Physics[`*`](exp(-I*H*t/`ℏ`), O__H(t), exp(I*H*t/`ℏ`)))

Physics:-`*`(Physics:-Bra(psi, t), O__S, Physics:-Ket(psi, t)) = Physics:-`*`(Physics:-Bra(psi, 0), O__H(t), Physics:-Ket(psi, 0))


where, on the left-hand-side, the Ket representing the state of the system is evolving with time (Schrödinger's picture), while on the the right-hand-side the Ket `ψ__0`is constant and it is O__H(t), the operator representing an observable physical quantity, that evolves with time (Heisenberg picture). As expected, both pictures result in the same expected value for the physical quantity represented by O.


To complete item b), the derivation of the evolution equation for O__H(t), we take the time derivative of the equation (7):

diff((rhs = lhs)(Physics[`*`](exp(I*H*t/`ℏ`), O__S, exp(-I*H*t/`ℏ`)) = O__H(t)), t)

diff(O__H(t), t) = I*Physics:-`*`(H, exp(I*t*H/`ℏ`), O__S, exp(-I*t*H/`ℏ`))/`ℏ`-I*Physics:-`*`(exp(I*t*H/`ℏ`), O__S, H, exp(-I*t*H/`ℏ`))/`ℏ`


To rewrite this equation in terms of the commutator  Physics:-Commutator(O__S, H), it suffices to re-order the product  H  exp(I*H*t/`ℏ`) placing the exponential first:

Library:-SortProducts(diff(O__H(t), t) = I*Physics[`*`](H, exp(I*H*t/`ℏ`), O__S, exp(-I*H*t/`ℏ`))/`ℏ`-I*Physics[`*`](exp(I*H*t/`ℏ`), O__S, H, exp(-I*H*t/`ℏ`))/`ℏ`, [exp(I*H*t/`ℏ`), H], usecommutator)

diff(O__H(t), t) = I*Physics:-`*`(exp(I*t*H/`ℏ`), H, O__S, exp(-I*t*H/`ℏ`))/`ℏ`-I*Physics:-`*`(exp(I*t*H/`ℏ`), Physics:-`*`(H, O__S)+Physics:-Commutator(O__S, H), exp(-I*t*H/`ℏ`))/`ℏ`


Normal(diff(O__H(t), t) = I*Physics[`*`](exp(I*H*t/`ℏ`), H, O__S, exp(-I*H*t/`ℏ`))/`ℏ`-I*Physics[`*`](exp(I*H*t/`ℏ`), Physics[`*`](H, O__S)+Physics[Commutator](O__S, H), exp(-I*H*t/`ℏ`))/`ℏ`)

diff(O__H(t), t) = -I*Physics:-`*`(exp(I*t*H/`ℏ`), Physics:-Commutator(O__S, H), exp(-I*t*H/`ℏ`))/`ℏ`


Finally, to express the right-hand-side in terms of  Physics:-Commutator(O__H(t), H) instead of Physics:-Commutator(O__S, H), we take the commutator of the equation (8) with the Hamiltonian

Commutator(O__S = Physics[`*`](exp(-I*H*t/`ℏ`), O__H(t), exp(I*H*t/`ℏ`)), H)

Physics:-Commutator(O__S, H) = Physics:-`*`(exp(-I*t*H/`ℏ`), Physics:-Commutator(O__H(t), H), exp(I*t*H/`ℏ`))


Combining these two expressions, we arrive at the expected result for b), the evolution equation of a given observable O__H in Heisenberg's picture

eval(diff(O__H(t), t) = -I*Physics[`*`](exp(I*H*t/`ℏ`), Physics[Commutator](O__S, H), exp(-I*H*t/`ℏ`))/`ℏ`, Physics[Commutator](O__S, H) = Physics[`*`](exp(-I*H*t/`ℏ`), Physics[Commutator](O__H(t), H), exp(I*H*t/`ℏ`)))

diff(O__H(t), t) = -I*Physics:-Commutator(O__H(t), H)/`ℏ`


Download:     Schrodinger_vs_Heisenberg_picture.pdf

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


In the following example I introduce some commutation rules that are standard in Quantum Mechanics. A major feature of the Maple Physics Package, is that it is possible to define tensors as Quantum Operators. This is of great interest because powerful tensor simplification rules can then be used in Quantum Mechanics. For an example, see the commutation rules of the components of the angular momentum operator in ?Physics,Examples. Here, I focus on a possible issue: when destroying all quantum operators, the pre-defined commutation rules still apply, which should not be the case. As shown in the post, this is link to the fact that these operators are also tensors.




`2016, August 16, 18:56 hours`




restart; with(Physics); interface(imaginaryunit = I)

First, set a 3D Euclidian space

Setup(mathematicalnotation = true, dimension = 3, signature = `+`, spacetimeindices = lowercaselatin, quiet)

[dimension = 3, mathematicalnotation = true, signature = `+ + +`, spacetimeindices = lowercaselatin]


Define two rank 1 tensors

Define(x[k], p[k])

`Defined objects with tensor properties`


{Physics:-Dgamma[a], Physics:-Psigma[a], Physics:-d_[a], Physics:-g_[a, b], p[k], x[k], Physics:-KroneckerDelta[a, b], Physics:-LeviCivita[a, b, c]}


Now, further define these tensors as quantum operators and gives the usual commutation rule between position and momentum operators (Quantum Mechanics).

Setup(hermitianoperators = {p, x}, algebrarules = {%Commutator(p[k], p[n]) = 0, %Commutator(x[k], p[l]) = I*`ℏ`*KroneckerDelta[k, l], %Commutator(x[k], x[l]) = 0}, realobjects = {`ℏ`})

[algebrarules = {%Commutator(p[k], p[n]) = 0, %Commutator(x[k], p[l]) = I*`ℏ`*Physics:-KroneckerDelta[k, l], %Commutator(x[k], x[l]) = 0}, hermitianoperators = {p, x}, realobjects = {`ℏ`}]


As expected:

(%Commutator = Commutator)(p[a], x[b])

%Commutator(p[a], x[b]) = -I*`ℏ`*Physics:-KroneckerDelta[a, b]


Now, reset all the Hermitian operators, so that all quantum operators are destroyed. This is useful if, for instance, one needs to compare some the result with the commutative case.

Setup(redo, hermitianoperators = {})

[hermitianoperators = none]


As expected, there are no quantum operators anymore...


[quantumoperators = {}]

(7) that the following expressions should commute (result should be true)

Library:-Commute(p[a], x[b])



Result should be 0NULL

Commutator(p[a], x[b])

-I*`ℏ`*Physics:-KroneckerDelta[a, b]


p[a], x[b]

p[a], x[b]






Below is just a copy & paste of the above section. The only difference, is that "Define(x[k], p[k])" has been commented, so that x[k]and p[k] are not a tensor. In that case, everything behaves as expected (but of course, the interesting feature of tensors is not available).



restart; with(Physics); interface(imaginaryunit = I)

First, set a 3D Euclidian space

Physics:-Setup(mathematicalnotation = true, dimension = 3, signature = `+`, spacetimeindices = lowercaselatin, quiet)

[dimension = 3, mathematicalnotation = true, signature = `+ + +`, spacetimeindices = lowercaselatin]


#Define two rank 1 tensors

Now, further define these tensors as quantum operators and gives the usual commutation rule between position and momentum operators (Quantum Mechanics)

Physics:-Setup(hermitianoperators = {p, x}, algebrarules = {%Commutator(p[k], p[n]) = 0, %Commutator(x[k], p[l]) = Physics:-`*`(Physics:-`*`(I, `ℏ`), Physics:-KroneckerDelta[k, l]), %Commutator(x[k], x[l]) = 0}, realobjects = {`ℏ`})

[algebrarules = {%Commutator(p[k], p[n]) = 0, %Commutator(x[k], p[l]) = I*`ℏ`*Physics:-KroneckerDelta[k, l], %Commutator(x[k], x[l]) = 0}, hermitianoperators = {p, x}, realobjects = {`ℏ`}]


As expected:

(%Commutator = Physics:-Commutator)(p[a], x[b])

%Commutator(p[a], x[b]) = -I*`ℏ`*Physics:-KroneckerDelta[a, b]


Now, reset all the Hermitian operators, so that all quantum operators are destroyed.

Physics:-Setup(redo, hermitianoperators = {})

[hermitianoperators = none]


As expected, there are no quantum operators anymore...


[quantumoperators = {}]

(15) that the following expressions should commute (result should be true)

Physics:-Library:-Commute(p[a], x[b])



Result should be 0``

Physics:-Commutator(p[a], x[b])



p[a], x[b]

p[a], x[b]







Dear all

Let q be  a real  different to one and for a fixed positive integer  n  given also 


Let x and y satisfies the condition

x*y -q*y*x=1

I will assume that the product is not commutative in all my computation

We would like to write the following function using only y

f(x,y)= x*y^n-q^n*y^n*x


all computation done I get f(x,y)=(q^n-1)/(q-1)*y^(n-1)

But how can I get the same result using Maple

Thank you very much for any help






Is there a maple routine or sequence of routines to minimize an energy functional (scalar energy with a function as an argument)?

I'd like to avoid applying calculus of variations/integration by parts by hand.

For example, I'm looking for something like:

E := int(diff(f(x),x)^2,x=0..1);
bc := f(0) = 0, f(1) = 1;

whose result would be:

       f(x) = x

Is there a way to use dsolve to do this?

Hi guys. I am new to the Maple environment.

Was trying to do some GR calculations when the following problem arose.

restart; with(Physics);
Setup(coordinates = (X = [t, r, theta, phi]), metric = -A(r)^2*(dt^2)+B(r)^2*(dr^2)+r^2*(dtheta^2)+r^2*(sin(theta)^2)*(dphi^2));
Setup(math = true);
g_[line_element]; g_[];
Christoffel[nonzero]; Christoffel[`~mu`, alpha, beta, nonzero];
D_[mu](g_[`~alpha`, `~beta`]);
expand(D_[2](g_[`~2`, `~beta`]));
D_[2](g_[`~2`, `~2`]);

The output for the last 3 lines are:

1. 0

2. Expansion in terms of Christoffel symbols (which does equal zero on substituting various values)

3. Non-zero value.

Obviously the answer must be zero for all cases (covariant derivative of metric). So what have I missed/misunderstood here?



The following command works fine until you use it in the combination conjugate and diff.

example in Physics:



phi(X) should now appear as phi with index x1 and a bar only, but

it comes as phi(X) x1 , the declare command is not effective. Non conjugate works fine.

Any idea - thanks in advance

Hi All, 

I'm using the Physics package, which enables GR calculations, ie defining metrics and tensor algebra. 

Was just curious if it were possible to add a perturbation to the metric when calculating Ricci and Christoffels. 

I would like something like 

g_[] = g1_[mu,nu] + h[mu,nu] 

And then do a calculation like, 



I know this would be possible if I define everything and re-write the calculations for calculating Ricci, i.e

Define(g1[mu,nu], h[mu,nu]); 

and the proceed with GR calculations to find Ricci, however was hoping there was an easier way to do this. 

Any help is appreciated. 

Thanks guys. 



I'm new to the physics package - wondering if i can tweak it a bit to look like things i'm used to:


is there a way to make Christoffel symbols print as upper case gamma, instead of  'G'?

KroneckerDelta print as lower case delta, instead of 'd'?


can i make the Schwarzschild metric look like it does in Hartle, Carroll, and others:


-(1 - 2M/r)dt^2 + (1-2M/r)^-1 + r^2(dtheta^2 + sin(theta)^2 dphi^2)


i know about setting the signature in Setup.

i have tried the 'Coordinates' command, but when i give it X=[t,r,theta,phi] i always seem to get back



i am running maple 2016


many thanks,





I want to write the functional Z of J Z = exp(Int(Int(J(x)*Delta(x-y)*J(y), x), y))with Delta(x) = Int(I*exp(-I*k*x)*(1/(k^2-m^2)), k) in terms of the fourier transform of J: J(x) = Int(J(p)*exp(-I*p*x), p).

Actually I'm in Minkowski space and all the integrals should be over 4 dimensions, x,y,k,p should all be four-vectors, but I wanted to keep things short. (The only way I have found to express a 4D integral is using Physics-Intc with the singleparameters of the four vector. Is there a more convenient way to get d^4x?) But still in 1D I cannot solve it.

To find the solution, an exponential of only one integral, is actually pretty easy, since there are integrals over e. g. exp(-I*x*(p-k)) deliver a delta distribution, but I cannot reproduce this in Maple since he doesn't perform the integral over x.

I have found that I can/have to use the command inttrans-fourier to gain the delta distribution, but when I try to use it for the problem mentioned above I run into all kinds of problems. Not to mention that I cannot manage to perform a fourier transformation in 4D.

Does anybody know how to solve this problem? Thanks!

1 2 3 4 5 6 7 Last Page 1 of 14