[Prime CAS] ichinrem negative results
|
03-07-2014, 11:54 PM
Post: #3
|
|||
|
|||
RE: [Prime CAS] ichinrem negative results
(03-07-2014 08:25 AM)Didier Lachieze Wrote: The CAS ichinrem function (Integer Chinese Remainder) returns often negative results. ... While both results [235 9009] and [-8774 9009] are valid and equivalent, I would prefer to have always the same result a modulo b with a in the interval [0,b[ The same problem drives me crazy on the HP 50g. Like the Prime, its CAS modulo functions (not MOD itself) sometimes return negative results. I think your only hope is to create a user-defined function or program which uses the old MOD function to rectify the result. Here's a tiny program that takes the matrix input for ichinrem and returns the smallest positive result: Code: EXPORT chin(M0) ichinrem([[12,23],[123,234]]) --> [-5025, 5382] chin([[12,23],[123,234]]) --> 357 If you want the modulus also, change "RETURN m(1) MOD m(2)" in the program to "RETURN [m(1) MOD m(2),m(2)]". Then the program would return [357, 5382] for the above example. I really wish there were a more elegant way to do this, but that's how I've handled it on the 50g for many years. <0|ΙΈ|0> -Joe- |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
[Prime CAS] ichinrem negative results - Didier Lachieze - 03-07-2014, 08:25 AM
RE: [Prime CAS] ichinrem negative results - Dominik Holenstein - 03-07-2014, 09:31 AM
RE: [Prime CAS] ichinrem negative results - Joe Horn - 03-07-2014 11:54 PM
RE: [Prime CAS] ichinrem negative results - Didier Lachieze - 03-09-2014, 08:49 AM
RE: [Prime CAS] ichinrem negative results - Joe Horn - 03-09-2014, 04:34 PM
RE: [Prime CAS] ichinrem negative results - Stefan - 03-09-2014, 05:11 PM
RE: [Prime CAS] ichinrem negative results - Didier Lachieze - 05-28-2014, 06:39 AM
|
User(s) browsing this thread: 2 Guest(s)