Pascal4QM

398 Reputation

8 Badges

4 years, 327 days

MaplePrimes Activity


These are replies submitted by Pascal4QM

Hi,

Using diff in the Physics framework might help. Once physics is loaded, z and conjugate(z) are considered as indepent variable allowing many derivative computation. The reason is that this is needed for functional derivative to recover equations from a given Lagrangian.

Maple Worksheet - Error

Failed to load the worksheet /maplenet/convert/PhysicsDiff.mw .
 

Download PhysicsDiff.mw

This workaround is of potential interest to some people. It is then welcomed. Thanks to Edgardo for the huge effort in developing the Physics package at the cutting edge of CAS technology.

@Carl Love Thanks, that’s good to be aware of these potential issues.

@mmcdara I tried it in code edit region. There is a warning suggesting to declare `` as a local variable. If done so, the warning disapear, so yes, it is seems it is considered as a variable.

@mmcdara Interesting, thanks. Indeed, when working with a large number of input and output, with this solution, there is less writing and need to count. The interpretation is simpler as well (especially when used with Matlab).

@Rouben Rostamian  All good, thanks!

@tomleslie However, it seems to not be general

restart;
test:= proc():
   return a,b,c:
end proc:

B,C:=test()[2..3]
                          B, C := b, c

B:=test()[2];
                             B := b

A,C := test()[1,3];
Error, invalid subscript selector

 

@tomleslie Hi, thanks, good solution!

Hi,

That's a very nice post, which will be useful to many people, congratulations!

You could try to slightly modify the initialization as follows (of course, that’s just a matter of preferences).

restart;
with(Physics):
with(Physics[Vectors]):
with(PDEtools):
interface(imaginaryunit = i):
CompactDisplay((E__field_, B__flux_, H__field_, D__flux_)(x, y, z, t));

In addition, Setup(mathematicalnotation = true) is not required anymore, as it is the default for recent releases.

To get (4.4.11) from (4.4.10), entering "(4.4.10) . (4.4.10)" with a dot as the scalar product gives an equivalent result.

 

@Carl Love Impressive, thanks!

@acer Thanks! That's exactly what I need.

@digerdiga Coordinates(X, P) automatically defines X and P as tensor, so that Define is not necessary anymore. But you could still used it instead, if you prefer.

@digerdiga Except for the macro not used, it seems OK as well:
 

restart; with(Physics); Setup(dimension = 3, metric = Euclidean, spacetimeindices = lowercaselatin, quiet)

[dimension = 3, metric = {(1, 1) = 1, (2, 2) = 1, (3, 3) = 1}, spacetimeindices = lowercaselatin]

(1)

Coordinates(X, P)

`Systems of spacetime coordinates are:`*{P = (p1, p2, p3), X = (x1, x2, x3)}

 

{P, X}

(2)

NULL

Setup(quantumop = {P, X}, algebrarule = {%Commutator(X[j], P[k]) = I*g_[j, k]}, %Commutator(X[j], X[k]) = 0, %Commutator(P[j], P[k]) = 0)

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

 

`* Partial match of  '`*algebrarule*`' against keyword '`*algebrarules*`' `

 

_______________________________________________________

 

[algebrarules = {%Commutator(Physics:-SpaceTimeVector[j](X), Physics:-SpaceTimeVector[k](P)) = I*Physics:-g_[j, k]}, quantumoperators = {p1, p2, p3, x1, x2, x3}]

(3)

L2 := P[j]^2*X[k]^2-P[j]*P[k]*X[j]*X[k]

Physics:-`*`(Physics:-`^`(Physics:-SpaceTimeVector[k](X), 2), Physics:-`^`(Physics:-SpaceTimeVector[j](P), 2))-Physics:-`*`(Physics:-SpaceTimeVector[k](X), Physics:-SpaceTimeVector[j](X), Physics:-SpaceTimeVector[k](P), Physics:-SpaceTimeVector[j](P))

(4)

Commutator(L2, X[j])

-(2*I)*Physics:-g_[a, j]*Physics:-`*`(Physics:-`^`(Physics:-SpaceTimeVector[k](X), 2), Physics:-SpaceTimeVector[a](P))-Physics:-`*`(Physics:-SpaceTimeVector[k](X), Physics:-SpaceTimeVector[a](X), -I*Physics:-g_[a, j]*Physics:-SpaceTimeVector[k](P)-I*Physics:-g_[j, k]*Physics:-SpaceTimeVector[a](P))

(5)

Simplify(%)

-(2*I)*Physics:-`*`(Physics:-`^`(Physics:-SpaceTimeVector[k](X), 2), Physics:-SpaceTimeVector[j](P))+I*Physics:-`*`(Physics:-SpaceTimeVector[j](X), Physics:-SpaceTimeVector[k](X), Physics:-SpaceTimeVector[k](P))+I*Physics:-`*`(Physics:-SpaceTimeVector[a](X), Physics:-SpaceTimeVector[j](X), Physics:-SpaceTimeVector[a](P))

(6)

Check(%, all)

`The products in the given expression check ok.`

 

`The repeated indices per term are: `[{`...`}, {`...`}, `...`]*`, the free indices are: `*{`...`}

 

[{k}, {k}, {a}], {j}

(7)

``


 

Download PhysicsCommutator_II.mw

@digerdiga It seems to work OK, see the attached. I have define X and P as coordinates, so that Define is not necessary.
 

restart; with(Physics); Setup(dimension = 3, metric = Euclidean, spacetimeindices = lowercaselatin, quiet)

[dimension = 3, metric = {(1, 1) = 1, (2, 2) = 1, (3, 3) = 1}, spacetimeindices = lowercaselatin]

(1)

Coordinates(X, P)

`Systems of spacetime coordinates are:`*{P = (p1, p2, p3), X = (x1, x2, x3)}

 

{P, X}

(2)

NULL

Setup(quantumop = {P, X}, algebrarule = {%Commutator(X[j], P[k]) = I*g_[j, k]}, %Commutator(X[j], X[k]) = 0, %Commutator(P[j], P[k]) = 0)

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

 

`* Partial match of  '`*algebrarule*`' against keyword '`*algebrarules*`' `

 

_______________________________________________________

 

[algebrarules = {%Commutator(Physics:-SpaceTimeVector[j](X), Physics:-SpaceTimeVector[k](P)) = I*Physics:-g_[j, k]}, quantumoperators = {p1, p2, p3, x1, x2, x3}]

(3)

Commutator(Physics:-`*`(Physics:-`^`(X[m], 2), Physics:-`^`(P[n], 2))-Physics:-`*`(Physics:-`*`(Physics:-`*`(X[m], X[n]), P[m]), P[n]), Physics:-`*`(Physics:-`*`(X[k], X[l]), P[l])-Physics:-`*`(Physics:-`^`(X[l], 2), P[k]))

Physics:-`*`(Physics:-`^`(Physics:-SpaceTimeVector[m](X), 2), -(2*I)*Physics:-g_[l, n]*Physics:-`*`(Physics:-SpaceTimeVector[k](X), Physics:-SpaceTimeVector[n](P), Physics:-SpaceTimeVector[l](P))-(2*I)*Physics:-g_[k, n]*Physics:-`*`(Physics:-SpaceTimeVector[n](P), Physics:-SpaceTimeVector[l](X), Physics:-SpaceTimeVector[l](P)))+(2*I)*Physics:-g_[l, m]*Physics:-`*`(Physics:-SpaceTimeVector[k](X), Physics:-SpaceTimeVector[l](X), Physics:-SpaceTimeVector[m](X), Physics:-`^`(Physics:-SpaceTimeVector[n](P), 2))+(2*I)*Physics:-g_[l, n]*Physics:-`*`(Physics:-`^`(Physics:-SpaceTimeVector[m](X), 2), I*Physics:-g_[l, n]+2*Physics:-`*`(Physics:-SpaceTimeVector[n](P), Physics:-SpaceTimeVector[l](X)), Physics:-SpaceTimeVector[k](P))-(2*I)*Physics:-g_[k, m]*Physics:-`*`(Physics:-`^`(Physics:-SpaceTimeVector[l](X), 2), Physics:-SpaceTimeVector[m](X), Physics:-`^`(Physics:-SpaceTimeVector[n](P), 2))-Physics:-`*`(Physics:-SpaceTimeVector[m](X), Physics:-`*`(Physics:-SpaceTimeVector[n](X), Physics:-`*`(Physics:-SpaceTimeVector[m](P), -I*Physics:-g_[l, n]*Physics:-`*`(Physics:-SpaceTimeVector[k](X), Physics:-SpaceTimeVector[l](P))-I*Physics:-g_[k, n]*Physics:-`*`(Physics:-SpaceTimeVector[l](X), Physics:-SpaceTimeVector[l](P)))+Physics:-`*`(-I*Physics:-g_[l, m]*Physics:-`*`(Physics:-SpaceTimeVector[k](X), Physics:-SpaceTimeVector[l](P))-I*Physics:-g_[k, m]*Physics:-`*`(Physics:-SpaceTimeVector[l](X), Physics:-SpaceTimeVector[l](P)), Physics:-SpaceTimeVector[n](P)))+I*Physics:-g_[l, n]*Physics:-`*`(Physics:-SpaceTimeVector[k](X), Physics:-SpaceTimeVector[l](X), Physics:-SpaceTimeVector[m](P), Physics:-SpaceTimeVector[n](P)))-I*Physics:-g_[l, m]*Physics:-`*`(Physics:-SpaceTimeVector[k](X), Physics:-SpaceTimeVector[l](X), Physics:-SpaceTimeVector[n](X), Physics:-SpaceTimeVector[m](P), Physics:-SpaceTimeVector[n](P))+Physics:-`*`(Physics:-SpaceTimeVector[m](X), Physics:-`*`(Physics:-SpaceTimeVector[n](X), -(2*I)*Physics:-g_[l, n]*Physics:-`*`(Physics:-SpaceTimeVector[m](P), Physics:-SpaceTimeVector[l](X), Physics:-SpaceTimeVector[k](P))-(2*I)*Physics:-g_[l, m]*Physics:-`*`(Physics:-SpaceTimeVector[l](X), Physics:-SpaceTimeVector[k](P), Physics:-SpaceTimeVector[n](P)))+I*Physics:-g_[k, n]*Physics:-`*`(Physics:-`^`(Physics:-SpaceTimeVector[l](X), 2), Physics:-SpaceTimeVector[m](P), Physics:-SpaceTimeVector[n](P)))+I*Physics:-g_[k, m]*Physics:-`*`(Physics:-`^`(Physics:-SpaceTimeVector[l](X), 2), Physics:-SpaceTimeVector[n](X), Physics:-SpaceTimeVector[m](P), Physics:-SpaceTimeVector[n](P))

(4)

Simplify(%)

-Physics:-`*`(Physics:-SpaceTimeVector[c](X), Physics:-SpaceTimeVector[k](X), Physics:-SpaceTimeVector[c](P))+I*Physics:-`*`(Physics:-SpaceTimeVector[b](X), Physics:-SpaceTimeVector[b](P), Physics:-SpaceTimeVector[f](X), Physics:-SpaceTimeVector[k](X), Physics:-SpaceTimeVector[f](P))-I*Physics:-`*`(Physics:-`^`(Physics:-SpaceTimeVector[b](X), 2), Physics:-SpaceTimeVector[f](X), Physics:-SpaceTimeVector[f](P), Physics:-SpaceTimeVector[k](P))-7*Physics:-`*`(Physics:-`^`(Physics:-SpaceTimeVector[b](X), 2), Physics:-SpaceTimeVector[k](P))-(2*I)*Physics:-`*`(Physics:-SpaceTimeVector[b](X), Physics:-SpaceTimeVector[b](P), Physics:-`^`(Physics:-SpaceTimeVector[d](X), 2), Physics:-SpaceTimeVector[k](P))+(5*I)*Physics:-`*`(Physics:-`^`(Physics:-SpaceTimeVector[b](X), 2), Physics:-SpaceTimeVector[d](P), Physics:-SpaceTimeVector[d](X), Physics:-SpaceTimeVector[k](P))-(2*I)*Physics:-`*`(Physics:-`^`(Physics:-SpaceTimeVector[b](X), 2), Physics:-SpaceTimeVector[k](P), Physics:-SpaceTimeVector[j](X), Physics:-SpaceTimeVector[j](P))-I*Physics:-`*`(Physics:-SpaceTimeVector[k](X), Physics:-SpaceTimeVector[m](X), Physics:-SpaceTimeVector[s](X), Physics:-SpaceTimeVector[m](P), Physics:-SpaceTimeVector[s](P))-(2*I)*Physics:-`*`(Physics:-`^`(Physics:-SpaceTimeVector[b](X), 2), Physics:-SpaceTimeVector[k](X), Physics:-`^`(Physics:-SpaceTimeVector[j](P), 2))+I*Physics:-`*`(Physics:-SpaceTimeVector[f](X), Physics:-SpaceTimeVector[k](X), Physics:-SpaceTimeVector[s2](X), Physics:-SpaceTimeVector[f](P), Physics:-SpaceTimeVector[s2](P))+I*Physics:-`*`(Physics:-SpaceTimeVector[c](X), Physics:-SpaceTimeVector[m](X), Physics:-SpaceTimeVector[c](P), Physics:-SpaceTimeVector[k](X), Physics:-SpaceTimeVector[m](P))

(5)

SumOverRepeatedIndices(%)

-Physics:-`*`(x1, Physics:-SpaceTimeVector[k](X), p1)-Physics:-`*`(x2, Physics:-SpaceTimeVector[k](X), p2)-Physics:-`*`(x3, Physics:-SpaceTimeVector[k](X), p3)+I*(Physics:-`*`(x1, p1, x1, Physics:-SpaceTimeVector[k](X), p1)+Physics:-`*`(x2, p2, x1, Physics:-SpaceTimeVector[k](X), p1)+Physics:-`*`(x3, p3, x1, Physics:-SpaceTimeVector[k](X), p1)+Physics:-`*`(x1, p1, x2, Physics:-SpaceTimeVector[k](X), p2)+Physics:-`*`(x2, p2, x2, Physics:-SpaceTimeVector[k](X), p2)+Physics:-`*`(x3, p3, x2, Physics:-SpaceTimeVector[k](X), p2)+Physics:-`*`(x1, p1, x3, Physics:-SpaceTimeVector[k](X), p3)+Physics:-`*`(x2, p2, x3, Physics:-SpaceTimeVector[k](X), p3)+Physics:-`*`(x3, p3, x3, Physics:-SpaceTimeVector[k](X), p3))-I*(Physics:-`*`(Physics:-`^`(x1, 2)+Physics:-`^`(x2, 2)+Physics:-`^`(x3, 2), x1, p1, Physics:-SpaceTimeVector[k](P))+Physics:-`*`(Physics:-`^`(x1, 2)+Physics:-`^`(x2, 2)+Physics:-`^`(x3, 2), x2, p2, Physics:-SpaceTimeVector[k](P))+Physics:-`*`(Physics:-`^`(x1, 2)+Physics:-`^`(x2, 2)+Physics:-`^`(x3, 2), x3, p3, Physics:-SpaceTimeVector[k](P)))-7*Physics:-`*`(Physics:-`^`(x1, 2)+Physics:-`^`(x2, 2)+Physics:-`^`(x3, 2), Physics:-SpaceTimeVector[k](P))-(2*I)*(Physics:-`*`(x1, p1, Physics:-`^`(x1, 2)+Physics:-`^`(x2, 2)+Physics:-`^`(x3, 2), Physics:-SpaceTimeVector[k](P))+Physics:-`*`(x2, p2, Physics:-`^`(x1, 2)+Physics:-`^`(x2, 2)+Physics:-`^`(x3, 2), Physics:-SpaceTimeVector[k](P))+Physics:-`*`(x3, p3, Physics:-`^`(x1, 2)+Physics:-`^`(x2, 2)+Physics:-`^`(x3, 2), Physics:-SpaceTimeVector[k](P)))+(5*I)*(Physics:-`*`(Physics:-`^`(x1, 2)+Physics:-`^`(x2, 2)+Physics:-`^`(x3, 2), p1, x1, Physics:-SpaceTimeVector[k](P))+Physics:-`*`(Physics:-`^`(x1, 2)+Physics:-`^`(x2, 2)+Physics:-`^`(x3, 2), p2, x2, Physics:-SpaceTimeVector[k](P))+Physics:-`*`(Physics:-`^`(x1, 2)+Physics:-`^`(x2, 2)+Physics:-`^`(x3, 2), p3, x3, Physics:-SpaceTimeVector[k](P)))-(2*I)*(Physics:-`*`(Physics:-`^`(x1, 2)+Physics:-`^`(x2, 2)+Physics:-`^`(x3, 2), Physics:-SpaceTimeVector[k](P), x1, p1)+Physics:-`*`(Physics:-`^`(x1, 2)+Physics:-`^`(x2, 2)+Physics:-`^`(x3, 2), Physics:-SpaceTimeVector[k](P), x2, p2)+Physics:-`*`(Physics:-`^`(x1, 2)+Physics:-`^`(x2, 2)+Physics:-`^`(x3, 2), Physics:-SpaceTimeVector[k](P), x3, p3))-I*(Physics:-`*`(Physics:-SpaceTimeVector[k](X), Physics:-`^`(x1, 2), Physics:-`^`(p1, 2))+Physics:-`*`(Physics:-SpaceTimeVector[k](X), x2, x1, p2, p1)+Physics:-`*`(Physics:-SpaceTimeVector[k](X), x3, x1, p3, p1)+Physics:-`*`(Physics:-SpaceTimeVector[k](X), x1, x2, p1, p2)+Physics:-`*`(Physics:-SpaceTimeVector[k](X), Physics:-`^`(x2, 2), Physics:-`^`(p2, 2))+Physics:-`*`(Physics:-SpaceTimeVector[k](X), x3, x2, p3, p2)+Physics:-`*`(Physics:-SpaceTimeVector[k](X), x1, x3, p1, p3)+Physics:-`*`(Physics:-SpaceTimeVector[k](X), x2, x3, p2, p3)+Physics:-`*`(Physics:-SpaceTimeVector[k](X), Physics:-`^`(x3, 2), Physics:-`^`(p3, 2)))-(2*I)*Physics:-`*`(Physics:-`^`(x1, 2)+Physics:-`^`(x2, 2)+Physics:-`^`(x3, 2), Physics:-SpaceTimeVector[k](X), Physics:-`^`(p1, 2)+Physics:-`^`(p2, 2)+Physics:-`^`(p3, 2))+I*(Physics:-`*`(x1, Physics:-SpaceTimeVector[k](X), x1, Physics:-`^`(p1, 2))+Physics:-`*`(x2, Physics:-SpaceTimeVector[k](X), x1, p2, p1)+Physics:-`*`(x3, Physics:-SpaceTimeVector[k](X), x1, p3, p1)+Physics:-`*`(x1, Physics:-SpaceTimeVector[k](X), x2, p1, p2)+Physics:-`*`(x2, Physics:-SpaceTimeVector[k](X), x2, Physics:-`^`(p2, 2))+Physics:-`*`(x3, Physics:-SpaceTimeVector[k](X), x2, p3, p2)+Physics:-`*`(x1, Physics:-SpaceTimeVector[k](X), x3, p1, p3)+Physics:-`*`(x2, Physics:-SpaceTimeVector[k](X), x3, p2, p3)+Physics:-`*`(x3, Physics:-SpaceTimeVector[k](X), x3, Physics:-`^`(p3, 2)))+I*(Physics:-`*`(Physics:-`^`(x1, 2), p1, Physics:-SpaceTimeVector[k](X), p1)+Physics:-`*`(x2, x1, p2, Physics:-SpaceTimeVector[k](X), p1)+Physics:-`*`(x3, x1, p3, Physics:-SpaceTimeVector[k](X), p1)+Physics:-`*`(x1, x2, p1, Physics:-SpaceTimeVector[k](X), p2)+Physics:-`*`(Physics:-`^`(x2, 2), p2, Physics:-SpaceTimeVector[k](X), p2)+Physics:-`*`(x3, x2, p3, Physics:-SpaceTimeVector[k](X), p2)+Physics:-`*`(x1, x3, p1, Physics:-SpaceTimeVector[k](X), p3)+Physics:-`*`(x2, x3, p2, Physics:-SpaceTimeVector[k](X), p3)+Physics:-`*`(Physics:-`^`(x3, 2), p3, Physics:-SpaceTimeVector[k](X), p3))

(6)

NULL


 

Download PhysicsCommutator.mw

@Samir Khan It is nice to see how Maple evolves with new features and improved reliability. Whether you are a student, a teacher, an engineer, or a researcher, many Maple’s feature are just unique. About the debugger, I consider that keeping some effort on this point is strategic. Maple’s debugger do not require an incremental improvement, it needs to be reinvented. As suggested by nm, Matlab’s debugger is a very good model of inspiration for that.


Thanks for this new release!

1 2 3 4 Page 1 of 4