Post Reply 
Exact items for a matrix from a program
06-07-2015, 08:07 PM
Post: #1
Exact items for a matrix from a program
hi all,
there is a way to get exact results for the items of a matrix, from a Home program (non CAS program)?
For example, in my last program, if a matrix is returned it has [[1, 0.5], [0.5, 0.25]]and I would like to return also in CAS view [[1, 1/2], [1/1, ¼]] without hitting "a b/c".
Something like the nice QPI (and QPImat) program by Han (inside the program)...

I tried to use exact() but no luck for now...

Thank you
Salvo

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
06-08-2015, 06:56 AM
Post: #2
RE: Exact items for a matrix from a program
(06-07-2015 08:07 PM)salvomic Wrote:  hi all,
there is a way to get exact results for the items of a matrix, from a Home program (non CAS program)?
For example, in my last program, if a matrix is returned it has [[1, 0.5], [0.5, 0.25]]and I would like to return also in CAS view [[1, 1/2], [1/1, ¼]] without hitting "a b/c".
Something like the nice QPI (and QPImat) program by Han (inside the program)...

I tried to use exact() but no luck for now...

Thank you
Salvo

This isn't exactly what you seek, but the STRING function has an option to convert decimals into fractions. For example:

STRING([[.1,.2],[.3,.4]],8) --> "[[1/10,1/5],[3/10,2/5]]"

The output is ugly, not "Textbook" style, but at least the fractions are there. If you want to present the result in a pretty fashion, you'd have to loop through the matrix and STRING each entry separately, I suppose.

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
06-08-2015, 07:43 AM
Post: #3
RE: Exact items for a matrix from a program
(06-08-2015 06:56 AM)Joe Horn Wrote:  This isn't exactly what you seek, but the STRING function has an option to convert decimals into fractions. For example:

STRING([[.1,.2],[.3,.4]],8) --> "[[1/10,1/5],[3/10,2/5]]"

The output is ugly, not "Textbook" style, but at least the fractions are there. If you want to present the result in a pretty fashion, you'd have to loop through the matrix and STRING each entry separately, I suppose.

thank you Joe, this works, but I want to export numbers to be treated after the calculation...
For example, ref() gives exact result, but exported from inside my program it doesn't export fractions but reals... (also using exact() command)...

Salvo

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
06-10-2015, 05:50 AM
Post: #4
RE: Exact items for a matrix from a program
Then I'd suggest using a loop that scans through the entire matrix (e.g. R goes from 1 to rowDim(M1), and C goes from 1 to colDim(M1)), and outputs exact(row(col(M1,C),R) at each iteration. Or something like that. Not a single command, but it works.

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
06-10-2015, 06:27 AM
Post: #5
RE: Exact items for a matrix from a program
(06-10-2015 05:50 AM)Joe Horn Wrote:  Then I'd suggest using a loop that scans through the entire matrix (e.g. R goes from 1 to rowDim(M1), and C goes from 1 to colDim(M1)), and outputs exact(row(col(M1,C),R) at each iteration. Or something like that. Not a single command, but it works.

thank you, I'll try it

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)