Items tagged with physics physics Tagged Items Feed

I am trying to setup a general metric with the Physics package.  The metric is composed of the Minkowski metric plus the product of two null vectors. Here is the code:




eta[mu,nu] := rhs(g_[]);



I get the following error:

Error, (in Physics:-Setup) wrong argument: g[mu, nu] = l[mu]*l[nu]+(Matrix(4, 4, {(1, 1) = -1, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (2, 2) = -1, (2, 3) = 0, (2, 4) = 0, (3, 3) = -1, (3, 4) = 0, (4, 4) = 1}, storage = triangular[upper], shape = [symmetric]))


My plan is to apply the rule g[~mu,~nu]*l[mu]*l[nu] = 0 and calculate the Christoffel symbols using the metric.

I am trying to use the Physics package because the DifferentialGeometry package seemed focused on Newman-Penrose.  I will not be using NP for the calculations, only a strict calculation of the Einstein field equations from the given metric.

Thank you.

With the package VectorCalculus we can study the speed and acceleration to their respective components. Considering the visualizaccion and algebraic calculations and to check with their respective commands. Both 2D and 3D.


Velocidad-Aceleració.mw     (in spanish)


Lenin Araujo Castillo

Physics Pure

Computer Science

Hello, everyone. I faced some promblems on maple. Hope you can help me.

I want to set up the commutation rules like Pauli sigma matrix in Physics Packages,

but failed to get the correct one.

Here is my maple code:

Setup(mathematicalnotation = true);

Setup(quantumop = {Q}, algebrarule = {%AntiCommutator(Q[j], Q[k]) = 2*KroneckerDelta[j, k], %Commutator(Q[j], Q[k]) = 2*I*(Sum(LeviCivita[i, k, l]*Q[l], l = 1 .. 3))});

Commutator(Q[1], Q[2]);
AntiCommutator(Q[1], Q[2]);
AntiCommutator(Q[1], Q[1]);
Commutator(Q[1], Q[1]);

In fact, Commutator(Q[1], Q[2]) give a incorrect result 0 while the correct answer is  2*I*Q[3].

Do anyone know how to resolve this?

The attached presentation is the last one of a sequence of three on Quantum Mechanics using Computer Algebra, covering the field equation for a quantum system of identical particles, its stationary solutions and the equations for small perturbations around them and, in this third presentation, the conditions for superfluidity of such a system of identical particles at low temperature. The novelty is again in how to tackle these problems in a computer algebra worksheet.   QuantumMechanics3.pdf

Edgardo S. Cheb-Terrab
Physics, Maplesoft

This is a mini-course I gave in Brazil last week, at the CBPF (Brazilian Center for Physics Research). The material will still receive polishment and improvements, towards evolving into a sort of manual, but it is also interesting to see it exactly as it was presented to people during the course. This material uses the update of Physics available at the Maplesoft Physics R&D webpage.

Edgardo S. Cheb-Terrab
Physics, Maplesoft

Hello everybody,


I want to use the physics package in the context of special relativity.  I am mostly interrested with the Lorenzts transformations, not having to unprotect gamma all the time, the 4-vectors for space, time and momentum in (ct,x,y).  For exemple, to be able to calculate the invariant (ct)^2-(r^2).  A small document (or worksheet) would be very nice of you.

I understande that someone could say that I want to use a gun to kill a fly.  But this is a process that will lead me in using it in general relativity and using tensors in my calculations.  It would be very interresting to have a Student,Physics package.  Don't you think so?

Thank you in advance for your trouble and comprehension.


Mario Lemelin
Maple 18 Ubuntu 13.10 - 64 bits
Maple 18 Win 7 - 64 bits messagerie : téléphone :  (819) 376-0987

can we load part of a package not the package whole !? for example from physics package i only need diff tool not all of the package tools,can i do sth for that !? 

hi,i want to take differential with respect to another differential using physics package,but using D instead of diff,could anyone help me do that ? for example :

restart; with(Physics):
A1 := -(1/24)*1*rho*((diff(phi[1](x, t), t))^2)*(h^3)-(1/2)*1*rho*((diff(u[ref](x, t), t))^2)*h-(1/2)*rho*((diff(w(x, t), t))^2)*h+(1/24)*1*1*((diff(phi[1](x, t), x))^2)*(h^3)+(1/2)*1*(1*((diff(u[ref](x, t), x)+(1/2)*(diff(w(x, t), x))^2)^2)+K*1*((diff(w(x, t), x)+phi[1](x, t))^2))*h-1*q*w(x, t):


here i want to compute A2 using D command,not diff and i do not want use convert command ! i just need to calculate A2 directly using D command. tnx for your help.


I wanted to define a 4th order tensor in the following way,

    Setup(mathematicalnotation = true);
    delta := KroneckerDelta;
    L[i, j, k, l] := lambda*delta[i, j]*delta[k, l]+mu*(delta[i, k]*delta[j, l]+delta[i, l]*delta[j, k]);

but when I type L[1, 1, 1, 1] it doesn't replace i, j, j and l by 1. i
do i need to define it in a different way?

which method i input a series of random number it output a periodic waveform

how to express bosonic and fermonic with physics package in maple?

what are the difference between upperscript and underscript?

Vector using package Physics, LinearAlgebra.     (in spanish)

I was recently asked about performing some General Relativity computations from a paper by Plamen Fiziev, posted in the arXiv in 2013. It crossed my mind that this question is also instrumental to illustrate how these General Relativity algebraic computations can be performed using the Physics package. The pdf and mw links at the end show the same contents but with the Sections expanded.

General Relativity using Computer Algebra


Problem: for the spacetime metric,

g[mu, nu] = (Matrix(4, 4, {(1, 1) = -exp(lambda(r)), (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (2, 1) = 0, (2, 2) = -r^2, (2, 3) = 0, (2, 4) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = -r^2*sin(theta)^2, (3, 4) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = exp(nu(r))}))


a) Compute the trace of


"Z[alpha]^(beta)=Phi R[alpha]^(beta)+`𝒟`[alpha]`𝒟`[]^(beta) Phi+T[alpha]^(beta)"


where `≡`(Phi, Phi(r)) is some function of the radial coordinate, R[alpha, `~beta`] is the Ricci tensor, `𝒟`[alpha] is the covariant derivative operator and T[alpha, `~beta`] is the stress-energy tensor


T[alpha, beta] = (Matrix(4, 4, {(1, 1) = 8*exp(lambda(r))*Pi, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (2, 1) = 0, (2, 2) = 8*r^2*Pi, (2, 3) = 0, (2, 4) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 8*r^2*sin(theta)^2*Pi, (3, 4) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = 8*exp(nu(r))*Pi*epsilon}))

b) Compute the components of "W[alpha]^(beta)"" ≡"the traceless part of  "Z[alpha]^(beta)" of item a)


c) Compute an exact solution to the nonlinear system of differential equations conformed by the components of  "W[alpha]^(beta)" obtained in b)


Background: The equations of items a) and b) appear in a paper from February/2013, "Withholding Potentials, Absence of Ghosts and Relationship between Minimal Dilatonic Gravity and f(R) Theories", by Plamen Fiziev, a Maple user.  These equations model a problem in the context of a Branse-Dicke theory with vanishing parameter "omega." The Brans–Dicke theory is in many respects similar to Einstein's theory, but the gravitational "constant" is not actually presumed to be constant - it can vary from place to place and with time - and the gravitational interaction is mediated by a scalar field. Both Brans–Dicke's and Einstein's theory of general relativity are generally held to be in agreement with observation.


The computations below aim at illustrating how this type of computation can be performed using computer algebra, and so they focus only on the algebraic aspects, not the physical interpretation of the results.

a) The trace of "  Z[alpha]^(beta)=Phi R[alpha]^(beta)+`𝒟`[alpha]`𝒟`[]^(beta) Phi+T[alpha]^(beta)"


b) The components of "W[alpha]^(beta)"" ≡"the traceless part of " Z[alpha]^(beta)"


c) An exact solution for the nonlinear system of differential equations conformed by the components of  "W[alpha]^(beta)"




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

I thought it would be interesting to review what happened with Physics in Maple during 2013. The proposed theme for the Physics project was the consolidation and integration of the package with the rest of the Maple library. There were more than 500 changes, enhancements in most of the Physics commands, plus 17 new Physics:-Library commands. The impact of these changes is across the board, from Vector Analysis to Quantum Mechanics, Relativity and Field Theory.

Consolidation of the Physics package is about making it robust and versatile in real case scenarios. With the launch of the Physics: Research and Development updates webpage, Maplesoft has pioneered feedback, adjustments in the package and new developments provided around the clock for all of its users. The result of this accelerated exchange with people around the world is what you find in Maple's updated Physics today.

In addition to changes improving the functionality in mathematical-physics, changes were introduced towards making the computational experience as natural as possible, now including textbook-like typesetting of inert forms for the whole mathematical language and vectorial differential operators.

Physics doubled in size in Maple 16, almost doubled again in Maple 17, and during 2013 Physics received the largest number of changes ever in the package in one year. We are aiming for real to provide a state-of-the-art environment for algebraic computations in Physics. The links at the end show the same but with the Examples sections expanded.



Simplification is perhaps the most common operation performed in a computer algebra system. In Physics, this typically entails simplifying tensorial expressions, or expressions involving noncommutative operators that satisfy certain commutator/anticommutator rules, or sums and integrals involving quantum operators and Dirac delta functions in the summands and integrands. Relevant enhancements were introduced for all these cases.



4-Vectors, Substituting Tensors


In Maple 17, it is possible to define a tensor with a tensorial equation, where the tensor being defined is on the left-hand side. Then, on the right-hand side, you write either a tensorial expression with free and repeated indices, or a Matrix or Array with the components themselves. With the updated Physics, you can also define a 4-Vector with a tensorial equation, where you indicate the vector's components on the right-hand side as a list.

One new Library routine specialized for tensor substitutions was added to the Maple library: SubstituteTensor, which substitutes the equation(s) Eqs into an expression, taking care of the free and repeated indices, such that: 1) equations in Eqs are interpreted as mappings having the free indices as parameters, and 2) repeated indices in Eqs do not clash with repeated indices in the expression. This new routine can also substitute algebraic sub-expressions of type product or sum within the expression, generalizing and unifying the functionality of the subs and algsubs  commands for algebraic tensor expressions.



Functional Differentiation


The Physics:-Fundiff command for functional differentiation has been extended to handle all the complex components ( abs , argument , conjugate , Im , Re , signum ) and vectorial differential operators in order to compute field equations using variational principles when the field function enters the Lagrangian together with its conjugate. For an example illustrating the use of the new capabilities in the context of a more general problem, see the MaplePrimes post Quantum Mechanics using Computer Algebra.



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


A database of solutions to Einstein's equations  was added to the Maple library in Maple 15 with a selection of metrics from "Stephani, H.; Kramer, D.; MacCallum, M.; Hoenselaers, C.; and Herlt, E.,  Exact Solutions to Einstein's Field Equations" and "Hawking, Stephen; and Ellis, G. F. R., The Large Scale Structure of Space-Time". More metrics from these two books were added for Maple 16 and Maple 17. These metrics can be searched using the command DifferentialGeometry:-Library:-MetricSearch, or directly using g_ (the Physics command representing the spacetime metric that also sets the metric to your choice).


With the updated Physics, fifty more metrics are available in the database from Chapter 28 of the aformentioned book entitled "Exact Solutions to Einstein's Field Equations".


It is now possible to list all the metrics of a chapter by indexing the metric command with the chapter's number, for example, entering g_["28"].



Commutators, AntiCommutators


When computing with products of noncommutative operators, the results depend on the algebra of commutators and anticommutators that you previously set. Besides that, in Physics, various mathematical objects themselves satisfy specific commutation rules. You can query about these rules using the Library commands Commute and Anticommute. Previously existing functionality and enhancements in this area were refined and implemented during 2013. Among them:


Both Commutator and AntiCommutator now accept matrices as arguments.


The AntiCommutator of products of fermionic operators - for instance annihilation and creation operators - is now derived automatically from the intrinsic anticommutation rules they satisfy.


Commutators and Anticommutators of vectorial quantum operators `#mover(mi("A",mathcolor = "olive"),mo("→"))`, `#mover(mi("B",mathcolor = "olive"),mo("→"))`, are now implemented and expressed using the dot (scalar) product, as in Physics:-Commutator(`#mover(mi("A",mathcolor = "olive"),mo("→"))`, `#mover(mi("B",mathcolor = "olive"),mo("→"))`) = `#mover(mi("A",mathcolor = "olive"),mo("→"))`.`#mover(mi("B",mathcolor = "olive"),mo("→"))`-`#mover(mi("B",mathcolor = "olive"),mo("→"))`.`#mover(mi("A",mathcolor = "olive"),mo("→"))`


If two noncommutative operators a and S  satisfy "[a^(†),S][-]=0" , then the commutator  "[a,S^(†)][-]" is automatically taken equal to 0; if in addition S is Hermitian, then  "[a,S][-]"is also automatically taken equal to zero.



Expand and Combine


In the context of Physics, the expansion and recombination of algebraic expressions requires additional care: products may involve non-commutative operators and then some of the standard expansion and combination rules do not apply, or apply differently. Similarly, the expansion of vectorial operators also follows special rules. During 2013, many of these algebraic operations were reviewed and related special formulas (such as Glauber's and Haussdorf's) were implemented.



New Enhanced Modes in Physics Setup


Four enhanced modes were added to the Physics setup. With these modes, you can:


Indicate the real objects of a computation.


Automatically combine powers of the same base.


Set Maple to take z and its conjugate, "z," as independent variables and in equal footing; this is Wirtinger calculus.


Redefine the sum command in order to perform multi-index summation.

These options combined provide flexibility, subsequently making the Physics environment more expressive.

Real Objects


Combining Powers of the Same Base


Complex variables: z and conjugate(z) in equal footing


Redefine Sum for Multi-Index Summation




Physics:-Dagger now has the same shortcut notation of Hermitian transpose , which acts on Vectors, vector products, equations, and automatically maps over the arguments of derivatives when the differentiation variables are real.



Vectors Package


A number of changes were performed in the Vectors subpackage to make the computations more natural and versatile:


You can now use geometrical coordinates indexed, as in r[j], to represent mathematical objects unrelated to the coordinates themselves (in this case the spherical coordinate r).  This is a more appropriate mimicry of the way we compute with paper and pencil.


Integrate the Vectors package commands with assuming and accept a tensor with 1 index (of type Library:-PhysicsType:-Tensor, defined using Define) as a possible abstract representation of the kth component of a vector.


When V is a vector of the Physics:-Vectors package, make its absolute value abs(V), compute automatically using Physics:-Vectors:-Norm


For an arbitrary vector  `#mover(mi("A"),mo("→"))`, make its Norm LinearAlgebra[Norm](`#mover(mi("A"),mo("→"))`) = "A*(A)," and introduce a new option conjugate to Norm, to specify whether to use `#mover(mi("A"),mo("→"))`.conjugate(`#mover(mi("A"),mo("→"))`) or `#mover(mi("A"),mo("→"))`.`#mover(mi("A"),mo("→"))` when computing LinearAlgebra[Norm](`#mover(mi("A"),mo("→"))`).


When `#mover(mi("A",mathcolor = "olive"),mo("→"))` is a quantum operator, Norm returns using Dagger instead of conjugate.


Commutators and Anticommutators of vectorial quantum operators `#mover(mi("A",mathcolor = "olive"),mo("→"))`, `#mover(mi("B",mathcolor = "olive"),mo("→"))`, are now implemented and expressed using the dot (scalar) product, as in "[A,B][-]=A*B-B*A . "


New PhysicsVectors type in the Library of types Library:-PhysicsTypes, in order to programmatically identify vectors of the Physics:-Vectors package.


Two examples illustrating the use of the new capabilities in the context of a more general problem are found in the MaplePrimes posts Quantum Mechanics using Computer Algebra and Quantum Mechanics (II).





Seventeen new commands, useful for programming and interactive computation, were added to the Physics:-Library package. These are:


Add unifies the standard add and sum commands using a more modern handling of arguments, free of premature evaluation problems, and brings new multi-index functionality.


ApplyCommandUsingImplicitAssumptions applies any command to expressions containing sums, integrals or products such that the command is applied to the summand (integrand or 1st argument of the product) taking into account the assumptions implicit in the summation (integration or product) range.


CombinePowersOfSameBase combines powers of the same base in products correctly handling the case of noncommutative products and powers, using Glauber's formula.


FromTensorFunctionalForm is a generalization of the former FromGeneralRelativityTensorFunctionalForm command, that also handles user defined tensor functions.


GetFAndDifferentiationVariables receives a derivative and returns a sequence with derivand and all the differentiation variables.


GetReplacementIndices receives a list of indices of different kinds (spacetime, space, spinor, etc) and any other arguments and returns a list with new indices of the same kinds - useful for replacements - not present in the rest of the arguments.


GetSymbolsWithSameType receives an expression x, of type commutative, anticommutative or noncommutative, and any other arguments, and returns symbols of the same type as x, and not present in the rest of arguments.


GetTensorDependency gets the dependency of a given tensor; this dependency typically depends of the spacetime metric or on the way you defined the tensor using Define.


GetTensorFunctionalForm is a generalization of the former GetGeneralRelativityTensorFunctionalForm command, that also handles user defined tensor functions.


IsLiteralSubscript returns true or false according to whether a symbol s is of the form x__y, that is, it has the substring __ after the first or next characters and before the last one.


IsRealObject returns true or false according to whether a mathematical expression, function or variable passed is known to be real, either because it was assumed to be real, or because it was set to be real using Setup and its realobjects keyword.


RealObjects sets and unsets mathematical variables and functions as real, and answers queries about them.


SortProducts sorts the operands of noncommutative products into any particular desired ordering while taking into account commutator and anticommutator algebra rules, such that the returned product is mathematically equivalent to the one received.


SubstituteTensor substitutes equations into an expression, taking care of the free and repeated indices such that: 1) the substitution equations are interpreted as mappings having the free indices as parameters, and 2) repeated indices in the substitution equations do not clash with existing repeated indices in the target expression.


ToContravariant and ToCovariant rewrite a given expression multiplying by the spacetime metric so that all of its free indices become respectively contravariant or covariant.


ToTensorFunctionalForm reverses the operation performed by the new FromTensorFunctionalForm described above.





Implement formulas for abstract k, n both nonnegint entering "`a+`^k*| A[n] >" and "a(-)^k*| A[n] >", where `a+` and "a-" are Creation and Annihilation operators, respectively, acting on the 1st quantum number of the space of quantum states labeled A.


Implement new PDEtools:-dchange rules for changing variables in Bras Kets and Brackets of the Physics package


Library:-Degree can now compute the degree for noncommutative products Enhance PDEtools:-Library:-Degree and PDEtools:-Coefficients, to work with Physics:-`.` the same way it does with Physics:-`*`


Changes in design:


When the spacetime is Euclidean, there is no difference in value between the covariant and contravariant components of a tensor. Therefore, represent both with covariant indices making simplification and all manipulations simpler. This change affects the display of indices on the screen as well as the output of SumOverRepeatedIndices.


The dot product A . B of quantum operators A and B now returns as a (noncommutative) product  A * B when neither A nor B involve Bras or Kets.


When A is a quantum operator (generic, Hermitian or unitary), the literal subscript object A__x is now considered an operator of the same kind.


Normal normalizes powers of the same base (including exponentials) by combining them. For example, A^n*A^m "->A^(n+m)."


Normal normalizes noncommutative products by sorting objects that commute between themselves putting those that involve Dagger and conjugate to the left, more aligned with normal ordering in quantum field theories.


FeynmanDiagrams does not return any crossed propagators unless explicitly requested using the new option includecrossedpropagators. The former option, normalproducts, was renamed as externallegs.



See Also


The Physics project, Physics, what is new in Physics in Maple 17, what is new in Physics in Maple 16



Edgardo S. Cheb-Terrab
Physics, Maplesoft

I am trying to reduce a tensor expression: ωiωjUi,j 

For which I have tried the following

restart; with(Physics)

Setup(dimension = [3, `+`], coordinatesystems = X, spacetimeindices = lowercaselatin):

`The dimension and signature of the tensor space are set to: [3, +] `


`Default differentiation variables for d_, D_ and dAlembertian are: `*{X = (x1, x2, x3)}


`Systems of spacetime Coordinates are: `*{X = (x1, x2, x3)}


`Defined objects with tensor properties`


omega[i] := d_[j](U[k](X))*ep_[i, j, k];

Physics:-LeviCivita[i, j, k]*Physics:-d_[`~j`](U[`~k`](X), [X])


Physics:-LeviCivita[l, m, n]*Physics:-d_[`~m`](U[`~n`](X), [X])


Physics:-LeviCivita[i, j, k]*Physics:-LeviCivita[l, m, n]*Physics:-d_[`~j`](U[`~k`](X), [X])*Physics:-d_[`~m`](U[`~n`](X), [X])*Physics:-d_[`~l`](U[`~i`](X), [X])


-(-Physics:-d_[n](U[i](X), [X])*Physics:-d_[k](U[`~n`](X), [X])+Physics:-d_[m](U[i](X), [X])*Physics:-d_[`~m`](U[k](X), [X])-Physics:-d_[i](U[k](X), [X])*Physics:-d_[l](U[`~l`](X), [X])+Physics:-d_[k](U[i](X), [X])*Physics:-d_[l](U[`~l`](X), [X]))*Physics:-d_[`~i`](U[`~k`](X), [X])


continuity := [D_[l](U[l](X)) = 0]

[Physics:-d_[l](U[`~l`](X), [X]) = 0]


red_eq := subs(continuity, expr)

-(-Physics:-d_[n](U[i](X), [X])*Physics:-d_[k](U[`~n`](X), [X])+Physics:-d_[m](U[i](X), [X])*Physics:-d_[`~m`](U[k](X), [X]))*Physics:-d_[`~i`](U[`~k`](X), [X])


Question 1. Am I using the continuity condition correctly? How do I use this condition correctly? If I change the index for the expression, substitution does not work correctly. 

Question 2. How do I expand the red_eq term in terms of the basis to give out the full expression? 

Question 3. I would like to eventually replace U by (A-Amean) in the current expression. How do I implement this? 


1 2 3 4 5 6 Page 1 of 6