MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Out of Memory. Exiting.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg27504] Re: Out of Memory. Exiting.
  • From: Roland Franzius <Roland.Franzius at uos.de>
  • Date: Thu, 1 Mar 2001 03:53:30 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Not for the first time here it is recommended ...

Mathematica (a mathematicians) have a poor performance handling
trigonometric expression (too many rules, too many ways to simplify an
expression). 

Your expression contains Reals( even 1.*..), so rationalize ist first

In:
mat = Rationalize[({{Cos[q]^2 - Cos[2*p]*Sin[q]^2, 
          1.*(Sin[2*p]*Sin[2.*p]*Sin[q] + Cos[p]^2*Cos[2.*p]*Sin[2*q]), 
          1.*Cos[2.*p]*Sin[2*p]*Sin[q] - 
            1.*Cos[p]^2*Sin[2.*p]*Sin[2*q]}, {-(Cos[p]^2*Sin[2*q]), 
          1.*Cos[q]*Sin[2*p]*Sin[2.*p] - 
            1.*Cos[2.*p]*(-(Cos[2*p]*Cos[q]^2) + Sin[q]^2), 
          1.*(Cos[2.*p]*Cos[q]*Sin[2*p] + 
                Sin[2.*p]*(-(Cos[2*p]*Cos[q]^2) + Sin[q]^2))},
{Sin[2*p]*
            Sin[q], -1.*Cos[2.*p]*Cos[q]*Sin[2*p] +
1.*Cos[2*p]*Sin[2.*p], 
          1.*(Cos[2*p]*Cos[2.*p] + Cos[q]*Sin[2*p]*Sin[2.*p])}})];

This rule eliminates all functions known to Mathematica. So no attempts for
looking at arguments and rules will occur 
In:
toPolynomial = {Cos[p] -> x/2 + 1/(2*x), Sin[p] -> x/(2*I) - 1/(2*I*x), 
   Cos[2*p] -> Cos[p]^2 - Sin[p]^2, Sin[2*p] -> 2*Sin[p]*Cos[p], Cos[q]
-> y/2 + 1/(2*y), 
   Sin[q] -> y/(2*I) - 1/(2*I*y), Sin[2*q] -> 2*Sin[q]*Cos[q]};

This is the reverse replacement rule
In:
toTrig = {x -> Cos[p] + I*Sin[p], y -> Cos[q] + I*Sin[q]};

In:
mat1 = mat //. toPolynomial // FullSimplify
Out:
{{((-1 + y^2)^2 + x^4*(-1 + y^2)^2 + 2*x^2*(1 + y^2)^2)/(8*x^2*y^2), 
   -((I*(1 + x^2)^2*((-1 + y)^2 + x^4*(-1 + y)^2 + 4*x^2*y)*(-1 +
y^2))/(16*x^4*y^2)), 
   ((-1 + x^4)*(-1 + y^2)*((-1 + y)^2 + x^4*(-1 + y)^2 + 2*x^2*(1 +
y^2)))/(16*x^4*y^2)}, 
  {(I*(1 + x^2)^2*(-1 + y^2)*(1 + y^2))/(8*x^2*y^2), 
   (2*x^2*(-1 + y^2)^2 + 2*x^6*(-1 + y^2)^2 + (-1 + y)^2*(1 + y^2) +
x^8*(-1 + y)^2*(1 + y^2) + 
     2*x^4*(1 + y)^2*(1 + y^2))/(16*x^4*y^2), 
   (I*(-1 + x^4)*(-1 + y)^2*(1 + y^2 + 2*x^2*(1 + y)^2 + x^4*(1 +
y^2)))/(16*x^4*y^2)}, 
  {-(((-1 + x^4)*(-1 + y^2))/(4*x^2*y)), (I*(-1 + x^8)*(-1 +
y)^2)/(8*x^4*y), 
   -(((-1 + y)^2 + x^8*(-1 + y)^2 - 2*x^4*(1 + y)^2)/(8*x^4*y))}}

Remove greatest numerator to get a simple polynomial

In:
factor = 16*x^4*y^2;

In:
Eigenvectors[mat1 factor]

Out:
{{-((1 - x^2 - y + x^2*y)/((1 + x^2)*(1 + y))), -((I*(-1 + x^2))/(1 +
x^2)), 1}, 
  {1/(4*x^2*(-1 + x^4)*y*(-1 + y^2))*(-2*y*((-1 + y)^2 + x^8*(-1 + y)^2
- 2*x^4*(1 + y)^2) + 
      1/2*(-1 - 4*x^2 - 6*x^4 - 4*x^6 - x^8 + 4*y - 8*x^4*y + 4*x^8*y -
6*y^2 + 8*x^2*y^2 - 
        4*x^4*y^2 + 8*x^6*y^2 - 6*x^8*y^2 + 4*y^3 - 8*x^4*y^3 +
4*x^8*y^3 - y^4 - 4*x^2*y^4 - 
        6*x^4*y^4 - 4*x^6*y^4 - x^8*y^4 + (1 + x^2)*Sqrt[1 + 2*x^2 + x^4
- 2*y + 12*x^2*y - 
           2*x^4*y + y^2 + 2*x^2*y^2 + x^4*y^2]*(-1 - 2*x^2 - x^4 + 3*y
- 2*x^2*y + 3*x^4*y - 
          3*y^2 + 2*x^2*y^2 - 3*x^4*y^2 + y^3 + 2*x^2*y^3 + x^4*y^3))) - 
    (I*(-1 + x^8)*(-1 + y)^2*(-4*I*x^2*(-1 + x^4)^2*(-1 + y)^2*y*(-1 +
y^2)*
        (1 + y^2 + 2*x^2*(1 + y)^2 + x^4*(1 + y^2)) - 2*I*x^2*(1 +
x^2)^2*(-1 + y^2)*(1 + y^2)*
        (-2*y*((-1 + y)^2 + x^8*(-1 + y)^2 - 2*x^4*(1 + y)^2) + 
         1/2*(-1 - 4*x^2 - 6*x^4 - 4*x^6 - x^8 + 4*y - 8*x^4*y + 4*x^8*y
- 6*y^2 + 8*x^2*y^2 - 
           4*x^4*y^2 + 8*x^6*y^2 - 6*x^8*y^2 + 4*y^3 - 8*x^4*y^3 +
4*x^8*y^3 - y^4 - 
           4*x^2*y^4 - 6*x^4*y^4 - 4*x^6*y^4 - x^8*y^4 + (1 + x^2)*
            Sqrt[1 + 2*x^2 + x^4 - 2*y + 12*x^2*y - 2*x^4*y + y^2 +
2*x^2*y^2 + x^4*y^2]*
            (-1 - 2*x^2 - x^4 + 3*y - 2*x^2*y + 3*x^4*y - 3*y^2 +
2*x^2*y^2 - 3*x^4*y^2 + y^3 + 
             2*x^2*y^3 + x^4*y^3)))))/(2*x^2*(-1 + x^4)*(-1 + y^2)*
      (4*x^2*(1 + x^2)^2*(-1 + x^8)*(-1 + y)^2*y*(-1 + y^2)*(1 + y^2) - 
       4*x^2*(-1 + x^4)*y*(-1 + y^2)*(2*x^2*(-1 + y^2)^2 + 2*x^6*(-1 +
y^2)^2 + 
         (-1 + y)^2*(1 + y^2) + x^8*(-1 + y)^2*(1 + y^2) + 2*x^4*(1 +
y)^2*(1 + y^2) + 
         1/2*(-1 - 4*x^2 - 6*x^4 - 4*x^6 - x^8 + 4*y - 8*x^4*y + 4*x^8*y
- 6*y^2 + 8*x^2*y^2 - 
           4*x^4*y^2 + 8*x^6*y^2 - 6*x^8*y^2 + 4*y^3 - 8*x^4*y^3 +
4*x^8*y^3 - y^4 - 
           4*x^2*y^4 - 6*x^4*y^4 - 4*x^6*y^4 - x^8*y^4 + (1 + x^2)*
            Sqrt[1 + 2*x^2 + x^4 - 2*y + 12*x^2*y - 2*x^4*y + y^2 +
2*x^2*y^2 + x^4*y^2]*
            (-1 - 2*x^2 - x^4 + 3*y - 2*x^2*y + 3*x^4*y - 3*y^2 +
2*x^2*y^2 - 3*x^4*y^2 + y^3 + 
             2*x^2*y^3 + x^4*y^3))))), 
   -((-4*I*x^2*(-1 + x^4)^2*(-1 + y)^2*y*(-1 + y^2)*(1 + y^2 + 2*x^2*(1
+ y)^2 + 
        x^4*(1 + y^2)) - 2*I*x^2*(1 + x^2)^2*(-1 + y^2)*(1 + y^2)*
       (-2*y*((-1 + y)^2 + x^8*(-1 + y)^2 - 2*x^4*(1 + y)^2) + 
        1/2*(-1 - 4*x^2 - 6*x^4 - 4*x^6 - x^8 + 4*y - 8*x^4*y + 4*x^8*y
- 6*y^2 + 8*x^2*y^2 - 
          4*x^4*y^2 + 8*x^6*y^2 - 6*x^8*y^2 + 4*y^3 - 8*x^4*y^3 +
4*x^8*y^3 - y^4 - 4*x^2*y^4 - 
          6*x^4*y^4 - 4*x^6*y^4 - x^8*y^4 + (1 + x^2)*Sqrt[1 + 2*x^2 +
x^4 - 2*y + 12*x^2*y - 
             2*x^4*y + y^2 + 2*x^2*y^2 + x^4*y^2]*(-1 - 2*x^2 - x^4 +
3*y - 2*x^2*y + 3*x^4*y - 
            3*y^2 + 2*x^2*y^2 - 3*x^4*y^2 + y^3 + 2*x^2*y^3 +
x^4*y^3))))/
     (4*x^2*(1 + x^2)^2*(-1 + x^8)*(-1 + y)^2*y*(-1 + y^2)*(1 + y^2) - 
      4*x^2*(-1 + x^4)*y*(-1 + y^2)*(2*x^2*(-1 + y^2)^2 + 2*x^6*(-1 +
y^2)^2 + 
        (-1 + y)^2*(1 + y^2) + x^8*(-1 + y)^2*(1 + y^2) + 2*x^4*(1 +
y)^2*(1 + y^2) + 
        1/2*(-1 - 4*x^2 - 6*x^4 - 4*x^6 - x^8 + 4*y - 8*x^4*y + 4*x^8*y
- 6*y^2 + 8*x^2*y^2 - 
          4*x^4*y^2 + 8*x^6*y^2 - 6*x^8*y^2 + 4*y^3 - 8*x^4*y^3 +
4*x^8*y^3 - y^4 - 4*x^2*y^4 - 
          6*x^4*y^4 - 4*x^6*y^4 - x^8*y^4 + (1 + x^2)*Sqrt[1 + 2*x^2 +
x^4 - 2*y + 12*x^2*y - 
             2*x^4*y + y^2 + 2*x^2*y^2 + x^4*y^2]*(-1 - 2*x^2 - x^4 +
3*y - 2*x^2*y + 3*x^4*y - 
            3*y^2 + 2*x^2*y^2 - 3*x^4*y^2 + y^3 + 2*x^2*y^3 +
x^4*y^3))))), 1}, 
  {1/(4*x^2*(-1 + x^4)*y*(-1 + y^2))*(-2*y*((-1 + y)^2 + x^8*(-1 + y)^2
- 2*x^4*(1 + y)^2) + 
      1/2*(-1 - 4*x^2 - 6*x^4 - 4*x^6 - x^8 + 4*y - 8*x^4*y + 4*x^8*y -
6*y^2 + 8*x^2*y^2 - 
        4*x^4*y^2 + 8*x^6*y^2 - 6*x^8*y^2 + 4*y^3 - 8*x^4*y^3 +
4*x^8*y^3 - y^4 - 4*x^2*y^4 - 
        6*x^4*y^4 - 4*x^6*y^4 - x^8*y^4 - (1 + x^2)*Sqrt[1 + 2*x^2 + x^4
- 2*y + 12*x^2*y - 
           2*x^4*y + y^2 + 2*x^2*y^2 + x^4*y^2]*(-1 - 2*x^2 - x^4 + 3*y
- 2*x^2*y + 3*x^4*y - 
          3*y^2 + 2*x^2*y^2 - 3*x^4*y^2 + y^3 + 2*x^2*y^3 + x^4*y^3))) - 
    (I*(-1 + x^8)*(-1 + y)^2*(-4*I*x^2*(-1 + x^4)^2*(-1 + y)^2*y*(-1 +
y^2)*
        (1 + y^2 + 2*x^2*(1 + y)^2 + x^4*(1 + y^2)) - 2*I*x^2*(1 +
x^2)^2*(-1 + y^2)*(1 + y^2)*
        (-2*y*((-1 + y)^2 + x^8*(-1 + y)^2 - 2*x^4*(1 + y)^2) + 
         1/2*(-1 - 4*x^2 - 6*x^4 - 4*x^6 - x^8 + 4*y - 8*x^4*y + 4*x^8*y
- 6*y^2 + 8*x^2*y^2 - 
           4*x^4*y^2 + 8*x^6*y^2 - 6*x^8*y^2 + 4*y^3 - 8*x^4*y^3 +
4*x^8*y^3 - y^4 - 
           4*x^2*y^4 - 6*x^4*y^4 - 4*x^6*y^4 - x^8*y^4 - (1 + x^2)*
            Sqrt[1 + 2*x^2 + x^4 - 2*y + 12*x^2*y - 2*x^4*y + y^2 +
2*x^2*y^2 + x^4*y^2]*
            (-1 - 2*x^2 - x^4 + 3*y - 2*x^2*y + 3*x^4*y - 3*y^2 +
2*x^2*y^2 - 3*x^4*y^2 + y^3 + 
             2*x^2*y^3 + x^4*y^3)))))/(2*x^2*(-1 + x^4)*(-1 + y^2)*
      (4*x^2*(1 + x^2)^2*(-1 + x^8)*(-1 + y)^2*y*(-1 + y^2)*(1 + y^2) - 
       4*x^2*(-1 + x^4)*y*(-1 + y^2)*(2*x^2*(-1 + y^2)^2 + 2*x^6*(-1 +
y^2)^2 + 
         (-1 + y)^2*(1 + y^2) + x^8*(-1 + y)^2*(1 + y^2) + 2*x^4*(1 +
y)^2*(1 + y^2) + 
         1/2*(-1 - 4*x^2 - 6*x^4 - 4*x^6 - x^8 + 4*y - 8*x^4*y + 4*x^8*y
- 6*y^2 + 8*x^2*y^2 - 
           4*x^4*y^2 + 8*x^6*y^2 - 6*x^8*y^2 + 4*y^3 - 8*x^4*y^3 +
4*x^8*y^3 - y^4 - 
           4*x^2*y^4 - 6*x^4*y^4 - 4*x^6*y^4 - x^8*y^4 - (1 + x^2)*
            Sqrt[1 + 2*x^2 + x^4 - 2*y + 12*x^2*y - 2*x^4*y + y^2 +
2*x^2*y^2 + x^4*y^2]*
            (-1 - 2*x^2 - x^4 + 3*y - 2*x^2*y + 3*x^4*y - 3*y^2 +
2*x^2*y^2 - 3*x^4*y^2 + y^3 + 
             2*x^2*y^3 + x^4*y^3))))), 
   -((-4*I*x^2*(-1 + x^4)^2*(-1 + y)^2*y*(-1 + y^2)*(1 + y^2 + 2*x^2*(1
+ y)^2 + 
        x^4*(1 + y^2)) - 2*I*x^2*(1 + x^2)^2*(-1 + y^2)*(1 + y^2)*
       (-2*y*((-1 + y)^2 + x^8*(-1 + y)^2 - 2*x^4*(1 + y)^2) + 
        1/2*(-1 - 4*x^2 - 6*x^4 - 4*x^6 - x^8 + 4*y - 8*x^4*y + 4*x^8*y
- 6*y^2 + 8*x^2*y^2 - 
          4*x^4*y^2 + 8*x^6*y^2 - 6*x^8*y^2 + 4*y^3 - 8*x^4*y^3 +
4*x^8*y^3 - y^4 - 4*x^2*y^4 - 
          6*x^4*y^4 - 4*x^6*y^4 - x^8*y^4 - (1 + x^2)*Sqrt[1 + 2*x^2 +
x^4 - 2*y + 12*x^2*y - 
             2*x^4*y + y^2 + 2*x^2*y^2 + x^4*y^2]*(-1 - 2*x^2 - x^4 +
3*y - 2*x^2*y + 3*x^4*y - 
            3*y^2 + 2*x^2*y^2 - 3*x^4*y^2 + y^3 + 2*x^2*y^3 +
x^4*y^3))))/
     (4*x^2*(1 + x^2)^2*(-1 + x^8)*(-1 + y)^2*y*(-1 + y^2)*(1 + y^2) - 
      4*x^2*(-1 + x^4)*y*(-1 + y^2)*(2*x^2*(-1 + y^2)^2 + 2*x^6*(-1 +
y^2)^2 + 
        (-1 + y)^2*(1 + y^2) + x^8*(-1 + y)^2*(1 + y^2) + 2*x^4*(1 +
y)^2*(1 + y^2) + 
        1/2*(-1 - 4*x^2 - 6*x^4 - 4*x^6 - x^8 + 4*y - 8*x^4*y + 4*x^8*y
- 6*y^2 + 8*x^2*y^2 - 
          4*x^4*y^2 + 8*x^6*y^2 - 6*x^8*y^2 + 4*y^3 - 8*x^4*y^3 +
4*x^8*y^3 - y^4 - 4*x^2*y^4 - 
          6*x^4*y^4 - 4*x^6*y^4 - x^8*y^4 - (1 + x^2)*Sqrt[1 + 2*x^2 +
x^4 - 2*y + 12*x^2*y - 
             2*x^4*y + y^2 + 2*x^2*y^2 + x^4*y^2]*(-1 - 2*x^2 - x^4 +
3*y - 2*x^2*y + 3*x^4*y - 
            3*y^2 + 2*x^2*y^2 - 3*x^4*y^2 + y^3 + 2*x^2*y^3 +
x^4*y^3))))), 1}}

In:
vec //. toTrig

Out:  ....

restores the trigonometric functions


You may use TrigToExp or something.   


Regards

Roland Franzius

Ivan Stegic schrieb:
> 
> Hello everyone...
> 
> I've searched the archives extensively, and found various answers to my
> problem. However, none of them helped me. I am trying to find the
> eigenvectors to a 3x3 matrix. I keep running into Out of Memory Exiting
> problems, whether I run it with the frontend or without. I am running
> Mathematica 3 on a RedHat Linux 5.1, Kernel 2.0.35  Pentium II 400 with
> 128MB of RAM. The matrix I have contains 2 variables, and I am trying to
> solve the for the Eigenvectors symbolically in terms of these variables.
> The catch is that the variables are trigonometric functions. Following is
> the command I execute. The result is "Out of Memory. Exiting." What can I
> do? Could someone else try this on their more powerful machines, or will it
> still run into the same problem? Or is there a way of simplifying this? Or
> the matrix?
> 
> Thanks very much,
> Ivan.
> 
> ------------------------
> [ivan@apollo ivan]$ more jobs/i.txt
> Eigenvectors[{{Cos[q]^2 - Cos[2*p]*Sin[q]^2,
>    1.*(Sin[2*p]*Sin[2.*p]*Sin[q] + Cos[p]^2*Cos[2.*p]*Sin[2*q]),
>    1.*Cos[2.*p]*Sin[2*p]*Sin[q] - 1.*Cos[p]^2*Sin[2.*p]*Sin[2*q]},
>   {-(Cos[p]^2*Sin[2*q]), 1.*Cos[q]*Sin[2*p]*Sin[2.*p] -
>     1.*Cos[2.*p]*(-(Cos[2*p]*Cos[q]^2) + Sin[q]^2),
>    1.*(Cos[2.*p]*Cos[q]*Sin[2*p] +
>       Sin[2.*p]*(-(Cos[2*p]*Cos[q]^2) + Sin[q]^2))},
>   {Sin[2*p]*Sin[q], -1.*Cos[2.*p]*Cos[q]*Sin[2*p] + 1.*Cos[2*p]*Sin[2.*p],
>    1.*(Cos[2*p]*Cos[2.*p] + Cos[q]*Sin[2*p]*Sin[2.*p])}}]>>>EVec-Symb;
> [ivan@apollo ivan]$
> ------------------------
> 
> (For those who are interested, this matrix is a rotation matrix that takes
> the orthonormal basis of a cone rotating around a replica cone from its
> initial to its final position. p and q are the cone semi-angle, and the
> parametrized position of the rotated cone respectively.)


-- 
Roland Franzius

  +++ exactly <<n>> lines of this message have value <<FALSE>> +++


  • Prev by Date: Re: out of memory, again.
  • Next by Date: Re: Number formatting for financial applications
  • Previous by thread: Re: out of memory, again.
  • Next by thread: Re: Integrate a matrix-function