Hi,
all,
Well, at long last these are my original solutions and comments for the last two sections, i.e.
LOL the Fifth: Gamma and
LOL the sixth: Miscellanea. The party's almost over ...
5. LOL the Fifth: Gamma
Executing this loop to list the values of \(\Gamma\)(10-1), \(\Gamma\)(10-2), ..., \(\Gamma\)(10-10), gives:
>DESTROY ALL @ FOR N=1 TO 10 @ N;GAMMA(10^(-N))@ NEXT N
N \(\Gamma\)(10-N)
-------------------
1 9.51350769867
2 99.4325851191
...
9 999999999.423
10 9999999999.42
where the fractional part seems to be quickly converging to some limit around ~0.42, so you must write code to find this limit to much greater accuracy (say 10-12 digits or more). Once done, answer these questions:
- Can you estimate the most accurate value you got ?
- Can you identify the symbolic, closed form of that numeric value ?
As the table above demonstrates, the
12-digit HP-71B lacks the precision to resolve the fractional part to at least 12 digits so we use the
34-digit Free42 Decimal with this small
15-step,
27-byte RPN program which displays just the fractional part of
\(\Gamma\)(10
-N) for
N=
-1,
-2, ...
01 LBL "GAM10" 09 FP
02 ALL 10 STOP
03 1 11 R↓
04 ►LBL 00 12 ISG ST X
05 ENTER 13 LBL 00
06 +/- 14 GTO 00 ►
07 10^X 15 END
08 GAMMA
XEQ "GAM10" ->
{ I in ST Y, fractional part in ST X, [R/S] to continue }
1 .513507698669 { using SHOW from now on }
2 .432585119151
3 .423772484595 12 .4227843350994561953914
4 .422883231624 13 .422784335098566044949
5 .422794225568 14 .42278433509847702999
6 .422785324154 15 .4227843350984681235
7 .422784434004 16 .422784335098467242 { best estimate }
8 .422784344989 17 .42278433509846684
9 .422784336088 18 .4227843350984742 { error grows, insufficient accuracy }
10 .422784335197
11 .422784335108
and we see that the fractional part seems to be converging to
0.4227843350984672 for
N =
16, truncating at
16 digits by ignoring two
"guard" digits, and the values for
N =
17 and
N =
18, as the accuracy is clearly worsening (the error begins to grow). Thus, my
estimate for the most accurate value obtained is:
0.4227843350984672
Can this value be
identified ? Well, yes, we can try any of the programs out there online or using your own or your calc's identification software. I did use my
HP-71B's
IDENTIFY program which identified the value as
1-EulerGamma.
If proceeding manually, one can notice that 1 -
0.4227843350984672 =
0.5772156649015328 , which is immediately recognizable but if not, just searching this value online immediately reports it as the
Euler–Mascheroni constant,
aka \(\gamma\) constant. So, the fractional part's limit is
symbolically identified as:
1 - \(\gamma\)
which is as can be expected because the
Laurent series expansion of the \(\Gamma\) function near zero is:
and you can see the
- \(\gamma\) term there.
Additional comments: Solver extraordinaire Gerson W. Barbosa tackled this mini-challenge extensively, correctly produced the limit to great accuracy and identified it as the
Euler-Mascheroni \(\gamma\) constant, but he also tried to significantly improve the accuracy and said (my
bold):
"Here we also notice that the mantissas of the errors, the second column in the table, appear to tend to another constant. Regardless of any attempt to identify it, we can try to use it to get a few more correct digits, [...] Now we have about 50% more correct digits, 23"
but I think that his reasoning is
circular because he's using the
actual,
externally-obtained 34-digit
\(\gamma\) value (
0.5772156649015328606065120900824024, as seen in his
"L5th" program,) to compute the second column of the table in order to obtain the
second constant
(0.98905599...,) and use it to improve the result. In other words, he's using the
real \(\gamma\) to improve the accuracy of his
computed \(\gamma\), i.e. a circular way of proceeding.
As for the second constant's
(0.98905599...) identification, it's mainly the
O(z) term in the
Laurent expansion above, namely:
\[ \frac{1}{12} (6 \gamma^2 + \pi^2) z\]
6. LOL the Sixth: Miscellanea
- Try and deduce what result will be output by this HP-71B expression without actually executing it:
NEIGHBOR(INTEGRAL(FNROOT(EPS,EPS,EPS),EPS,EPS,EPS),GAMMA(EPS))
Was your deduction correct ? Can you explain the result obtained ?
The expression returns the value 10, exactly. EPS is the constant 1E-499 and GAMMA(EPS) is thus 1E499, which is just used to indicate NEIGHBOR the direction used to return the nearest machine-representable number to its first argument (the value of INTEGRAL,) so its value isn't relevant as long as it's ≥ 10. The breakdown is:
>FNROOT(EPS,EPS,EPS) -> -9.99999999999E499 = -MAXREAL
>INTEGRAL(-MAXREAL,EPS,EPS,EPS) -> 9.99999999999
>GAMMA(EPS) -> 1.E499
>NEIGHBOR(9.99999999999,1E499) -> 10
so:
>NEIGHBOR(INTEGRAL(FNROOT(EPS,EPS,EPS),EPS,EPS,EPS),GAMMA(EPS) -> 10
- I executed this command-line expression on my HP-71B but it just resulted in System Error. Can you find out what's wrong ?
FOR I=64204 TO 64215 @ DISP CHR$(HTD(REV$(PEEK$(DTH$(2*I),2)))); @ NEXT I
A trick question. The expression above just peeks characters from the specified addresses in the System ROMs, which happen to be the ones which form the error message "System Error" so that's what you get. The expression itself is perfectly correct and returns the pertinent text.
Additional comments: JoJo1973 had the right intuition here. He wrote:
"[...] to write a program resulting in the largest number of errors. Of course the easiest way to accomplish the task is to dump the ROM area where the messages are actually stored [...]"
which goes to the gist of the matter.
- Some nice results I got:
√ 95888 = 309.657875727390470000000975517...
√ 22008840 = 4691.3580123456789961013...
In radians:
>EXP(ACOS(430/433)) -> 1.12500000006 { ~ 9/8 }
>EXP(ACOS(538/541)) -> 1.11111111113 { ~ 10/9 }
[...]so perhaps there's some hidden pattern at large here.
None that I know of, perhaps just a coincidence. Regrettably, no one commented on those nice results I found, which is a pity as the last two seem to me rather remarkable. Another nice one I also found is:\[ \Gamma \cosh \left (\sqrt[6]{\frac{250}{57}}\phi \right ) \]where \(\phi\) is the Golden Ratio and which evaluates to 6.2000000002 on my HP-71B.
Additional comments: The first square root (√ 95888) can be used to generate an integer perfect square nearly as awesome as the ones shown in LOL the First, namely
309657875727390472 = 958879999999999999999993958468209
with no less than 18 consecutive '9's in the middle ! I'd say this must be the smallest perfect square with that many consecutive '9's (or any other diigit) in the middle, by far.
- What does this HP-71B user-defined function compute ?
10 DEF FNC(M,N)=M!/N!/(M-N)!
Another trick question. At first sight it would seem that the "!" symbol stands for the factorial (which is the case for standard mathematical notation,) so this user-defined function would seem to be computing m!/n!/(m-n)! , which is the number of combinations of m things taken n at a time without repetition.
However, this is not the case here because the HP-71B uses the keyword FACT for the factorial while "!" is the comment delimiter, so everything in the line after the first "!" is considered a comment and of course it won't be executed at all.
This means that the line reduces to 10 DEF FNC(M,N)=M , which just returns the value passed in the M argument. As J-F Garnier said: "It doesn't do much, I'm afraid."
- The HP-71B does not allow for variable names beginning with a 2-letter or more prefix, but executing this assignment in a program or from the keyboard ...
FORM=STOP
... doesn't result in a Syntax Error so what gives ?
Yet another trick question. The HP-71B parser doesn't generally care for spaces between keywords, etc., so it interprets this line as FOR M=S TO P , which just begins a FOR-NEXT loop using scalar numeric variables M, S and P, all of it perfectly legal syntax.
Additional comments: JoJo1973 nailed this one, despite not owning a 71B. His experience with a non-HP, non-calc machine (a Commodore 64 no less) served him well to understand what was happening. As he rethorically asked: "FORM=STOP is a variable assignment or the beginning of a loop: FOR M = S TO P ?".
- Write code to compute to full accuracy this function S(x) given the argument x. Use your code to compute S(42): \[ S(x) = \frac{1}{\sum_{n=0}^{\infty} \binom {2 n}{n}^3 \frac{{nx \space + \space 5}}{2^{12 n \space + \space 4}}} \]My original solution is this 3-line HP-71B user-defined function:
1 DEF FNS(X) @ S=0 @ T=0 @ N=0 @ REPEAT @ S=S+T
2 T=COMB(2*N,N)^3*(X*N+5)/2^(12*N+4) @ N=N+1
3 UNTIL S=S+T @ FNS=1/S @ END DEF
>DESTROY ALL
>FNS(42)
3.14159265358 { fully correct save 1 ulp }
This is yet another marvelous Ramanujan's series. The correct value of this series is exactly \(\pi\) and has the awesome BBP formula-like property that, as the denominators are exactly 16 · 2n, this can be used to compute the second block of n binary digits of \(\pi\) without having to compute the first n binary digits.
Additional comments: John Keith provided a nice RPL solution for this mini-challenge and he also added an interesting observation but he never posted the value produced by his program and that's not Ok. Remember: you must mandatorily post both code AND results, one without the other won't do, certainly not when also posting the result is so extremely little extra work.
Juan14 provided algebraic manipulations to achieve extra speed, a working 35-step RPN program to be run in Free42 Decimal and the result accurate to 34 digits save 1 ulp. Not bad. Plus he was amazed by yet another unexpected appearance of \(\pi\).
That's all, the party's over now and it was enjoyable even if few people actually attended so let's call it a wrap. Thanks to everyone who viewed this thread and/or contributed to it.
This will be my last
challenge-oriented
SRC for an indefinite period of time so I really hope you enjoyed it while it lasted.
All good things ...
Bye.
V.