ASA Connect

 View Only
  • 1.  Symbolic Matrix Calculator

    Posted 06-03-2020 09:31
    Does anyone have recommendations for a reliable online symbolic matrix calculator?  For the time being, just matrix multiplication is all I need.  
    Something that will multiply matrices, such as the example below (commas indicate separate rows):

    [a1 a2 a3, b1 b2 b3] * [c1 c2 c3, d1 d2 d3, e1 e2 e3]

    Is there an R or Python package that can do this?  SAS Proc IML is great for numerical matrices, but doesn't have the capability to multiple symbolic matrices.

    ------------------------------
    Brandy Sinco, BS, MA, MS
    Statistician Senior
    Michigan Medicine
    ------------------------------


  • 2.  RE: Symbolic Matrix Calculator

    Posted 06-03-2020 20:23
    Hi Brandy,

    I'm not sure I haven't misunderstood your question, but its pretty straightforward to put together code in R which illustrates the underlying arithmetic operations for matrix multiplication:

    # This function takes row and column dims and creates character
    # matrices. Start allows for (row) lettering to pick up from
    # where the last ended
    symb_mat = function(nrow, ncol, start = 1){
    r = letters[start:(nrow+start-1)]
    c = 1:ncol
    int = interaction(expand.grid(r, c), sep = '')
    noquote(matrix(int, ncol = ncol))
    }

    # This generates another text matrix, pasting in multiplication
    # and addition symbols as appropriate
    symb_mat_mult = function(a, b){
    if (ncol(a) != nrow(b)) {stop('Rows in A must equal columns in B')}
    m = matrix(nrow = nrow(a), ncol = ncol(b))
    for (r in 1:nrow(a)){
    for (c in 1:ncol(b)){
    m[r, c] = paste0(mapply(paste0, a[r, ], '*', b[, c]), collapse = '+')
    }
    }
    return(noquote(m))
    }

    # Demo, as per your example:
    A = symb_mat(2, 3)
    B = symb_mat(3, 3, start = 3)
    print(A)
    print(B)
    C = symb_mat_mult(A, B)
    print(C)

    Hope it helps!




    ------------------------------
    Simon Riley
    Graduate Assistant (PhD)
    University of Florida
    ------------------------------



  • 3.  RE: Symbolic Matrix Calculator

    Posted 06-04-2020 09:53
    I think "sympy" in Python will do what you want.

    There is also an excellent free program "Maxima" (based on the old M.I.T. "macsyma") which I have found to be just as fast as Maple. Google it for whatever platform you have.

    Giles Warrack

    ------------------------------
    Anthony Warrack
    Associate Professor
    North Carolina A&T State University
    ------------------------------



  • 4.  RE: Symbolic Matrix Calculator

    Posted 06-04-2020 07:07
    The best symbolic mathematics software that I have every used is Maple.  I just checked and they do have some online calculators that will do exactly what you are asking.  You can find them at Math Apps for Students - Online Calculators and Math Apps for Students. There is matrix multiplication here and much, much more.  (I checked that the online versions do symbolic computations before posting this.)

    Cheers!

    Tom

    ------------------------------
    Thomas Kent
    ------------------------------



  • 5.  RE: Symbolic Matrix Calculator

    Posted 06-04-2020 08:43
    Hello Brandy,

    If it is only occasionally that you need to do that, then your best choice is Wolfram Alpha. 
    Example: 
    You type: {{a, b},{c ,d}}{{e, f},{g,h}}
    Wolfram Alpha interprets...
    ... and Outputs:

    Regards,


    ------------------------------
    Rene Valverde-Ventura
    ------------------------------



  • 6.  RE: Symbolic Matrix Calculator

    Posted 06-04-2020 09:24
    Hi Brandy

    I haven't used any of these, but I am aware of

    * the SymPy package in Python and
    * the rSymPy package in R, which calls it.
    * Also so the Ryacas package in R. 

    Hope that helps, Blaise

    ------------------------------
    Blaise Egan
    Lead Data Scientist
    British Telecommunications PLC
    ------------------------------



  • 7.  RE: Symbolic Matrix Calculator

    Posted 06-04-2020 09:32
    Mathematica was a huge time saver for me in a couple of instances many years ago. Once I transitioned to Linux I learned about Maxima (http://maxima.sourceforge.net/index.html), which works very well too.

    > "Maxima is a system for the manipulation of symbolic and numerical expressions, including differentiation, integration, Taylor series, Laplace transforms, ordinary differential equations, systems of linear equations, polynomials, sets, lists, vectors, matrices and tensors."

    There is an online interface that gives you access to Maxima without the need to install anything:
    http://maxima.cesga.es/

    ------------------------------
    Arthur Carbonare De Avila
    ------------------------------



  • 8.  RE: Symbolic Matrix Calculator

    Posted 06-04-2020 10:28
    If "online" also means free, you might consider Wolfram Alpha (wolframalpha.com).  Your example (slightly modified) would be entered as

    Multiply[{{a1, a2, a3}, {b1, b2, b3}}, {{c1, c2, c3}, {d1, d2, d3}, {f1, f2, f3}}]

    Wolfram Alpha output
    "e" is treated as 2.71828 so I changed that to "f".

    Alternatively, using Mathematica, Maple, or MATLAB would work better if you have the money to do so.  I use Mathematica extensively for symbolic manipulations.  (I have nothing against Maple or MATLAB.  But I could only afford one of those three.)

    There are also several freeware symbolic apps.  Here is a relatively comprehensive listing:  https://en.wikipedia.org/wiki/List_of_computer_algebra_systems (which also includes software that costs money).

    Jim






    ------------------------------
    Jim Baldwin
    Retired
    ------------------------------



  • 9.  RE: Symbolic Matrix Calculator

    Posted 06-05-2020 09:15
    Thanks to everyone who responded with so many helpful suggestions.

    ------------------------------
    Brandy Sinco, BS, MA, MS
    Statistician Senior
    Michigan Medicine
    ------------------------------