| |
 |
|
|
Science Forum Index » Math - Symbolic Forum » vector/matrix calculus software...
Page 1 of 1
|
| Author |
Message |
| gcg2k7... |
Posted: Thu Jun 19, 2008 5:03 am |
|
|
|
Guest
|
Hi everyone,
I'm looking for software that can do symbolic matrix calculus with
vectors and matrices as first-class objects. That is, I'd like to be
able to define vectors and matrices by their sizes (and possibly other
properties) and be able to compute derivatives with the answer given
in terms of vectors/matrices rather than individual scalar elements.
I know other people have asked about this before, but I have yet to
find a satisfying answer. If no software exists that can do this, why
not? I know that a LOT of people would find this capability very
useful, so I'm surprised it hasn't been done (I'm looking at you Univ.
of Waterloo and/or Mathworks :)
Any pointers greatly appreciated,
-Graham |
|
|
| Back to top |
|
| Walter Roberson... |
Posted: Thu Jun 19, 2008 6:18 am |
|
|
|
Guest
|
In article <bcd68e7e-411a-4214-985a-e7abf9d7e2b6 at (no spam) l42g2000hsc.googlegroups.com>,
gcg2k7 <grindlay at (no spam) gmail.com> wrote:
Quote: I'm looking for software that can do symbolic matrix calculus with
vectors and matrices as first-class objects. That is, I'd like to be
able to define vectors and matrices by their sizes (and possibly other
properties) and be able to compute derivatives with the answer given
in terms of vectors/matrices rather than individual scalar elements.
When people have asked for matrix derivatives, I have never been
sure whether they want element-by-element matrix operations, or
if they want matrix operations. If I have x*A^2 + y*A = B
then is that A^2 what mathlab would write as A.^2, or is it
the matrix produce A*A ?
--
"[I]t lacks context, and may or may not make sense."
-- Walter J. Phillips |
|
|
| Back to top |
|
| gcg2k7... |
Posted: Thu Jun 19, 2008 10:06 am |
|
|
|
Guest
|
Quote: Here are two interpretations of your question. Answers given in Maple.
# interpretation 1:
restart;
A := < <a(t) | b(t)>, <c(t) | d(t)> >; # A 2x2 matrix
map(diff, A, t); # dA / dt
map(diff, A, t, t); # d^2A / dt^2
map(diff, A.A, t); # d(A^2) / dt
# interpretation 2:
restart;
diff(A(t).B(t), t); # derivative of a non-commutative product
diff(A(t).B(t), t, t); # second derivative of a non-commutative product
If you are asking for something else, you should be more explicit
in your description.
--
Rouben Rostamian
I guess I wasn't clear enough in my initial formulation of the
question. Let me try again.
Given the following (in Matlab notation):
a (n x 1 vector)
X (n x n matrix)
b (n x 1 vector)
I'd like to be able to compute derivatives like:
d(a'Xb)/dX = ab'
without ab' turning into [a1*b1 a1*b2 ; a2*b1 a2*b2]
This is obviously a very simple example, but I think the basic idea of
what I'm interested in should be clear. I'm mostly a Matlab user and
my Maple experience is largely via the Symbolic toolbox, but if
there's a way to do the above by issuing Maple commands that would be
great.
thanks,
Graham |
|
|
| Back to top |
|
| Rouben Rostamian... |
Posted: Thu Jun 19, 2008 11:59 am |
|
|
|
Guest
|
On 2008-06-19, gcg2k7 <grindlay at (no spam) gmail.com> wrote:
Quote:
I'm looking for software that can do symbolic matrix calculus with
vectors and matrices as first-class objects. That is, I'd like to be
able to define vectors and matrices by their sizes (and possibly other
properties) and be able to compute derivatives with the answer given
in terms of vectors/matrices rather than individual scalar elements.
Here are two interpretations of your question. Answers given in Maple.
# interpretation 1:
restart;
A := < <a(t) | b(t)>, <c(t) | d(t)> >; # A 2x2 matrix
map(diff, A, t); # dA / dt
map(diff, A, t, t); # d^2A / dt^2
map(diff, A.A, t); # d(A^2) / dt
# interpretation 2:
restart;
diff(A(t).B(t), t); # derivative of a non-commutative product
diff(A(t).B(t), t, t); # second derivative of a non-commutative product
If you are asking for something else, you should be more explicit
in your description.
--
Rouben Rostamian |
|
|
| Back to top |
|
| Rouben Rostamian... |
Posted: Thu Jun 19, 2008 11:49 pm |
|
|
|
Guest
|
On 2008-06-19, gcg2k7 <grindlay at (no spam) gmail.com> wrote:
Quote:
I guess I wasn't clear enough in my initial formulation of the
question. Let me try again.
Given the following (in Matlab notation):
a (n x 1 vector)
X (n x n matrix)
b (n x 1 vector)
I'd like to be able to compute derivatives like:
d(a'Xb)/dX = ab'
without ab' turning into [a1*b1 a1*b2 ; a2*b1 a2*b2]
This is obviously a very simple example, but I think the basic idea of
what I'm interested in should be clear. I'm mostly a Matlab user and
my Maple experience is largely via the Symbolic toolbox, but if
there's a way to do the above by issuing Maple commands that would be
great.
Perhaps a more elementary problem is the computation of
the derivative dX/dX. How would you represent the result
without coordinates?
You may already know that it is possible to do that once
we introduce a new product (tensor product) of matrices
and the corresponding algebra. I don't know if matlab
or maple are set up to handle such algebras. My guess
is that they don't, but Maple's tensor calculus package
may have facilities for this. I don't know enough about
it to tell.
--
Rouben Rostamian |
|
|
| Back to top |
|
| Walter Roberson... |
Posted: Fri Jun 20, 2008 6:36 am |
|
|
|
Guest
|
In article <9ccc7c9f-3660-4540-85c0-2ed025d994a6 at (no spam) 34g2000hsh.googlegroups.com>,
gcg2k7 <grindlay at (no spam) gmail.com> wrote:
Quote: Given the following (in Matlab notation):
a (n x 1 vector)
X (n x n matrix)
b (n x 1 vector)
I'd like to be able to compute derivatives like:
d(a'Xb)/dX = ab'
without ab' turning into [a1*b1 a1*b2 ; a2*b1 a2*b2]
This is obviously a very simple example, but I think the basic idea of
what I'm interested in should be clear.
No, it isn't clear to me. It doesn't answer the question of
whether you want element-by-element computation or matrix computation.
If matrix solutions are considered, then your result is incorrect.
As X is allowed to vary, let X be a nilpotent matrix. Then Xb is n x n
of 0's, and a'Xb is 1 x n of 0's, for any a and b, which is clearly
not the same as ab' . (Does ab' even have the same size as d(a'Xb)/dX ??)
--
"The human mind is so strangely capricious, that, when freed from
the pressure of real misery, it becomes open and sensitive to the
ideal apprehension of ideal calamities." -- Sir Walter Scott |
|
|
| Back to top |
|
| gcg2k7... |
Posted: Fri Jun 20, 2008 8:08 am |
|
|
|
Guest
|
Quote: Given the following (in Matlab notation):
a (n x 1 vector)
X (n x n matrix)
b (n x 1 vector)
I'd like to be able to compute derivatives like:
d(a'Xb)/dX = ab'
without ab' turning into [a1*b1 a1*b2 ; a2*b1 a2*b2]
This is obviously a very simple example, but I think the basic idea of
what I'm interested in should be clear.
No, it isn't clear to me. It doesn't answer the question of
whether you want element-by-element computation or matrix computation.
In my example, I'm interested in the partial derivative with respect
to the matrix A. So yes, I'm interested in matrix computation. What
I didn't (and perhaps should have) explicitly state, was that ab' =
[a1*b1 a1*b2 ; a2*b1 a2*b2] refers to the case where n = 2.
Quote: If matrix solutions are considered, then your result is incorrect.
As X is allowed to vary, let X be a nilpotent matrix. Then Xb is n x n
of 0's, and a'Xb is 1 x n of 0's, for any a and b, which is clearly
not the same as ab' . (Does ab' even have the same size as d(a'Xb)/dX ??)
Umm, you're saying that multiplying an nxn matrix A by an nx1 vector b
(A*b) results in an nxn matrix? Maybe this is a case of it being
difficult to clearly express math in ASCII. To be crystal clear, I'd
like to be able to compute the type of matrix derivatives that you can
find in Section 2 of the Matrix Cookbook (see Section 2.4.1 eq. 58 for
my example):
http://www.imm.dtu.dk/pubdb/views/edoc_download.php/3274/pdf/imm3274.pdf
I hope this makes things clear.
-Graham |
|
|
| Back to top |
|
| rjf... |
Posted: Fri Jun 20, 2008 10:41 am |
|
|
|
Guest
|
On Jun 20, 11:08 am, gcg2k7 <grind... at (no spam) gmail.com> wrote:
Most computer algebra systems allow you to build your own simplifier
by defining rules.
Your reference appears to consist of a bunch of formulas which could
be used, if they are not already in some system. |
|
|
| Back to top |
|
| |
|
Page 1 of 1
All times are GMT - 5 Hours
The time now is Fri Dec 05, 2008 9:16 am
|
|