Post Reply 
overflow
03-08-2020, 04:57 AM
Post: #1
overflow
I have calculator competitions at school and there is a company called UIL that makes the test we take and the rest of the schools in our area, they have a question that has a number like 2018 raised the power 2442 or something and my calculator hits an overflow, is there a program out there that can let me solve this on the calculator? I use an HP prime btw
Find all posts by this user
Quote this message in a reply
03-08-2020, 01:07 PM
Post: #2
RE: overflow
Here's one way of doing 2018^2442 on the Prime. Please note that in CAS, pressing the LOG key types the log10() function, and Shift LOG types the alog10() function.

(1) Be sure you're in CAS view. This doesn't work in Home. Why? Dunno.
(2) log10(2018.)*2442 [Be sure to include the decimal point!] --> 8070.61747736
(3) alog10(fp(Ans)) --> 4.1445497719

The first result (in step 2) tells us the exponent of the final answer: 8070. Ignore everything after the decimal point.
The second result (in step 3) gives us the mantissa of the final answer: 4.14455 (rounded off)
Therefore, the answer for 2018^2442 is 4.14455 × 10^8070.

Please note that step 3 will almost always return some inaccurate digits, since it chops off the integer part of step 2's result, thereby losing that many digits of accuracy. In the above example, step 3 returns 4.1445497719, but the last 3 digits of that are wrong. So always discard the last few digits from step 3's result.

Programming the above method is trivial, and is left to the student for homework. Smile

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
03-08-2020, 02:37 PM
Post: #3
RE: overflow
This reminds me that the native LongFloat "library" is still missing.
I would really like to see that
and
a proper RPL stack (internally using list processing)
I could finally retire my iron-age hp 50G
and solely depend on the Prime.
– –
VPN
Find all posts by this user
Quote this message in a reply
03-08-2020, 02:52 PM
Post: #4
RE: overflow
Another way, by scaling x^y to k (1+ε)^y

2018^2442
= 1.009^2442 * 4 * 2^2440 * 1000^2442
= 1.009^2442 * 4 * 1.024^244 * 1000^(2442+244)
≈ 4.144549796E12 * 10^8058
= 4.144549796 * 10^8070
Find all posts by this user
Quote this message in a reply
03-08-2020, 04:25 PM
Post: #5
RE: overflow
Texas UIL? Did that as a kid.

Sounds like this question was intentionally written to force students to use properties of logs as Joe pointed out. I don't know of any calculators that go to 10^8070 natively. HP's typically go to 10^499, the TI-84+: 10^99, TI-Nspire:10^999. Perhaps they picked such a large value in case some kid had a DM42 which goes to 10^6144.
Find all posts by this user
Quote this message in a reply
03-08-2020, 05:43 PM
Post: #6
RE: overflow
(03-08-2020 04:25 PM)Wes Loewer Wrote:  Texas UIL? Did that as a kid.

Sounds like this question was intentionally written to force students to use properties of logs as Joe pointed out. I don't know of any calculators that go to 10^8070 natively. HP's typically go to 10^499, the TI-84+: 10^99, TI-Nspire:10^999. Perhaps they picked such a large value in case some kid had a DM42 which goes to 10^6144.

SysRPL allows nnnnn exponents (old 48 series)
- -
VPN
Find all posts by this user
Quote this message in a reply
03-08-2020, 07:22 PM
Post: #7
RE: overflow
(03-08-2020 05:43 PM)CyberAngel Wrote:  SysRPL allows nnnnn exponents (old 48 series)

Nice. I hadn't thought of that.

I looked up the Texas UIL rules and it says that the calculator must have its memory cleared before the test but then students can hand-enter whatever programs they want after the test has started. So no emacs, but you could edit a string and run ASM.

Of course, by the time you do all that, you could have had the answer using logs. Smile
Find all posts by this user
Quote this message in a reply
03-08-2020, 07:52 PM
Post: #8
RE: overflow
(03-08-2020 04:25 PM)Wes Loewer Wrote:  Texas UIL? Did that as a kid.

To clarify, I competed in one Texas UIL Math competition in Algebra and Geometry. I didn't even have a calculator yet as I was still using a slide rule. UIL used to have a slide rule competitions. It's been a few years, but as I recall, the competition that year allowed either slide rule or calculator.

I have a nephew who did UIL Calculator contests a few years ago. He told me the coach had them all use HP calculators as RPN was so much faster.
Find all posts by this user
Quote this message in a reply
03-08-2020, 08:13 PM (This post was last modified: 03-08-2020 08:13 PM by DA74254.)
Post: #9
RE: overflow
(03-08-2020 01:07 PM)Joe Horn Wrote:  Here's one way of doing 2018^2442 on the Prime. Please note that in CAS, pressing the LOG key types the log10() function, and Shift LOG types the alog10() function.

(1) Be sure you're in CAS view. This doesn't work in Home. Why? Dunno.
(2) log10(2018.)*2442 [Be sure to include the decimal point!] --> 8070.61747736
(3) alog10(fp(Ans)) --> 4.1445497719

The first result (in step 2) tells us the exponent of the final answer: 8070. Ignore everything after the decimal point.
The second result (in step 3) gives us the mantissa of the final answer: 4.14455 (rounded off)
Therefore, the answer for 2018^2442 is 4.14455 × 10^8070.

Please note that step 3 will almost always return some inaccurate digits, since it chops off the integer part of step 2's result, thereby losing that many digits of accuracy. In the above example, step 3 returns 4.1445497719, but the last 3 digits of that are wrong. So always discard the last few digits from step 3's result.

Programming the above method is trivial, and is left to the student for homework. Smile

My emphasis. What do you mean with this? I just get a "syntax error" on that. What does "fp" mean?

Esben
15C CE, 28s, 35s, 49G+, 50G, Prime G2 HW D, SwissMicros DM32, DM42, DM42n, WP43 Pilot
Elektronika MK-52 & MK-61
Find all posts by this user
Quote this message in a reply
03-08-2020, 08:29 PM (This post was last modified: 03-08-2020 08:41 PM by J-F Garnier.)
Post: #10
RE: overflow
(03-08-2020 01:07 PM)Joe Horn Wrote:  (1) Be sure you're in CAS view. This doesn't work in Home. Why? Dunno.
(2) log10(2018.)*2442 [Be sure to include the decimal point!] --> 8070.61747736
(3) alog10(fp(Ans)) --> 4.1445497719

... Therefore, the answer for 2018^2442 is 4.14455 × 10^8070.


(03-08-2020 02:52 PM)Albert Chan Wrote:  Another way, by scaling x^y to k (1+ε)^y

2018^2442
= 1.009^2442 * 4 * 2^2440 * 1000^2442
= 1.009^2442 * 4 * 1.024^244 * 1000^(2442+244)
≈ 4.144549796E12 * 10^8058
= 4.144549796 * 10^8070

Combining the simple method 1 and the more accurate method 2:
(1) 2018^2442 = 2.018^2442 * 10^(3*2442)
(2) log10(2.018)*2442--> 744.617477362
(3) alog10(fp(Ans)) --> 4.14454979627
(4) 3*2442+744=8070

Therefore, the answer for 2018^2442 is 4.144549796 × 10^8070.

J-F
Visit this user's website Find all posts by this user
Quote this message in a reply
03-08-2020, 09:23 PM
Post: #11
RE: overflow
(03-08-2020 01:07 PM)Joe Horn Wrote:  (1) Be sure you're in CAS view. This doesn't work in Home. Why? Dunno.
(2) log10(2018.)*2442 [Be sure to include the decimal point!] --> 8070.61747736
(3) alog10(fp(Ans)) --> 4.1445497719

It's weird! In HOME mode, fp(Ans) returns the proper value but alog10(fp(Ans)) returns 1.
If you manually type in alog10(.61747736) then 4.1445497719 is displayed. I guess there are separate Ans registers for Home and CAS modes?

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
03-08-2020, 09:38 PM (This post was last modified: 03-08-2020 09:39 PM by DA74254.)
Post: #12
RE: overflow
Thank you toml_12953 Smile
I got it now. I embarrasingly added an extra set of parenthesis, which wasn't to my Primes liking..

Esben
15C CE, 28s, 35s, 49G+, 50G, Prime G2 HW D, SwissMicros DM32, DM42, DM42n, WP43 Pilot
Elektronika MK-52 & MK-61
Find all posts by this user
Quote this message in a reply
03-08-2020, 10:12 PM
Post: #13
RE: overflow
(03-08-2020 09:23 PM)toml_12953 Wrote:  
(03-08-2020 01:07 PM)Joe Horn Wrote:  (1) Be sure you're in CAS view. This doesn't work in Home. Why? Dunno.
(2) log10(2018.)*2442 [Be sure to include the decimal point!] --> 8070.61747736
(3) alog10(fp(Ans)) --> 4.1445497719

It's weird! In HOME mode, fp(Ans) returns the proper value but alog10(fp(Ans)) returns 1.
If you manually type in alog10(.61747736) then 4.1445497719 is displayed. I guess there are separate Ans registers for Home and CAS modes?

I just tap twice on the needed argument in the history and I gets copied into prompt line.
No ANS needed.
– –
VPN
Find all posts by this user
Quote this message in a reply
03-08-2020, 11:55 PM
Post: #14
RE: overflow
(03-08-2020 02:37 PM)CyberAngel Wrote:  This reminds me that the native LongFloat "library" is still missing.
I would really like to see that
and
a proper RPL stack (internally using list processing)
I could finally retire my iron-age hp 50G
and solely depend on the Prime.
– –
VPN

Yeah, what he said! Big Grin

Actually, no LongFloat required. The HP50 in exact mode gives the, er, exact answer- all 8071 digits. It does take almost 3 minutes however.
Find all posts by this user
Quote this message in a reply
03-11-2020, 05:16 PM (This post was last modified: 03-11-2020 05:26 PM by StephenG1CMZ.)
Post: #15
RE: overflow
Although not "Longfloat" there is an extended precision library that might help.
https://www.hpmuseum.org/forum/thread-13024.html
(I don't know if it implements ^)

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
03-11-2020, 06:18 PM
Post: #16
RE: overflow
(03-11-2020 05:16 PM)StephenG1CMZ Wrote:  Although not "Longfloat" there is an extended precision library that might help.
https://www.hpmuseum.org/forum/thread-13024.html
(I don't know if it implements ^)

Not quite the same, bit pretty good.
Thanks for the link!
– –
VPN
Find all posts by this user
Quote this message in a reply
Post Reply 




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