# HP Forums

Full Version: SVD
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
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
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
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!
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
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!
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).
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
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.
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :