MaplePrimes Posts

MaplePrimes Posts are for sharing your experiences, techniques and opinions about Maple, MapleSim and related products, as well as general interests in math and computing.

Latest Post
  • Latest Posts Feed
  • Due to the mechanistic process of our students and little creativity in analysis in schools and universities to be professionally trained is that STEM education appears (science, technology, engineering and mathematics) is a new model that is being considered in other countries and with very slow step in our city. In this work the methods with STEM will be visualized but using computational tools provided by Maplesoft which is a company that leads online education for adolescents and adults in the current market. In Spanish.

    ECI_UNT_2018.pdf

    ECI_UNT_2018.mw

    Lenin Araujo Castillo

    Ambassador of Maple

    There is a bug in inttrans:-hilbert:

    restart;

    inttrans:-hilbert(sin(a)*sin(t+b), t, s);
    # should be:
    sin(a)*cos(s+b);   expand(%);

    sin(a)*cos(s)

     

    sin(a)*cos(s+b)

     

    sin(a)*cos(s)*cos(b)-sin(a)*sin(s)*sin(b)

    (1)

    ########## correction ##############

    `inttrans/expandc` := proc(expr, t)
    local xpr, j, econst, op1, op2;
          xpr := expr;      
          for j in indets(xpr,specfunc(`+`,exp)) do
              econst := select(type,op(j),('freeof')(t));
              if 0 < nops(econst) and econst <> 0 then
                  xpr := subs(j = ('exp')(econst)*combine(j/('exp')(econst),exp),xpr)
              end if
          end do;
          for j in indets(xpr,{('cos')(linear(t)), ('sin')(linear(t))}) do
              if type(op(j),`+`) then
                  op1:=select(has, op(j),t); ##
                  op2:=op(j)-op1;            ##
                  #op1 := op(1,op(j));
                  #op2 := op(2,op(j));
                  if op(0,j) = sin then
                      xpr := subs(j = cos(op2)*sin(op1)+sin(op2)*cos(op1),xpr)
                  else
                      xpr := subs(j = cos(op1)*cos(op2)-sin(op1)*sin(op2),xpr)
                  end if
              end if
          end do;
          return xpr
    end proc:

    #######################################

    inttrans:-hilbert(sin(a)*sin(t+b), t, s); expand(%);

    -(1/2)*cos(a-b)*sin(s)+(1/2)*sin(a-b)*cos(s)+(1/2)*cos(a+b)*sin(s)+(1/2)*sin(a+b)*cos(s)

     

    sin(a)*cos(s)*cos(b)-sin(a)*sin(s)*sin(b)

    (2)

     


    Download hilbert.mw

     

    To demonstrate Maple 2018’s new Python connectivity, we wanted to integrate a large Python library. The result is the DeepLearning package - this offers an interface to a subset of the Tensorflow framework for machine learning.

    I thought I’d share an application that demonstrates how the DeepLearning package can be used to recognize the numbers in images of handwritten digits.

    The application employs a very small subset of the MNIST database of handwritten digits. Here’s a sample image for the digit 0.

    This image can be represented as a matrix of pixel intensities.        

    The application generates weights for each digit by training a two-layer neural network using multinomial logistic regression. When visualized, the weights for each digit might look like this.

    Let’s say that we’re comparing an image of a handwritten digit to the weights for the digit 0. If a pixel with a high intensity lands in

    • an intensely red area, the evidence is high that the number in the image is 0
    • an intensely blue area, the evidence is low that the number in the image is 0

    While this explanation is technically simplistic, the application offers more detail.

    Get the application here

    Using Maple's native syntax, we can calculate the components of acceleration. That is, the tangent and normal scalar component with its respective units of measure. Now the difficult calculations were in the past because with Maple we solved it and we concentrated on the interpretation of the results for engineering. In spanish.

    Calculo_Componentes_Aceleracion_Curvilínea.mw

    Uso_de_comandos_y_operadores_para_calculos_de_componentes_de_la_aceleración.mw

    Lenin Araujo Castillo

    Ambassador of Maple

     

     

    The Maple splash screen needs a makeover, it's not too exciting so looking at the maplesoft website the opening screen has an image that would have been rather fitting for the Maple 2018 splash screen.  Here's the image I'm talking about.

    Last week, my colleague Erik Postma and I had the pleasure of spending a few hours with a group of bright and motivated high school students at the Math for Real: High School Math Solves Real Problems workshop held at the Fields Institute for Research in Mathematical Sciences in Toronto, and sponsored by the Fields Institute and NSERC PromoScience. The purpose of this three-day workshop was to train students for the International Mathematical Modeling Challenge, also known as IM2C.

    The IM2C is hosted by York University and run by the IM2C-Canada committee, consisting of parents and high school teachers, as well as faculty and students in York’s Department of Mathematics and Statistics. In this competition, students working in small teams have five days to solve a mathematical modelling problem in diverse application areas. To support the “Real World” aspect of the contest, students are expected not just to showcase their mathematical creativity and problem-solving skills, but they are also asked to clearly communicate their analyses and conclusions through a written report and visualizations.

    The contest allows students to use appropriate software tools to help them with their tasks. Of course I am biased but I can’t help thinking that Maple is the perfect tool for students wanting to do a combination of prototyping, modelling, visualization and document-preparation. The IM2C organizers also thought that the students could benefit from our software, so Erik gave an hour-long introduction to Maple. I was impressed by the students’ enthusiastic remarks and sometimes challenging questions, though admittedly they were partly motivated by the chance to receive as prizes our highly coveted limited-quantity “Math Matters” t-shirts.

    The workshop also introduced the students to other software products, taught modelling and writing skills, and had them work on fun practice problems. Over the lunch break, I was struck by the sense of camaraderie at this event, which probably should not have surprised me, as unlike many other competitions involving mathematics, this one is a true team-based activity. Both Erik and I are eager to see what the students will be doing with Maple. Responding to the students’ enthusiasm and interest, Maplesoft has agreed to offer complimentary Maple licenses to all students participating in IM2C. 

    As a Corporate Affiliate of the Fields Institute, Maplesoft is pleased to provide training and support to students and researchers that come to Fields for its many events. Developers like myself are encouraged to participate in the institute’s events when possible, and I’ve had the opportunity to attend a number of workshops in the past few years. I encourage you to look at their wide range of activities and to consider visiting the culturally diverse city of Toronto!


    Minimum:
    1. Maple Tour
    2. Maple Quick Start
    3. Quick Help
    4. Quick Reference Card
    5. Math Apps
    6. Plotting Guide
    ...
    https://drive.google.com/file/d/1ZAlFQ8_MbuKNsr2PDIyEHmIoogKInBmE/view?usp=sharing

    Is that only for my students?

    In worksheets:
    https://drive.google.com/file/d/1cfA8WKPXSQQxJQR7KbyYHBY6g4OjHaSn/view?usp=sharing

    The first update to the Maple 2018 Physics, Differential Equations and Mathematical Functions packages is available. As has been the case since 2013, this update contains fixes, enhancements to existing functionality, and new developments in the three areas. 

    The webpage for these updates will continue being the Maplesoft R&D Physics webpage. Starting with Maple 2018, however, this update is also available from the MapleCloud.

    To install the update: open Maple and click the Cloud icon (upper-right corner), select "Packages" and search for "Physics Updates". Then, in the corresponding "Actions" column, click the third icon (install pop-up).

    NOTE May/1: the "Updates" icon of the MapleCloud toolbar (that opens when you click the upper-right icon within a Maple document / worksheet), now works fine, after having installed the Physics Updates version 32 or higher.

    These first updates include:

    • New Physics functionality regarding Tensor Products of Quantum States; and Coherent States.
    • Updates to pdsolve regarding PDE & Boundary Conditions (exact solutions);
    • A change in notation: d_(x), the differential of a coordinate in the Physics package, is now displayed as shown in this Mapleprimes post.


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

    This is about the recent implementation of tensor products of quantum state spaces in the Physics package, in connection with an exchange with the Physics of Information Lab of the University of Waterloo. As usual this development is available to everybody from the Maplesoft R&D Physics webpage. This is the last update for Maple 2017. The updates for Maple 2018, starting with this same material, will begin being distributed through the MapleCloud next week.

    Tensor Product of Quantum State Spaces

     

    Basic ideas and design

     

     

    Suppose A and B are quantum operators and Ket(A, n), et(B, m) are, respectively, their eigenkets. The following works since the introduction of the Physics package in Maple

    with(Physics)

    Setup(op = {A, B})

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

     

    [quantumoperators = {A, B}]

    (1)

    A*Ket(A, alpha) = A.Ket(A, alpha)

    Physics:-`*`(A, Physics:-Ket(A, alpha)) = alpha*Physics:-Ket(A, alpha)

    (2)

    B*Ket(B, beta) = B.Ket(B, beta)

    Physics:-`*`(B, Physics:-Ket(B, beta)) = beta*Physics:-Ket(B, beta)

    (3)

    where on the left-hand sides the product operator `*` is used as a sort of inert form (it has all the correct mathematical properties but does not perform the contraction) of the dot product operator `.`, used on the right-hand sides.

     

    Suppose now that A and B act on different, disjointed, Hilbert spaces.

     

    1) To represent that, a new keyword in Setup , is introduced, to indicate which spaces are disjointed, say as in disjointedhilbertspaces = {A, B}.  We want this notation to pop up at some point as {`&Hscr;`[A], `&Hscr;`[B]} where the indexation indicates all the operators acting on that Hilbert space. The disjointedspaces keyword has for synonyms disjointedhilbertspaces and hilbertspaces. The display `&Hscr;`[A] is not yet implemented.

     

    NOTE: noncommutative quantum operators acting on disjointed spaces commute between themselves, so after setting  - for instance - disjointedspaces = {A, B}, automatically, A, B become quantum operators satisfying (see comment (ii) on page 156 of ref. [1])

     

    "[A,B][-]=0"

     

    2) Product of Kets and Bras (KK, BB, KB and BK) where K and B belong to disjointed spaces, are understood as tensor products satisfying, for instance with disjointed spaces A and B (see footnote on page 154 of ref. [1]),

     

    `&otimes;`(Ket(A, alpha), Ket(B, beta)) = `&otimes;`(Ket(B, beta), Ket(A, alpha)) 

     

    `&otimes;`(Bra(A, alpha), Ket(B, beta)) = `&otimes;`(Ket(B, beta), Bra(A, alpha)) 

     

    while of course

    Bra(A, alpha)*Ket(A, alpha) <> Bra(A, alpha)*Ket(A, alpha)

     

    Details

       

     

    3) All the operators of one disjointed space act transparently over operators, Bras and Kets of the other disjointed spaces, for example

     

    A*Ket(B, n) = A*Ket(B, n)

    and the same for the Dagger of this equation, that is

    Bra(B, n)*Dagger(A) = Bra(B, n)*Dagger(A)

     

    And this happens automatically. Hence, when we write the left-hand sides and press enter, they are automatically rewritten (returned) as the right-hand sides.

     

    Note that for the product of an operator times a Bra or a Ket we are not using the notation that expresses the product with the symbol 5.

     

    Regarding the display of Bras and Kets and their tensor products, two enhancements are happening:

     

    • 

    A new Setup option hideketlabel makes all the labels in Kets and Bras to be hidden when displaying Kets, Bras and Bracket(s), with the indices presented one level up, as if they were a sequence of labels, so that:

     "Ket(A,m,n,l"  

    is displayed as

    Ket(A, m, n, l)

     

      

    This is the notation used more frequently when working in quantum information. This hideketlabel option is already implemented entering Setup(hideketlabel = true)

    • 

    Tensor products formed with operators, or Bras and Kets, that belong to disjointed spaces (set as such using Setup ), are displayed with the symbol 5 in between, as in Ket(A, n)*Ket(B, n) instead of Ket(A, n)*Ket(B, n), and `&otimes;`(A, B) instead of A*B.

    Tensor product notation and the hideketlabel option

       

    The implementation of tensor products using `*` and `.`

       

    Basic exercising with the new functionality

       

    Related functionality already in place before these changes

       

    Reference

     

    [1] Cohen-Tannoudji, Diue, Laloe, Quantum Mechanics, Chapter 2, section F.

    [2] Griffiths Robert B., Hilbert Space Quantum Mechanics, Quantum Computation and Quantum Information Theory Course, Physics Department, Carnegie Mellon University, 2014.

    See also

       

     


     

    Download TensorProductDesign.mw
     

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

    Carmichael's lambda(n) function (as it relates to Euler's Totient Function).....this is just one of 8 stages of animation. 

     

    Here's the complete animation with supporting music by the mighty Stormtroopers Of Death....

    https://youtu.be/QN-s3EpZICs

     

     

     

     

    Today we are pleased to announce the release of Maple 2018.

    For many people, today is just another day in March. It’s not like the release of a new version of a software product is a world-shaking event. But for us here at Maplesoft, these first few days after the latest version of Maple is released are always a bit more special. There’s always a nervous energy whenever we release Maple and everyone else gets to see what we’ve been pouring our efforts into for the past year.

    I’m not going to start this post by calling the latest version of Maple “game-changing” or “cutting edge” or any other marketing friendly platitude. I’m well aware that the latest version of Maple isn’t going to change the world.

    What I would say though is that with every new release of software comes an opportunity. Every new software release is an opportunity to re-evaluate how that software has evolved to better suit your needs and requirements. So… if you've been sitting on the sidelines and watching version after version go by, assuming that it won't affect you, that's wrong! There's a lot that you could be missing out on.

    The way that these release announcements usually work is that we try to amaze and astound you with a long list of features. Don’t worry, I’ll get into that in a bit. But first I wanted to walk through a simple exercise of release arithmetic.

    I’ll start with one of those basic truths that has always been hiding in plain sight. The build number # for Maple 2018 is 1298750. Here at Maplesoft, every time our developers make a change to Maple this build number goes up by 1. These changes are sometimes small and sometimes very big; they can be as small as fixing a documentation typo or they can constitute implementing a major feature spread across numerous files in our source tree.

    I have come to look at these build numbers in a slightly different way. I look at build numbers as representing all of the small to large sized steps our developers take to get you from one version to the next (or put another way, how many steps behind you are if you are using the older versions). With that in mind, let’s do some quick math:

    If you are using Maple 2017 (2017.0 was build # 1231047), there have been 1298750 – 1231047 = 67703 steps since that release (these numerous "steps" are what built the "long list" of features below). If you’re using Maple 2016 (#1113130) this number grows to 185620. And so it goes… Maple 2015 (#1022128) = 276622 steps, Maple 18 (#922027) = 376723, Maple 17 (#813473) = 485277, you get the idea. If you’re using a really old version of Maple – there’s a good chance that we have fixed up a bunch of stuff or added something that you might find interesting in the time since your last upgrade!

     

    Every new release of Maple adds functionality that pushes Maple into new domains, rounds out existing packages, fills gaps, and addresses common user requests. Let's explore some additions:

     

    Clickable Math - a.k.a. math that looks like math and can be interacted with using your mouse - has evolved. What was once a collection of operations found in the right-click or main menu items or in interactive smart-popups or in many additional dialogs, has been brought together and enhanced to form the new Context Panel.

    We can summarize the Context Panel as follows: Enter an expression and relevant operations that you can apply to that expression appear in a panel on the right side of your screen. Easy, right? It's a great change that unlocks a large part of the Maple library for you.

    The addition of the Context Panel is important. It represents a shift in the interaction model for Maple – you’ll see more and more interaction being driven through the context panel in future releases. Already, the changes for the Context Panel permeate through to various other parts of Maple too. You’ll see an example in the Units section below and here’s another for coding applications.

    The Context Panel also gives you access to embedded component properties – this makes it much easier to modify parts of your application.

    There’s much more we can say about the Context Panel but in the interest of keeping this post (somewhat) concise I’ll stop there. If you are interested and want to see more examples, watch this video.

     

    Coding in Maple - For many of us, using the Maple coding language is fundamental; it's just what we do. Whether you write a lot of procedures, or modify the start-up code for your worksheet, or put a sequence of commands in a code edit region, or include a button or slider in your application, you’ll find yourself using Maple’s code editing tools.

    For Code Edit Regions and the Maple Code Editor, there’s automatic command completion for packages, commands, and even file paths.

    maplemint has been integrated into the Code Editor, providing code analysis while you write your code.

    mint and maplemint have been unified and upgraded. If you’ve never heard of these before, these are tools for analysing your Maple code. They provide information on procedures, giving parameter naming conflicts, unreachable code, unused parameters or variables, and more. Mint is available for use with external text files and maplemint runs directly inside of Maple.

    For more, I’ve got another video.

     

    For many engineers and scientists, units are intrinsically linked with calculations. Here's something else in Maple 2018 that will improve your everyday experience – units are now supported in many core routines such as in numeric equation solving, integration, and optimization.

    Here’s a quick example of using units in the int command with some thermophysical data:

    We define an expression that gives the pressure of methane as a function of the specific volume V.

    P := ThermophysicalData:-Property("pressure", "methane", "temperature" = 350*Unit('K'), "density" = 1/V):
    -(int(P, V = 1.0*Unit('m'^3/'kg') .. .5*Unit('m'^3/'kg'), numeric));

    You'll also find unit formatting in the Context Panel.

    Near and dear to my heart, data analysts also have some occasion to rejoice. Maple 2018 finally adds an Interpolate command that supports irregular data! This is one of those items that users have been requesting for a long time and I'm very happy to say that it's finally here.

    Furthering the data story, there are new sources for thermochemical data as well as updates to ensure that existing datasets for thermophysical data and scientific constants are up to date.

     

    If you're interested in protecting your content in Maple, listen up:

    You can now encrypt procedures; anyone can use your code, but they can't see the source!

    You can also lock your Maple documents - effectively protecting them from accidental changes or other unintended modifications.

     

     

    Of course, I won't leave mathematics out of this. As always, there’s a ton of new and updated stuff here.

    There's a new computational geometry package. There are improvements across all fields of mathematics including group theory, graph theory, integration, differential equations and partial differential equations. And there's a ton of new work in Physics (many of you who have been following the Physics project will already know about these).

    You can recreate some of the visualizations above as follows:

    Here’s an example of the new VoronoiDiagram Command:

    m := LinearAlgebra:-RandomMatrix(40, 2):
    ComputationalGeometry:-VoronoiDiagram(m, showpoints, symbol = solidcircle, symbolsize = 7,colorregions=ColorTools:-GetPalette("Dalton"));

    Here’s another change that I’ve seen mentioned several times on MaplePrimes – the ability to control the  border of arrows:

    plots:-display(plottools:-arrow([0, 0], [2, 2], 0.5e-1, .2, .1, border = false, color = "DarkGrey", legend = "A+B"),
                           plottools:-arrow([0, 0], [1, 2], .15, .3, .15, border = false, color = "Crimson", legend = "A"),
                           plottools:-arrow([1, 2], [2, 2], .15, .3, .15, border = false, color = "CornflowerBlue", legend = "B"),
                       size = [600, 400]);

    You can rotate Tickmarks in plots using the rotation option. Some plots, such as those in the TimeSeriesAnalysis package, use rotation by default.

    ts := TimeSeriesAnalysis:-TimeSeries([7, 23, 21, 19, 13, 46, 42, 30, 31, 26, 19, 9, 16, 26, 17, 33, 31, 46, 42, 35, 45, 30, 11, 17, 23, 20, 15, 36, 31, 55, 49, 39, 36, 28, 12, 11, 21, 23, 27, 33, 36, 49, 42, 37, 33, 45, 12, 7, 23, 32, 25, 42, 27, 52, 50, 34, 41, 40, 16, 14], frequency = monthly, startdate = "2005-09");
    TimeSeriesAnalysis:-SeasonalSubseriesPlot(ts, startingperiod = 9, seasonnames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], space = .25, size = [800, 400]);

     

    I’ll also mention some updates to the Maple language – items that the readers of this forum will likely find useful.

    Dates and Times – Maple 2018 adds new data structures that represent dates and times. There are numerous functions that work with dates and times, including fundamental operations such as date arithmetic and more advanced functionality for working with Calendars.

    today := Date();

    Year( today ), DayOfMonth( today ), Month( today );

    Date arithmetic:

    One_year_ago := today - 365*Unit(d);

     

    Until - An optional until clause has been added to Maple's loop control structure.

    Here's an example, the following code finds the next prime number after 37 and then terminates the loop.

    n := 37;

    do n := n+1 until

        isprime(n):

    n;

    As always with these posts, we can't cover everything. This post is really just the beginning of the story. I would love to spend another couple of pages describing the inner-workings of every single improvement to Maple 2018 for you; however I'd rather you just try these features yourself, so go ahead, get out there and try out Maple 2018 today. You won't be disappointed that you did.

    Hello,

     

    It has come to my attention that Alan Baker has recently passed away, and not being of an institutional affliation it was some what late in me finding out.

    But his work was of huge inspiration to me, so I felt as if it should be noted how brilliant this man was, and how much he ought to be missed be the mathematical community at large.

    https://en.wikipedia.org/wiki/Alan_Baker_(mathematician)

    I've created a worksheet that outputs a boggle board.  I think it could be more efficient than the method I came up with but the idea is there.  The only way I could figure to rotate the letters was to output them to a bmp format then read them back in and use imagetools for rotation.  I used Times Roman font but the font Boggle uses I think is Tunga, Latha or Mangal.  

    Note - remove the colon in the last line to produce the output.  One other thing I believe, in Tools->Options-> (uncheck)Limit Expression Length to 1000000  

    Saving the file with the output would have produced a file in the tens of Megabytes and may have caused error loading.


     

    restart; gc()

    with(plots); with(ImageTools)

    a := [seq(k, k = "A" .. "Z")]

    ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]

    (1)

    for i in a do plotsetup(bmp, plotoutput = cat("c:/test/", i, ".bmp")); img || i := textplot([0, 1, i, font = ["times", "roman", 200]], axes = none, scaling = constrained) end do
    NULL

    plotsetup = default

    (2)

    plotsetup(default)

    with(combinat)``

    ``

    Setting up the 16 boggle cubes

     

    cube1 := ["H", "E", "E", "N", "W", "G"]

    cube2 := ["T", "M", "I", "O", "C", "U"]

    cube3 := ["D", "E", "X", "L", "R", "I"]

    cube4 := ["S", "P", "F", "A", "K", "F"]

    cube5 := ["T", "O", "E", "S", "I", "S"]

    cube6 := ["H", "N", "L", "N", "Z", "R"]

    cube7 := ["R", "L", "T", "Y", "T", "E"]

    cube8 := ["D", "E", "Y", "L", "R", "V"]

    cube9 := ["C", "A", "O", "S", "P", "H"]

    cube10 := ["Qu", "U", "M", "H", "I", "N"]

    cube11 := ["D", "Y", "I", "S", "T", "T"]

    cube12 := ["S", "N", "I", "E", "E", "U"]

    cube13 := ["T", "O", "O", "W", "A", "T"]

    cube14 := ["W", "H", "E", "V", "R", "T"]

    cube15 := ["J", "B", "O", "O", "A", "B"]

    cube16 := ["N", "A", "E", "A", "E", "G"]

    cubes := [seq(cat("cube", i), i = 1 .. 16)]

    ["cube1", "cube2", "cube3", "cube4", "cube5", "cube6", "cube7", "cube8", "cube9", "cube10", "cube11", "cube12", "cube13", "cube14", "cube15", "cube16"]

    (3)

    c := randperm(cubes)

    ["cube13", "cube14", "cube11", "cube6", "cube9", "cube1", "cube16", "cube7", "cube3", "cube2", "cube12", "cube5", "cube4", "cube10", "cube8", "cube15"]

    (4)

    cc := map(parse, c)

    [cube13, cube14, cube11, cube6, cube9, cube1, cube16, cube7, cube3, cube2, cube12, cube5, cube4, cube10, cube8, cube15]

    (5)

    ccf := [seq(op(randcomb(cc[i], 1)), i = 1 .. 16)]

    ["A", "H", "I", "N", "A", "N", "E", "T", "D", "M", "E", "S", "K", "N", "E", "O"]

    (6)

    with(ArrayTools)

    g := Reshape(Array(ccf), [4, 4])

    Array(%id = 18446744074360417206)

    (7)

    rr := proc () randcomb([0, 90, 180, 270], 1) end proc

    Reshape(Array([seq(display(Preview(Rotate(Read(cat("c:/test/", ccf[i], ".bmp")), op(rr()))), axes = none), i = 1 .. 16)]), [4, 4])
     

    ````

     

     

     

    NULL


     

    Download Boggle3-6final.mw

    This is an application of the previous posts
    https://www.mapleprimes.com/posts/209057-Procedure-For-Expanding-Tensor-Product

    I have a fourth version of the ExpandQop that will expand automaticaly the power of
    quantum tensor product. This is just a minor change to the procedure.

    Now here is an application for all this that will help understanding a little about
    quantum computing. This is the classical concept of quantum teleportation.

    You will need to run the above mentionned file and uncomment the save line in the file
    before running the example.

    LL
     

    ######################################################################
    # NOTICE                                                             #
    # Author: Louis Lamarche                                             #
    #         Institute of Research of Hydro-Quebec (IREQ)               #
    #         Science des données et haute performance                   #
    #         2018, March 7                                              #
    #                                                                    #
    # Function name: ExpandQop (x)                                       #
    #       Purpose: Compute the tensor product of two quantum           #
    #                operators in Dirac notations                        #
    #      Argument: x: a quantum operator                               #
    #  Improvements: Manage all +, -, *, /, ^, mod  operations           #
    #                in the argument. Manages multiple tensor products   #
    #                like A*B*C*F                                        #
    #       Version: 3                                                   #
    #                                                                    #
    #  Copyrigth(c) Hydro-Quebec.                                        #
    #        Note 1: Permission to use this softwate is granted if you   #
    #                acknowledge its author and copyright                #
    #        Note 2: Permission to copy this softwate is granted if you  #
    #                leave this 21 lines notice intact. Thank you.       #
    ######################################################################
    restart;

    with(Physics):
    interface(imaginaryunit=i):
    Setup(mathematicalnotation=true);

    [mathematicalnotation = true]

    (1)

    Setup(unitaryoperators={I,U,X,Y,Z,H,HI,CNOT,CnotI});
    Setup(noncommutativeprefix={q,beta,psi});

    [unitaryoperators = {CNOT, CnotI, H, HI, I, U, X, Y, Z}]

     

    [noncommutativeprefix = {beta, psi, q}]

    (2)

    Setup(bracketrules= { %Bracket(%Bra(q0), %Ket(q0))=1,
                          %Bracket(%Bra(q1), %Ket(q1))=1,
                          %Bracket(%Bra(q1), %Ket(q0))=0,
                          %Bracket(%Bra(q0), %Ket(q1))=0
                        });

    [bracketrules = {%Bracket(%Bra(q0), %Ket(q0)) = 1, %Bracket(%Bra(q0), %Ket(q1)) = 0, %Bracket(%Bra(q1), %Ket(q0)) = 0, %Bracket(%Bra(q1), %Ket(q1)) = 1}]

    (3)

    ####################################################################################
    # Load the procedure and set the required global variables
    #
    read "ExpandQop.m": optp:=op(0,Ket(q0)*Ket(q1)): optpx:= op(0,(Ket(q0)+Ket(q1))^2):
    #
    ####################################################################################

    #
    # Pauli operators
    #
    print("Pauli gates");
    I:=Ket(q0)*Bra(q0)+Ket(q1)*Bra(q1);        # = sigma[0]
    X:=Ket(q1)*Bra(q0)+Ket(q0)*Bra(q1);        # = sigma[1] = sigma[x]
    Y:=-i*Ket(q1)*Bra(q0)+i*Ket(q0)*Bra(q1);   # = sigma[2] = sigma[y]
    Z:=Ket(q0)*Bra(q0)-Ket(q1)*Bra(q1);        # = sigma[3] = sigma[z]

    "Pauli gates"

     

    Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q0))+Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q1))

     

    Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q0))+Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q1))

     

    -I*Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q0))+I*Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q1))

     

    Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q0))-Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q1))

    (4)

    ##############################
    # Defining the Hadamard gate #
    ##############################
    print("Hadamard gate");
    H:= Ket(q0)*Bra(q0)/sqrt(2)+Ket(q0)*Bra(q1)/sqrt(2)+Ket(q1)*Bra(q0)/sqrt(2)-Ket(q1)*Bra(q1)/sqrt(2);

    "Hadamard gate"

     

    (1/2)*2^(1/2)*Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q0))+(1/2)*2^(1/2)*Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q1))+(1/2)*2^(1/2)*Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q0))-(1/2)*2^(1/2)*Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q1))

    (5)

    # This is usefull to represent a 2 qubits system
    # A more general approach is needed for a n qubit system.
    DefineStates:=proc()
        Ket(q00):=Ket(q0)*Ket(q0);  Ket(q01):=Ket(q0)*Ket(q1);
        Ket(q10):=Ket(q1)*Ket(q0);  Ket(q11):=Ket(q1)*Ket(q1);
        Bra(q00):=Dagger(Ket(q00)); Bra(q01):=Dagger(Ket(q01));
        Bra(q10):=Dagger(Ket(q10)); Bra(q11):=Dagger(Ket(q11));
        return;
        end proc:
    UndefineStates:=proc()
        Ket(q00):='Ket(q00)'; Ket(q01):='Ket(q01)';
        Ket(q10):='Ket(q10)'; Ket(q11):='Ket(q11)';
        Bra(q00):='Bra(q00)'; Bra(q01):='Bra(q01)';
        Bra(q10):='Bra(q10)'; Bra(q11):='Bra(q11)';
        return;
        end proc:

    ####################################
    # Defining the CNOT gate (2 qubits)
    ####################################
    print("CNOT gate");
    CNOT:=Ket(q00)*Bra(q00)+ Ket(q01)*Bra(q01)+ Ket(q11)*Bra(q10)+Ket(q10)*Bra(q11);
    DefineStates();
    'CNOT'=CNOT;

    "CNOT gate"

     

    Physics:-`*`(Physics:-Ket(q00), Physics:-Bra(q00))+Physics:-`*`(Physics:-Ket(q01), Physics:-Bra(q01))+Physics:-`*`(Physics:-Ket(q11), Physics:-Bra(q10))+Physics:-`*`(Physics:-Ket(q10), Physics:-Bra(q11))

     

    CNOT = Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0), Physics:-Bra(q0), Physics:-Bra(q0))+Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Bra(q1), Physics:-Bra(q0))+Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q1), Physics:-Bra(q0), Physics:-Bra(q1))+Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q0), Physics:-Bra(q1), Physics:-Bra(q1))

    (6)

    ###########################
    # Defining the Bell states
    ###########################
    Ket(beta,x,y)='CNOT.(((H.Ket(x)))*Ket(y))';
    Ket(beta00):=CNOT.(Expand((H.Ket(q0)))*Ket(q0));
    Ket(beta01):=CNOT.(Expand((H.Ket(q0)))*Ket(q1));
    Ket(beta10):=CNOT.(Expand((H.Ket(q1)))*Ket(q0));
    Ket(beta11):=CNOT.(Expand((H.Ket(q1)))*Ket(q1));

    Physics:-Ket(beta, x, y) = Physics:-`.`(CNOT, Physics:-`*`(Physics:-`.`(H, Physics:-Ket(x)), Physics:-Ket(y)))

     

    (1/2)*2^(1/2)*(Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0))+Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q1)))

     

    (1/2)*2^(1/2)*(Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q1))+Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q0)))

     

    -(1/2)*2^(1/2)*(-Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0))+Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q1)))

     

    (1/2)*2^(1/2)*(Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q1))-Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q0)))

    (7)

    ##########################################################
    # Quantum teleportation
    # Reference: Quantum Computation and Quantum Information
    #            10th Anniversary Edition
    #            Michael A. Nielsen & Isaac L. Chuang
    #            Cambridge University Press, Cambridge 2010
    #            pp 25-28
    ##########################################################
    print("State to be teleported");
    Ket(psi) := a*Ket(q0)+b*Ket(q1);
    print("Step 1: Compute the tensor product of the state to be teleported with ", 'Ket(beta00)');
    Ket(psi[0])='Ket(psi)'*'Ket(beta00)';
    Ket(psi[0]):=Expand(Ket(psi)*Ket(beta00));
    print("This is a 3 qubits state");
    #######
    print("Step 2: Pass these 3 qubits through a  CNOT*I  operator");
    'CnotI'='CNOT*I';
    CnotI:=ExpandQop(Expand(CNOT*I)):
    #
    # To see what the CNOTI operator looks like
    #
    # print("CNOTI=");
    # print(op(1,CNOTI)+op(2,CNOTI)+op(3,CNOTI)+op(4,CNOTI));
    # print(op(5,CNOTI)+op(6,CNOTI)+op(7,CNOTI)+op(8,CNOTI));
    'Ket(psi[1])'='CnotI.Ket(psi[0])';
    Ket(psi[1]):=Expand(CnotI.Ket(psi[0]));
    #######
    print("Step 3: Pass these 3 qubits through an Haldamard*I  operator");
    'HalI'='H*I';
    HalI:=ExpandQop(Expand(H*I)):
    #
    # To see what the Haldamard*I operator looks like
    #
    # print("HalI=");
    # print(op(1,HalI)+op(2,HalI)+op(3,HalI)+op(4,HalI));
    # print(op(5,HalI)+op(6,HalI)+op(7,HalI)+op(8,HalI));
    'Ket(psi[2])'='HalI.Ket(psi[1])';
    Ket(psi[2]):=Expand(HalI.Ket(psi[1]));
     

    "State to be teleported"

     

    a*Physics:-Ket(q0)+b*Physics:-Ket(q1)

     

    "Step 1: Compute the tensor product of the state to be teleported with ", Physics:-Ket(beta00)

     

    Physics:-Ket(psi[0]) = Physics:-`*`(Physics:-Ket(psi), Physics:-Ket(beta00))

     

    (1/2)*2^(1/2)*a*Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0), Physics:-Ket(q0))+(1/2)*2^(1/2)*a*Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Ket(q1))+(1/2)*2^(1/2)*b*Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q0), Physics:-Ket(q0))+(1/2)*2^(1/2)*b*Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q1), Physics:-Ket(q1))

     

    "This is a 3 qubits state"

     

    "Step 2: Pass these 3 qubits through a  CNOT*I  operator"

     

    CnotI = Physics:-`*`(CNOT, I)

     

    Physics:-Ket(psi[1]) = Physics:-`.`(CnotI, Physics:-Ket(psi[0]))

     

    (1/2)*2^(1/2)*a*Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0), Physics:-Ket(q0))+(1/2)*2^(1/2)*a*Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Ket(q1))+(1/2)*2^(1/2)*b*Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q1), Physics:-Ket(q0))+(1/2)*2^(1/2)*b*Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q0), Physics:-Ket(q1))

     

    "Step 3: Pass these 3 qubits through an Haldamard*I  operator"

     

    HalI = Physics:-`*`(H, I)

     

    Physics:-Ket(psi[2]) = Physics:-`.`(HalI, Physics:-Ket(psi[1]))

     

    (1/2)*a*Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0), Physics:-Ket(q0))+(1/2)*a*Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Ket(q1))+(1/2)*b*Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0), Physics:-Ket(q1))+(1/2)*b*Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Ket(q0))+(1/2)*a*Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q0), Physics:-Ket(q0))+(1/2)*a*Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q1), Physics:-Ket(q1))-(1/2)*b*Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q0), Physics:-Ket(q1))-(1/2)*b*Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q1), Physics:-Ket(q0))

    (8)

    UndefineStates();
    print("Using contracted names for the first two qubits");
    Ket(q00)*Bra(q0)*Bra(q0)='I';
    Ket(q01)*Bra(q0)*Bra(q1)='I';
    Ket(q10)*Bra(q1)*Bra(q0)='I';
    Ket(q11)*Bra(q1)*Bra(q1)='I';
    'Ket(psi[2])'=Ket(q00)*Bra(q0)*Bra(q0).Ket(psi[2])+
                  Ket(q01)*Bra(q0)*Bra(q1).Ket(psi[2])+
                  Ket(q10)*Bra(q1)*Bra(q0).Ket(psi[2])+
                  Ket(q11)*Bra(q1)*Bra(q1).Ket(psi[2]);

    "Using contracted names for the first two qubits"

     

    Physics:-`*`(Physics:-Ket(q00), Physics:-Bra(q0), Physics:-Bra(q0)) = I

     

    Physics:-`*`(Physics:-Ket(q01), Physics:-Bra(q0), Physics:-Bra(q1)) = I

     

    Physics:-`*`(Physics:-Ket(q10), Physics:-Bra(q1), Physics:-Bra(q0)) = I

     

    Physics:-`*`(Physics:-Ket(q11), Physics:-Bra(q1), Physics:-Bra(q1)) = I

     

    Physics:-Ket(psi[2]) = (1/2)*a*Physics:-`*`(Physics:-Ket(q00), Physics:-Ket(q0))+(1/2)*b*Physics:-`*`(Physics:-Ket(q00), Physics:-Ket(q1))+(1/2)*a*Physics:-`*`(Physics:-Ket(q01), Physics:-Ket(q0))-(1/2)*b*Physics:-`*`(Physics:-Ket(q01), Physics:-Ket(q1))+(1/2)*a*Physics:-`*`(Physics:-Ket(q10), Physics:-Ket(q1))+(1/2)*b*Physics:-`*`(Physics:-Ket(q10), Physics:-Ket(q0))+(1/2)*a*Physics:-`*`(Physics:-Ket(q11), Physics:-Ket(q1))-(1/2)*b*Physics:-`*`(Physics:-Ket(q11), Physics:-Ket(q0))

    (9)

    print("Rewriting this result by hand");
    'Ket(psi[2])'=(Ket(q00)*(a*Ket(q0)+b*Ket(q1))+
                   Ket(q01)*(a*Ket(q0)-b*Ket(q1))+
                   Ket(q10)*(a*Ket(q1)+b*Ket(q0))+
                   Ket(q11)*(a*Ket(q1)-b*Ket(q0)))/2;

    "Rewriting this result by hand"

     

    Physics:-Ket(psi[2]) = (1/2)*Physics:-`*`(Physics:-Ket(q00), a*Physics:-Ket(q0)+b*Physics:-Ket(q1))+(1/2)*Physics:-`*`(Physics:-Ket(q01), a*Physics:-Ket(q0)-b*Physics:-Ket(q1))+(1/2)*Physics:-`*`(Physics:-Ket(q10), a*Physics:-Ket(q1)+b*Physics:-Ket(q0))+(1/2)*Physics:-`*`(Physics:-Ket(q11), a*Physics:-Ket(q1)-b*Physics:-Ket(q0))

    (10)

    DefineStates();
    print("If Alice measures 00 Bob does noting");
    ''I'.   '2*Bra(q00).Ket(psi[2])'' =  I.   2*Bra(q00).Ket(psi[2]);
    print("If Alice measures 01 Bob applies the X gate");
    ''X'.   '2*Bra(q01).Ket(psi[2])'' =  X.   2*Bra(q01).Ket(psi[2]);
    print("If Alice measures 10 Bob applies the Z gate");
    ''Z'.   '2*Bra(q10).Ket(psi[2])'' =  Z.   2*Bra(q10).Ket(psi[2]);
    print("If Alice measures 11 Bob applies the X gate and then the Z gate");
    ''Z'.'X'. '2*Bra(q11).Ket(psi[2])'' =  Z.X. 2*Bra(q11).Ket(psi[2]);

    "If Alice measures 00 Bob does noting"

     

    Physics:-`.`('I', 'Physics:-`.`(Physics:-`*`(2, Physics:-Bra(q00)), Physics:-Ket(psi[2]))') = a*Physics:-Ket(q0)+b*Physics:-Ket(q1)

     

    "If Alice measures 01 Bob applies the X gate"

     

    Physics:-`.`('X', 'Physics:-`.`(Physics:-`*`(2, Physics:-Bra(q01)), Physics:-Ket(psi[2]))') = a*Physics:-Ket(q0)+b*Physics:-Ket(q1)

     

    "If Alice measures 10 Bob applies the Z gate"

     

    Physics:-`.`('Z', 'Physics:-`.`(Physics:-`*`(2, Physics:-Bra(q10)), Physics:-Ket(psi[2]))') = a*Physics:-Ket(q0)+b*Physics:-Ket(q1)

     

    "If Alice measures 11 Bob applies the X gate and then the Z gate"

     

    Physics:-`.`('Z', 'X', 'Physics:-`.`(Physics:-`*`(2, Physics:-Bra(q11)), Physics:-Ket(psi[2]))') = a*Physics:-Ket(q0)+b*Physics:-Ket(q1)

    (11)

     


     

    Download QuantumTeleportation.mw

     

     

    Version 2 do not enable to expand multiple product like A*A*B*E
    Version 3 will now do that.
    I just forgot to add this feature.

    LL.
     

    ######################################################################
    # NOTICE                                                             #
    # Author: Louis Lamarche                                             #
    #         Institute of Research of Hydro-Quebec (IREQ)               #
    #         Science des données et haute performance                   #
    #         2018, March 7                                              #
    #                                                                    #
    # Function name: ExpandQop (x)                                       #
    #       Purpose: Compute the tensor product of two quantum           #
    #                operators in Dirac notations                        #
    #      Argument: x: a quantum operator                               #
    #  Improvements: Manage all +, -, *, /, ^, mod  operations           #
    #                in the argument. Manages multiple tensor products   #
    #                like A*B*C*F                                        #
    #       Version: 3                                                   #
    #                                                                    #
    #  Copyrigth(c) Hydro-Quebec.                                        #
    #        Note 1: Permission to use this softwate is granted if you   #
    #                acknowledge its author and copyright                #
    #        Note 2: Permission to copy this softwate is granted if you  #
    #                leave this 21 lines notice intact. Thank you.       #
    ######################################################################
    restart;

    with(Physics):
    interface(imaginaryunit=i):
    Setup(mathematicalnotation=true);

    [mathematicalnotation = true]

    (1)

    Setup(quantumoperators={A,B,C,Cn});
    Setup(noncommutativeprefix={a,b,q});

    [quantumoperators = {A, B, C, Cn}]

     

    [noncommutativeprefix = {a, b, q}]

    (2)

    opexp:= op(0,10^x):            # exponentiation id
    opnp := op(0,10*x):            # normal product id
    optp := op(0,Ket(q0)*Ket(q1)): # tensor product id
    opdiv:= `Fraction`:            # fraction       id          
    opsym:= op(0,x):               # symbol         id
    opint:= op(0,10):              # integer        id
    opflt:= op(0,10.0):            # float          id
    opcpx:= op(0,i):               # complex        id
    opbra:= op(0,Bra(q)):          # bra            id
    opket:= op(0,Ket(q)):          # ket            id
    opmod:= op(0, a mod b):        # mod            id
    ExpandQop:=proc(x)
        local nx,ret,j,lkb,cbk,rkb,no,lop,success;
        lop:=op(0,x);
        no:=nops(x);
        if lop = opsym or lop = opint or lop = opflt or
           lop = opbra or lop = opket or lop = opcpx then
             ret:=x;
        else
        if lop = opexp then
            ret:=x;
        else       
        if lop = opnp then
            ret:=1;
            for j from 1 to no do
                ret:=ret*ExpandQop(op(j,x));
            end do;        
        else
        if lop = `+` then
            ret:=0;
            for j from 1 to no do
                ret:=ret+ExpandQop(op(j,x));
            end do;
        else
        if lop = `-` then
            ret:=0;
            for j from 1 to no do
                ret:=ret-ExpandQop(op(j,x));
            end do;
        else
        if lop = opdiv then
           ret:=1;
           for j from 1 to no do
               ret:=ret/ExpandQop(op(j,x));
           end do;
        else
        if lop = opmod then
           ret:=x;
        else
        if lop = optp then
           if (no > 3 ) then
               success:=false;
               nx:=x;
               while not success do
                 lkb:=0; cbk:=0; rkb:=0;ret:=1;
                 for j from 1 to no do
                     if (j>1) then
                          if(lkb=0) then
                              if( type(op(j-1,nx),Ket) and
                                  type(op(j,nx),Bra) ) then lkb:=j-1; fi;
                          else
                              if( type(op(j-1,nx),Ket) and
                                  type(op(j,nx),Bra) ) then rkb:=j;   fi;
                          fi;
                          if( type(op(j-1,nx),Bra) and type(op(j,nx),Ket) )
                                                       then cbk:=j;   fi;
                     fi;
                 end do;
                 if ( (lkb < cbk) and (cbk<rkb) ) then
                     for j from 1     to lkb   do ret := ret*op(j,nx); end do;
                     for j from cbk   to no    do ret := ret*op(j,nx); end do;
                     for j from lkb+1 to cbk-1 do ret := ret*op(j,nx); end do;
                 else
                   ret:=nx;
                 fi;
                 
                 if nx = ret then
                    success := true;
                 else
                    nx := ret;
                 fi
               end do;
           else
               ret:=x;
           fi;
        else ret:=x;
        fi; # optp
        fi; # opmod
        fi; # opdiv
        fi; # `-`
        fi; # `+`
        fi; # `opnp
        fi; # `opexp`
        fi; # opsym, opint, opflt, opbra, opket, opcpx

        return ret;
    end proc:

    # For saving
    # save opexp,opnp,optp,opdiv,opint,opflt,opcpx,opbra,opket,opmod, ExpandQop,"ExpandQop.m"

    # Let A be an operator in a first Hilbert space of dimension n
    #  using the associated orthonormal ket and bra vectors
    #
    #
    kets1:=Ket(a1)*Ket(a2)*Ket(a3)*Ket(a4)*Ket(a5):
    A:=kets1*Dagger(kets1);


    # Let B be an operator in a second Hilbert (Ketspace of dimension m
    #  using the associated orthonormal ket and bra vectors
    #
    #
    kets2:=Ket(b1)*Ket(b2)*Ket(b3):
    B:=kets2*Dagger(kets2);


    # The tensor product of the two operators acts on a n+m third
    # Hilbert space   unsing the appropriately ordered ket
    # and bra  vectors of the two preceding spaces. The rule for
    # building this operator in Dirac notation is as follows,
    #
    #


    print("Maple do not compute the tensor product of operators,");
    print("C=A*B gives:");
    C:=A*B;

    print("ExpandQop(C) gives the expected result:");
    Cn:=ExpandQop(C);

    Physics:-`*`(Physics:-Ket(a1), Physics:-Ket(a2), Physics:-Ket(a3), Physics:-Ket(a4), Physics:-Ket(a5), Physics:-Bra(a5), Physics:-Bra(a4), Physics:-Bra(a3), Physics:-Bra(a2), Physics:-Bra(a1))

     

    Physics:-`*`(Physics:-Ket(b1), Physics:-Ket(b2), Physics:-Ket(b3), Physics:-Bra(b3), Physics:-Bra(b2), Physics:-Bra(b1))

     

    "Maple do not compute the tensor product of operators,"

     

    "C=A*B gives:"

     

    Physics:-`*`(Physics:-Ket(a1), Physics:-Ket(a2), Physics:-Ket(a3), Physics:-Ket(a4), Physics:-Ket(a5), Physics:-Bra(a5), Physics:-Bra(a4), Physics:-Bra(a3), Physics:-Bra(a2), Physics:-Bra(a1), Physics:-Ket(b1), Physics:-Ket(b2), Physics:-Ket(b3), Physics:-Bra(b3), Physics:-Bra(b2), Physics:-Bra(b1))

     

    "ExpandQop(C) gives the expected result:"

     

    Physics:-`*`(Physics:-Ket(a1), Physics:-Ket(a2), Physics:-Ket(a3), Physics:-Ket(a4), Physics:-Ket(a5), Physics:-Ket(b1), Physics:-Ket(b2), Physics:-Ket(b3), Physics:-Bra(b3), Physics:-Bra(b2), Physics:-Bra(b1), Physics:-Bra(a5), Physics:-Bra(a4), Physics:-Bra(a3), Physics:-Bra(a2), Physics:-Bra(a1))

    (3)

    kets3:=kets1*kets2;
    bras3:=Dagger(kets3);
    print("Matrix elements computed with C appears curious");
    'bras3.C. kets3'="...";
    bras3.C.kets3;
    print("Matrix elements computed with Cn as expected");
    'bras3.Cn.kets3'=bras3.Cn.kets3;

    Physics:-`*`(Physics:-Ket(a1), Physics:-Ket(a2), Physics:-Ket(a3), Physics:-Ket(a4), Physics:-Ket(a5), Physics:-Ket(b1), Physics:-Ket(b2), Physics:-Ket(b3))

     

    Physics:-`*`(Physics:-Bra(b3), Physics:-Bra(b2), Physics:-Bra(b1), Physics:-Bra(a5), Physics:-Bra(a4), Physics:-Bra(a3), Physics:-Bra(a2), Physics:-Bra(a1))

     

    "Matrix elements computed with C appears curious"

     

    Physics:-`.`(bras3, C, kets3) = "..."

     

    Physics:-Bracket(Physics:-Bra(b1), Physics:-Ket(a1))*Physics:-Bracket(Physics:-Bra(b2), Physics:-Ket(a2))*Physics:-Bracket(Physics:-Bra(b3), Physics:-Ket(a3))*Physics:-Bracket(Physics:-Bra(a1), Physics:-Ket(b1))*Physics:-Bracket(Physics:-Bra(a2), Physics:-Ket(b2))*Physics:-Bracket(Physics:-Bra(a3), Physics:-Ket(b3))*Physics:-Bracket(Physics:-Bra(a4), Physics:-Ket(a4))^2*Physics:-Bracket(Physics:-Bra(a5), Physics:-Ket(a5))^2*Physics:-Bracket(Physics:-Bra(a1), Physics:-Ket(a1))*Physics:-Bracket(Physics:-Bra(a2), Physics:-Ket(a2))*Physics:-Bracket(Physics:-Bra(a3), Physics:-Ket(a3))*Physics:-Bracket(Physics:-Bra(b1), Physics:-Ket(b1))*Physics:-Bracket(Physics:-Bra(b2), Physics:-Ket(b2))*Physics:-Bracket(Physics:-Bra(b3), Physics:-Ket(b3))

     

    "Matrix elements computed with Cn as expected"

     

    Physics:-`.`(bras3, Cn, kets3) = Physics:-Bracket(Physics:-Bra(a1), Physics:-Ket(a1))^2*Physics:-Bracket(Physics:-Bra(a2), Physics:-Ket(a2))^2*Physics:-Bracket(Physics:-Bra(a3), Physics:-Ket(a3))^2*Physics:-Bracket(Physics:-Bra(a4), Physics:-Ket(a4))^2*Physics:-Bracket(Physics:-Bra(a5), Physics:-Ket(a5))^2*Physics:-Bracket(Physics:-Bra(b1), Physics:-Ket(b1))^2*Physics:-Bracket(Physics:-Bra(b2), Physics:-Ket(b2))^2*Physics:-Bracket(Physics:-Bra(b3), Physics:-Ket(b3))^2

    (4)

    print("Example");
    En:=ExpandQop(10*(1-x+y+z)*i*(1/sqrt(2))*A*B);

    "Example"

     

    -(5*I)*2^(1/2)*(-1+x-y-z)*Physics:-`*`(Physics:-Ket(a1), Physics:-Ket(a2), Physics:-Ket(a3), Physics:-Ket(a4), Physics:-Ket(a5), Physics:-Ket(b1), Physics:-Ket(b2), Physics:-Ket(b3), Physics:-Bra(b3), Physics:-Bra(b2), Physics:-Bra(b1), Physics:-Bra(a5), Physics:-Bra(a4), Physics:-Bra(a3), Physics:-Bra(a2), Physics:-Bra(a1))

    (5)

    print("Another example");
    'F'='A*B/sqrt(2)+B*A/sqrt(2)';
    F:=A*B/sqrt(2)+B*A/sqrt(2):
    'op(1,F)'=op(1,F);
    'op(2,F)'=op(2,F);

    'Fn'='ExpandQop(F)';
    Fn:=ExpandQop(F):
    'op(1,Fn)'=op(1,Fn);
    'op(2,Fn)'=op(2,Fn);

    "Another example"

     

    F = Physics:-`*`(Physics:-`*`(A, B), Physics:-`^`(sqrt(2), -1))+Physics:-`*`(Physics:-`*`(B, A), Physics:-`^`(sqrt(2), -1))

     

    op(1, F) = (1/2)*2^(1/2)*Physics:-`*`(Physics:-Ket(a1), Physics:-Ket(a2), Physics:-Ket(a3), Physics:-Ket(a4), Physics:-Ket(a5), Physics:-Bra(a5), Physics:-Bra(a4), Physics:-Bra(a3), Physics:-Bra(a2), Physics:-Bra(a1), Physics:-Ket(b1), Physics:-Ket(b2), Physics:-Ket(b3), Physics:-Bra(b3), Physics:-Bra(b2), Physics:-Bra(b1))

     

    op(2, F) = (1/2)*2^(1/2)*Physics:-`*`(Physics:-Ket(b1), Physics:-Ket(b2), Physics:-Ket(b3), Physics:-Bra(b3), Physics:-Bra(b2), Physics:-Bra(b1), Physics:-Ket(a1), Physics:-Ket(a2), Physics:-Ket(a3), Physics:-Ket(a4), Physics:-Ket(a5), Physics:-Bra(a5), Physics:-Bra(a4), Physics:-Bra(a3), Physics:-Bra(a2), Physics:-Bra(a1))

     

    Fn = ExpandQop(F)

     

    op(1, Fn) = (1/2)*2^(1/2)*Physics:-`*`(Physics:-Ket(a1), Physics:-Ket(a2), Physics:-Ket(a3), Physics:-Ket(a4), Physics:-Ket(a5), Physics:-Ket(b1), Physics:-Ket(b2), Physics:-Ket(b3), Physics:-Bra(b3), Physics:-Bra(b2), Physics:-Bra(b1), Physics:-Bra(a5), Physics:-Bra(a4), Physics:-Bra(a3), Physics:-Bra(a2), Physics:-Bra(a1))

     

    op(2, Fn) = (1/2)*2^(1/2)*Physics:-`*`(Physics:-Ket(b1), Physics:-Ket(b2), Physics:-Ket(b3), Physics:-Ket(a1), Physics:-Ket(a2), Physics:-Ket(a3), Physics:-Ket(a4), Physics:-Ket(a5), Physics:-Bra(a5), Physics:-Bra(a4), Physics:-Bra(a3), Physics:-Bra(a2), Physics:-Bra(a1), Physics:-Bra(b3), Physics:-Bra(b2), Physics:-Bra(b1))

    (6)

    print("Final example, multiple products");
    G:=B*B*B;
    'G'=ExpandQop(G);

    "Final example, multiple products"

     

    Physics:-`*`(Physics:-Ket(b1), Physics:-Ket(b2), Physics:-Ket(b3), Physics:-Bra(b3), Physics:-Bra(b2), Physics:-Bra(b1), Physics:-Ket(b1), Physics:-Ket(b2), Physics:-Ket(b3), Physics:-Bra(b3), Physics:-Bra(b2), Physics:-Bra(b1), Physics:-Ket(b1), Physics:-Ket(b2), Physics:-Ket(b3), Physics:-Bra(b3), Physics:-Bra(b2), Physics:-Bra(b1))

     

    G = Physics:-`*`(Physics:-Ket(b1), Physics:-Ket(b2), Physics:-Ket(b3), Physics:-Ket(b1), Physics:-Ket(b2), Physics:-Ket(b3), Physics:-Ket(b1), Physics:-Ket(b2), Physics:-Ket(b3), Physics:-Bra(b3), Physics:-Bra(b2), Physics:-Bra(b1), Physics:-Bra(b3), Physics:-Bra(b2), Physics:-Bra(b1), Physics:-Bra(b3), Physics:-Bra(b2), Physics:-Bra(b1))

    (7)

     


     

    Download ExpandQopV3.mw

    First 38 39 40 41 42 43 44 Last Page 40 of 297