11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

34 • Chapter 2: Procedures, Variables, and Extending Maple> Real, unReal := selectremove(isReal, x);> Real * ’‘&^‘’(x, unReal);> else> ’‘&^‘’(x, y);> end if;> else> Real * ‘&^‘(unReal, y);> end if;>> elif type(y, ‘*‘) then> # Similar to the x-case but easier since> # x cannot be a product here.> Real, unReal := selectremove(isReal, y);> if Real=1 then> ’‘&^‘’(x, y);> else> Real * ‘&^‘(x, unReal);> end if;>> else> ’‘&^‘’(x,y);> end if;> end proc:You can place all the special multiplication rules for the symbols I,J, and K in the remember table of ‘&^‘.Information: For more information on remember tables, see Chapter6 of the Introductory <strong>Programming</strong> <strong>Guide</strong>.> ‘&^‘(I,I) := -1: ‘&^‘(J,J) := -1: ‘&^‘(K,K) := -1:> ‘&^‘(I,J) := K: ‘&^‘(J,I) := -K:> ‘&^‘(I,K) := -J: ‘&^‘(K,I) := J:> ‘&^‘(J,K) := I: ‘&^‘(K,J) := -I:Since ‘&^‘ is a neutral operator, you can write products of Hamiltoniansusing &^ as the multiplication symbol.> (1 + 2*I + 3*J + 4*K) &^ (5 + 3*I - 7*J);20 + 41 I + 20 J − 3 K> (5 + 3*I - 7*J) &^ (1 + 2*I + 3*J + 4*K);20 − 15 I − 4 J + 43 K> 56 &^ I;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!