From: us on 27 Mar 2010 15:58 Don Robison <joe_blow_281(a)hotmail.com> wrote in message <1817186076.455340.1269718178462.JavaMail.root(a)gallium.mathforum.org>... > >> syms x > >> d = x^2 > d = > x^2 > >> x=[0,0;1,0] note: X is reassigned to a 2x2 DOUBLE... one of the solutions syms x; d=x^2; xd=[0,0;1,0]; r=subs(d,'x',xd) %{ % r = 0 0 1 0 %} us
From: Don Robison on 27 Mar 2010 12:50 Hello us. This is Don Robison. Thank you for your help, but the code does not return x^2. I need to evaluate a symbolic expression such as x^i*y^i*z^k, and have the matrix multiplied by itself i,j,k times. The code you gave seems to just return xd without taking it to the second power. the input must be a trinomial with any power, the output must be that a sum of matrices that have been multiplied by themselves as many times as the exponent in the term. the output I am looking for in this particular instance would be [0,0;0,0] or xd^2.
From: ImageAnalyst on 27 Mar 2010 19:43 Do you mean to use .^ (dot caret) instead of ^ (caret) to take element- by-element squaring? Otherwise without the dot, it's completely different. Just checking....
From: Matt J on 27 Mar 2010 19:52 ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <23cb4247-0a3e-47af-90c6-7889c83e2524(a)30g2000yqi.googlegroups.com>... > Do you mean to use .^ (dot caret) instead of ^ (caret) to take element- > by-element squaring? Otherwise without the dot, it's completely > different. Just checking.... ============= That doesn't explain the discrepancy between x^2 and eval(d), though. They should be the same regardless of which kind of exponentiation is used...
From: Roger Stafford on 27 Mar 2010 19:54
Don Robison <joe_blow_281(a)hotmail.com> wrote in message <1396842502.455793.1269723085870.JavaMail.root(a)gallium.mathforum.org>... > Hello us. This is Don Robison. Thank you for your help, but the code does not return x^2. I need to evaluate a symbolic expression such as x^i*y^i*z^k, and have the matrix multiplied by itself i,j,k times. The code you gave seems to just return xd without taking it to the second power. > > the input must be a trinomial with any power, the output must be that a sum of matrices that have been multiplied by themselves as many times as the exponent in the term. > > the output I am looking for in this particular instance would be [0,0;0,0] or xd^2. Actually [0,0;0,0] is the correct answer! The matrix product of that matrix by itself is all zeros. Roger Stafford |