Post Reply 
HP 15C and INT(1/√(1-x),0,1)
01-13-2018, 01:35 AM
Post: #41
RE: HP 15C and INT(1/√(1-x),0,1)
(01-12-2018 10:57 AM)Dieter Wrote:  
(11-27-2017 01:33 AM)Carsen Wrote:  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 you can get the current approximation of the integral during a running calculation. This is described in appendix E of the 15C manual ("Owner's Handbook", p. 257 of the English version): "Obtaining the Current Approximation to an Integral".

Dieter

Is that so? I guess I'll have to pilfer my Dad's HP-15C and Handbook for a few days and break open my calculus book and notes. There are a lot of techniques I do not know about regarding the HP-15C but I fully intend to eventually. The Voyager Series is so elegant and perfect (close to perfect, that is).
Find all posts by this user
Quote this message in a reply
01-14-2018, 09:37 AM
Post: #42
RE: HP 15C and INT(1/√(1-x),0,1)
(01-14-2018 09:20 AM)Mike (Stgt) Wrote:  So the clock frequency range is named as difference. Still looking for the values.

From Craig Finseth hp-15c page :
Code:
The clock speed is about 220kHz and on the HP-41 is about 340kHz (60% faster).
Find all posts by this user
Quote this message in a reply
01-14-2018, 10:30 AM
Post: #43
RE: HP 15C and INT(1/√(1-x),0,1)
(01-12-2018 04:18 AM)JimP Wrote:  I tried the DM15 (SwissMicros) with FIX2 and received the 1.99 answer within 30 seconds -- clearly faster. Then thought I'd try to split the difference between your tests with FIX3. The machine shut down before it could give an answer, 5 minutes later...

Are you sure the battery isn't just dead on your DM15?

I ran that same test on mine and got the answer of 1.99 (FIX 2) in 8 seconds, 1.999 (FIX 3) in 61s and 1.9999 (FIX 4) in 478s.

This is on a DM15L (exactly the same electronics and firmware as a DM15) on firmware V24 running at 48MHz. There is no real advantage to running the calculator at 12MHz because, while the drain on the battery may be slower at a lower frequency, it takes longer to get things done anyway so you're no better off energy-wise at the end of the day.
Find all posts by this user
Quote this message in a reply
01-17-2018, 05:06 AM
Post: #44
RE: HP 15C and INT(1/√(1-x),0,1)
From the HP-41C service manual, page 2-1:
Code:
The nominal oscillator frequency of 1440 kHz is reduced by 
a factor of 4 to produce a system operating frequency between 
343 and 378 kHz

And from the 1LF5-0301/1LF5-002 CPU detailed description, page 3-4:
Code:
The 1LE3 CPU is designed for 41C and 11C, 12C calculator. 
At wafer and package level,  their part numbers are designated as follows:
Wafer: 1LF5-01 (11C, 12C) 1LF5-03 (41C)
Package: 1LF5-0301 (11C, 12C) 1LF5-002 (41C)
The difference between the two parts are programmed at metal mask [...] 
The operating range of the two chips are also different and are 
summarized as follow:
41C Clock frequency range: 340 to 380 kHz 
11C, 12C Clock frequency range: 200 to 230 kHz

Both documents are available on TOS.
Find all posts by this user
Quote this message in a reply
01-17-2018, 01:12 PM (This post was last modified: 01-17-2018 01:13 PM by Didier Lachieze.)
Post: #45
RE: HP 15C and INT(1/√(1-x),0,1)
(01-17-2018 12:03 PM)Mike (Stgt) Wrote:  Hmm... what makes me uncertain about the MCode instruction count shown by my 'firmware interpreter'.

Why? For the Voyagers this is up to ~3950 MCode instructions per second, knowing that between key press the CPU goes to sleep.
Find all posts by this user
Quote this message in a reply
01-17-2018, 07:07 PM
Post: #46
RE: HP 15C and INT(1/√(1-x),0,1)
(01-17-2018 05:41 PM)Mike (Stgt) Wrote:  Why? -- I ran the 8-Queens programs for the HP41 and HP15C you find in here on a 'firmware interpreter' to count the MCode instructions (not the user program steps). When - for the HP15C - I find 18,210,956 MCode instructions and divide it by the ~3950 MCode instructions per second you named I get 4,610 seconds or 1 hr and ~17 min what is within 2 minutes of the value shown in the a. m. link.

The numbers seem plausible, but this does not neccessarily mean that the calculation is correct. ;-) I still wonder if the 15C really is that slow. Compare it to the 34C: the two given programs are virtually identical (the 15C version even requires one step less) but the 15C is slighty slower. The 34C was my first HP calculator, so I know that it is not very fast and slower than the HP67. But is the 15C really even slower?

Maybe someone with a physical (and original) 15C can try the program listed on the linked webpage and see if it really takes almost 80 minutes to finish.

Dieter
Find all posts by this user
Quote this message in a reply
01-17-2018, 08:49 PM
Post: #47
RE: HP 15C and INT(1/√(1-x),0,1)
I have a 15C, original made in USA. I can do the test for you, if you can post the link with the code again, since I'm lost in all the replies and I am not sure where to look!

Software Failure: Guru Meditation

--
Antonio
IU2KIY
Find all posts by this user
Quote this message in a reply
01-17-2018, 09:22 PM (This post was last modified: 01-17-2018 09:23 PM by Dieter.)
Post: #48
RE: HP 15C and INT(1/√(1-x),0,1)
(01-17-2018 08:49 PM)TheKaneB Wrote:  I have a 15C, original made in USA. I can do the test for you, if you can post the link with the code again, since I'm lost in all the replies and I am not sure where to look!

Here you are: 8-queens benchmark in the original Articles Forum.

Simply do a browser search for "15C" there and find the program about halfway down the page, where it says

HP-15C
HP-15C LE
DM-15
-----------

The following program is supposed to run in about 80 minutes on a regular 15C.

Dieter
Find all posts by this user
Quote this message in a reply
01-17-2018, 09:38 PM
Post: #49
RE: HP 15C and INT(1/√(1-x),0,1)
Ok, I have the calculator running. We'll see how it goes Smile

Software Failure: Guru Meditation

--
Antonio
IU2KIY
Find all posts by this user
Quote this message in a reply
01-17-2018, 10:35 PM (This post was last modified: 01-17-2018 10:59 PM by TheKaneB.)
Post: #50
RE: HP 15C and INT(1/√(1-x),0,1)
EDIT: 1h 18m 45s ( +/- 1 s)

While we're waiting for the result (still running) I should mention that the code for the 15C of that benchmark is very bad. It doesn't take advantage of the built in looping instructions (ISG and DSE), while the 41C version does. So the two times are not comparable.

I think we should rewrite the code with some optimization. I bet we can make it much faster than that Smile

HP 15C code
Code:

HP-15C
 HP-15C LE
 DM-15
-----------


 LBL A  CLEAR REG
        8 STO .0
 LBL 0  RCL 0 RCL .0
        TEST 5 GTO 4
        1 STO+ 0
        RCL 0 STO I
        RCL .0 STO(i)
 LBL 1  1 STO+ .1
        RCL 0 STO 9
 LBL 2  1 STO- 9
        RCL 9 x=0? GTO 0
        RCL 0 STO I RCL(i)
        RCL 9 STO I
        Rv RCL(i) -
        x=0? GTO 3
        ABS RCL 0 RCL 9 -
        TEST 6 GTO 2
 LBL 3  RCL 0 STO I
        1 STO-(i)
        RCL(i) TEST 0 GTO 1
        1 STO- 0
        RCL 0 TEST 0 GTO 3
 LBL 4  RCL .1
        RTN


HP 41C code
Code:

 HP-41C
 HP-41CV
 HP-41CX
 HP-41CY
 HP-41CL
 HP-42S
 DM-41
 DM-41L
 DM-42
 HP-71B / HP-41 Translator ROM Module HP-82490A
------------------------------------------------


 LBL A   CLRG
         8 STO 11
 LBL 00  RCL 00 RCL 11
         X=Y? GTO 04
         ISG 00 DEG
         STO IND 00
 LBL 01  ISG 10 DEG
         RCL 00 STO 09
 LBL 02  DSE 09 DEG
         RCL 09 X=0? GTO 00
         RCL IND 00 RCL IND 09 -
         X=0? GTO 03
         ABS RCL 00 RCL 09 -
         X<>Y? GTO 02
 LBL 03  DSE IND 00 GTO 01
         DSE 00 GTO 03
 LBL 04  RCL 10
         RTN

Software Failure: Guru Meditation

--
Antonio
IU2KIY
Find all posts by this user
Quote this message in a reply
01-18-2018, 12:22 AM (This post was last modified: 01-18-2018 12:23 AM by TheKaneB.)
Post: #51
RE: HP 15C and INT(1/√(1-x),0,1)
No, I didn't care to optimize it, it was just food for thought Smile

24 seconds in 79 minutes is VERY underwhelming though...

Software Failure: Guru Meditation

--
Antonio
IU2KIY
Find all posts by this user
Quote this message in a reply
01-21-2018, 03:57 PM (This post was last modified: 01-21-2018 05:44 PM by TheKaneB.)
Post: #52
RE: HP 15C and INT(1/√(1-x),0,1)
Back to the original topic:

I used a C implementation of the Romberg algorithm to find the integral of
f(x) = 1 / sqrt(1 - x) over the interval 0 - 1

It runs for a relatively long time (several seconds on my 3 GHz Intel i5) and it came up with this result:

result = 2.000052194143781214563660
function evaluations = 1073741825 (1 billion of function evaluations!)

I set an accuracy of 0.0001 with max steps = 100. I also used the interval from 0 to 0.99999999999 or else it would evaluate to NAN.

If i set an accuracy of 0.01 I get this:
result = 2.005444550190635499831160
function evaluations = 16777217

Code:

#include <stdio.h>
#include <math.h>

void
dump_row(size_t i, double *R){
   printf("R[%2zu] = ", i);
   for(size_t j = 0; j <= i; ++j){
      printf("%.12f ", R[j]);
   }
   printf("\n");
}

double
romberg(double (*f/* function to integrate */)(double), double /*lower limit*/ a, double /*upper limit*/ b, size_t max_steps, double /*desired accuracy*/ acc){
   double R1[max_steps], R2[max_steps]; //buffers
   double *Rp = &R1[0], *Rc = &R2[0]; //Rp is previous row, Rc is current row
   double h = (b-a); //step size
   Rp[0] = (f(a) + f(b))*h*.5; //first trapezoidal step

   dump_row(0, Rp);

   for(size_t i = 1; i < max_steps; ++i){
      h /= 2.;
      double c = 0;
      size_t ep = 1 << (i-1); //2^(n-1)
      for(size_t j = 1; j <= ep; ++j){
         c += f(a+(2*j-1)*h);
      }
      Rc[0] = h*c + .5*Rp[0]; //R(i,0)

      for(size_t j = 1; j <= i; ++j){
         double n_k = pow(4, j);
         Rc[j] = (n_k*Rc[j-1] - Rp[j-1])/(n_k-1); //compute R(i,j)
      }

      //Dump ith column of R, R[i,i] is the best estimate so far
      dump_row(i, Rc);

      if(i > 1 && fabs(Rp[i-1]-Rc[i]) < acc){
         return Rc[i-1];
      }

      //swap Rn and Rc as we only need the last row
      double *rt = Rp;
      Rp = Rc;
      Rc = rt;
   }
   return Rp[max_steps-1]; //return our best guess
}

int functionCounter = 0;

double myfunc(double x) {
    functionCounter++;
    double l = 1 / sqrt( 1 - x );
    return l;
}

int main() {
    printf("result = %.24f\nfunction evaluations = %d\n", romberg(&myfunc, 0, 0.99999999999, 100, 0.0001), functionCounter);
}

The code source is from wikipedia: https://en.wikipedia.org/wiki/Romberg%27s_method

Software Failure: Guru Meditation

--
Antonio
IU2KIY
Find all posts by this user
Quote this message in a reply
01-21-2018, 04:46 PM
Post: #53
RE: HP 15C and INT(1/√(1-x),0,1)
(01-21-2018 03:57 PM)TheKaneB Wrote:  I used a C implementation of the Romberg algorithm to find the integral of
f(x) = 1 / sqrt(1 / x) over the interval 0 - 1

It runs for a relatively long time (several seconds on my 3 GHz Intel i5) and it came up with this result:

result = 2.000052194143781214563660
function evaluations = 1073741825 (1 billion of function evaluations!)

I set an accuracy of 0.0001 with max steps = 100. I also used the interval from 0 to 0.99999999999 or else it would evaluate to NAN.

If i set an accuracy of 0.01 I get this:
result = 2.005444550190635499831160
function evaluations = 16777217

(I'm assuming the f(x) = 1 / sqrt(1 / x) is a typo?)

There's room for improvement there. The Romberg implementation in Free42, based on code written by Hugh Steers, reaches those levels of accuracy with 32767 and 255 evaluations, respectively.

I used ACC = 0.000025 and 0.0025, respectively, since Free42 treats ACC as a relative error, and using 0.0001 and 0.01 produce results that are less accurate than your examples.
Visit this user's website Find all posts by this user
Quote this message in a reply
01-21-2018, 05:11 PM
Post: #54
RE: HP 15C and INT(1/√(1-x),0,1)
yes that was a typo, see the code for reference.

Software Failure: Guru Meditation

--
Antonio
IU2KIY
Find all posts by this user
Quote this message in a reply
07-20-2018, 01:04 PM
Post: #55
RE: HP 15C and INT(1/√(1-x),0,1)
The HP-15C ADVANCED FUNCTIONS HANDBOOK has on page 47 a section about:

Transformation of Variables
Quote:In many problems where the function changes very slowly over most of a very wide interval of integration, a suitable transformation of variables may decrease the time required to calculate the integral.

You can use \(x=1-t^2\) which leads to:
\[ \begin{eqnarray}
dx&=&-2t\cdot dt \\
\sqrt{1-x}&=&t \\
\int_0^1\frac{1}{\sqrt{1-x}}dx&=&\int_1^0\frac{-2t}{t}dt \\
&=&2\int_0^1dt \\
&=&2t\bigg\vert_0^1 \\
&=&2-0=2
\end{eqnarray} \]

Or then use \(x=\cos^2(t)\) which leads to:
\[ \begin{eqnarray} \\
dx&=&-2\cos(t)\sin(t)dt \\
\sqrt{1-x}&=&\sin(t) \\
\int_0^1\frac{1}{\sqrt{1-x}}dx&=&\int_{\frac{\pi}{2}}^0\frac{-2\cos(t)\sin(t)}{\sin(t)}dt \\
&=&2\int_0^{\frac{\pi}{2}}\cos(t)dt \\
&=&2\sin(t)\bigg\vert_0^{\frac{\pi}{2}} \\
&=&2-0=2
\end{eqnarray} \]

In both cases the resulting function can be integrated without problems.
It's just a coincidence that both integrals can also be calculated easily algebraically.

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
Post Reply 




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