Hi,
I'm a collaborator of the author of the previous post. Let me try to
elaborate a little on what it is we want to do
Basically we are trying to simplify some complex symbolic expressions
we have generated which include matrices and vectors as variables.
Unfortunately these formulas are too long/complex to manipulate by
hand and we we are looking for some way to do this automatically.
Sage's manual explains how to simplify expressions with some
variables: The following example is extracted from the reference
manual
sage: var(’x, y, a, b, c’)
(x, y, a, b, c)
sage: f = x*(x-1)/(x^2 - 7) + y^2/(x^2-7) + 1/(x+1) + b/a + c/a; f
(x - 1)*x/(x^2 - 7) + y^2/(x^2 - 7) + b/a + c/a + 1/(x + 1)
sage: f.combine()
((x - 1)*x + y^2)/(x^2 - 7) + (b + c)/a + 1/(x + 1)
We want to do exactly the same, but in our case variables a,b,c, etc
would be vectors and matrices. Our question is: is it possible to use
sage to perform this kind of simplification with matrices and vectors?
Or, what is probably the same question, how can I generate variables
that are matrices and vectors?
I tried the following, but it seems this is not really generating
matrices and vectors:
sage: A = matrix(RR, 1000, 1000, sparse=True).parent()
sage: A
Full MatrixSpace of 1000 by 1000 sparse matrices over Real Field with
53 bits of precision
sage: matr = var('matr', domain=A)
sage: V = vector(RR, 1000).parent()
sage: V
Vector space of dimension 1000 over Real Field with 53 bits of
precision
sage: vec = var('vec', domain=V)
I hope someone here will be able to shed some light on this or suggest
a different approach/tool for achieving the symbolic simplification we
are pursuing
Thank you very much in advance,
Miquel
On Sep 10, 2:44 pm, BSC-BCN <[email protected]> wrote:
> Conjugate Gradient Algorithm
>
> 1.Compute r0:=b Ax0, p0:=r0
> 2.For j =0;1; ....,until convergence Do:
> 3. aj :=(rj,rj)/(Apj,pj)
> 4.xj+1:= xj + ajpj
> 5.rj+1:=rj-ajApj
> 6.bj :=(rj+1,rj+1)/(rj,rj)
> 7.pj+1:=rj+1+bjpj
> 8.End Do
>
> Derivation for two steps in one go
>
> Compute r0:=bAx0, p0:=r0
> For j=0;2;....,unitl convergence Do:
> aj := (rj,rj)/ (Apj,pj)
> xj+1:= xj + ajpj
> rj+1:=rj-ajApj
> bj :=(rj+1,rj+1)/(rj,rj)
> pj+1:=rj+1+bjpj
>
> aj+1 := (rj+1,rj+1)/ (APj+1,pj+1)
> xj+2:= xj+1 + aj+1pj+1
> rj+2:=rj+1-aj+1Apj+1
> bj+1 :=(rj+2,rj+2)/(rj+1,rj+1)
> pj+2:=rj+2+bj+1pj+1
>
> End Do
>
> All the equation must rely on the following initial variables:rj,pj,xj
> and on constant Matrix A
>
> Xj+2 have to be in function of rj,pj,xj and A it can't contain rj+1,pj
> +1,xj+1 and so on for rj+2, xj+2
>
> Some explanation:
>
> (rj,rj) is scalar-product of vectors rj,rj
> Apj is Matrix-vector multiplication where A is matrix and pj is a
> vector
> aj and bj are parametars
>
> I hope now is more clear what I want to do...As I said the expressions
> that I get are pretty big and I would like to use SAGE to try to
> simplify and make more compact. In case that I want to do 3 or more
> steps in one go the expressions would become even more bigger..
>
> Thanks
> Branimir
>
> On Sep 8, 3:23 pm, Jason Grout <[email protected]> wrote:
>
> > On 9/8/10 7:45 AM, BSC-BCN wrote:
>
> > I hope you can understand
>
> > > me...
>
> > I don't think I really do, but this thread might contain some useful
> > things for you:
>
> >http://groups.google.com/group/sage-devel/browse_thread/thread/cafb48...
>
> > Thanks,
>
> > Jason
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org