Andriy

270 Reputation

13 Badges

12 years, 197 days

MaplePrimes Activity


These are replies submitted by Andriy

1) I guess the copying of some code from Maple IDE and pasting it here have to give the symbols, not the image

I guess it will be better to have after pasting

restart;

not



2) Besides that it would be great if you introduce a special tag for code presentation. A text presented within this tag should be specially formatted for better perseption.

3) I'd like to have a possibility to use browser spellchecker without opening html-form.

I guess you should create some rules for making posts and questions and present it here. Everyone creates his own rules (style) and it is not good.

You can take as a pattern a message system of http://stackoverflow.com

If Maple is working in default regime

(when created by me file maple.ini
c:\Program Files\Maple 17\Users\maple.ini
with the  string
libname := cat( kernelopts( homedir ), kernelopts( dirsep ), "MapleLib" ), libname:
is deleted)

then all works great. But if I am trying to use my MapleLib, then the application "The Cosmic Travel Planner" (and many others) cannot run some code automatically.

I have provided the full control over this folder for EVERYONE but it doesn't resolve the problem.

PS
Dear developers! I guess you should explain better how Maple community can vote for the applications upploaded for competition within the Mobius project. Is it like on facebook or dirrect e-mail are the only possible ways of votation? I fortuned the asterisk in the Maple cloud in IDE and pusshed it. It appeared to be my vote for the application! I guess, you should mention about this way of votation somewhere. If the vote through the IDE is not accepted then you should mention about it too.

@Carl Love 

it is a list of thread-safe functions while Physics is a package. Besides that `.` is thread-safe ( http://www.maplesoft.com/support/help/Maple/view.aspx?path=dot ) so I supposed that Physics:-`.` can be thread safe too. Very likely I was wrong.

The problem is solved in Maple 17.02

restart; d := conjugate(u)*conjugate(y)+conjugate(v)*conjugate(x); z := conjugate(f)/d+G*w*conjugate(w)*conjugate(y)/d; z2 := simplify(z)

conjugate(u)*conjugate(y)+conjugate(v)*conjugate(x)

 

conjugate(f)/(conjugate(u)*conjugate(y)+conjugate(v)*conjugate(x))+G*w*conjugate(w)*conjugate(y)/(conjugate(u)*conjugate(y)+conjugate(v)*conjugate(x))

 

(G*abs(w)^2*conjugate(y)+conjugate(f))/(conjugate(u)*conjugate(y)+conjugate(v)*conjugate(x))

(1)

restart; d := conjugate(u)*conjugate(y)+conjugate(v)*conjugate(x); z := conjugate(f)/d+conjugate(G)*w*conjugate(w)*conjugate(y)/d; z2 := simplify(z)

conjugate(u)*conjugate(y)+conjugate(v)*conjugate(x)

 

conjugate(f)/(conjugate(u)*conjugate(y)+conjugate(v)*conjugate(x))+conjugate(G)*w*conjugate(w)*conjugate(y)/(conjugate(u)*conjugate(y)+conjugate(v)*conjugate(x))

 

(conjugate(G)*abs(w)^2*conjugate(y)+conjugate(f))/(conjugate(u)*conjugate(y)+conjugate(v)*conjugate(x))

(2)

``


solved.mw

Hi ecterrab

Thank you for solutions.

Regarding the second problem only the end user knows what form of presentation of complex number is preferable in his case. Moreover, there are few situations when splitting of a complex number into Re + I Im is preferable to not splitting. Therefore, the decision to split or not to split indeed have to be strongly dependent on a particular task. For objective reasons Maple is unable to handle what form of complex number is simplifying for the end user. So, the correct behaviour of Simplify/conjugate is not to split a complex number at all. The compromise might be not splitting for conjugate command and splitting (in some sittuations) for Simplify command. Of couse it is only my oppinion.

Hi ecterrab

Thank you for solutions.

Regarding the second problem only the end user knows what form of presentation of complex number is preferable in his case. Moreover, there are few situations when splitting of a complex number into Re + I Im is preferable to not splitting. Therefore, the decision to split or not to split indeed have to be strongly dependent on a particular task. For objective reasons Maple is unable to handle what form of complex number is simplifying for the end user. So, the correct behaviour of Simplify/conjugate is not to split a complex number at all. The compromise might be not splitting for conjugate command and splitting (in some sittuations) for Simplify command. Of couse it is only my oppinion.

@ecterrab

Thank you for explaining the difference between `*` and `.` and for explaining presented in PhysicsUpdate.mw. They are really helpful.

One more observation. Physics:-Simplify cannot always simplify the elementary expressions with fermionic operators:

restart; 
with(Physics); Setup(mathematicalnotation = true); Setup(anticommutativeprefix = psi);

for i to 4 do
ap[i] := Creation(psi, i, notation = explicit);
am[i] := Annihilation(psi, i, notation = explicit)
end do;

z := ap[1].am[2].am[2];
Simplify(z);


0

z := am[1].am[2].am[2]; 
Simplify(z);


Simplify_problem.mw

I suppose that some kind of defect appeared in Physics package.

The first run of the code below gives the result in improper notations.

restart; Physics:-Version(); with(Physics); with(Library); Setup(mathematicalnotation = true, anticommutativeprefix = psi); for i to 2 do ap[i] := Creation(psi, i, notation = explicit); am[i] := Annihilation(psi, i, notation = explicit) end do; H := Physics:-`*`(a, ap[1]).am[1]; phi := Physics:-`*`(a, Ket(psi, 1, 0))

 

a*(`a+`[psi[1]].`a-`[psi[1]])

 

a*Physics:-Ket(psi, 1, 0)

(1)

And only the second run gives the result in proper notations.

restart; Physics:-Version(); with(Physics); with(Library); Setup(mathematicalnotation = true, anticommutativeprefix = psi); for i to 2 do ap[i] := Creation(psi, i, notation = explicit); am[i] := Annihilation(psi, i, notation = explicit) end do; H := Physics:-`*`(a, ap[1]).am[1]; phi := Physics:-`*`(a, Ket(psi, 1, 0))

 

a*Physics:-`.`(`a+`[psi[1]], `a-`[psi[1]])

 

a*Physics:-Ket(psi, 1, 0)

(2)

NULL

notations.mw

@ecterrab

Thank you for explaining the difference between `*` and `.` and for explaining presented in PhysicsUpdate.mw. They are really helpful.

One more observation. Physics:-Simplify cannot always simplify the elementary expressions with fermionic operators:

restart; 
with(Physics); Setup(mathematicalnotation = true); Setup(anticommutativeprefix = psi);

for i to 4 do
ap[i] := Creation(psi, i, notation = explicit);
am[i] := Annihilation(psi, i, notation = explicit)
end do;

z := ap[1].am[2].am[2];
Simplify(z);


0

z := am[1].am[2].am[2]; 
Simplify(z);


Simplify_problem.mw

I suppose that some kind of defect appeared in Physics package.

The first run of the code below gives the result in improper notations.

restart; Physics:-Version(); with(Physics); with(Library); Setup(mathematicalnotation = true, anticommutativeprefix = psi); for i to 2 do ap[i] := Creation(psi, i, notation = explicit); am[i] := Annihilation(psi, i, notation = explicit) end do; H := Physics:-`*`(a, ap[1]).am[1]; phi := Physics:-`*`(a, Ket(psi, 1, 0))

 

a*(`a+`[psi[1]].`a-`[psi[1]])

 

a*Physics:-Ket(psi, 1, 0)

(1)

And only the second run gives the result in proper notations.

restart; Physics:-Version(); with(Physics); with(Library); Setup(mathematicalnotation = true, anticommutativeprefix = psi); for i to 2 do ap[i] := Creation(psi, i, notation = explicit); am[i] := Annihilation(psi, i, notation = explicit) end do; H := Physics:-`*`(a, ap[1]).am[1]; phi := Physics:-`*`(a, Ket(psi, 1, 0))

 

a*Physics:-`.`(`a+`[psi[1]], `a-`[psi[1]])

 

a*Physics:-Ket(psi, 1, 0)

(2)

NULL

notations.mw

@ecterrab 

Some issues emerged with SortProducts and expand.

In the following example I demonstrate that Physics:-SortProducts command doesn't sort operators in expression when this expression contains the same operator twice.

restart; Physics:-Version(); with(Physics); with(Library); Setup(mathematicalnotation = true); Setup(anticommutativeprefix = psi); for i to 4 do ap[i] := Creation(psi, i, notation = explicit); am[i] := Annihilation(psi, i, notation = explicit) end do; ApAm1 := [seq(ap[j], j = 1 .. 4), seq(am[j], j = 1 .. 4)]; z := ap[1].ap[2].ap[1]; z := SortProducts(z, ApAm1, useanticommutator)

 

[`a+`[psi[1]], `a+`[psi[2]], `a+`[psi[3]], `a+`[psi[4]], `a-`[psi[1]], `a-`[psi[2]], `a-`[psi[3]], `a-`[psi[4]]]

 

Physics:-`.`(`a+`[psi[1]], `a+`[psi[2]], `a+`[psi[1]])

 

Physics:-`.`(`a+`[psi[1]], `a+`[psi[2]], `a+`[psi[1]])

(1)

Besides that SortProduct doesn't sort operators in expression at one time. Of course, one can call collect(z,`.`) and then repeat sorting, However, it is possible (my case) when you don't really know how many times you should repeat sorting. It would be useful to have a possibility to sort them at one time.

z := A*am[2].ap[2].am[1].ap[1]; z := SortProducts(z, ApAm1, useanticommutator); z := collect(z, `.`); z := SortProducts(z, ApAm1, useanticommutator)

A*Physics:-`.`(`a-`[psi[2]], `a+`[psi[2]], `a-`[psi[1]], `a+`[psi[1]])

 

A*(-Physics:-`.`(`a+`[psi[1]], `a-`[psi[1]], -Physics:-`.`(`a+`[psi[2]], `a-`[psi[2]])+1)-Physics:-`.`(`a+`[psi[2]], `a-`[psi[2]])+1)

 

-A*Physics:-`.`(`a+`[psi[1]], `a-`[psi[1]])-A*Physics:-`.`(`a+`[psi[2]], `a-`[psi[2]])+A*Physics:-`.`(`a+`[psi[1]], `a-`[psi[1]], `a+`[psi[2]], `a-`[psi[2]])+A

 

-A*Physics:-`.`(`a+`[psi[1]], `a-`[psi[1]])-A*Physics:-`.`(`a+`[psi[2]], `a-`[psi[2]])-A*Physics:-`.`(`a+`[psi[1]], `a+`[psi[2]], `a-`[psi[1]], `a-`[psi[2]])+A

(2)

expand command doesn't work in some special situations (demonstrated below). Besides the result of AntiCommutator(HH(1,1), HH(1,2)) contains both Physics[`*`] and Physics[`.`]. Is it possible to convert all Physics[`*`] operations into Physics[`.`]?

PS   I don't understand the sense of the following sentence from the Help page: "Physics[`.`] - scalar product between Bras, Kets, and quantum operators." Namely, I don't know what does it means "scalar product of quantum operators". I don't understand the need in additional Product (Physics[`.`]) for operators different from Physics[`*`].

restart; with(Physics); with(Library); Setup(mathematicalnotation = true); Physics:-Setup(anticommutativeprefix = psi); am := proc (i, sigma) local k::posint; if [i, sigma]::(Not(list(posint))) then return 'procname(args)' end if; k := 2*i-2+sigma; Annihilation(psi, k, notation = explicit) end proc; ap := proc (i, sigma) local k::posint; if [i, sigma]::(Not(list(posint))) then return 'procname(args)' end if; k := 2*i-2+sigma; Creation(psi, k, notation = explicit) end proc; nn := proc (i, sigma) if [i, sigma]::(Not(list(posint))) then return 'procname(args)' end if; ap(i, sigma).am(i, sigma) end proc; HH := proc (i, sigma) if [i, sigma]::(Not(list(posint))) then return 'procname(args)' end if; h1*am(i, sigma)+h5*am(i, sigma).nn(i, 3-sigma) end proc; f := 2; ApAm1 := [seq(seq(ap(i, sigma), sigma = 1 .. 2), i = 1 .. f), seq(seq(am(i, sigma), sigma = 1 .. 2), i = 1 .. f)]; z := AntiCommutator(HH(1, 1), HH(1, 2)); z := SortProducts(z, ApAm1, useanticommutator); z2 := expand(z)

2

 

[`a+`[psi[1]], `a+`[psi[2]], `a+`[psi[3]], `a+`[psi[4]], `a-`[psi[1]], `a-`[psi[2]], `a-`[psi[3]], `a-`[psi[4]]]

 

h1*h5*(2*Physics:-`*`(`a-`[psi[1]], `a-`[psi[2]], `a+`[psi[1]], `a-`[psi[1]])+Physics:-`.`(`a-`[psi[2]], `a-`[psi[1]]))+h5*(h1*(2*Physics:-`*`(`a-`[psi[2]], `a-`[psi[1]], `a+`[psi[2]], `a-`[psi[2]])+Physics:-`.`(`a-`[psi[1]], `a-`[psi[2]]))+h5*(-Physics:-`.`(`a-`[psi[1]], `a+`[psi[1]], `a-`[psi[1]], `a-`[psi[2]])+2*Physics:-`.`(Physics:-`*`(`a-`[psi[1]], `a-`[psi[2]], `a+`[psi[1]], `a-`[psi[1]]), `a+`[psi[2]], `a-`[psi[2]])+Physics:-`.`(`a-`[psi[2]], `a-`[psi[1]], `a+`[psi[2]], `a-`[psi[2]])))

 

h1*h5*(2*Physics:-`*`(Physics:-`*`(`a+`[psi[1]], `a-`[psi[1]], `a-`[psi[2]])-`a-`[psi[2]], `a-`[psi[1]])-Physics:-`.`(`a-`[psi[1]], `a-`[psi[2]]))+h5*(h1*(2*Physics:-`*`(-Physics:-`*`(`a+`[psi[2]], `a-`[psi[1]], `a-`[psi[2]])-`a-`[psi[1]], `a-`[psi[2]])+Physics:-`.`(`a-`[psi[1]], `a-`[psi[2]]))+h5*(-Physics:-`.`(-Physics:-`.`(`a+`[psi[1]], `a-`[psi[1]])+1, `a-`[psi[1]], `a-`[psi[2]])-2*Physics:-`.`(Physics:-`.`(`a+`[psi[1]], `a-`[psi[1]], `a-`[psi[2]])-`a-`[psi[2]], `a+`[psi[2]], `a-`[psi[1]], `a-`[psi[2]])+Physics:-`.`(-Physics:-`.`(`a+`[psi[2]], `a-`[psi[1]], `a-`[psi[2]])-`a-`[psi[1]], `a-`[psi[2]])))

 

Error, (in type/satisfies) too many levels of recursion

 

NULL

 

SortProduct_expand_problem.mw

@ecterrab 

Some issues emerged with SortProducts and expand.

In the following example I demonstrate that Physics:-SortProducts command doesn't sort operators in expression when this expression contains the same operator twice.

restart; Physics:-Version(); with(Physics); with(Library); Setup(mathematicalnotation = true); Setup(anticommutativeprefix = psi); for i to 4 do ap[i] := Creation(psi, i, notation = explicit); am[i] := Annihilation(psi, i, notation = explicit) end do; ApAm1 := [seq(ap[j], j = 1 .. 4), seq(am[j], j = 1 .. 4)]; z := ap[1].ap[2].ap[1]; z := SortProducts(z, ApAm1, useanticommutator)

 

[`a+`[psi[1]], `a+`[psi[2]], `a+`[psi[3]], `a+`[psi[4]], `a-`[psi[1]], `a-`[psi[2]], `a-`[psi[3]], `a-`[psi[4]]]

 

Physics:-`.`(`a+`[psi[1]], `a+`[psi[2]], `a+`[psi[1]])

 

Physics:-`.`(`a+`[psi[1]], `a+`[psi[2]], `a+`[psi[1]])

(1)

Besides that SortProduct doesn't sort operators in expression at one time. Of course, one can call collect(z,`.`) and then repeat sorting, However, it is possible (my case) when you don't really know how many times you should repeat sorting. It would be useful to have a possibility to sort them at one time.

z := A*am[2].ap[2].am[1].ap[1]; z := SortProducts(z, ApAm1, useanticommutator); z := collect(z, `.`); z := SortProducts(z, ApAm1, useanticommutator)

A*Physics:-`.`(`a-`[psi[2]], `a+`[psi[2]], `a-`[psi[1]], `a+`[psi[1]])

 

A*(-Physics:-`.`(`a+`[psi[1]], `a-`[psi[1]], -Physics:-`.`(`a+`[psi[2]], `a-`[psi[2]])+1)-Physics:-`.`(`a+`[psi[2]], `a-`[psi[2]])+1)

 

-A*Physics:-`.`(`a+`[psi[1]], `a-`[psi[1]])-A*Physics:-`.`(`a+`[psi[2]], `a-`[psi[2]])+A*Physics:-`.`(`a+`[psi[1]], `a-`[psi[1]], `a+`[psi[2]], `a-`[psi[2]])+A

 

-A*Physics:-`.`(`a+`[psi[1]], `a-`[psi[1]])-A*Physics:-`.`(`a+`[psi[2]], `a-`[psi[2]])-A*Physics:-`.`(`a+`[psi[1]], `a+`[psi[2]], `a-`[psi[1]], `a-`[psi[2]])+A

(2)

expand command doesn't work in some special situations (demonstrated below). Besides the result of AntiCommutator(HH(1,1), HH(1,2)) contains both Physics[`*`] and Physics[`.`]. Is it possible to convert all Physics[`*`] operations into Physics[`.`]?

PS   I don't understand the sense of the following sentence from the Help page: "Physics[`.`] - scalar product between Bras, Kets, and quantum operators." Namely, I don't know what does it means "scalar product of quantum operators". I don't understand the need in additional Product (Physics[`.`]) for operators different from Physics[`*`].

restart; with(Physics); with(Library); Setup(mathematicalnotation = true); Physics:-Setup(anticommutativeprefix = psi); am := proc (i, sigma) local k::posint; if [i, sigma]::(Not(list(posint))) then return 'procname(args)' end if; k := 2*i-2+sigma; Annihilation(psi, k, notation = explicit) end proc; ap := proc (i, sigma) local k::posint; if [i, sigma]::(Not(list(posint))) then return 'procname(args)' end if; k := 2*i-2+sigma; Creation(psi, k, notation = explicit) end proc; nn := proc (i, sigma) if [i, sigma]::(Not(list(posint))) then return 'procname(args)' end if; ap(i, sigma).am(i, sigma) end proc; HH := proc (i, sigma) if [i, sigma]::(Not(list(posint))) then return 'procname(args)' end if; h1*am(i, sigma)+h5*am(i, sigma).nn(i, 3-sigma) end proc; f := 2; ApAm1 := [seq(seq(ap(i, sigma), sigma = 1 .. 2), i = 1 .. f), seq(seq(am(i, sigma), sigma = 1 .. 2), i = 1 .. f)]; z := AntiCommutator(HH(1, 1), HH(1, 2)); z := SortProducts(z, ApAm1, useanticommutator); z2 := expand(z)

2

 

[`a+`[psi[1]], `a+`[psi[2]], `a+`[psi[3]], `a+`[psi[4]], `a-`[psi[1]], `a-`[psi[2]], `a-`[psi[3]], `a-`[psi[4]]]

 

h1*h5*(2*Physics:-`*`(`a-`[psi[1]], `a-`[psi[2]], `a+`[psi[1]], `a-`[psi[1]])+Physics:-`.`(`a-`[psi[2]], `a-`[psi[1]]))+h5*(h1*(2*Physics:-`*`(`a-`[psi[2]], `a-`[psi[1]], `a+`[psi[2]], `a-`[psi[2]])+Physics:-`.`(`a-`[psi[1]], `a-`[psi[2]]))+h5*(-Physics:-`.`(`a-`[psi[1]], `a+`[psi[1]], `a-`[psi[1]], `a-`[psi[2]])+2*Physics:-`.`(Physics:-`*`(`a-`[psi[1]], `a-`[psi[2]], `a+`[psi[1]], `a-`[psi[1]]), `a+`[psi[2]], `a-`[psi[2]])+Physics:-`.`(`a-`[psi[2]], `a-`[psi[1]], `a+`[psi[2]], `a-`[psi[2]])))

 

h1*h5*(2*Physics:-`*`(Physics:-`*`(`a+`[psi[1]], `a-`[psi[1]], `a-`[psi[2]])-`a-`[psi[2]], `a-`[psi[1]])-Physics:-`.`(`a-`[psi[1]], `a-`[psi[2]]))+h5*(h1*(2*Physics:-`*`(-Physics:-`*`(`a+`[psi[2]], `a-`[psi[1]], `a-`[psi[2]])-`a-`[psi[1]], `a-`[psi[2]])+Physics:-`.`(`a-`[psi[1]], `a-`[psi[2]]))+h5*(-Physics:-`.`(-Physics:-`.`(`a+`[psi[1]], `a-`[psi[1]])+1, `a-`[psi[1]], `a-`[psi[2]])-2*Physics:-`.`(Physics:-`.`(`a+`[psi[1]], `a-`[psi[1]], `a-`[psi[2]])-`a-`[psi[2]], `a+`[psi[2]], `a-`[psi[1]], `a-`[psi[2]])+Physics:-`.`(-Physics:-`.`(`a+`[psi[2]], `a-`[psi[1]], `a-`[psi[2]])-`a-`[psi[1]], `a-`[psi[2]])))

 

Error, (in type/satisfies) too many levels of recursion

 

NULL

 

SortProduct_expand_problem.mw

@ecterrab 

I will test the new version of Coefficients with great pleasure.

@ecterrab 

I will test the new version of Coefficients with great pleasure.

macro command solved the problem.

The procedure below

coeffuniversal := proc (z) 
local W, h;
W := [seq(h*op(i, z), i = 1 .. nops(z))];
#W := [seq(select(type, W[i], commutative), i = 1 .. numelems(W))];
W := map(u->select(type, u, commutative), W);
map(u->u/h, W)
end proc

gets the coefficients both operator expression and wave function expression. Internal variable 'h' is dynamically created at the procedure call so it doesn't interfere with the variable 'h' that may exist in the argument 'z'.

I'd prefer to multiply by 1 rather than 'h', namely to replace the first command of the procedure with the following one

W := [seq(`%*`(1, op(i, z)), i = 1 .. nops(z))]

but it doesn't give the desired result.

There is a short summary of this thread in the attached file.
coefficients.mw

The procedure below

coeffuniversal := proc (z) 
local W, h;
W := [seq(h*op(i, z), i = 1 .. nops(z))];
#W := [seq(select(type, W[i], commutative), i = 1 .. numelems(W))];
W := map(u->select(type, u, commutative), W);
map(u->u/h, W)
end proc

gets the coefficients both operator expression and wave function expression. Internal variable 'h' is dynamically created at the procedure call so it doesn't interfere with the variable 'h' that may exist in the argument 'z'.

I'd prefer to multiply by 1 rather than 'h', namely to replace the first command of the procedure with the following one

W := [seq(`%*`(1, op(i, z)), i = 1 .. nops(z))]

but it doesn't give the desired result.

There is a short summary of this thread in the attached file.
coefficients.mw

3 4 5 6 7 8 9 Page 5 of 10