Bland3

30 Reputation

5 Badges

6 years, 128 days

MaplePrimes Activity


These are replies submitted by Bland3

@acer 

I had mistakenly "found" that using msubsup would give a lowered (raised) superscript (subscript), but it seems to not be applied universally. For instance, if I just typeset 1st, 2nd, 3rd, 4th, I get different results based on whether they are all grouped together or placed separately.

Here is some code that produces two different textplots: One good example with everything on the same line with a lowered superscript, and a bad example with the superscripts being above the line. I used the good example and copy-pasted and trimmed that code to produce the bad example. I don't know why this would produce inconsistent results. I didn't clean up the sizing and all. This is just proof of concept.

 

 

Restart:
with(StringTools):
with(plots):
with(ImageTools):

LegendLabelSet:= {}:
#
use Typesetting in
#
#
# 
  fstlabel := mrow(msubsup(mn("1", font="cmr16", size="20"),mo(" "),mtext("st",font="cmr16",size="17")),  mtext(" thing", font="cmr16", size="20" )):
  seclabel := mrow(msubsup(mn("2", font="cmr16", size="20"),mo(" "),mtext("nd",font="cmr16",size="17")), mtext(" thing", font="cmr16", size="20" )):
  thrlabel := mrow(msubsup(mn("3", font="cmr16", size="20"),mo(" "),mtext("rd",font="cmr16",size="17")), mtext(" thing", font="cmr16", size="20" )):
  foulabel :=mrow(msubsup(mn("4", font="cmr16", size="20"),mo(" "),mtext("th",font="cmr16",size="17")),  mtext(" thing", font="cmr16", size="20" )):
#
  FirstThruFourthLabel := mrow(msubsup(mn("1", font="cmr16", size="20"),mo(" "),mtext("st",font="cmr16",size="17")),  mtext(" thing", font="cmr16", size="20" ),mphantom(mtext(" ")),msubsup(mn("2", font="cmr16", size="20"),mo(" "),mtext("nd",font="cmr16",size="17")),  mtext(" thing", font="cmr16", size="20" ),mphantom(mtext(" ")),msubsup(mn("3", font="cmr16", size="20"),mo(" "),mtext("rd",font="cmr16",size="17")),  mtext(" thing", font="cmr16", size="20" ),mphantom(mtext(" ")),mphantom(mtext(" ")),msubsup(mn("4", font="cmr16", size="20"),mo(" "),mtext("th",font="cmr16",size="17")),  mtext(" thing", font="cmr16", size="20" )):
#
#
#
end use: 
#
LegendLabelSet := LegendLabelSet union {[5.0+0.00,0.25, fstlabel,'align'='right' ]} :
LegendLabelSet := LegendLabelSet union {[5.0+1.25,0.25, seclabel, 'align'='right' ]} :
LegendLabelSet := LegendLabelSet union {[5.0+2.58,0.25, thrlabel, 'align'='right']} :
LegendLabelSet := LegendLabelSet union {[5.0+4.0,0.25, foulabel, 'align'='right' ]} :
LegendLabelSet := LegendLabelSet union {[5.0+0.0,0.00,FirstThruFourthLabel, 'align'='right', font=[cmr16,19] ]} :
LegendLabelPlot:=textplot(LegendLabelSet):
display(LegendLabelPlot, view=[4..15,-0.75..1.0], axes=none);

 

Is there a way to produce this uniformly?  Adding additional content to fstlabel doesn't seem to do much. I just tried changing it to

 fstlabel := mrow(msubsup(mn("1", font="cmr16", size="20"),mo(" "),mtext("st",font="cmr16",size="17")),  mtext(" thing", font="cmr16", size="20" ), mtext("TestingTestingTesting",font="cmr16",size="17")) ;

 

and got the same formatting of the 1st label.

 

 

 

I've got the formatting close to what I'd need to reproduce the editing I added with the LPIC LaTeX package. The basic idea is to incorporate the image for the figure, add a chosen amount of whitespace, then add LaTeX formatted textplots superposed onto the image, not so dissimilar to that ImageTools that you made a post about.
Edit: Even without my particular goal, I think it's of interest to be able to have a LaTeX-like typesetting and have found several other questions asking how to do this.

In case anyone stumbles across this. What I have for vertically aligning the subscripts in a LaTeX-like manner is to use the mover command in the subscript combined with a size=1 to kept the look OK:

use Typesetting in 
myvarname := msub(mi("f",size="18"),  mover(mo(" ",size="1"), mrow(mi("i",size="15"), mo(",",size="15", bold), msub(mi("g",size="15"), mover(mo(" ",size="1"),mi("h",size="13")))) ) ) :
end use:

Which will give something similar to $f_{i,g_{h}}$ in LaTeX (the curly brackets around the h are optional in LaTeX). I'm not finished playing with the sizes for final formatting - adjust to taste.

It seems that putting in sizes at the definition of the typeset text is also more robust than trying to define a default size when making a textplot and specifying the subscripts in the definition. I'm not sure why or if I've just done something inccorect, but putting it into the typeset text seems to work well.

@acer 

My main driving issue is that I made plots using Maple for a publication, then edited those plots using LaTeX to give it the fancy LaTeX formatting for things like expectation vales, dagger symbols, etc. I need to produce .eps files that are not edited within the LaTeX document itself so that the .eps file plugged into the publication draft is self-contained. I'm unaware of a method using LaTeX to take an .eps, edit it using one's favorite TeX packages, then export that marked up .eps as a new file. There are some things that do a similar but not exactly what I was looking for, so it seemed that the most expedient solution would be to just add those features to the figures generated by Maple. I've been pulling my hair out ever since. So, the main goal is to be able to take a plot made, "freeze it," then add other stuff around it, so that I can make a new .eps that will be self-contained.

All of these procedures and strange constructions are the result of getting things to work piece by piece. Perhaps this would be easiest to do using the ImageTools package since you have made a pretty good post about using ImageTools package, although the documentation on ImageTools:-Read doesn't include .eps files for the allowed formats. Truthfully, this method didn't occur to me until writing this reply.

Why the weird procedure that overlaps with built-in features? In my post on scalable subplots  I used an idea you once proposed about using a procedure to generate the subplots without having to mess with saving an image, importing, and hoping that the given image is of sufficient quality. When I got the textplot formatted roughly correctly (I could at least get the symbols printed), the view set by my display( ... ) command would remove some of the added text. No big deal, just made the view larger, but then the axes were too large and in the way. So I simply repurposed that work from making the subplot into making the axes for the plot as I wanted them separate from the view and inluded axes=none into the display command. Maybe there was a built-in function for this, I don't know, but I have something that works. In wanting the format the y-axis into scientific notation, I thought, "Why not just make it so I can put in any typset expression for the axis tickmark label," but then failed to construct a correctly working procedure.

What I currently have working is that I've just added the typeset tickmark labels along with the other textplots to be added after the fact and feed that procedure an empty set for the yaxistickmarklabel set. In the what I'm currently working on, the typeset tickmark label is just scientific notation, but it's easy enough to build the set of things to textplot.

@acer 

 

Edit: It seems like just putting it in by hand is the simplest method. I'll make a couple edits to my procedures before posting for others.

 

Thanks for the answers. I've got one more thing I'd like to do. I'm trying to make a procedure such that I feed it the

  • Points to generate axes line segments
  • tickmark locations
    • e.g. [1,2,3,4,5,6,7]
  • tickmark labels
    • e.g. [1,3,5,7]
  • length of tickmarks
  • typeset labels for tickmarks
  • tickmark label obtions
    • e.g. 'font'=["roman",18]

But what I can't figure out is how to feed in pre-formatted typeset labels. I have a version that I just give it the numbers, but then formatting is inconsistent like decimal vs. scientific notation.

 

I've attached a working draft without the typeset labels, and a draft of one thing that I've tried. I'd like to keep it within the procedure to make it consistent and repeatable.

TypesetTickmarksDraft.mw

I've attempted to insert the contents and that failed:
"Maple Worksheet - Error
Failed to load the worksheet /maplenet/convert/TypesetTickmarksDraft.mw "

 

My intention once I get it working is to upload simpler versions of what I have that has been working so that others don't have as difficult of a time with it.

 

Maple is really difficult to make publication-ready images - it sucks, in fact. I'm not sure I will continue using it if they don't make LaTeX directly usable for typesetting. MatLAB and Mathematica have it, Python, Sage, Java have it, and there are LaTeX to *ML converters available. It's just awful to have to keep fighting with Maple's tedious syntax, lack of documentation, and crap searching on Maple Primes (I've had search results just yield a page of other search results - why?). I've lost over a week's time due to this crap.

 

@acer, Thank you again.

I agree that the search is quite bad. I tried the advanced search and put typesetting and nothing else. Not many things gave up with that tag, and I didn't see this post (which I put typesetting).

 

It would be definitely useful to have an intelligent procedure that generates subscripts sufficiently well. For this purpose, I think I can get by. modifying the quick example of

 `#msub(mi("f"),mrow(mi("i"),mo(","),mi("j")));`

to

 `#msub(mi("f"),mrow(mi("i"),mo(","),mi("j",size="7")));`

adjusts the size of the j to be 7. Obviously this isn't for your knowledge, but in case someone else stumbles across this question. I attempted to nest the  size  with the  mi  commands before. I'll try to post a modified version of my above worksheet once I get it working. The main thing of the initial worksheet that I attached was dealing with the subscripts in the very last example of that sheet. I spent a significant chunk of time trynig various things, and added how to change things bit by bit in that sheet for others in case they run into a similar "how the heck do I do that?" moment.

I'll try to make the changes for my use and post a new example if I run into issues.

@acer I appreciate the time you take to respond to these, but I don't see the things that you're talking about. I don't follow MaplePrimes regularly, to be honest, but I do attempt to search for the things what I ask questions on. For something from two days ago, I checked your posts, answers,and replies and I don't see where you've discussed the notion of controlling the typesetting size with an inline command. I see you've discussed things related to typesetting in Display of Package Names two days ago but I don't understand the connection to what I'm asking.

Searching anything that restricted the number of results to something manageable didn't yield much that helped, so I asked.

It does seem that you've answered similar concerns before like in this post from 2017, that I found just searching "typesetting," but the code to generate the typeset quantity KB is downright confusing to me. I don't disagree with the notion that if I knew all of the various manipulations that using pre-built Maple functions to generate a typeset output is useful, but for something like making a decent y-axis label, it shouldn't be that complicated. Maybe this comes across like a temper tantrum, but I consistently spend hour after hour trying to get crap to work in Maple, and to be told "well, just search for it" like I haven't put any effort is extremely frustrating. It's not even that the Maple documentation is helpful. The MathML and Typesetting articles provide no hlep in doing something like adding an XML character what is being typeset.

If these things have been done so repeatedly, why doesn't Maple collect these answers and combine them into some useful tutorial so that when someone goes to the page on plots and typesetting we get something more useful than https://www.maplesoft.com/support/help/maple/view.aspx?path=plot%2ftypesetting where there could be a link to an advanced tutorial for creating nice typeset things. We can apparently use XML, but not with <tag>stuff</tag> format, so we can't even use the free things that move from LaTeX to the *ML languages and adjust the code based on the results. We shouldn't have to hack together things like KB in that example code - Maple should have something that works for sub and superscripts.

I would gladly work through other examples and develop things that work if I could find useful information to start. As an example of this, in my maple sheet (which isn't able to be input into my main post, but after seeing your recent posts, this seems to be a MaplePrimes issue as of late), I started with some basic information that might be helpful for someone who doesn't speak *ML languages, without the additional formatting from the .mw file. I'm happy to organize things as I understand the to help others, I just wish I could get something that works for what I need it to. Here's what I added to the start of that file:

# Some basics
## mn : number formatting 
## mi : italics formatting 
## mo : operator formatting 
## msub   : subscript
## msup   : superscript
## msubsup: subscript & superscript
## mrow   : used to concatenate strings of different type
### for instance `#msub(mi("f"),mrow(mi("i"),mo("&comma;"),mi("j")));`
#### gives f with a subcript "i,j"
## "&SymbolName;"  : Input a symbol given by SymbolName
### &auml;         : a with two dots over it
### &dagger;       : dagger symbol commonly used to Hermitian conjugate
### &lang;         : left angle bracket
### &rang;         : right angle bracket

# Mozilla has a useful list of MathML Elements: 
## https://developer.mozilla.org/en-US/docs/Web/MathML/Element
# Wikipedia has a nice list of XML symbol names: 
## https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references 

Sure it's helpful to work through things ourselves, but it's also dang slow compared to having a small starter list of useful information and a list of resources for more more advanced topics to explore as we need.

Thank you, @acer, for the reply. I would appreciate being able to see that. Something that I conclude that document with, but didn't put into the main question was the issue of double subcripts. LaTeX handles this quite nicely, but the ML formatting as I'm able to do it is quite clunky. Here's the example from the file I attached above

 

# Double subscripts and capital letters are particularly ugly
plot(sin(x), x=5..20, view=-2..2, size=[500,300],
     axis[1]=[gridlines=[seq(i,i=5..20,5)]],
     axis[2]=[gridlines=[$-2..2]], axes=boxed,
     title=typeset( 
                   `#mo("&lang;");`,   
                   `#msub(mi("F"),mrow(mo("&pm;"),mo("&comma;"),msub(mi("d"),mi("i"))));`,
                   `#mo("&rang;");`   ), font=[Roman, 25]
                   );

In that, the variable F has as its subscript "pm, d_i", which is quite bad to look at when written between brackets. All of the things I found to adjust in MLs use the tag formatting <command>stuff </command> and I didn't find a way to make that work in Maple for the typesetting.

Sorry for not more explicitly putting that into the main question.

@acer Thanks for pointing out the issue. It now downloads for me and opens in my maple. That comment was a big part of why I made this post. I apologize for not stating that directly. This is 100% derivative of your suggestion (no pun intended).

@dharr

That makes the plotting much better. Thanks!

@dharr

You're right. The eigenvectors are still correct despite the non-exact eigenvalue. Working it out by hand (observation) the pairs <1,0|-1,0> and <0,1|0,1>. Of course these are orthogonal . I was mistaken before. And for mu=/= 0, the particle-hole symmetry comes through. For mu=0 the states at +/-2 (with w=0 as in my maple file), the high degenercy makes the particle hole symmetry not obvious. But of course, it's still there.

The nullspace wokrs for mu=0, but fails for mu>0 since the eigenvalues aren't strictly zero, but are exponentially small compared to the next eigenvalue pair. (physicists label these as "zero" due to the exponentially small energy compared to the rest of the staes)

I think I need to sit down with a cup of tea and write out something that will allow guessing the eigenvector, but I don't think this will be inherently useful, either, because I would then need a good ansatz for the eigenvector, which for this particlar model is easy, but in general is quite impractical.

@Carl Love @dharr

There are two separate issues (along with issues of my maple coding being inefficient for plotting)

Long-story short: Is it feasible for me to construct a class like “shape=symmetric” to hunt for the eigenvectors and values in pairs? This way I could write “shape=particleholesymmetric” and have the eigenvectors and values more neatly organized. Being in physics, I demand this matrix be Hermitian so I’d like to include that somehow into the classification scheme. And at the end, is there a simple suggestion for plotting many functions on one display?

As for the symmetry of the Hamiltonian giving eigenvectors of the form <u|v> for an eigenvalue E implying that we have another eigenvector <v|u> for -E. I agree that it follows directly from multiplying out. But the command LinearAlgebra:-Eigenvectors(Matrix(M, shape= symmetric, datatype= float[8])) is not giving me exactly two eigenvalues of 0. It gives an eigenvalue 0 and a second of 4.4 x 10^-16 for the mu=0 case. I’ll stick to the mu=0 case for my response sine the zero eigenvalues correspond to vectors of the form <u1,0,…,0,uL| v1,0,…,0,vL> which I’ll shorthand as <u1,uL|v1,vL>. Of course by the symmetry, we see vi=ui, but I’ll write it to be more concrete. For 0 eigenvalue Maple gives <0,-1|0,-1> and for the ~10^-16 eigenvalue Maple spits out <1,0|-1,0>, which does not have the symmetry.

Is there a way to give Maple a guess for some of the eigenvalues? For this problem, I know for mu<2w that I have two e-vals +/-E0 such that E0<<E1 where E1 is the next lowest-lying positive eigenvalue. These states should obey the symmetry constraint (or the more general condition for <u|v> <-> <v*|u*> with * being complex conjugation). So, can I give ansatz for either the eigenvalues or, even better, the form of the eigenvectors?

Returning to the mu=0 case: A naive basis is <1,0|1,0> and <0,1|0,1>, but I’m looking for eigenvectors that exponentially decay (oscillating exp. Is okay) from the edges at 1 and L. For the mu=0, we have only at very edge at i=1,L.  Physically the mode I would want is <1,1|1,1> and <1,-1|1,-1> (up to an overall phase and normalization). Supposing I know that such modes should exist, is it possible to tell Maple to search for them in that basis? In principle, I could have a problem that I can’t exactly solve but should still have such exponentially decaying modes. Naively, this seems like it should be faster than actually solving for eigenvectors and eigenvalues for the full space since I am looking for just the lowest lying pair and the modes that decay away from the edges. In particular, if they exist at one boundary, I expect that it would be at the other boundary as well.. for a given physical situation.

On a similar note, for the mu=0, the non-zero energy states are highly degenerate. So the particle-hole symmetry is not immediate. Can maple be told to write them in the form <u|v> and <v|u> from the onset. That is, once it finds one eigenvector, can it use the particle-hole symmetry to generate the others?

I’ve attached this for the case of L=16 for mu from 0 to 2.5 with w fixed at 1. We can see the gap in the spectrum for mu<2w, so it all checks out, but the actual organization of everything obscures what is going on (which is fine, mathematically, less satisfying physically). For mu=0, it’s just the ends of the chain. For mu=w, we still have nice “edge” eigenvectors. For mu=2w, these edge eigenvectors span the whole space. And for mu=2.5 the gap is fully opened and the edge modes totally disappear.

 

For my maple code. I don’t need it to be extremely efficient, but I would like some way of not typing out display (plotter[1],…,plotter[2L]) by hand. I tried throwing them all into a list, but that gave an error. I don’t mind the randomly generated colors so much, but it’s a pain to copy-paste and edit numbers until I make the full list.

This window isn't loving the insert contents option, but heres my maple code:
Kitaev_BdG_MajoranaModeIssues.mw

 




 

I realized about a week back I was misreading the help file. Should anyone else stumble onto this, it's worth nothing that the built in operators for Annhilation(psi,m) acts on the mth position of ket(psi, n_1,n_2,...m_n, ..., m_L). I don't know of a way to convert the list to a string to write it as abstractly as possible, but for the Hamiltonian I have, the computation time is going like 2^(L^2), so it probably doesn't matter since writing it out for a few sites isn't too bad.

@ecterrab

Mr. Cheb-Terrab,

Thank you for getting back to me.

I know that in the initial setup I didn't specify that, so I agree that that makes sense up to equation (5) of the mose recent worksheet. But then in (6) through (10) I specified to always anti-commute the ann-ann and cre-cre to zero, but in (9) is doesn't calculate this. Then when I attempt to define the anti-commutative prefix, it spits out an error since it doesn't play with the KroneckerDelta nicely. That's basically what I did from just before (15) to the end. I tried to manipulate the anto-commutative prefix as well as the non-commutative prefix and specifying the algebra.

As for the built in functions, I would like to, but if I try to give it a list, it gives an error. If I try to work this out for an 8 site lattice, I have to keep track of things like

but then to make it for 6 or 9 sites, I then have to retype everything. It's not the end of the world or anything, but I'm looking for some way to do this with list/vectors so it doesn't matter whether I use 7 or 8 sites and don't have to copy-paste and remove/add to adjust everything over.

 

Went through yesterday and tried a bunch of things in the algebra definitions. It doesn't seem to like trying the anticommutativeprefix or noncommutativeprefix labeling when trying to make it so the ann-ann or cre-cre anticommute while AC(ann[i]cre[j]) -> delta[i,j]
 

restart

with(Physics): with(combinat): with(LinearAlgebra): with(ArrayTools): with(ListTools): Setup(mathematicalnotation=true):

Setup(mathematicalnotation=true):

Setup(quantumop={cre,ann}, algebrarules={%AntiCommutator(cre[j],ann[k])=I*KroneckerDelta[j,k]})

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

 

[algebrarules = {%AntiCommutator(cre[j], ann[k]) = I*Physics:-KroneckerDelta[j, k]}, quantumoperators = {ann, cre}]

(1)

 Algebra handles the anti-cummutations fine of the creation and annihilations, but not annihilation-annihilation or creation-creation. It also doesn't simplify products of these (such that terms like annihilation[j] ^2 should evaluate to 0). So here it doesn't know what to do with the annihilation-annihilation Anti-Commutator, so it assumes it commutes.

AntiCommutator(cre[1],ann[1]);
AntiCommutator(cre[1],ann[2]);

I

 

0

(2)

Simplify(ann[1]*ann[1]);

Physics:-`^`(ann[1], 2)

(3)

AntiCommutator(ann[1],ann[1]);

Physics:-AntiCommutator(ann[1], ann[1])

(4)

 

AntiCommutator(ann[1],ann[2]);
value(ann[1]*ann[2] + ann[2]*ann[1]);
Simplify(%);

Physics:-AntiCommutator(ann[1], ann[2])

 

Physics:-`*`(ann[1], ann[2])+Physics:-`*`(ann[2], ann[1])

 

2*Physics:-`*`(ann[1], ann[2])

(5)

 

Okay, so suppose we try to add additional rules to the algebra:

restart

with(Physics): with(combinat): with(LinearAlgebra): with(ArrayTools): with(ListTools): Setup(mathematicalnotation=true):

Setup(mathematicalnotation=true):

Setup(quantumop={cre,ann}, algebrarules={%AntiCommutator(cre[j],ann[k])=I*KroneckerDelta[j,k],%AntiCommutator(cre[j],cre[k])=0, %AntiCommutator(ann[j],ann[k])=0})

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

 

[algebrarules = {%AntiCommutator(ann[j], ann[k]) = 0, %AntiCommutator(cre[j], ann[k]) = I*Physics:-KroneckerDelta[j, k], %AntiCommutator(cre[j], cre[k]) = 0}, quantumoperators = {ann, cre}]

(6)

AntiCommutator(cre[1],ann[1]);
AntiCommutator(cre[1],ann[2]);

I

 

0

(7)

Simplify(ann[1]*ann[1]);

Physics:-`^`(ann[1], 2)

(8)

AntiCommutator(ann[1],ann[1]);

Physics:-AntiCommutator(ann[1], ann[1])

(9)

 

AntiCommutator(ann[1],ann[2]);
value(ann[1]*ann[2] + ann[2]*ann[1]);
Simplify(%);

Physics:-AntiCommutator(ann[1], ann[2])

 

Physics:-`*`(ann[1], ann[2])+Physics:-`*`(ann[2], ann[1])

 

2*Physics:-`*`(ann[1], ann[2])

(10)

type(ann, anticommutative);

false

(11)

 But this has all of the problems of above - my original post used this "expanded" set of rules that Maple seems to be ignoring.

 

I can give it the particular values to set to zero, but not a pair of  generic inputs

restart

with(Physics): with(combinat): with(LinearAlgebra): with(ArrayTools): with(ListTools): Setup(mathematicalnotation=true):

Setup(mathematicalnotation=true):

Setup(quantumop={cre,ann}, algebrarules={%AntiCommutator(cre[j],ann[k])=I*KroneckerDelta[j,k],%AntiCommutator(cre[1],cre[2])=0, %AntiCommutator(ann[1],ann[1])=0})

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

 

[algebrarules = {%AntiCommutator(ann[1], ann[1]) = 0, %AntiCommutator(cre[1], cre[2]) = 0, %AntiCommutator(cre[j], ann[k]) = I*Physics:-KroneckerDelta[j, k]}, quantumoperators = {ann, cre}]

(12)

AntiCommutator(cre[1],ann[1]);
AntiCommutator(cre[1],ann[2]);
AntiCommutator(cre[1],cre[1]);
AntiCommutator(cre[1],cre[2]);
AntiCommutator(ann[1],ann[1]);
AntiCommutator(ann[1],ann[2]);

I

 

0

 

Physics:-AntiCommutator(cre[1], cre[1])

 

0

 

0

 

Physics:-AntiCommutator(ann[1], ann[2])

(13)

type(ann, anticommutative);
type(cre, anticommutative);

false

 

false

(14)

 

Adding additional rules to the algebra, like multiplication doesn't seem to play nicely

restart

with(Physics): with(combinat): with(LinearAlgebra): with(ArrayTools): with(ListTools): Setup(mathematicalnotation=true):

Setup(mathematicalnotation=true):

Setup(quantumop={cre,ann}, algebrarules={%AntiCommutator(cre[j],ann[k])=I*KroneckerDelta[j,k],%AntiCommutator(cre[j],cre[k])=0, %AntiCommutator(ann[j],ann[k])=0, %ann[i]*%ann[i]=0})

Error, invalid input: Physics:-Setup expects value for keyword parameter algebrarules to be of type {Matrix, truefalse, list(Or(specfunc([Physics:-Commutator, %Commutator]), specfunc([Physics:-AntiCommutator, %AntiCommutator])) = algebraic), set(Or(specfunc([Physics:-Commutator, %Commutator]), specfunc([Physics:-AntiCommutator, %AntiCommutator])) = algebraic), identical(none, NULL, "not given"), Or(specfunc([Physics:-Commutator, %Commutator]), specfunc([Physics:-AntiCommutator, %AntiCommutator])) = algebraic}, but received {%ann[i]^2 = 0, %AntiCommutator(ann[j], ann[k]) = 0, %AntiCommutator(cre[j], ann[k]) = I*Physics:-KroneckerDelta[j, k], %AntiCommutator(cre[j], cre[k]) = 0}

 

And this gives an error saying I can't multiply the operator by itself in the algebra. Tried with and without the % on the ann[i], as well as using Mutliply, *, ., and ^2.

 

But, suppose we try to use the anticommutative prefix, I can't define them such that creation-creation operators and annihilation-annihilation operators anti-commute and also that the cre-ann anticommutator goes to the delta function

 

restart

with(Physics): with(combinat): with(LinearAlgebra): with(ArrayTools): with(ListTools): Setup(mathematicalnotation=true):

Setup(mathematicalnotation=true):

Setup(quantumop={cre,ann}, algebrarules={%AntiCommutator(cre[j],ann[k])=I*KroneckerDelta[j,k]},anticommutativeprefix={cre,ann})

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

 

Error, (in Physics:-Setup) unable to proceed because, taking into account {}, we would have cre[j] and ann[k] anticommutative and AntiCommutator(cre[j], ann[k]) = I*Physics:-KroneckerDelta[j, k]

 

It works for a single anti-commuting variable:

restart

with(Physics): with(combinat): with(LinearAlgebra): with(ArrayTools): with(ListTools): Setup(mathematicalnotation=true):

Setup(mathematicalnotation=true):

Setup(quantumop={cre,ann}, algebrarules={%AntiCommutator(cre[j],ann[k])=I*KroneckerDelta[j,k]},anticommutativeprefix={ann})

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

 

[algebrarules = {%AntiCommutator(cre[j], ann[k]) = I*Physics:-KroneckerDelta[j, k]}, anticommutativeprefix = {_lambda, ann}, quantumoperators = {ann, cre}]

(15)

AntiCommutator(cre[1],ann[1]);
AntiCommutator(cre[1],ann[2]);

I

 

0

(16)

Simplify(ann[1]*ann[1]);

0

(17)

AntiCommutator(ann[1],ann[1]);

0

(18)

 

AntiCommutator(ann[1],ann[2]);
value(ann[1]*ann[2] + ann[2]*ann[1]);
Simplify(%);

0

 

0

 

0

(19)

type(ann, anticommutative);
type(cre, anticommutative);

true

 

false

(20)

But suppose we try to do these as separate lists, then it doesn't keep track properly

restart

with(Physics): with(combinat): with(LinearAlgebra): with(ArrayTools): with(ListTools): Setup(mathematicalnotation=true):

Setup(mathematicalnotation=true):

Setup(quantumop={cre,ann}, algebrarules={%AntiCommutator(cre[j],ann[k])=I*KroneckerDelta[j,k]},anticommutativeprefix={ann},anticommutativeprefix={cre})

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

 

[algebrarules = {%AntiCommutator(cre[j], ann[k]) = I*Physics:-KroneckerDelta[j, k]}, anticommutativeprefix = {_lambda, cre}, quantumoperators = {ann, cre}]

(21)

AntiCommutator(cre[1],ann[1]);
AntiCommutator(cre[1],ann[2]);

I

 

0

(22)

Simplify(ann[1]*ann[1]);

Physics:-`^`(ann[1], 2)

(23)

AntiCommutator(cre[1],cre[1]);
AntiCommutator(ann[1],ann[1]);

0

 

Physics:-AntiCommutator(ann[1], ann[1])

(24)

 

AntiCommutator(ann[1],ann[2]);

Physics:-AntiCommutator(ann[1], ann[2])

(25)

type(ann, anticommutative);
type(cre, anticommutative);

false

 

true

(26)

Since that treats the Kronecker delta function fine, we can try to use a function to set the product to zero

restart

with(Physics): with(combinat): with(LinearAlgebra): with(ArrayTools): with(ListTools): Setup(mathematicalnotation=true):

zero:=(j,k)->0;

proc (j, k) options operator, arrow; 0 end proc

(27)

Setup(quantumop={cre,ann},noncommutativeprefix={ann,cre}, algebrarules={%AntiCommutator(cre[j],ann[k])=I*KroneckerDelta[j,k],%AntiCommutator(cre[j],cre[k])=zero(j,k), %AntiCommutator(ann[j],ann[k])=0})

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

 

[algebrarules = {%AntiCommutator(ann[j], ann[k]) = 0, %AntiCommutator(cre[j], ann[k]) = I*Physics:-KroneckerDelta[j, k], %AntiCommutator(cre[j], cre[k]) = 0}, noncommutativeprefix = {ann, cre}, quantumoperators = {ann, cre}]

(28)

AntiCommutator(cre[1],ann[1]);
AntiCommutator(cre[1],ann[2]);

I

 

0

(29)

Simplify(ann[1]*ann[1]);

Physics:-`^`(ann[1], 2)

(30)

AntiCommutator(ann[1],ann[1]);

Physics:-AntiCommutator(ann[1], ann[1])

(31)

 

AntiCommutator(ann[1],ann[2]);
value(ann[1]*ann[2] + ann[2]*ann[1]);
Simplify(%);

Physics:-AntiCommutator(ann[1], ann[2])

 

Physics:-`*`(ann[1], ann[2])+Physics:-`*`(ann[2], ann[1])

 

2*Physics:-`*`(ann[1], ann[2])

(32)

type(ann, anticommutative);
type(cre, anticommutative);

false

 

false

(33)

 

 

 


 

Download LatticeCalcsAlgebraIssues.mw

 

@ecterrab 

I hid some of the outputs and put in a couple comments. When trying to add some additional components, I either get nothing new, or error messages.
 

restart

with(Physics):

with(combinat):

with(LinearAlgebra):

with(ArrayTools):

with(ListTools):

 

Setup(mathematicalnotation=true):

Setup(quantumop={cre,ann}, algebrarules={%AntiCommutator(cre[j],ann[k])=I*KroneckerDelta[j,k]})

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

 

[algebrarules = {%AntiCommutator(cre[j], ann[k]) = I*Physics:-KroneckerDelta[j, k]}, quantumoperators = {ann, cre}]

(1)

 Algebra handles the anti-cummutations fine of the creation and annihilations, but not annihilation-annihilation or creation-creation. It also doesn't simplify products of these (such that terms like annihilation[j] ^2 should evaluate to 0)

AntiCommutator(cre[1],ann[1])

I

(2)

AntiCommutator(cre[1],ann[2])

0

(3)

value(%)

0

(4)

Simplify(ann[1]*ann[1])

Physics:-`^`(ann[1], 2)

(5)

AntiCommutator(ann[1],ann[1])

Physics:-AntiCommutator(ann[1], ann[1])

(6)

Setting that aside, I can generate the confiurations of Fermions on the lattice but using triangular arrays to generate a basis, then permuting to find all configurations

Config_Gen := proc(Length)
global Configurations;
local fermionarray,n_n,V,Ln,i_i;
fermionarray:= Array(triangular[upper],1..Length+1,1..Length,fill=1);
for n_n from 1 to Length+1 do
V[n_n] := fermionarray(n_n,1..Length);
Ln[n_n] := permute(convert(V[n_n],list));
end do;
Configurations := Ln[1];
for i_i from 2 to Length+1 do
    Configurations := [op( Configurations), op(Ln[i_i] ) ];
#    Configurations := Reverse([op( Configurations), op(Ln[i_i] ) ]);
end do;
 print("Table of configuratons is", fermionarray);
 print("The table written as a set of vectors is", V);
 print("Permutations of generators is", Ln);
 print("Full list of Configurations is", Configurations);
end proc;

proc (Length) local fermionarray, n_n, V, Ln, i_i; global Configurations; fermionarray := Array(triangular[upper], 1 .. Length+1, 1 .. Length, fill = 1); for n_n to Length+1 do V[n_n] := fermionarray(n_n, 1 .. Length); Ln[n_n] := combinat:-permute(convert(V[n_n], list)) end do; Configurations := Ln[1]; for i_i from 2 to Length+1 do Configurations := [op(Configurations), op(Ln[i_i])] end do; print("Table of configuratons is", fermionarray); print("The table written as a set of vectors is", V); print("Permutations of generators is", Ln); print("Full list of Configurations is", Configurations) end proc

(7)

Config_Gen(4)

"Table of configuratons is", Matrix(5, 4, {(1, 1) = 1, (1, 2) = 1, (1, 3) = 1, (1, 4) = 1, (2, 1) = 0, (2, 2) = 1, (2, 3) = 1, (2, 4) = 1, (3, 1) = 0, (3, 2) = 0, (3, 3) = 1, (3, 4) = 1, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = 1, (5, 1) = 0, (5, 2) = 0, (5, 3) = 0, (5, 4) = 0})

 

"The table written as a set of vectors is", table(%id = 18446746987972117182)

 

"Permutations of generators is", Ln

 

"Full list of Configurations is", [[1, 1, 1, 1], [0, 1, 1, 1], [1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 0], [0, 0, 1, 1], [0, 1, 0, 1], [0, 1, 1, 0], [1, 0, 0, 1], [1, 0, 1, 0], [1, 1, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 0]]

(8)

Need to go from this list to the actual states by adding creation (for kets) and annihlation (for bras) operators. It creates these fine, but again, I can't simplify this down. Big picture is that I want to use this to create a more "fundamental" Hamiltonian that acts on the configuration basis rather than the Fermionic operators. (They are, of course, equivalent, but please humor me here)

for i_i from 1 to 2^4 do
Ket(psi,Configurations[i_i]):= product(cre[j_j]^Configurations[i_i][j_j],j_j = 1 .. 4)* Ket(psi,Vacuum):
nnn:= sum(Configurations[i_i][j_j],j_j=1..4) :
fff:=(-1)^(nnn*(nnn-1)/2):
Bra(psi,Configurations[i_i]):= fff* Bra(psi,Vacuum) * product(( ann[j_j] )^Configurations[i_i][j_j],j_j = 1 .. 4):
end do:
Bracket( Bra(psi,Vacuum),Ket(psi,Vacuum) );
Bracket( Bra(psi,[1,1,1,1]),Ket(psi,[1,1,1,1]) );
SimplifyFermionicOperators(Bracket( Bra(psi,[1,1,1,1]),Ket(psi,[1,1,1,1]) ));

1

 

Physics:-`.`(Physics:-`*`(Physics:-Bra(psi, Vacuum), ann[1], ann[2], ann[3], ann[4]), Physics:-`*`(cre[1], cre[2], cre[3], cre[4], Physics:-Ket(psi, Vacuum)))

 

SimplifyFermionicOperators(Physics:-`.`(Physics:-`*`(Physics:-Bra(psi, Vacuum), ann[1], ann[2], ann[3], ann[4]), Physics:-`*`(cre[1], cre[2], cre[3], cre[4], Physics:-Ket(psi, Vacuum))))

(9)

AntiCommutator(ann[1],ann[2])

Physics:-AntiCommutator(ann[1], ann[2])

(10)

value(ann[1]*ann[2] + ann[2]*ann[1])

Physics:-`*`(ann[1], ann[2])+Physics:-`*`(ann[2], ann[1])

(11)

Okay, so suppose we try to add additional rules to the algebra:

restart

with(Physics):

with(combinat):

with(LinearAlgebra):

with(ArrayTools):

with(ListTools):

Setup(mathematicalnotation=true):

Setup(quantumop={cre,ann}, algebrarules={%AntiCommutator(cre[j],ann[k])=I*KroneckerDelta[j,k],%AntiCommutator(cre[j],cre[k])=0, %AntiCommutator(ann[j],ann[k])=0})

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

 

[algebrarules = {%AntiCommutator(ann[j], ann[k]) = 0, %AntiCommutator(cre[j], ann[k]) = I*Physics:-KroneckerDelta[j, k], %AntiCommutator(cre[j], cre[k]) = 0}, quantumoperators = {ann, cre}]

(12)

   But this has all of the problems of above - my original post used this "expanded" set of rules that Maple seems to be ignoring.

 

Adding additional rules to the algebra:

restart

with(Physics):

with(combinat):

with(LinearAlgebra):

with(ArrayTools):

with(ListTools):

Setup(mathematicalnotation=true):

Setup(quantumop={cre,ann}, algebrarules={%AntiCommutator(cre[j],ann[k])=I*KroneckerDelta[j,k],%AntiCommutator(cre[j],cre[k])=0, %AntiCommutator(ann[j],ann[k])=0, %ann[i]*%ann[i]=0})

Error, invalid input: Physics:-Setup expects value for keyword parameter algebrarules to be of type {Matrix, truefalse, list(Or(specfunc([Physics:-Commutator, %Commutator]), specfunc([Physics:-AntiCommutator, %AntiCommutator])) = algebraic), set(Or(specfunc([Physics:-Commutator, %Commutator]), specfunc([Physics:-AntiCommutator, %AntiCommutator])) = algebraic), identical(none, NULL, "not given"), Or(specfunc([Physics:-Commutator, %Commutator]), specfunc([Physics:-AntiCommutator, %AntiCommutator])) = algebraic}, but received {%ann[i]^2 = 0, %AntiCommutator(ann[j], ann[k]) = 0, %AntiCommutator(cre[j], ann[k]) = I*Physics:-KroneckerDelta[j, k], %AntiCommutator(cre[j], cre[k]) = 0}

 

And this gives an error saying I can't multiply the operator by itself in the algebra. Tried with and without the % on the ann[i], as well as using Mutliply, *, ., and ^2.

 

 

 

 

 

 

 


 

Download LatticeCalcsAlgebraIssues.mw

1 2 Page 1 of 2