SVD
12-13-2013, 08:17 PM
Post: #1
 jgreenb2 Member Posts: 50 Joined: Dec 2013
SVD
I can't seem to get SVD to work for non-square matrices. This works perfectly on the 50g but fails on the Prime...unless I'm doing something wrong. Anyone else seen this?
12-13-2013, 08:40 PM
Post: #2
 Mark Hardman Senior Member Posts: 525 Joined: Dec 2013
RE: SVD
On the latest firmware:

$SVD\left ( \begin{bmatrix} 1 & -1 \\ 1 & -1 \\ \sqrt{3} & 0 \end{bmatrix} \right )$

Gives "Error: Bad Argument Type" in both Home and CAS.

Looks like a definite bug to me.

Mark Hardman

Ceci n'est pas une signature.
12-13-2013, 09:16 PM
Post: #3
 Mark Hardman Senior Member Posts: 525 Joined: Dec 2013
RE: SVD
If it is a bug, it is a minor bug.

Try entering the SVD command in lowercase:

$\textrm{simplify} \left ( \textrm{svd}\left ( \begin{bmatrix} 1 & -1 \\ 1 & -1 \\ \sqrt{3} & 0 \end{bmatrix} \right ) \right )$

Gives a result of:

$\begin{bmatrix} 0.5477 & 0.7071 & -0.4472 \\ 0.5477 & -0.7071 & -0.4472 \\ 0.6325 & 5.1840 \times 10^{-17} & 0.7746 \end{bmatrix}$

Mark Hardman

Ceci n'est pas une signature.
12-13-2013, 09:34 PM (This post was last modified: 12-13-2013 09:37 PM by jgreenb2.)
Post: #4
 jgreenb2 Member Posts: 50 Joined: Dec 2013
RE: SVD
Mark,

Thanks. How did you think to do this? The toolbox menu inserts in uppercase and the manual defines SVD in uppercase. Did you just try at random or is there some logic to when this matters?

Also, using SVD() (uppercase) on a square matrix seems to work...very odd!
12-13-2013, 09:44 PM
Post: #5
 Mark Hardman Senior Member Posts: 525 Joined: Dec 2013
RE: SVD
Search the old forum archives. The difference between UPPERCASE/lowercase for commands on the Prime has already generated several other bug reports. It is a matter of confusion that the Prime Team will hopefully address in a future release.

Mark Hardman

Ceci n'est pas une signature.
12-13-2013, 10:03 PM
Post: #6
 jgreenb2 Member Posts: 50 Joined: Dec 2013
RE: SVD
Thanks, I'll check it out. I admit I want to like this calculator but it's been a bit of a trial so far!
12-15-2013, 10:04 AM
Post: #7
 parisse Senior Member Posts: 1,322 Joined: Dec 2013
RE: SVD
The current algorithm covered only square real matrices (as you can guess, implementing numeric algorithms is not my main business, and giac/xcas uses LAPACK for svd, therefore it was only required here), svd was also sometimes able to return an answer for rectangular matrices. I'm improving it, it will handle rectangular real or complex matrices that are well conditionned (0 or small singular values will not be handled, I'm not writing a dedicated numerical algorithm for that, just reusing existing routines).
12-15-2013, 03:42 PM (This post was last modified: 12-15-2013 03:46 PM by jgreenb2.)
Post: #8
 jgreenb2 Member Posts: 50 Joined: Dec 2013
RE: SVD
Parisse,

Thanks for the clarification. Nice to know these things are being worked out. As long as there's a reasonable error message for ill-conditioned matrices I'll be happy

It would also be nice if it worked correctly in RPN: svd() should take a matrix from the stack and just push U, S, V back onto the stack.

--jeff
12-16-2013, 09:22 AM
Post: #9
 parisse Senior Member Posts: 1,322 Joined: Dec 2013
RE: SVD
Actually, you don't really need a message for ill-conditionned matrix, just look at the ratio between the largest singular value and the smallest one in s.
 « Next Oldest | Next Newest »