The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
(50g) Cordic Algorithm [TAN(X)]
05-03-2015, 04:00 PM
Post: #1
(50g) Cordic Algorithm [TAN(X)]
Hello 50g fans,

I never heard about Jaques Laporte. Some days ago I read in this forum about his passing away. A lot of forum member mourn his lost and appreciate his work for thiat community. So I got curious what his work was and the connection to the hp calculators.

After reading his old websites, I learned from his "cordic for dummies", how the cordic algorithm works. So I've had the idea that this would be a nice to have a little program for the hp 50g. The program is "brutal force" there is no elegance (with complex numbers or matrices calculation or anything else optimized).

The original algorithm from Volder works with a binary shift right. So he didn't need
the multiplication like my program.

Tip: compare the values from hp 50g with the values of the program.

Code:
%%HP: T(3)A(R)F(,);                  @@Program name: CTAN
    \<< { } { 1, ,1 ,01 ,001 ,0001 } 
        \-> X                         @@ X:    Argument for tangens 
             WLST                     @@ WLST: List how often subtracted
             DLST                     @@ DLST: List with negative powers of ten
                                      @@          simulating right shift 
        \<< 0, DUPDUP 1, X 
             \-> X2 Y2               @@ X2, Y2: new values 
                   CNT               @@ CNT:    value how often subtracted 
                   X1 Y1             @@ X1, Y1: old values (X1 is now 1, and 
                                     @@         Y1 is the argument from TAN)
 
        \<< -105, SF 
            1, 5, FOR J 
                         CORP J GET                @@ CORP: is a list with the values
                                                   @@ {ATAN(1) ATAN(0,1) ATAN(0,01) ATAN(0,001) ATAN(0,0001)}
                      \-> TB                       @@ TB: is the actual value f. e. ATAN(0,01)
                      \<< WHILE  Y1 TB \>=         @@ As long Y1 is greater then TB 
                          REPEAT Y1 TB - 'Y1' STO  @@ Y1 is subtracted by TB
                          'CNT' INCR DROP          @@ CNT counts how often this takes place
                          END 

                          WLST CNT + 'WLST' STO    @@ IF Y1 is smaller then TB the the while loop is left.
                                                   @@ The value of CNT is stored in WLST.  
                          0, 'CNT' STO             @@ and CNT is initialised with zero 
                      \>>
          
                   NEXT 

            1, 5, FOR J 
                      1, WLST J GET DUP            @@ 1, is the start value for the START-loop
                                                   @@ In WLST the end value is found and is doubled on stack
                      IF 0, ==                     @@ IF the end-value is zero, 
                      THEN DROP DROP               @@ the remaining values are cleared
                      ELSE DLST J GET              @@ IF NOT the actual negativ power of ten is stored in TB  
                           \-> TB
                           \<< START X1 Y1 TB * - 'X2' STO  @@ the heart of the cordic-algorithm, the
                                     Y1 X1 TB * + 'Y2' STO  @@ 'transformation of the coordinates'
                                     Y2 'Y1' STO            @@ old values initialised with new values
                                     X2 'X1' STO            
                               NEXT
                           \>>
                      END
                  NEXT 
           Y2 X2 /                   @@ calculate tan of y2 and x2 
           -105, CF
        \>>
      \>>
    \>>
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(50g) Cordic Algorithm [TAN(X)] - peacecalc - 05-03-2015 04:00 PM



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