solving unknowns in matrix - in Maxima



Evan Cooch <evan.cooch at gmail.com> writes:
> Greetings --
>
> Consider the following matrix:
>
> a : matrix([-0.7-0.3*h1,0.6-0.6*h1],[0.5-0.5*h2,-0.35-0.65*h2]);
>
> I'm trying to solve for h1 and h2, such that dominant eigenvalue of a is 0.
>
> I know how to do this in a couple of other CAS systems, but am stumped
> with Maxima. I know the solution in thiscase is
>
> h2=(11-81*h1)/(151-21*h1)
>
> Any pointers would be much appreciated (to aid and abet my attempt to
> port a bunch of teaching material to Maxima).
>
> Thanks!

An almost complete answer:

Firstly, let's not use the icky decimals any longer than necessary:

(%i1) a : rat(matrix([-0.7-0.3*h1,0.6-0.6*h1],[0.5-0.5*h2,-0.35-0.65*h2]));
<snip: warnings from rat>
                          [   3 h1 + 7    3 h1 - 3  ]
                          [ - --------  - --------  ]
                          [      10          5      ]
(%o1)/R/                  [                         ]
                          [    h2 - 1     13 h2 + 7 ]
                          [  - ------   - --------- ]
                          [      2           20     ]

Right, now use eivals to grab the eigenvalues:

(%i2) load("eigen")$

(%i3) evals: first(eivals(a));
                     2                            2
(%o3) [- (sqrt(169 h2  + (324 h1 - 662) h2 + 36 h1  - 396 h1 + 529) + 13 h2
 + 6 h1 + 21)/40, 
           2                            2
sqrt(169 h2  + (324 h1 - 662) h2 + 36 h1  - 396 h1 + 529) - 13 h2 - 6 h1 - 21
-----------------------------------------------------------------------------]
                                     40


The solve() function doesn't seem to have much luck, but to_poly_solve
does much better:

(%i4) load("to_poly_solve")$
*** output flushed ***
(%i5) to_poly_solve(first(evals)=0, h2);
                                       2
                    %pi          126 h1  + 588 h1 - 3314
(%o5) %union(%if((- --- < parg(- -----------------------))
                     2                 21 h1 - 151
                     2
               126 h1  + 588 h1 - 3314     %pi         81 h1 - 11
  %and (parg(- -----------------------) <= ---), [h2 = -----------], %union()))
                     21 h1 - 151            2          21 h1 - 151
(%i6) to_poly_solve(second(evals)=0, h2);
                                     2
                    %pi        126 h1  + 588 h1 - 3314
(%o6) %union(%if((- --- < parg(-----------------------))
                     2               21 h1 - 151
                     2
               126 h1  + 588 h1 - 3314     %pi         81 h1 - 11
    %and (parg(-----------------------) <= ---), [h2 = -----------], %union()))
                     21 h1 - 151            2          21 h1 - 151

Frustratingly, I can't see how to tell Maxima that h1 and h2 are real,
so all the parg values are zero. Also, the %union with only one element
is a bit rubbish. Anyway, I can do one more thing:

(%i7) eq: first(second(first(%o6)));
                                    81 h1 - 11
(%o7)                          h2 = -----------
                                    21 h1 - 151

Then:

(%i21) radcan(second(evals)), eq;
(%o21)                                 0


Looking at the picture given by

  plot2d(first(evals), [h1, -10, 5]), eq;

it looks like something more complicated is going on with the other
eigenvalue. Maybe you know a bit more about the situation - I'd be
interested to know what the graph is saying.


Rupert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 315 bytes
Desc: not available
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20130102/1d03f8c4/attachment.pgp>;