ecterrab

6368 Reputation

17 Badges

13 years, 194 days

MaplePrimes Activity


These are replies submitted by ecterrab

@John Fredsted 

Coming back to this issue. I revised now Landau's book and, indeed, the implementation in Physics is not wrong at all, but you are correct regarding the uses of g_[a, b] and the display of g{a, ~b] as kd_[a,~b]. On page 17, he defines KroneckerDelta as a tensor with the indices one covariant the other contravariant, not saying whether kd_[a, b] is a tensor, but saying "by raising or lowering one index in KroneckerDelta[a, ~b] we respectively obtain the contravariant and covariant tensor g_[~a, ~b], g_[a, b] ", which in turn is a tensor, and of course we know that raising and lowering the indices of a tensor the object remains a tensor ... But, kd_[a, b] is an exception here.

Anyway, I suppose my memory got blurred by the years. Landau's paragraph is also not that good for a computer implementation, where tensors are identified by their name, not by the covariant/contravariant character of their indices. The implementation of what the book says regarding notation also requires some gymnastics, with computations flowing with "kd_ is a tensor only if its indices are one covariant the other contravariant, not otherwise", and g_[a, ~b] is always displayed as kd_[a, ~b],.

On the other hand, following Landau's book also regarding notation proved to always be appropriate. I'll spend a day tomorrow verifying to what point such a design can be implemented in a robust way.

Independent of that, kd_[a,b] with both indices covariant will not be a tensor anymore already in the next Physics Updates (i.e. v.282 or higher). That will end, once and for all, the potential problem of using kd_[a, b] (with a, b being space or spacetime indices) in quantum mechanics to represent not a tensor but the standard Kronecker delta symbol (1 if a=b, or if a <> b, and unevaluated when equality cannot be resolved).

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

@Carl Love 

...hmm I'm afraid I find K's post is not clear enough. In the lines of what you say, both acer and dharr answered the question in a complete manner, then why K's next comment saying "Apparently there is no simple solution" ... Anyway, what I do see tricky is a general representation of the multinomial theorem, and the like, using computer algebra, that is something both computable and as simple as what you see in for instance Wikipedia. -I thought that is K was asking. I didn't understand his question. Anyway ...

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

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

@mistel 
 

Issue 1. is now fixed, and the fix available to everybody within the Maplesoft Physics Updates version 277 or higher. What follows is your worksheet with some comments intercalated.

 

restart; with(Physics); Physics:-Version()[2]

`2019, January 7, 16:59 hours, version in the MapleCloud: 277, version installed in this computer: 277`

(1)

Setup(hilbertspaces = {{A, alpha}, {B, beta}}, quantumbasisdimension = {A = 1 .. N[a], B = 1 .. N[b]}, quantumdiscretebasis = {A, B, alpha, beta}, bracketrules = {%Bracket(Bra(A, i), Ket(Psi)) = Ket(beta, i), %Bracket(Bra(A, i), Ket(alpha, j)) = C[i, j], %Bracket(Bra(B, i), Ket(Psi)) = Ket(alpha, i), %Bracket(Bra(B, j), Ket(beta, i)) = C[i, j]})

[bracketrules = {%Bracket(%Bra(A, i), %Ket(Psi)) = Physics:-Ket(beta, i), %Bracket(%Bra(A, i), %Ket(alpha, j)) = C[i, j], %Bracket(%Bra(B, i), %Ket(Psi)) = Physics:-Ket(alpha, i), %Bracket(%Bra(B, j), %Ket(beta, i)) = C[i, j]}, disjointedspaces = {{A, alpha}, {B, beta}}, quantumbasisdimension = {A = 1 .. N[a], B = 1 .. N[b]}, quantumdiscretebasis = {A, B, alpha, beta}]

(2)

proj := Sum(Sum(Ket(A, i).Bra(A, i).Ket(B, j).Bra(B, j), i = 1 .. N[a]), j = 1 .. N[b])

Sum(Sum(Physics:-`*`(Physics:-Ket(A, i), Physics:-Ket(B, j), Physics:-Bra(A, i), Physics:-Bra(B, j)), i = 1 .. N[a]), j = 1 .. N[b])

(3)

proj2 := Projector(Ket(A, i)).Projector(Ket(B, i))

Physics:-`*`(Sum(Physics:-`*`(Physics:-Ket(A, i), Physics:-Bra(A, i)), i = 1 .. N[a]), Sum(Physics:-`*`(Physics:-Ket(B, i), Physics:-Bra(B, i)), i = 1 .. N[b]))

(4)

proj.Ket(Psi)

Sum(Sum(C[i, j]*Physics:-`*`(Physics:-Ket(A, i), Physics:-Ket(B, j)), i = 1 .. N[a]), j = 1 .. N[b])

(5)

NULL

This weakness in the output before v.277, requiring one extra step, is now fixed:

proj2.Ket(Psi)

Sum(Sum(C[i__1, i]*Physics:-`*`(Physics:-Ket(A, i__1), Physics:-Ket(B, i)), i = 1 .. N[b]), i__1 = 1 .. N[a])

(6)

proj-proj2

Sum(Sum(Physics:-`*`(Physics:-Ket(A, i), Physics:-Ket(B, j), Physics:-Bra(A, i), Physics:-Bra(B, j)), i = 1 .. N[a]), j = 1 .. N[b])-Physics:-`*`(Sum(Physics:-`*`(Physics:-Ket(A, i), Physics:-Bra(A, i)), i = 1 .. N[a]), Sum(Physics:-`*`(Physics:-Ket(B, i), Physics:-Bra(B, i)), i = 1 .. N[b]))

(7)

To answer your question, the issue is not about Physics but about computer algebra design. Consider

Sum(f[j], j = 1 .. n)-(Sum(f[k], k = 1 .. n))

Sum(f[j], j = 1 .. n)-(Sum(f[k], k = 1 .. n))

(8)

You see, not zero. This is an intentional design in all computer algebra systems I am aware of. For good or for bad, it allows for further manipulations.

Here is another example, more specific to the Maple system

exp(-x)-1/exp(x)

exp(-x)-1/exp(x)

(9)

Again, not zero unless you ask for the exponentials to be combined or simplified

combine(exp(-x)-1/exp(x))

0

(10)

A different, however similar problem, is this one about the indices, consider

(Sum(f[j], j = 1 .. n))*(Sum(g[j], j = 1 .. m))

(Sum(f[j], j = 1 .. n))*(Sum(g[j], j = 1 .. m))

(11)

combine((Sum(f[j], j = 1 .. n))*(Sum(g[j], j = 1 .. m)))

(Sum(f[j], j = 1 .. n))*(Sum(g[j], j = 1 .. m))

(12)

So, nada. Reason: if the summation index is the same, you cannot make the product of both summands be the new summand of a double sum (as you expected when asking for (4) to automatically become (3)). Change the second summation index

(Sum(f[j], j = 1 .. n))*(Sum(g[k], k = 1 .. m))

(Sum(f[j], j = 1 .. n))*(Sum(g[k], k = 1 .. m))

(13)

Now the transformation of the product of two sums into a single double sum is possible

combine((Sum(f[j], j = 1 .. n))*(Sum(g[k], k = 1 .. m)))

Sum(Sum(f[j]*g[k], k = 1 .. m), j = 1 .. n)

(14)

lprint(%)

Sum(Sum(f[j]*g[k], k = 1 .. m), j = 1 .. n)

 

 

With regards to Physics, it is not different. If you define proj2 with a different summation index

proj2 := Projector(Ket(A, i)).Projector(Ket(B, j))

Physics:-`*`(Sum(Physics:-`*`(Physics:-Ket(A, i), Physics:-Bra(A, i)), i = 1 .. N[a]), Sum(Physics:-`*`(Physics:-Ket(B, j), Physics:-Bra(B, j)), j = 1 .. N[b]))

(15)

You do not receive 0 when taking the difference, as it happens in all computer algebra systems

proj-proj2

Sum(Sum(Physics:-`*`(Physics:-Ket(A, i), Physics:-Ket(B, j), Physics:-Bra(A, i), Physics:-Bra(B, j)), i = 1 .. N[a]), j = 1 .. N[b])-Physics:-`*`(Sum(Physics:-`*`(Physics:-Ket(A, i), Physics:-Bra(A, i)), i = 1 .. N[a]), Sum(Physics:-`*`(Physics:-Ket(B, j), Physics:-Bra(B, j)), j = 1 .. N[b]))

(16)

And if you combine, you get 0 as it happens in Maple in general, independent of its Physics package.

combine(Sum(Sum(Physics[`*`](Physics[Ket](A, i), Physics[Ket](B, j), Physics[Bra](A, i), Physics[Bra](B, j)), i = 1 .. N[a]), j = 1 .. N[b])-Physics[`*`](Sum(Physics[`*`](Physics[Ket](A, i), Physics[Bra](A, i)), i = 1 .. N[a]), Sum(Physics[`*`](Physics[Ket](B, j), Physics[Bra](B, j)), j = 1 .. N[b])))

0

(17)

A comment to the side: you are using Maple's default Document mode. I prefer the Worksheet mode, where the input lines are identified by a prompt and, mainly, whatever you write in an input line is - by default - active math, while whatever you write in a text region is - by default - text, not active math. This is the most common situation, I think, and so with Worksheet you can work faster and cleaner. For those reasons I recommend working using a Worksheet instead of a Document. You can set this in the Preferences of your Maple: Interface -> Default format for new worksheets -> Worksheet then click on Apply Globally. For presentation purposes, like in the above, I additionally go to the menu View -> Show/Hide Contents and uncheck both Section Boundaries Execution and Group Boundaries. The result is as you see above.


 

Download projector_2d_space_(reviewed).mw

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

My vote is the same as yours, answers to technical questions take time and share skills with the community. Having these answer deleted by whoever posted the question is, just, not OK at all.

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

@mistel 
 

How is that you cannot type over thing on this worksheet. Anyway, below I typed it for you, the changes I suggested you according to what you say you wanted. I don't discard you may want to change the definition of H further, but I leave the continuation of this for you. By giving a look at the help pages, indicated or not, I imagine you will have no problem, and in any case I need to move to other things. Hopefully alltogether these 4 answers are sufficient for you to take off with your computation.

 

Physics:-Version()[2]

`2018, December 30, 7:35 hours, version in the MapleCloud: 272, version installed in this computer: 272`

(1)

with(Physics)

Setup(hermitianoperators = {H}, hilbertspaces = {{A, C, H}, {B, C, H}}, quantumbasisdimension = {A = 1 .. Na, B = 1 .. Nb, C[1] = 1 .. Na, C[2] = 1 .. Nb}, quantumdiscretebasis = {A, B, C}, bracketrules = {%Bracket(Bra(A, i), Ket(C, j, k)) = delta[i, j]*Ket(B, k), %Bracket(Bra(B, i), Ket(C, j, k)) = delta[i, k]*Ket(A, j), %Bracket(Bra(C, i, j), H, Ket(C, k, l)) = H[i, j, k, l]})

[bracketrules = {%Bracket(%Bra(A, i), %Ket(C, j, k)) = Physics:-KroneckerDelta[i, j]*Physics:-Ket(B, k), %Bracket(%Bra(B, i), %Ket(C, j, k)) = Physics:-KroneckerDelta[i, k]*Physics:-Ket(A, j), %Bracket(%Bra(C, i, j), H, %Ket(C, k, l)) = H[i, j, k, l]}, disjointedspaces = {{A, C, H}, {B, C, H}}, hermitianoperators = {H}, quantumbasisdimension = {A = 1 .. Na, B = 1 .. Nb, C[1] = 1 .. Na, C[2] = 1 .. Nb}, quantumdiscretebasis = {A, B, C}]

(2)

Ket(C, k, l) = Ket(A, k).Ket(B, l)

Physics:-Ket(C, k, l) = Physics:-`*`(Physics:-Ket(A, k), Physics:-Ket(B, l))

(3)

Bra(C, i, j) = Bra(A, i).Bra(B, j)

Physics:-Bra(C, i, j) = Physics:-`*`(Physics:-Bra(A, i), Physics:-Bra(B, j))

(4)

This works

Bra(C, i, j).H.Ket(C, k, l)

H[i, j, k, l]

(5)

Bra(A, i).Bra(B, j).Ket(A, k).Ket(B, l)

Physics:-KroneckerDelta[i, k]*Physics:-KroneckerDelta[j, l]

(6)

What I want

Bra(A, i)*Bra(B, j)*H*Ket(A, k)*Ket(B, l) = Bra(C, i, j)*H*Ket(C, k, l)

Physics:-`*`(Physics:-Bra(A, i), Physics:-Bra(B, j), H, Physics:-Ket(A, k), Physics:-Ket(B, l)) = Physics:-`*`(Physics:-Bra(C, i, j), H, Physics:-Ket(C, k, l))

(7)

Bra(C, i, j)*H*Ket(C, k, l) = Bra(C, i, j).H.Ket(C, k, l)

Physics:-`*`(Physics:-Bra(C, i, j), H, Physics:-Ket(C, k, l)) = H[i, j, k, l]

(8)

 

(Did you really mean you were unable to type over things in this procedure to adapt it to your needs?)

 

 
"H := K ->   if (procname::Not(indexed) or nops(procname) < 4) and K::Ket and op(1,K)::identical(A,B) then      if procname::'indexed' then         H[op(procname), op(2..-1, K)]     else          H[op(2..-1, K)]     fi  else      'procname . K'  fi:"

 

Let's see it in action. Start erasing all Physics performance remember tables, that remember results like (7) computed before the definition of H

Library:-Forget()

 

Then you have

H.Ket(A, k)

H[k]

(9)

Bra(B, j).H

H[j]

(10)

Bra(B, j).H.Ket(A, k)

H[j, k]

(11)

and this is already what you wanted to compute:

Bra(A, i).Bra(B, j).H.Ket(A, k).Ket(B, l)

H[i, j, k, l]

(12)

Bracket(Bra(A, i).Bra(B, j), H, Ket(A, k).Ket(B, l))

H[i, j, k, l]

(13)

Bra(A, m).H[i, j, k, l]

Physics:-`.`(Physics:-Bra(A, m), H[i, j, k, l])

(14)

Bra(C, i, j).H.Ket(C, k, l)

H[i, j, k, l]

(15)

Bra(C, i, j)*H*Ket(C, k, l) = Bra(C, i, j).H.Ket(C, k, l)

Physics:-`*`(Physics:-Bra(C, i, j), H, Physics:-Ket(C, k, l)) = H[i, j, k, l]

(16)

Setup(op = X)

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

 

_______________________________________________________

 

[quantumoperators = {A, B, C, H, X}]

(17)

Bra(X, i, j, k).H.Ket(X, m, n, s)

Physics:-Bracket(Physics:-Bra(X, i, j, k), H, Physics:-Ket(X, m, n, s))

(18)

NULL


 

Download algebra_rules_(reviewed_III).mw

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

@mistel 

I intended to show you how you can make it work, just: "define the action of the operator H on Kets"

Once you understand the idea you can adjust the procedure shown to handle more situations, say different than the one you posted. For example: if you want to use the same definition of H with all Kets (including C Kets) change op(2, K) by op(2..-1, K). If you want to restrict the action of H to only Kets A and B then change "if K::Ket then" by "if K::Ket and op(1, K)::identical(A, B) then". If you want H to accumulate no more than 4 indices then instead of "if K::Ket ..." use "if (procname::Not(indexed) or nops(procname) < 4) and K::Ket ..."; and so on. 

Of course if you are going to define H as a procedure, you need to know the Maple language 101. For that, the documentation is pretty good, and the language is just incredibly simple and easy to use.

IMPORTANT: give a look at the help page ?Physics,Library, there you will find a whole programming language for Physics, approx 200 commands, one of them is a subpackage with approx 100 Physics types. All that can be extremely helpful at the time of writing simple or complicated programs to tell the Maple system more precisely what you want to do.

In one thing, however, you caught me sleeping: in my reply I wrote the else clause with 'H . K'. It makes sense. But to use both algebra rules (say for C) and a procedure definition for H (say for A and B), the internal code was expecting that clause to be 'H(K)'. Therefore, replace 'H . K' by 'H(K)' in that procedure definition and then you can use both algebra rules (that you defined for C Kets) and the procedure definition for whatever else (A and B Kets) .

Anyway, I adjusted that in the code too, and uploaded a new version 272 of the Maplesoft Physics Updates so that after installing it, the procedure I posted in the previous reply will work as expected  in both cases, with 'H . K' or 'H(K)' in the else clause.

Summarizing: there is no bug here, just one idea: code H, according to what you need.

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

To get some help you need to post the problem itself, within a Maple worksheet, formulated as much as you can.

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

@vv 
 

Maple has subs, eval and subs[eval], and you can eval(subs(...))) . All together they provide enormous flexibility. The following example shows the differences between these commands. Suppose you have the (artificially unevaluated, for the purpose of this example) expression:

'exp(0)+exp(sin(x))'

exp(0)+exp(sin(x))

(1)

The simplest and oldest manipulation: substitute x = 0: the substitution is performed, the expression, however, is not evaluated

subs(x = 0, 'exp(0)+exp(sin(x))')

exp(0)+exp(sin(0))

(2)

Suppose now you want to evaluate only the subexpressions where a substitution happened: use subs[eval]

subs[eval](x = 0, 'exp(0)+exp(sin(x))')

exp(0)+1

(3)

If you want to substitute and then evaluate everything, you can use eval@subs

eval(subs(x = 0, 'exp(0)+exp(sin(x))'))

2

(4)

So subs[eval] is not the same as eval@subs. Still, you can obtain the same result (3) using eval alone, ie substitute and evaluate only the subexpressions that changed after substituting

eval('exp(0)+exp(sin(x))', x = 0)

exp(0)+1

(5)

Right. But then why having eval and subs[eval] and why the help page warning "use subs[eval] with care"? Because subs performs substitutions regardless of whether they are syntactically or mathematically correct (these two different things can be wrong). For example, consider

'exp(0)+diff(sin(x), x)'

exp(0)+diff(sin(x), x)

(6)

Substituting x = 0 in this diff construction is wrong, however if you want to do that, for any reason you may have, you can substitute

subs(x = 0, 'exp(0)+diff(sin(x), x)')

exp(0)+diff(sin(0), 0)

(7)

Therefore, if you use subs[eval], the wrongly constructed derivative is evaluated, resulting in

subs[eval](x = 0, 'exp(0)+diff(sin(x), x)')

Error, invalid input: diff received 0, which is not valid for its 2nd argument

 

 

while if you use eval you get it right

eval('exp(0)+diff(sin(x), x)', x = 0)

exp(0)+eval(diff(sin(x), x), {x = 0})

(8)

A case where the substitution is syntatically correct but (I'd say) mathematically wrong

Int(exp(x*s), x = a .. b)

Int(exp(x*s), x = a .. b)

(9)

In the above, s does not depend on x. One could argue that substituting s = f(x) would make sense only if done after you performed the integration. Still, for any reason one may want to substitute s = f(x) before performing the integration. You can do both

subs(s = f(x), Int(exp(x*s), x = a .. b))

Int(exp(x*f(x)), x = a .. b)

(10)

eval(Int(exp(x*s), x = a .. b), s = f(x))

eval(Int(exp(x*s), x = a .. b), {s = f(x)})

(11)

In summary: eval is safer, but if you know what you are doing, subs or subs[eval] are "faster" (although in 99.99% of the time you cannot measure the difference). The reason why subs[eval] is faster is because it happens all within the Maple kernel (C program) while eval will consult first the existence of a library (Maple language compiled code) routine of the form `eval/F` where F is the function being evaluated. You can check: there is eval/diff, eval/int, eval/sum, eval/eval, and some others. For all those, eval is safer than subs. When, for all the functions F in expression, there exists no eval/F, generally speaking, there is no difference between subs[eval] and eval.

NULL


 

Download subs_versus_eval.mw

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

@Carl Love 

What you say is not a rule, nor a documented design. For example, pdsolve introduces sums with summation indices (see a recent post I made about pdsolve tackling PDE & BC), and I intentionally removed all these _n from around: you now see a clean 'n', at most 'n' and 'n1' which for me already looks ugly ... I'd never write n1 with paper and pencil. Likewise, integral transforms used by pdsolve to solve PDEs are return with neat greek letters as integration variables, not the old '_U' still used by the inttrans package.

In the same line, all the FunctionAdvisor is moving from these old _U style to a clean 't' etc.

The answer to the original question of this thread was given by Tom Leslie: in ?pdsolve it is clearly said what _c[n] represents, and the information that they are "separation constants", not arbitrary constants coming from ODE integration, is relevant in the PDE context. That is why they are different, visually and computationally.

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

Hi @Rouben Rostamian  

I realize there are different opinions, but I prefer the current design. I wrote this program more than 20 years ago, primarily because of my work on differential equations, it even got transported into the Physics package as Physics:-CompactDisplay. This is a very popular Maple command. In my opinion, the observation by vv, a case where a function with is applied to different variables and you happen to be interested in the different derivatives is unusual to justify this change you suggest. It would add complexity to the code and to the different cases I'd need to remember at the time of looking at the screen.

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

@mistel 

My comments appear below in italic while your original text is non-italic. I also transformed your Maple "document" into a Maple "worksheet", really easier to edit and work with. You can always set "worksheet" as your default mode in the Maple preferences.

 

Below, any few changes to your input lines are mentioned explicitly. As usual to reproduce the input/output you see please verify that you have installed the latest Maplesoft Physics Updates, version 268 or higher.

 

Physics:-Version()[2]

`2018, December 27, 10:45 hours, version in the MapleCloud: 268, version installed in this computer: 268`

(1)

with(Physics)

 

If H is an operator that acts on the same space as C, then indicate that from the beginning. I am then including H in hilbertspaces in your input:

Setup(redo, hermitianoperators = {H}, hilbertspaces = {{A, C, H}, {B, C, H}}, quantumbasisdimension = {A = 1 .. Na, B = 1 .. Nb, C[1] = 1 .. Na, C[2] = 1 .. Nb}, quantumdiscretebasis = {A, B, C}, bracketrules = {%Bracket(Bra(A, i), Ket(C, j, k)) = delta[i, j]*Ket(B, k), %Bracket(Bra(B, i), Ket(C, j, k)) = delta[i, k]*Ket(A, j), %Bracket(Bra(C, i, j), H, Ket(C, k, l)) = H[i, j, k, l]})

[bracketrules = {%Bracket(%Bra(A, i), %Ket(C, j, k)) = Physics:-KroneckerDelta[i, j]*Physics:-Ket(B, k), %Bracket(%Bra(B, i), %Ket(C, j, k)) = Physics:-KroneckerDelta[i, k]*Physics:-Ket(A, j), %Bracket(%Bra(C, i, j), H, %Ket(C, k, l)) = H[i, j, k, l]}, disjointedspaces = {{A, C, H}, {B, C, H}}, hermitianoperators = {H}, quantumbasisdimension = {A = 1 .. Na, B = 1 .. Nb, C[1] = 1 .. Na, C[2] = 1 .. Nb}, quantumdiscretebasis = {A, B, C}]

(2)

Ket(C, k, l) = Ket(A, k).Ket(B, l)

Physics:-Ket(C, k, l) = Physics:-`*`(Physics:-Ket(A, k), Physics:-Ket(B, l))

(3)

Bra(C, i, j) = Bra(A, i).Bra(B, j)

Physics:-Bra(C, i, j) = Physics:-`*`(Physics:-Bra(A, i), Physics:-Bra(B, j))

(4)

This works

Bra(C, i, j).H.Ket(C, k, l)

H[i, j, k, l]

(5)

Bra(A, i).Bra(B, j).Ket(A, k).Ket(B, l)

Physics:-KroneckerDelta[i, k]*Physics:-KroneckerDelta[j, l]

(6)

This does not work``

Bra(A, i).Bra(B, j).H.Ket(A, k).Ket(B, l)

Physics:-`*`(Physics:-Bra(A, i), Physics:-Bracket(Physics:-Bra(B, j), H, Physics:-Ket(A, k)), Physics:-Ket(B, l))

(7)

Bracket(Bra(A, i).Bra(B, j), H, Ket(A, k).Ket(B, l))

Physics:-`*`(Physics:-Bra(A, i), Physics:-Bra(B, j), Physics:-`.`(H, Physics:-Ket(A, k)), Physics:-Ket(B, l))

(8)

What I want

Bra(A, i)*Bra(B, j)*H*Ket(A, k)*Ket(B, l) = Bra(C, i, j)*H*Ket(C, k, l)

Physics:-`*`(Physics:-Bra(A, i), Physics:-Bra(B, j), H, Physics:-Ket(A, k), Physics:-Ket(B, l)) = Physics:-`*`(Physics:-Bra(C, i, j), H, Physics:-Ket(C, k, l))

(9)

Bra(C, i, j)*H*Ket(C, k, l) = Bra(C, i, j).H.Ket(C, k, l)

Physics:-`*`(Physics:-Bra(C, i, j), H, Physics:-Ket(C, k, l)) = H[i, j, k, l]

(10)


I see. You have a couple of issues here:

 

1. 

The right-hand side of (10) is an operator while, normally, it would be a real scalar. Solution: you can always substitute H by some scalar, say H at the end.

2. 

Since Hbelongs to a tensor product of spaces, it can be an entangled operator, i.e. one that you cannot represent as a product of "A[i]  times B[j]" , so how would you represent, for example Bra(B, j)*H*Ket(A, k)? That is relevant since you want to compute `&otimes;`(Bra(A, i), Bra(B, j))*H*`&otimes;`(Ket(A, k), Ket(B, l)) and if you intend to do that all with algebra rules you need a computational representation for Bra(B, j)*H*Ket(A, k)that is not just itself.

 

Because of 2. I don't think what you want is possible by only using algebra rules in some natural way. The best approach in a case like this one is to take advantage of the possibility of defining the action of a quantum operator over a Ket. I.e.define Has a procedure.

 

Basically, what you want is:
 

"if H is applied to a Ket then

    if H itself is indexed then
        return H accumulating its indices, followed by the index of the Ket
    else

        return H indexed by the index of the Ket;
otherwise
    return the dot product operation uncomputed, unevaluated

"

 

In Maple language that is written as

 

 
"H := K ->   if K::Ket then      if procname::'indexed' then         H[op(procname), op(2, K)]     else          H[op(2, K)]     fi  else      'H . K'  fi:"

 

Let's see this definition  in action. Start by erasing all Physics performance remember tables, that remember results like (7) computed before the definition of H

Library:-Forget()

 

Then you have

H.Ket(A, k)

H[k]

(11)

Bra(B, j).H

H[j]

(12)

Bra(B, j).H.Ket(A, k)

H[j, k]

(13)

and this is already what you wanted to compute:

Bra(A, i).Bra(B, j).H.Ket(A, k).Ket(B, l)

H[i, j, k, l]

(14)

Bracket(Bra(A, i).Bra(B, j), H, Ket(A, k).Ket(B, l))

H[i, j, k, l]

(15)

``


 

Download algebra_rules_(reviewed_II).mw

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

@Rouben Rostamian  

It was a genuine question, I do not use rhetorical flourish or irony - I don't believe in that as valuable communication tools, I think rather the opposite. My question was targeting the kind of answer you gave, to improve the paragraphs of this help page. I will make explicit that "all differentiation variables" refer to differentiation variables in general, also for functions that were not declared, and that by differentiation variables I mean their display in derivatives, ie. that all derivatives are displayed indexed after you turn this ON.

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

@tomleslie 

Yes, this was a typo in the Example 8 of the previous post on PDE & BC. It was, however, a fortunate typo :) Example 8, after correcting the typo, is also solvable, and the no solution you observed actually pointed to a place in the new routines where an extra tweak was necessary. Example 8 (without the typo) is now solvable after installing the Maplesoft Physics Updates version 266 or higher.

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

@Preben Alsholm 

Your observations make sense to me. Here is some info regarding Physics:-Version() that may help to determine what is going on with nm's Maple installation. The output of Physics:-Version() is as follows:

  • The MapleCloud version reported is the one reported by PackageTools:-GetProperty(5137472255164416, "X-CloudVersion")
  • The library reported, from where Physics is being loaded, is the first library in the list returned by LibraryTools:-FindLibrary('Physics')
  • The timestamp is the one returned by LibraryTools:-Timestamp(P)[1]
  • The version reported as "installed in your computer" is the one returned by PackageTools:-IsPackageInstalled("Physics Updates", ':-output = :-version')

From what you say, somehow, PackageTools:-IsPackageInstalled("Physics Updates", ':-output = :-version') is telling that version 264 is there. So it found Physics Updates (the whole or portions of it) in the toolbox\2018 directory. I would remove everything below toolsbox\2018, entirely, then check what is being reported. Likewise, if I were to re-install Maple, I would first uninstall Maple, using its unistaller, then remove, manually, all the Maple directory, using the File Manager, then re-install it.

Finally, suppose you have Maple working fine again. If the problem in your computer happens only when you use PackageTools:-Install, I can't imagine what could that be (support@maplesoft.com can) but I can suggest a workaround. In your maple.ini (in mac it is called .mapleinit) you can set the value of libname. Set it as in

libname := "the directory you prefer", libname:
 
Then, libraries (.mla or .maple) found in "the directory you prefer" will be scanned before those found in the (default directories of) libname. All this is explained in ?libname. Then download any package (not using PackageTools:-Install, just downloading them), and place the downloaded .maple file in "the directory you prefer". Then open Maple and everything found in "the directory you prefer" will be loaded from there instead of from the default directories of libname. That is a way to install the package manually, without using PackageTools:-Install. The drawback of this approach is that you need to manually install/uninstall every time, 

BTW another question: what is the value of libname for you? It should contain the toolbox directory.

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

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