# HP Forums

Full Version: exact results with roots
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi all,
I wonder if there is a way to get something like the "SQ()" function in HP50:
For example I input √2 in CAS, then I press "ab/c" and get approx(), that's 1.414213..., but if I press again "ab/c" I get a fraction and not the root (√2) again, like it was in HP 50g, using SQ()...

If not, I hope this function could be added in a next firmware upgrade...

cheers
Salvo
(01-24-2015 01:32 PM)Han Wrote: [ -> ]http://www.hpmuseum.org/forum/thread-18.html

Would that fit your needs?

yes, thank you!
very interesting.

Is there a way to use it with a matrix? :-)
ex. having a matrix with [[1, 1.414213...], [3.141592..., 1.7320...]] to get [[1, √2], [∏, √3]]... The program, as it is, give error...
I found that we could use this method:
1. use mat2list with the matrix
2. use QPI
3. use list2mat; but this one require the matrix dimension
I hope to get an automatic program for that...
(01-24-2015 03:06 PM)salvomic Wrote: [ -> ]
(01-24-2015 01:32 PM)Han Wrote: [ -> ]http://www.hpmuseum.org/forum/thread-18.html

Would that fit your needs?

yes, thank you!
very interesting.

Is there a way to use it with a matrix? :-)
ex. having a matrix with [[1, 1.414213...], [3.141592..., 1.7320...]] to get [[1, √2], [∏, √3]]... The program, as it is, give error...
I found that we could use this method:
1. use mat2list with the matrix
2. use QPI
3. use list2mat; but this one require the matrix dimension
I hope to get an automatic program for that...

You can, except Home view by design forces all matrices to be numeric and does not allow symbolic objects. Since all PPL programs are considered to be "Home" programs, the entries inside each matrix will always be converted back to decimal form. You can get what you want using by converting over to a CAS program, though.
(01-24-2015 06:23 PM)Han Wrote: [ -> ]You can, except Home view by design forces all matrices to be numeric and does not allow symbolic objects. Since all PPL programs are considered to be "Home" programs, the entries inside each matrix will always be converted back to decimal form. You can get what you want using by converting over to a CAS program, though.

ok, thank you.

salvo
any help to have a template for this? - I'm not so able for now with the new language...

(having a matrix selected)
(matdim is a variable = matrix dimension)

- mat2list (M) ;-)
- apply QPI program ;-)
- list2mat (M, matdim)
- results (again the matrix but with QPI applied)

:-)

Thank you in advance!
(01-25-2015 04:16 PM)salvomic Wrote: [ -> ]any help to have a template for this? - I'm not so able for now with the new language...

(having a matrix selected)
(matdim is a variable = matrix dimension)

- mat2list (M) ;-)
- apply QPI program ;-)
- list2mat (M, matdim)
- results (again the matrix but with QPI applied)

:-)

Thank you in advance!

Code:
#cas qpimat(m):= BEGIN   local s:=dim(m);   m:=mat2list(m);   m:=QPI(m);   m:=list2mat(m,s(2));    return m; END; #end

Create a new program named qpimat and make sure it's a CAS program. Then type in the code above. Note that you must be in CAS view in order to see symbolic matrices. In Home view, qpimat does nothing.
(01-25-2015 04:21 PM)Han Wrote: [ -> ]...
Create a new program named qpimat and make sure it's a CAS program. Then type in the code above. Note that you must be in CAS view in order to see symbolic matrices. In Home view, qpimat does nothing.

thank you a lot!
I created a program "QPIMAT" with Connectivy Kit, pasted the code and sent to calc, it works well with a test matrix, writing "qpimat()" directly, but I cannot see it listed in Catalog User (I've only QPI): why?
It's on Programs list...
(01-25-2015 05:56 PM)salvomic Wrote: [ -> ]thank you a lot!
I created a program "QPIMAT" with Connectivy Kit, pasted the code and sent to calc, it works well with a test matrix, writing "qpimat()" directly, but I cannot see it listed in Catalog User (I've only QPI): why?
It's on Programs list...

It's technically a CAS function. Perhaps this is why it is not listed. In the CAS view, you can create functions; for example: f(x):=x^2. You can see that if all such functions were listed as programs, it can cause a lot of clutter. Perhaps this may change in the future... I have no idea.
(01-25-2015 10:33 PM)Han Wrote: [ -> ]It's technically a CAS function. Perhaps this is why it is not listed. In the CAS view, you can create functions; for example: f(x):=x^2. You can see that if all such functions were listed as programs, it can cause a lot of clutter. Perhaps this may change in the future... I have no idea.

yes,
I understand.
The problem is related to the fact we can't use "EXPORT" with #cas/#end structure, I think, so the function won't listed.
I hope in the future could be a way to get that, as it's very useful!

Thanks again!

salvo
(01-25-2015 10:33 PM)Han Wrote: [ -> ]It's technically a CAS function. ...