Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: symbolic solver question
Replies: 3   Last Post: Dec 15, 2012 12:37 PM

 Messages: [ Previous | Next ]
 Steven Lord Posts: 18,038 Registered: 12/7/04
Re: symbolic solver question
Posted: Dec 12, 2012 9:22 AM

"Paul Mennen" <nospam@mennen.org> wrote in message
news:ka9ob8\$r68\$1@newscl01ah.mathworks.com...
> Here is my matlab session:
>

>>> syms s a A
>>> A = [0 0 -2*a a; 0 0 a -2*a; 1 0 0 0; 0 1 0 0];
>>> eig(A)

>
> ans =
>
> (-a)^(1/2)
> -(-a)^(1/2)
> 3^(1/2)*(-a)^(1/2)
> -3^(1/2)*(-a)^(1/2)
>
> OK, so far so good.
> I asked for the eigenvalues of the matrix A and it shows the 4 eigenvalues
> that I expected. So then for the sake of understanding the solver, I
> though I would try to compute the eigenvalues by setting the determinant
> of (sI-A) equal to zero:
>

>>> solve('det(s*eye(4)-A) = 0',s)
> Warning: Explicit solution could not be found.
>
> Why doesn't this work?

Because you're passing a string into SOLVE and so it can't "see" the
variable A you've defined in your workspace. It's treating it as a general
symbolic value. Depending on the version of MATLAB you're using, either:

solve(det(s*eye(4)-A)==0, s)

or:

solve(det(s*eye(4)-A), s)

should work. I would recommend using EIG instead of this SOLVE call
particularly if you're going to work with larger matrices.

--
Steve Lord
slord@mathworks.com
http://www.mathworks.com

Date Subject Author
12/12/12 Paul Mennen
12/12/12 Steven Lord
12/15/12 Paul Mennen
12/12/12 Alan Weiss