Post Reply 
HP 15C and INT(1/√(1-x),0,1)
11-26-2017, 07:51 PM (This post was last modified: 11-26-2017 07:57 PM by salvomic.)
Post: #1
HP 15C and INT(1/√(1-x),0,1)
hi,
I'm trying to get in HP 15C the integral
Integrate[1/Sqrt[1 - x], {x, 0, 1}]
\[ \int_0^1{\frac{1}{\sqrt{1-x}}}dx \]
With this code:
Code:

00 LBL 1
01 CHS
02 ENTER
03 1
04 +
05 ENTER
06 SQRT
07 1/x
08 RTN
then 0 ENTER 1, f ∫ 1
The real HP15C is running but after 30 mins no result; the emulator iOS HP15 returns 1.999870566 after 1~2 min (the HP50g emulator returns 1.9999839292, the hardware HP50g doesn't return result after a few minutes...)
The actual result is 2 (Prime, Wolfram...).

I wonder:
1. Is there a better way to get it in hardware HP15C?
2. Why the result in emulator is not 2?
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
11-26-2017, 11:01 PM (This post was last modified: 11-26-2017 11:09 PM by Dieter.)
Post: #2
RE: HP 15C and INT(1/√(1-x),0,1)
(11-26-2017 07:51 PM)salvomic Wrote:  With this code:
Code:

00 LBL 1
01 CHS
02 ENTER
03 1
04 +
05 ENTER
06 SQRT
07 1/x
08 RTN

What are the two ENTERs supposed to do?
They are not required.

(11-26-2017 07:51 PM)salvomic Wrote:  then 0 ENTER 1, f ∫ 1

What display setting do you use here?
Remember, this setting directly influences the accuracy of the result – and thus the execution time.

Code:
01 LBL 1
02 CHS
03 1
04 +
05 SQRT
06 1/x
07 RTN

Set FIX 4, and the official HP emulator returns 1,9999 almost immediately.
FIX 6 already causes the emulator to run for a while... until it stops with Error 0.

(11-26-2017 07:51 PM)salvomic Wrote:  I wonder:
1. Is there a better way to get it in hardware HP15C?
2. Why the result in emulator is not 2?

Answers to both questions can be found in the 15C Advanced Functions Handbook which explains the Integrate function in detail. Take a look at the graph near x=1 and you'll see why this integrand is not trivial and why you should not expect a plain 2. As x approaches 1 the function approaches infinity. The AFH shows how such cases can be handled.

It's always a good idea to start with a moderate display setting like SCI 2 or FIX 2 or maybe FIX 4. Higher settings may cause very long integration times, especially on a hardware 15C.

Dieter
Find all posts by this user
Quote this message in a reply
11-26-2017, 11:13 PM (This post was last modified: 11-26-2017 11:16 PM by peacecalc.)
Post: #3
RE: HP 15C and INT(1/√(1-x),0,1)
Hello Salvo,

try your little program LBL1 without step 03 and 05 (both ENTER).

Because if you use your function with lets say 0.2 you get:

at step 01: -0.2 x-reg
at step 02: -0.2 x-reg, y-reg
at step 04: 0.8 x-reg, -0.2 yreg
at step 05: 0.8 x-reg, 0.8 yreg, -0.2 z-reg
at step 07: 1/√0.8 x-reg, 0.8 yreg, -0.2 z-reg

but the values in y-reg and z-reg are useless for the build-in integral-program, it may interfer with next looping because then t-reg is loaded and this reg copies it's value to the z-reg if there is a stack-down command.

Okay, Dieter was fast as flash, but I can't delete my post.
Find all posts by this user
Quote this message in a reply
11-27-2017, 01:33 AM
Post: #4
RE: HP 15C and INT(1/√(1-x),0,1)
Good evening (at least where I live)

I tested your integral on my (hardware) HP 50g. In exact mode, I receive the answer of 2 immediately. In approx. mode on the HP 50g with a fix of 4, I get 1.9999 in a matter of 3 to 4 minutes. I did not time it. I did not use the Equation Writer and I was in RPN mode. I used the integral function that is on the [TAN] key and I built the equation on the stack with RPN. It's fun.

Next I tested your integral on my Dad's (hardware 1987) HP-15C. I entered the equation as such...

1.) LBL 1
2.) 1
3.) SWAP
4.) -
5.) SQRT
6.) 1/x
7.) RTN

I set the HP-15C to a fix of 2 and integrated the integral from 0 to 1. In a time of 2 minutes and 42 seconds, I got the answer of 1.99.
Then I set the 15C to a fix of 4 and attempted to integrate the integral again. In a time of 16 minutes and 28 seconds, I stopped the 15C and didn't get an answer as a result.

I can't give any advice as I am not a proficient user of the HP-15C ONLY because I don't own one yet. But I hope my input on how I solved the integral on my calculators (and my Dad's) proved useful. Oh and I can help with the HP 50g. I would say I am a solid user of the machine.
Find all posts by this user
Quote this message in a reply
11-27-2017, 09:38 AM (This post was last modified: 11-27-2017 09:57 AM by salvomic.)
Post: #5
RE: HP 15C and INT(1/√(1-x),0,1)
(11-26-2017 11:01 PM)Dieter Wrote:  What are the two ENTERs supposed to do?
They are not required.
hi Dieter, you are right!
Without the ENTER I get 1.9999 in iOS in about 2 min (1 min with SCI 4).
In hardware HP15C no result after 27 min now with your program.
I controlled that all was ok with ON/y^x procedure (all flags and -88.88.88.88.88), I reset also the continuous memory (ON/-) but the same with FIX 4, with FIX 2 I get 1.99 after about 3 mins
Quote:...
What display setting do you use here?
Remember, this setting directly influences the accuracy of the result – and thus the execution time.
Nothing, FIX 4. I thought there was something wrong in Reg but it seems not.

Quote:Set FIX 4, and the official HP emulator returns 1,9999 almost immediately.
FIX 6 already causes the emulator to run for a while... until it stops with Error 0.
ok here in iOS. Also SCI 4 got 1.9999 after 1 min.
However not in hardware: this is strange by me: FIX 4 and nothing happens after 27 min, also with SCI 4...

Quote:Answers to both questions can be found in the 15C Advanced Functions Handbook which explains the Integrate function in detail. Take a look at the graph near x=1 and you'll see why this integrand is not trivial and why you should not expect a plain 2. As x approaches 1 the function approaches infinity. The AFH shows how such cases can be handled.

It's always a good idea to start with a moderate display setting like SCI 2 or FIX 2 or maybe FIX 4. Higher settings may cause very long integration times, especially on a hardware 15C.

Dieter

Thanks! I'll look there. The integral isn't trial at all.

(11-26-2017 11:13 PM)peacecalc Wrote:  Hello Salvo,
try your little program LBL1 without step 03 and 05 (both ENTER).
...
Okay, Dieter was fast as flash, but I can't delete my post.

thanks a lot! also your contribute is important for me. Smile

(11-27-2017 01:33 AM)Carsen Wrote:  Good evening (at least where I live)

I tested your integral on my (hardware) HP 50g. In exact mode, I receive the answer of 2 immediately. In approx. mode on the HP 50g with a fix of 4, I get 1.9999 in a matter of 3 to 4 minutes. I did not time it. I did not use the Equation Writer and I was in RPN mode. I used the integral function that is on the [TAN] key and I built the equation on the stack with RPN. It's fun.
well, in Exact in 50g I missed EVAL... Using it with EQN editor I get 2 immediatly, but with std setting in "number format" mode no luck after a few minutes. With FIX 4 I got the result 1.9999 in less than 3 min.
Quote:Next I tested your integral on my Dad's (hardware 1987) HP-15C. I entered the equation as such...

1.) LBL 1
2.) 1
3.) SWAP
4.) -
5.) SQRT
6.) 1/x
7.) RTN

I set the HP-15C to a fix of 2 and integrated the integral from 0 to 1. In a time of 2 minutes and 42 seconds, I got the answer of 1.99.
the same as the Dieter program, here: ok in iOS, nothing after various minutes in Hardware...
Quote:Then I set the 15C to a fix of 4 and attempted to integrate the integral again. In a time of 16 minutes and 28 seconds, I stopped the 15C and didn't get an answer as a result.
In fact!
Quote:I can't give any advice as I am not a proficient user of the HP-15C ONLY because I don't own one yet. But I hope my input on how I solved the integral on my calculators (and my Dad's) proved useful. Oh and I can help with the HP 50g. I would say I am a solid user of the machine.
thank you!
HP 50g is a very "big" machine, precise and solid, indeed. I like it (also I like the Prime).

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
11-27-2017, 07:40 PM (This post was last modified: 11-28-2017 09:42 PM by salvomic.)
Post: #6
RE: HP 15C and INT(1/√(1-x),0,1)
I need also a good emulator for Mac OS X...
I made tries on these with different results in Mac OS X 10.13.1 High Sierra using the program for INT(1/√(1-x),0,1):
Code:

01 LBL 1
02 CHS
03 1
04 +
05 SQRT
06 1/x
07 RTN
RLM 2.2 [RLM] old, but the best: it returned 1.999949803 in a few minutes, with a beautiful "running" on screen Smile
Free 15C RPN [HP 15C.com] not working with the program: it hangs, without showing "running", with the Mac rainbow spinner...
HP 15C Simulator [HP15C Simulator]: the old version doesn't start at all; the last beta starts, but returns "error 0".

Has HP an "original" working emulator for Mac OS X (like that wonderful in iOS)?

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
01-08-2018, 04:07 PM (This post was last modified: 01-09-2018 02:35 PM by salvomic.)
Post: #7
RE: HP 15C and INT(1/√(1-x),0,1)
I could try a confrontation between a classic and a Limited edition HP15.
They started in the same instant, running to calculate the “not trivial” integral: ∫(1/(√(1-x)),0,1) that’s close 2.
Both started with four digit precision (FIX 4).
LE returned the results (1.9999) after about 3 mins, then it started again with 6 digit precision (FIX 6).
After 50 mins the classic 15C (FIX 4) was still running, instead the LE (FIX 6) gave up with “Error 0” message ("Improper mathematics operation": why?)
The code is:
Code:

LBL 0
CHS
1
+
SQRT
INV
RTN
They run with: 0 ENTER 1, f-∫ 0 (integral of label 0)...

After 75 mins the old HP15C is still running...
At this time (after a pause) I start again LE with FIX5.
After 25 mins LE returns 1.99999 and old HP15 still running (just now since 100 mins)...
At the end I stopped HP15C (old) after about 2h without the result (with FIX4)...

Besides the different speed, I wonder if the error in LE with FIX6 was only random or a limit for it (but I don't think)...

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
01-08-2018, 09:35 PM (This post was last modified: 01-08-2018 09:36 PM by salvomic.)
Post: #8
RE: HP 15C and INT(1/√(1-x),0,1)
(01-08-2018 08:37 PM)Mike (Stgt) Wrote:  ...
Two suggestions: i) Use an HP40G or any other machine with CAS, emulated or not, to solve this integral. Before you lift your finger from the Enter key the _exact_ result will be displayed.
ii) If you are interested in the numerical approximation only have a look into the PPC ROM Users' Manual (that comes on the CD from MoHP), routine IG - InteGrate on p. 220 (p. 230 of the PDF). ...

Ciao.....Mike

hello Mike, thanks for advice.
Yes, actually I'm using the Prime and 50g to solve that type of integrals.
With old calculators (like the HP15) I like to test their capability and the various times of execution.
I never noted issues in HP15C (classic) until I tried that integral (and the first time with FIX9!) and the routine never end, so I wondered why...
So I'm trying the same thing in the various calculator I've.
With 50g or Prime the result 2 is returned in few seconds...
I noted also the same problem of HP15C in HP41C with Advanced pac: the used routine should be the same, I believe (reading the manual of the module.
It's better with the HP42s, and definitely with Free42, emulator of HP15, but not i41CX that has the same problem that the real HP41CX.

However, you're right, if it's stupid but it works, it isn't stupid Smile
When I want use HP15C I'll keen FIX low: 2 or 3 and go with wind...

I haven't a 40g, at the moment, only 39g (but still I have not tried in it).

ciao,
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
01-08-2018, 10:15 PM
Post: #9
RE: HP 15C and INT(1/√(1-x),0,1)
(01-08-2018 04:07 PM)salvomic Wrote:  I could try a confrontation between a classic and a Limited edition HP15.
They started in the same instant, running to calculate the “not trivial” integral: ∫(1/(√(1-x)),0,1) that’s close 2.

The indefinite integral is –2√(1–x) so the integral from 0 to 1 is exactly 2.

(01-08-2018 04:07 PM)salvomic Wrote:  After 50 mins the classic 15C (FIX 4) was still running, instead the LE (FIX 6) gave up with “Error 0” message ("Improper mathematics operation": why?)

You can find out yourself: as soon as the error occurs, switch to program mode an see at which line you are. Since the stack is filled with x, press R↓ to check x.

I suspect that the error is caused by the 1/x instruction, and this may happen if x is so close to 1 that 1–x is evaluated to zero, which leads to an attempt to divide by zero. But this is just a guess. ;-)

This usually does not happen as the interval should not be evaluated at its limits. But if Δx eventually becomes extremely small this may well be possible.

Dieter
Find all posts by this user
Quote this message in a reply
01-08-2018, 10:38 PM
Post: #10
RE: HP 15C and INT(1/√(1-x),0,1)
(01-08-2018 10:15 PM)Dieter Wrote:  You can find out yourself: as soon as the error occurs, switch to program mode an see at which line you are. Since the stack is filled with x, press R↓ to check x.

I suspect that the error is caused by the 1/x instruction, and this may happen if x is so close to 1 that 1–x is evaluated to zero, which leads to an attempt to divide by zero. But this is just a guess. ;-)

This usually does not happen as the interval should not be evaluated at its limits. But if Δx eventually becomes extremely small this may well be possible.

Dieter

I'll try again. I suspect also that the problem is with 1/x. I found that with FIX2, 3,4,5 no error is reported, but with 6 LE returns the error (the old HP15C I don't know as normally I put it off after two hours without results, as to wait without result it is boring a lot).

∫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
01-09-2018, 12:16 PM
Post: #11
RE: HP 15C and INT(1/√(1-x),0,1)
Test with HP 42s and Free42.
Both returns a result with a few seconds with accuracy 1E9, but maybe I miss something...
Code (function label FX):
Code:

00 { 19-Byte Prgm }
01▸LBL "FX"
02 MVAR "X"
03 RCL "X"
04 +/-
05 1
06 +
07 SQRT
08 1/X
09 RTN
10 END

Input:
LLIM 0
ULIM 1
ACC 1E9
then ∫f(x)

HP 42s returns 1.867415
Free42 returns 1.933972
both are no close to 1.9999

Are the different due only to different long float library?
Anyone with DM42 could try, please?

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
01-09-2018, 12:49 PM
Post: #12
RE: HP 15C and INT(1/√(1-x),0,1)
(01-09-2018 12:16 PM)salvomic Wrote:  Test with HP 42s and Free42.
Both returns a result with a few seconds with accuracy 1E9, but maybe I miss something...
Code (function label FX):
Code:

00 { 19-Byte Prgm }
01▸LBL "FX"
02 MVAR "X"
03 RCL "X"
04 +/-
05 1
06 +
07 SQRT
08 1/X
09 RTN
10 END

Input:
LLIM 0
ULIM 1
ACC 1E9
then ∫f(x)

HP 42s returns 1.867415
Free42 returns 1.933972
both are no close to 1.9999

Are the different due only to different long float library?
Anyone with DM42 could try, please?

Salvo

ACC = 1E9??
Try 1E-5

Greetings,
    Massimo

-+×÷ ↔ left is right and right is wrong
Visit this user's website Find all posts by this user
Quote this message in a reply
01-09-2018, 01:26 PM
Post: #13
RE: HP 15C and INT(1/√(1-x),0,1)
(01-09-2018 12:16 PM)salvomic Wrote:  Test with HP 42s and Free42.
Both returns a result with a few seconds with accuracy 1E9,

What? An accuracy of ±1000000000 ?

(01-09-2018 12:16 PM)salvomic Wrote:  but maybe I miss something...

You bet. #-)
ACC=1E–5 on Free42 returns an integral of 1,99587 almost immediately.

(01-09-2018 12:16 PM)salvomic Wrote:  Are the different due only to different long float library?

AFAIK neither Free42 nor DM42 use a longfloat library.

Dieter
Find all posts by this user
Quote this message in a reply
01-09-2018, 01:32 PM (This post was last modified: 01-09-2018 04:57 PM by salvomic.)
Post: #14
RE: HP 15C and INT(1/√(1-x),0,1)
(01-09-2018 12:49 PM)Massimo Gnerucci Wrote:  ACC = 1E9??
Try 1E-5

yes! what a silly I was... Smile
Thank Massimo, with 1E-6 Free 42 (iOS) returns 1.999998 after a few seconds, HP 42s with 1E-6 still running after 90 mins...

∫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
01-09-2018, 01:34 PM
Post: #15
RE: HP 15C and INT(1/√(1-x),0,1)
(01-09-2018 01:26 PM)Dieter Wrote:  You bet. #-)
ACC=1E–5 on Free42 returns an integral of 1,99587 almost immediately.

yes, Dieter, I don't know why I was missing the - sign!
Free42 returns the result quick also with 1E-6...

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
01-09-2018, 03:42 PM
Post: #16
RE: HP 15C and INT(1/√(1-x),0,1)
(01-09-2018 12:16 PM)salvomic Wrote:  Anyone with DM42 could try, please?

DM42, no USB power:

ACC = 0.01
1.983493
time < 1s

ACC = 0.001
1.998968
time ~ 4s

ACC = 0.0001
1.999871
time ~ 28s

I also broke it into two segments (0 to 0.9999, ACC 0.0001 and 0.9999 to 1, ACC 0.01) and got 1.999932 (with 0.000195 summed error) in ~ 2s.
Find all posts by this user
Quote this message in a reply
01-09-2018, 04:53 PM
Post: #17
RE: HP 15C and INT(1/√(1-x),0,1)
I’ve removed two steps from your function code:

Code:

00 { 16-Byte Prgm }
01▸LBL "FX"
02 MVAR "X"
03 1
04 RCL- "X"
05 SQRT
06 1/X
07 END

On the DM42 with Main and Goose LCD refresh disabled and USB power it takes 1’07” to return 1,99998387978 with ACC=1E-5 and 2’39” when on battery.
With Main and Goose LCD refresh enabled it takes 1’19’’ on USB power and 3’26” on battery.

(01-09-2018 01:26 PM)Dieter Wrote:  ACC=1E–5 on Free42 returns an integral of 1,99587 almost immediately.
Are you using the decimal or the binary version of Free32?
Find all posts by this user
Quote this message in a reply
01-09-2018, 06:19 PM
Post: #18
RE: HP 15C and INT(1/√(1-x),0,1)
(01-09-2018 04:53 PM)Didier Lachieze Wrote:  Are you using the decimal or the binary version of Free32?

Free42 Decimal version 1.5.5.

Dieter
Find all posts by this user
Quote this message in a reply
01-09-2018, 06:31 PM
Post: #19
RE: HP 15C and INT(1/√(1-x),0,1)
(01-08-2018 10:15 PM)Dieter Wrote:  I suspect that the error is caused by the 1/x instruction, and this may happen if x is so close to 1 that 1–x is evaluated to zero, which leads to an attempt to divide by zero. But this is just a guess. ;-)

I now tried the integrate function of Free42 Decimal 1.5.5. with a modified function that records the largest X during integration. For ACC=1E–8 (result: 1.99999596995) the largest X was 0,999999999956, i.e. 1–4,4E–11. With 10 digit precision this rounds to 1 so that 1–x becomes zero and 1/x generates an error.

But once again – try this on your 15C and see what you get.

Dieter
Find all posts by this user
Quote this message in a reply
01-09-2018, 06:58 PM
Post: #20
RE: HP 15C and INT(1/√(1-x),0,1)
(01-09-2018 04:53 PM)Didier Lachieze Wrote:  I’ve removed two steps from your function code:

...

On the DM42 with Main and Goose LCD refresh disabled and USB power it takes 1’07” to return 1,99998387978 with ACC=1E-5 and 2’39” when on battery.
With Main and Goose LCD refresh enabled it takes 1’19’’ on USB power and 3’26” on battery.

Didier, thanks for tests!
I'm trying your code with HP42s and HP15 (original and LE) again...
HP 42s:
accuracy 1E-6: no results after 4h, then I stopped the calculator
accuracy 1E-5: 1.999967 (Y=0.000020) after 1h10m


(01-08-2018 10:15 PM)Dieter Wrote:  ...
I now tried the integrate function of Free42 Decimal 1.5.5. with a modified function that records the largest X during integration. For ACC=1E–8 (result: 1.99999596995) the largest X was 0,999999999956, i.e. 1–4,4E–11. With 10 digit precision this rounds to 1 so that 1–x becomes zero and 1/x generates an error.
Interesting...

(01-08-2018 10:15 PM)Dieter Wrote:  But once again – try this on your 15C and see what you get.

Dieter

ok Dieter, similar result here with Free42...
Now, I'll try again with your hints in the real HP42.
However, yesterday I tried and here the results:
(01-08-2018 04:07 PM)salvomic Wrote:  ...
After 75 mins the old HP15C is still running...
At this time (after a pause) I start again LE with FIX5.
After 25 mins LE returns 1.99999 and old HP15 still running (just now since 100 mins)...
At the end I stopped HP15C (old) after about 2h without the result (with FIX4)...

original HP15 had problems already with 1E-5, HP 15C LE returned the result with 1E-5 in 25 minutes but returned error with 1E-6...

∫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: 2 Guest(s)