HP Forums
exact results with roots - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: exact results with roots (/thread-2918.html)



exact results with roots - salvomic - 01-24-2015 01:29 PM

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()...

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

cheers
Salvo


RE: exact results with roots - Han - 01-24-2015 01:32 PM

http://www.hpmuseum.org/forum/thread-18.html

Would that fit your needs?


RE: exact results with roots - salvomic - 01-24-2015 03:06 PM

(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...


RE: exact results with roots - Han - 01-24-2015 06:23 PM

(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.


RE: exact results with roots - salvomic - 01-24-2015 06:41 PM

(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


RE: exact results with roots - salvomic - 01-25-2015 04:16 PM

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!


RE: exact results with roots - Han - 01-25-2015 04:21 PM

(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.


RE: exact results with roots - salvomic - 01-25-2015 05:56 PM

(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...


RE: exact results with roots - Han - 01-25-2015 10:33 PM

(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.


RE: exact results with roots - salvomic - 01-25-2015 10:39 PM

(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


RE: exact results with roots - salvomic - 03-05-2015 10:30 AM

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

Han, please,
is it possible to rationalize (symbolic representation) using QPI (on in other way) some "classical" irrational or transcendental expressions, like √π (1.77245385091), π^2 (9.86960440109), 2/π, 1/√π, golden ratio (0.618 033 988 749 894 = ((\sqrt(5) -1)/2), euler_gamma ...?

thanks for info!

Salvo