Search code examples
matrixmaple

Error when trying to sum two products, where one product is a 1x2 matrix


First question that I've posted here, I'm working on some code for my final on Monday and for some reason I keep getting the following error. Any help would be MASSIVELY appreciated. Thanks!;

The following imagine shows the error in my code, I had switched to 1D math and still can't seem to find the issue


Solution

  • In Maple the global name D has a preassigned value. It is the differential operator. For example,

    f := t -> sec(t):
    
    D(f);
    
          t -> sec(t)*tan(t)
    

    The global name D is also protected, ie. you cannot assign another values to it.

    And in general it is not a good idea to use the name D like a dummy variable in your code (since is has already been assigned a system procedure, by default). Your example is an (unfortunate) example of strangeness that could ensue.

    D * Vector([-3,1]);
      Error, (in LinearAlgebra:-Multiply) invalid arguments
    

    You have a couple of alternatives:

    1) Use another name instead, such as DD.

    2) If you Maple version is recent then you could declare it (once) as a local name for top-level use. For example,

    restart;
    
    local D;
    
                   D
    
    D * Vector([-3,1]);
    
                 [-3 D]
                 [    ]
                 [ D  ]
    

    If you do declare local D for top-level use then you can still utilize the differential operator by its global name :-D. Eg.

    restart;
    local D:
    
    f := t -> sec(t):
    
    D(f);     # does nothing, since this is the local D
    
                 D(f)
    
    :-D(f);
    
           t -> sec(t)*tan(t)
    

    If all that sounds confusing, you'll probably be better off just using another name instead.

    The are only a few short symbols with preassigned values or uses, eg. Pi, I, D.

    You might want to also have a look at the Help page for Topics initialconstants and trydeclaringlocal .