Home
        SandMath
         Contents
1.           2 3 1  Hyperbolic Functions     Yes there are many unanswered questions in the universe  but certainly one of them is why  oh why   didn   t HP MotherGoose provide a decent set of hyperbolic functions in the  otherwise pathetic  MATH   PAC  and worse yet  adding insult to injury  how come that error wasn   t corrected in the Advantage  ROM     For sure we ll never know  so it   s about time we move on and get on with our lives     whilst correcting  this forever and ever  The first incarnation of these functions came in the AECROM module  I believe  programmed by Nelson C  Crowle  a real genius behind such ground breaking module   but it was also  somehow limited to 10 digit precision  The versions in the SandMath all use internally13 digit routines      __  Function   Author   Description  _    O  Z     o  gt Z o o   H    HSIN   Angel Martin   Hyperbolic Sine   H    HCOS_   Angel Martin ___  Hyperbolic Cosine _ _ _ _ _ o Z oS     H    HASIN   Angel Martin _  Inverse Hyperbolic Sine   H    HACOS_   Angel Martin _  Inverse Hyperbolic Cosine _ __               o      o       lt     The use of the function launcher permits convenient access to these six functions without having to  assign them to any key in USER mode  Efficient usage of the keyboard  which can double up for other  launchers or the standard USER mode assignment if that   s also required  Combining the XFL and the  SHIFT keys does the trick in a clean and logical way           The formulas used are well 
2.      Jalar  cos am      J__ x  Kf    TI als      Tal       sin  a7    2 sin am     Ya 2       These expressions are valid for any real number as order     with the same issues as the first kind  functions above when the order is integer  To avoid the singularities and to reduce the calculation time   the following expressions are used for integer orders     mY  x    2 y   Ln x 2  Ja      Z CD  fk n x       Zfg n x    2 Ka x    C1   2 fy   Ln x 2       CD   Lf fi 0 x     ZCI   gx 0 x    where y is the Euler    Mascheroni constant  0 5772      and   g  n X     x 2        n k 1     k  3 k 0 1 2     n 1   f  10 x     x 2         H k    H n k      k   n k    5 k 0 1 2        and H n  is the Aarmonic number  defined as    H n    X 1 k    k   1 2    n  Where  Y        1  Yn       and Kn  x    K  x         note that for x lt 0  Y n x  and K n x  are complex numbers         c  Angel M  Martin Revision 44_E Page 58                SandMath_44 Manual    The graphics below plot the Bessel functions of the second kind  Y  x   and their modified  K  x   for  integer orders a 0 1 2           Note that KNBS and YNBS are FOCAL programs that use dedicated MCODE functions specially written  for the calculations   BS and  BS2   Their entries are located in the sub functions FAT  thus won t be  shown in the main CAT listings     in case you wonder about their whereabouts     Getting Spherical  are we     The spherical Bessel functions jn and yn  and are  very closely  related to the ordinary Besse
3.      with special guests Riemann   s ZETA and  Lambert s W  both branches      Function Author Description    D  IBS   Ange Martin _  Bessel I n x  of thefirstkind   pi  JBS   Angel Martin _  Bessel J n x  of the firstkind ____  A5    KBS   Angel Martin __  Bessel K n x  of the second kind _____ _        SIBS   Angel Martin __  Spherical Bessel i n x    pi    SJBS_   Angel Martin __  Spherical Bessel j n x     Dig    SYBS_   Angel Martin _  Spherical Bessel  nx   Dei   WLo   Angel Martin   Lambert s W  mainbranch     _ _                        WL1i Argel Martin _  Lambert s W     secondary branch           TAJ    YBS   Angel Martin _  Bessel Y n x  of the second kind ____ _ _        TA    ZETA   Angel Martin _  Riemann s Zeta   directmethod o               ZETAX   JM Baillard ______  Riemann   s Zeta     Borwein algorithm _ __ _             The SandMath Module includes a set of functions written with the harmonic analysis in mind   specifically to facilitate the calculation of the Bessel functions in their more general sense  for any real  number for order and argument    Bessel functions of the First kind     I n x  and J n x     The formulae used are as follows     ox   _ 1 as   r   dm   J        SL   z  Xu miT m a 1  2      aa     1 op 2m4  a x   i Jalir    PETTE 9    Where   denotes the Gamma function     These expressions are valid for any real number as order  although there are issues for negative  integers due to the singularities in the poles of the gamma function   
4.     In fact that   s exactly what the functions do in RUN mode  upon completion the fraction is    converted     to a decimal number  then D gt F presents the final output  That   s why the display settings determine the  accuracy of the conversions  even if it   s not obviously seen     This has the advantage that the result is always reduced to the best possible fit  For instance  when  calculating 2 4 plus 18 24 in program mode     with the four values in the stack     the result will be 120  in Y and 96 in X  thus 120 96   However on RUN mode  or SST   ing the program  will show the reduced  fraction     574    USER RAG Oo 2 4    If you want to see the reduced result from a program execution you ll need to add program steps to  perform the division and add a conversion to fraction after the fraction math operation step  The code  Snippet below describes this  see lines 10 and 11      01  LBL  TEST   02 2   03 ENTER    04 4   05 ENTER    06 18   07 ENTER    08 24   09 F        D gt F    12 END    INT  and FRC  are two more test functions which criteria is the integer or fractional nature of the  number in X  Having them available comes very handy for decision branching in FOCAL programs  The  Fractions section of the module is the natural placement for them     The answer is YES   NO depending on whether the condition is true or false  In program mode the  following line is skipped it the test is false         c    ngel M  Martin Revision 44_E Page 24    SandMath_44 Manual
5.    l  mly    m                          Pressing  A  will calculate an estimation of the function for the argument in X  using the fourier temrs  calculated previously  In this case     X 5  XEQ  A    gt  f x    23 254423  X 1  XEQ  A    gt  f x     0 154639  which obviously misses the point     Typically the functions used are related to the harmonic analysis though  Here   s an nteresting one  the     Christmas Tree    function and its Fourier representation for different number of terms            c    ngel M  Martin Revision 44_E Page 75    SandMath_44 Manual       Appendix 10   Fourier Coefficients by brute force     Since the coefficients are basically integrals of the functions combined with trigonometric functions   nothing  besides common sense  stops us from using INTEG to calculate them  This brute force  approach is just a work around  considering the time requirements for the execution     but it can be  useful to calcuate a single term randomly  as opposed to the sequential approach used by FFOUR     So here the idea is to calculate the n th  Coefficient independently  which responds to the following  definig equation              n TA   a Notice that the module SIROM  7       Solve and Integrate    ROM  contains  2  RON    not only FROOT and FINTG  but  i PROMPT zi   _ also the program FOURN in its           7        APPLIED    section     so you can use    peT     that 4k rom instead of the Advantage        ma     that ll also save you from having to    type i
6.   04 STO 02 16 RCL 00  05 1 17 RCL 02  06 STO 03 18 YX  07 CLX 19     08 STO 00 20     09 LBL 01 21 X Y   10 RCL 01 22 GTO 01  11 RCL 03 23 END   12          c    ngel M  Martin    Revision 44_E    Page 73    SandMath_44 Manual       Fourier Series     In mathematics  a Fourier series decomposes periodic functions or periodic signals into the sum of a   possibly infinite  set of simple oscillating functions  namely sines and cosines  or complex  exponentials   The study of Fourier series is a branch of Fourier analysis     The partial sums for f are trigonometric polynomials  One expects that the functions XN f approximate  the function f  and that the approximation improves as N tends to infinity  The infinite sum    ag    oo       an cos nx    bn sin nz    2 n l   is called the Fourier series of f  The Fourier series does not always converge  and even when it does  converge for a specific value x0 of x  the sum of the series at x0 may differ from the value f x0  of the  function  It is one of the main questions in harmonic analysis to decide when Fourier series converge     and when the sum is equal to the original function     FFOUR Calculates the Fourier coefficients for a periodic function F x   defined as     ee    l pee   fd st A i   o gt  f  Gn   l f  x  cos   A Ja x    NXOR    i   f t f    y l   mx      fy   b         tx  sin ix    aa a L J    with the following characteristics             centered in x   x0    with period 2L on an interval  x0  x0 2L     with a give
7.   1 000000005   0 000100000   0 000100000   0 000100000  11013 23287   10 00000000   11013 23292   10 00000000   0 999999996   10 00271302       By now you ve become an expert in the HYP launcher and for sure appreciate its compactness     lots of  keystrokes     With a couple of exceptions it   s a100  accuracy     and really the only sore point is in the point 0 001  for the HACOS  But don   t worry  there   s no bugs creating havoc here     it   s just the nature of the beast   bound to occur with the limited precision used  even 13 digits  in the Coconut CPU     No wonder you   re going to repeat the same table for the trigonometric functions and see how it stacks  up  right     While you re at it  go ahead and calculate the power of two of the square root  pressing      Ex   9  7  2   j   but don   t call HP to report a bug     For very small arguments the accuracy of SINH and COSH will also start to show incorrect digits   However HTAN  and HATAN  use an enhanced formula that will hold the accuracy regardless of how  small the argument is         c  Angel M  Martin Revision 44_E Page 26    SandMath_44 Manual          The SandMath Module includes a set of functions written to extend the native RCL functionality      mainly in the direct math operations missing when compared to the STO equivalents  but also  increasing its versatility and ease of use  There are five new RCL Math functions  plus a launcher to  access them in a convenient and useful way         RCL   __   A
8.   5  ENTER     XEQ   MFCT      gt     Sf 41  type  41  UFL   SFCT    gt        Sf 100  type  100  EFL   SFCT    gt     To complete this trinity of factorials     Occasionally the hyperfactorial of n is considered  It is written  as H n  and defined by     H n    JJ k     1   2  33    n    1   1   n      k 1    The figures below show a plot for both the hyperfactorial and its logarithm     itself a convenient scale  change very useful to avoid numeric range problems  Note that they   re extended to all real arguments   and not only the natural numbers     also called the    K function        Hin  Ini Hind     T 100    3  B0    60     a    7     6 8 1    See below a couple of simple FOCAL program to calculate the hyperfactorial  which runs beyond the  numeric range dramatically soon   and its logarithm written by JM Baillard  Understandably slow and  limited as these programs are  you can visit his web site for a comprehensive treatment using  dedicated MCODE functions for the many different possible cases        01 LBL  HFCT  01 LBL  LOGHF    02 1 02 0   03 LBL 01 03 LBL 01   04 RCL Y 04 RCL Y   05 ENTER  05 ENTER    06 Y X 06 LOG   07   07     08 DSE Y 08     09 GTO 01 09 DSE Y   10 END 10 GTO 01  11 END        c    ngel M  Martin Revision 44_E Page 44    SandMath_44 Manual       Logarithm Multi Factorial     The product of all odd integers up to some odd positive integer n is often called the double factorial of  n  even though it only involves about half the factors of the 
9.   Fr w E Ti T Ten   re  a ee TAE Ke E  Mi A im    ae  Mo  me is N  W ea     a kan A mo  il fare aA  Jea  i   S je 1 a    uf T i a  a  az m ee ee b tn  Wav ava avalehal etal chal ar af nn  cf Dee va vas mah d i OG a OE pa af See va Nas E    a  LI a as i K  ar    a iris  T a i  oe i a par ni PE L ie  ae      te   Fe ii Ps pei  a e nal T Fi   i a     Y i Ls F ee   et RT in FA 1E  al Lt pi Fa e diy      DF ps r Pa i VA F  Fi      rod Png  4 r   1i  a AAU    os Ma aye Wai  Tin ai a a    ms j SE h    ue   a at  a     ee   ay  ne oats a  i i Leader e244 Moe PE a ai  i i n a We  56  gt  buriani i        c    ngel M  Martin Revision 44_E Page 32    SandMath_44 Manual       Combinations and Permutations     two must have classics     Nowadays would be unconceivable to release a calculator without this pair in the function set     but  back in 1979 when the 41 was designed things were a little different  So here there are  finally and for  the record     NPR calculates Permutations  defined as the number of possible different arrangements of N different  items taken in quantities of R items at a time  No item occurs more than once in an arrangement  and  different orders of the same R items in an arrangement are counted separately  The formula is     n      n    k      NCR calculates Combinations  defined as the number of possible sets or N different items taken in  quantities or R items at a time  No item occurs more than once in a set  and different orders of the  same R items is a se
10.   er      108 LBLO8    46     109 RCL 03   47 a0 2   a2 3 27   a1 a2 6     110 COS      48 iii      49 E a  f  50 cbrt  x R3 2   413 RCL 02 a2 3  C 51 f  T 114    F 52 RCL 02 a2 3 f 115    X   s H F 116  54    x1  117 OOOO  55 ARCLX  3  118  56 119 ARCL X 3   57 STO 00 real root 120  58 RCL 01 cbrt  x R3 2  121 STO IND05  59 RCL 03 cbrt  x R3 2  122 120  60   123  ST  03  61 3 1244 ISG05     02O  62 SQRT 125 GTO 08 O i  63   126 END     c  Angel M  Martin Revision 44_E Page 21    SandMath_44 Manual       2 1 4  Additional Tests  Rounded and otherwise     Ending the first section we have the following additional test functions     Function   Author   Description _     Z    gt Z S   X 1    Melson C  Crowle   Is X  exactly  equal to 1   Is X equal to or greater than Y     Angel Martin Rounded Comparison  FRC    Angel Martin Is X a fractional number    F  Angel Martin Is X an integer number    Angel Martin Is X equal to or greater than zero        They follow the general rule  returning YES   NO in RUN mode  and skipping a program line if false in a  program  Their criteria are self explanatory for the first three  These functions come very handy to  reduce program steps and improve the legibility of the FOCAL programs     X gt  Y  compares the values in the X and Y registers  skipping one line if false   X gt  0  compares with zero the value in the X register  skipping one line if false     These functions are arguably    missing    on the mainframe set  a fact partially correct
11.  Alpha Integer Part  ATAN2 Dual argument ATAN  BS gt D Base to Dec  CBRT Cubic Root  CEIL Ceil function  CHSYX CHSY by X  CROOT Cubic Equation Roots  CVIETA Driver for CROOT  D gt BS Dec to Base  D gt H Dec to Hex  E3 E  1 00X  FLOOR Floor Function  GEU Euler s Constant  H gt D Hex to Dec  HMS  HMS Multiply  HMS  HMS Divide  LOGYX LOG b of X  MANTXP Mantissa  MKEYS Mass Key Assgn   P gt R Complete P R  QREM Quotient Reminder  QROOT 2nd  Degree Roots  QROUT Outputs Roots  R gt P Complete R P  R gt S Rectangular to Spherical  S gt R Spherical to Rectangular  STLINE Straight Line from Stack  T gt BS__ Dec to Base  VMANT View Mantissa  X 3 X 3  X 1  Is X 1   X Y R Is X Y   rounded   X gt  0  is X gt  0   X gt  Y  is X gt  Y   Y41 X Xth  Root of Y  YAAX Extended Y X  YX    Modified Y X     FRC_  Fraction Math Launcher    D gt F Decimal to Frac  F  Fraction Addition  F  Fraction Subtract  F  Fraction Multiply  F  Fraction Divide  FRC  is X fractional   INT  Is X Integer      HYP_  Hyberbolics Launcher    HACOS Hypebolic ACOS    O CON DUM BWN FP OT     num A aA A PHP PP BPP HPWBWWWWWWWwWWWNNNNNNNNNNPRP RP RP RP RP RP RP RP PRP PB  e O O WON DUN PWN PRP CO HO WON DU BPWNPRP ODO HW WON DU PWNHRP DUO WON DU PWN FP OO    Name Description    LHL MATH _ Secton Header      1 GMF Reciprocal Gamma  Cont  Frc    2FL Main Function Launcher   FL Launcher by Name   Z FLH Launcher by index   BETA Beta Function   Cl Cosine Integral   El Exponential Integral   ELIPF Eliptic Integral 1st  Kind   ERF
12.  Anger functions     WEBAN     In mathematics  the Anger function  introduced by C  T  Anger  1855   is a function defined as    1 iT  J  z        cos v       zsin    d      T  The Weber function introduced by H  F  Weber  1879   is a closely related function defined by   1 jf   E  z        sin v      zsin   d    WT Jo    If v is an integer then Anger functions Jv are the same as Bessel functions Jv  and Weber functions  can be expressed as finite linear combinations of Struve functions  Hn and Ln      With n and x in the stack  WEBAN will return both J n x  and E n x  in the Y and X stack registers  respectively     The figures below show four of these functions for 4 orders  0  0 5  1  and 1 5      Anger on the left  plots  and Weber on the right   Check  J 0 0    1  and E 0 0    1        Note that WEBAN will return both values to the stack     REGISTERS  ROO thru R06    FLAGS  none  Stack  Y  Example     2  SQRT  PI   FL  WEBAN    gt   E sqrt 2   x      0 315594385  X lt  gt Y   gt   J sqrt 2   x   0 366086559    Or   Dial    H    W         c  Angel M  Martin Revision 44_E Page 81    SandMath_44 Manual       3 5 2  Hankel  Struve  and similar functions     The second sub function launcher is the Hankel group  It   s loosely centered on the Hankel functions   plus related sort  The launcher prompt is activated by pressing  H  at the main XFL prompt  and offers  the following 14 choices     in two line ups controlled by the  SHIFT  key  Note the different leadings on  each s
13.  Digamma  and the Bessel functions     LOGYX is the base b Logarithm  defined by the expression     logio x  E log   2     bgs    gnl    log   6     where the base b is expected to be in register Y  and the argument in register X     QREM Calculates the Remainder    R    and the Quotient    Q    of the Euclidean division between the  numbers in the Y  dividend  and X  divisor  registers  Q is returned to the Y registers and R is placed in  the X register  The general equation is  Y   Q X   R  where both Q and R are integers     CBRT calculates the cubic root of a number  Note that this is identical to the mainframe function X Y  with Y 1 3 for positive values of X  but unfortunately that results in DATA ERROR when X lt 0     and  therefore the need for a new function  Obviously CBRT  x      CBRT x   for x gt 0    Y 1 X and X 3 are purely shortcut functions  obviously equivalent to 1 X  Y X  and to X42   LASTx    respectively   but with additional precision due to the 13 digit intermediate calculations         c  Angel M  Martin Revision 44_E Page 16    SandMath_44 Manual       Y  X is used to calculate powers exceeding the numeric range of the calculator  simply returning the  base in X and the exponent in Y  The result is shown in ALPHA in RUN mode   For instance calculate  8569 to obtain     Pga4hbb tt E 133    USER RAL Hiz 4       YX  is a modified form of the native Y X function  with the only difference being its tolerance to the  0 0 case     which results in DATA ERROR
14.  Error Function   FFOUR Fourier Series   GAMMA Gamma Function  Lanczos   HCI Hyperbolic Cosine Integral  HGF  Generalized Hypergeometric Function  HSI Hyperbolic Sine Integral   IBS Bessel In Function   ICBT Incomplete Beta Function  ICGM  Lower  Incomplete Gamma Function  JBS Bessel Jn Function   KBS Bessel Kn Function   LINX Polylogarithm   LNGM Logarithm Gamma Function  PSI Digamma Function   PSIN Polygamma   PP2 Point to Point Dist   POCH Pochhammer Symbol    SI Sine Integral    SIBS Spherical   Bessel   SJBS Spherical J Bessel   SYBS Spherical Y Bessel   WLO Lambert W Function   WL1 Lambert W Function   YBS Bessel Yn   ZETA Zeta Function  Direct method   ZETAX Zeta Function  Borwein   ZOUT Output Complex to ALPHA  DECX Decrease X   DECY Decrease Y   INCX Increase X   INCY Increase Y    PRB STS _   T Percentual   CORR Correlation Coefficient  COV Sample Covariance   DSP  Display Digits   EVEN  is X Even    GCD Greatest Common Divisor  LCM Least Common Multiple  LGMF Log Multi Factorial   LR Linear Regression   LRY LR Y value   NCR Permutations        c  Angel M  Martin    Revision 44 _E    Page 12    SandMath_44 Manual       52  53  54  55  56  57  58  59  60  61  62  63    HASIN  HATAN  HCOS  HSIN  HTAN     RcL_  Extended Recall    AIRCL  RCL   RCL   RCL   RCL   RCL     Hyperbolic ASIN  Hyperbolic ATAN  Hyperbolic COS  Hyperbolic SIN  Hyperbolic TAN       ARCL Integer Part  Recall Power  Recall Add   Recall Subtract  Recall Multiply  Recall Divide    Functions in blue ar
15.  Integral S    Notable examples of    multi purposed function    are also the Carlson Integrals  themselves a generator  for several other functions like the Elliptic Integrals  More about this in the corresponding paragraphs  later on        Exponential Integral and associates   The first sub section covers the Exponential  Logarithmic  Trigonometric and Hyperbolic integrals   They re all calculated using their expressions using the Generalized Hyper geometric function  in a clear  demonstration of the usefulness or the adopted approach   For real nonzero values of x  the exponential integral Ei x  is defined as    4  e  Rifas        dt       co t    Integrating the Taylor series for exp t  and extracting the logarithmic singularity  we can derive the  following series representation for real values     g      oo  Fi a   y   In  x    X     x   0       k k    k 1  where we substitute the series by its Hyper Geometric representation     Yt x k kk    x F 1 1 2 2 x     The logarithmic integral has an integral representation defined for all positive real numbers by the  definite integral     z dt  o Int    li        The function li x  is related to the exponential integral Ei x  via the equation     iia    Elie j  which is the one used to program it in the SandMath module         c  Angel M  Martin Revision 44_E Page 69    SandMath_44 Manual          The different trigonometric and hyperbolic integral definitions and their relations with the Hyper   Geometric funcion  for the rel
16.  M   Lambert s W   SST   Incomplete Gamma   N   FCAT  sub functions CATalog     O   Carlson Launcher   R   Exponential integral   S   Error Function     T   Polygamma  PsiN    V   Cosine Integral    W   Spherical Y n x     X   Incomplete Beta    Z   Sine Integral        Spherical J n x          Fractions Launcher   R S   View Mantissa    ZB   Cancels out to the OS   ALPHA   Sub function Launcher   0N   Turns the calculator OFF       A green    H    on the overlay prefixing the function name represents the Hyperbolic functions  This also  includes the Hyperbolic Sine and Cosine integrals  in addition to the three    standard    ones  Using the   SHIFT  key will toggle between the direct and inverse functions  Pressing   lt    will take you back to  the main XFL prompt     The Fraction functions are encircled by a red line on the overlay  at the bottom and left rows of the  keyboard  They include the fraction math  plus a fraction Viewer and fraction Integer tests     The Hankel and Carlson launchers will present their choices in their prompts  and will be covered later  in the manual     Note that the RCL Math functions are also linked to the main launcher  to invoke them use the   Yell   launcher  sort of    Hyper RCL    thus need to press   MA1    HYP  to get the     RCL  _ _    prompt         c  Angel M  Martin Revision 44_E Page 10    SandMath_44 Manual       Appendix 1   Launcher Maps     The figures below provide a better overview  illustrating the hierarchy between laun
17.  M  Martin Revision 44_E Page 30       SandMath_44 Manual       3  Upper Page Functions in detail     It   s time now to move on to the second page within the SandMath     holding the Special Functions and  the Statistical and Probability groups  Let   s see first the Statistical section     easier to handle and of  much less extension  and later on we ll move into high level math  taking advantage of the extended  launchers and additional functionality described in the introduction of this manual           The following functions are in this general group  Some of them are plain catch up  with the aim to  complete the set of basic functions  Some others are a little more advanced  reaching into the high  level math as well      _  Function   Author        s  Description     O Z       OZ oO O     DSP    Angel Martin _  Number of decimal places      EVEN    Angel Martin _  Tests whether x is an even number _ __            o      o           GCD Angel Martin Greatest Common Divider        LCM   Angel Martin _  Least Common Multiple O O O SS     MFCT_   Ballard _____  Multifactorial o O     NCR_____  Angel Martin ____  Combinations of N elements taken in groups of R _ __    NPR     ngelMartin   Permutations of N elements taken in groups of R  ODD      ngel Martin             Tests whether x in an odd number  PDF     ngelMartin   Normal Probability Density Function  Prime Factorization  PRIME    Jason DeLooze   Primality Test     finds one factor  RAND   Hakan Th  rgren   Random 
18.  ROM    DF    routine     As per the fraction arithmetic functions  there   s not much to say about them     apart from the fact that  they use the four stack levels to enter both fractions components  the inputted values are expected to  be all integers   and return the numerator and denominator of the result fraction in registers Y and X  respectively  In RUN mode the execution continues to show the fraction result in ALPHA  according to  the currently set number of decimals  see below      The fraction arithmetic functions can be used in chained calculations  there   s no need to re enter the  intermediate results  and the Stack enabled makes unnecessary to press ENTER     Notice that fractions  are entered using the Numerator first     To re calculate the fraction after changing the decimal settings just press the divide key  followed by  D gt F to re generate the fraction values     For example calculate 2 7 over 4 13  then add 9 17 to the result     2  ENTER     7  ENTER     4  ENTER   13   F    9 ENTER   17  F    gt  347 238 in FIX 6 mode     34 238    USER RAG iz 4        c  Angel M  Martin Revision 44_E Page 23    SandMath_44 Manual       Needless to say the fractional representation display will not be produced in PRGM mode  but it ll have  a silent execution instead     Note that the fraction math functions operate on integer numbers in the stack  returning also the  numerator and denominator as integers  To get the decimal number just execute       to divide them 
19.  a numeric one which could be misinterpreted         The indirect addressing is actually quite simple  as it simply consists of an offset added to the register  number in the index  All the function code must do is remove it from the entry data provided by the  OS  and the task is done  The offset value is hex 80  or 128 decimal  We ll revisit this when discussing  the RCL launcher        And the third objective is provided    for free    by the OS as well  no need for extra code at all     just  using the appropriate prompting bits in the function   s name         c  Angel M  Martin Revision 44_E Page 27    SandMath_44 Manual       Stack arguments are more involved than the indirect addressing  No attempt has been made to use the  mainframe internal routines to accommodate this case  so stack prompts are excluded  Note that even  if the Stack arguments are not directly allowed  controlled by the prompting bits   it is unfortunately  possible to use the decimal key in an indirect register sequence  that is after pressing the SHIFT key   This won   t work properly in the current design so must be avoided     ORT RAND    STO y  2 4 2  RCL Launcher     the Total Rekall  aay       The basic idea of a launcher is a function capable of calling a set of other functions  The grouping in  this case will be for the five RCL Math functions described above  plus logically the standard RCL  operation     inclusive its indirect registers addressing  Other enhancements include the prompt  l
20.  e  calculating the function value  is reduced to a single    MCODE function     The following trivial looking program  it really can   t get any simpler   uses SOLVE within the Advantage  Pack  no less  Starting with zero  obvious guess values are the previous root and the root incremented  by one  Successive repetitions will unearth all those roots  just make sure you have the    turbo    mode  enabled on V41  or equivalent emulator   Enjoy     The first few roots j n k  of the Bessel function Jn x  are given in the following table for small  nonnegative integer values of n and k    See also  http   cose math bas bg webMathematica webComputing BesselZeros  jsp    1 LBL   ITJBS       2   XY  3 STOO00  4 XoY  5 0  E  X lt  gt     7      JB   8 INTEG  q RTN  10  LBL JZER   11   HLMATH  12 STOP  13 STO00  14 0  15  16  17  18  19  20 SOLVE  71 STOP  22 INCX  23 GTO 00  24  26 RCL OO  26 X lt Y  27  JBS  28 END         Orders     k dof  Oy    1 24048 38317   2  55201  7 0156   3  86537   10 1735   4   11 7915   13 3237   5 14 9309 16 4706  Fix           mH     O 2      Ja  x  Fy  x     5 1356 6 3602  64172 9 7670  11 6198   13 0152  14 7960 16 2235    17 9598 19 4094    Ja  x     7 5883    11 0647    14 3725    17 6160    J   x   6 7715  12 3386  15 7002    18 9801    20 8269 22 2178    PY  I      y A ey    A A hte      b4    Note that the program listing also includes code to calculate the Integral of JBS  defined as incomplete  function with the argument in the upper integrati
21.  handle  requiring quite a number of coefficients to be calculated for good  accuracy result  Moreover  that calculation involves a lot of registers to store the values     since there  isn t any iterative approach based on recursion     m   O       The expression below is definitely too inaccurate  only three or four digits are correct  to deserve a  dedicated MCODE function     Tr    1277   43697 348077  A isl O  A aE  7 g 1l  ne Ta ove  z  12     480     10320    5806080   182476800    A paper from 1968 by A  Strecok lists the first 200 coefficients of a power series that represents the  inverse error function  While using this approach it became clear that at least 30 of them are needed for  a 10 digit accuracy for 0 lt  x  lt  0 85  This only gets worse as x approaches 1  getting into a clear  example of the    law of diminishing results        A better method for the vicinity of 1 is probably to use an asymptotic expansion  such as     2 2  log                log   los                  _     74     y2 s         og log  J  1 4 oh    A combination of both approaches would seem to be the best compromise  depending on the  argument    Typing the 30 coefficients is not fun however  thus the best is no doubt to use a data file in  X Memory to keep them safe          erf   z  x           c  Angel M  Martin Revision 44_E Page 72    SandMath_44 Manual       How many logarithms  say again     LINX calculates the polylogarithm function   also known as Jonqui  re s function  a spec
22.  implementation  Also provision for the case x 0 was added   trivially returning the character    0    for any base  The prompt can be filled using the two top keys as  shortcuts  from 1 to 10  A J   or the numeric keys 0 9     Ha e BASE 35    USER RAD Hic q4 USER RAD ji   4       Because of its importance  the hexadecimal conversions have the dedicated MCODE functions D gt H  and H gt D  Use them to convert the number in X to its Hex value in Alpha  and vice versa  The  maximum number allowed is 0x2540BE3FF or 9 99999999 E9 decimal   much smaller than with T gt BS   so there s a price to pay for convenience  These functions were written by William Graham and  published in PPCJ V12N6 p19  enhancing in turn the initial versions first published by Derek Amos in  PPCCJ V12N1 p3         c    ngel M  Martin Revision 44_E Page 18    SandMath_44 Manual       2 1 3  First  Second and Third degree Equations     A MCODE implementation of these offers no doubt the ultimate solution  even if it doesn t involve any  high level math or sophisticated technique  The Stack is used for the coefficients as input  and for the  roots as output  No data registers are used     Function Author Description      STLINE    _  Angel Martin _  Calculates straight line coefficients from two data points       QROOT   Angel Martin _  Calculates the two roots of the equation                 QROUT    AngelMartin ___  Displays the rootsin Xand Y            o        o Z   o                CROOT Calculates the t
23.  includes more general purpose functions  re visiting  the usual themes  Fractions  Base conversion  Hyperbolic functions  RCL Math extensions  as well as  simple but neat little gems to round off the page  In sum  all the usual suspects for a nice ride time     The second page delves into deeper territory  touching upon the special functions field and  Probability Statistics  Some functions are plain    catch up    for the 41 system  sorely lacking in its native  incarnation   whilst others are a divertment into a tad more complex math realms  All in all a mixed   and matched collection that hopefully adds some value to the legacy of this superb machine     for many  of us the best one ever     I am especially thankful for the essential contributions from Jean Marc Baillard  more than 3 4ths of  this module are directly attributable to his original programs  one way or another     Wherever possible the 13 digit OS routines have been used throughout the module     ensuring the  optimal use of the available resources to the MCODE programmer  This prevents accuracy loss in  intermediate calculations  and thus more exact results  For a limited precision CPU  certainly per today   s  standards  the Coconut chip still delivers a superb performance when treated nicely     The module uses routines from the Page 4 Library  a k a     Library 4      Many routines in the library  are general purpose system extensions  but some of them are strictly math related  as auxiliary code  reposi
24.  is always given  for additional information that can  and should  also be  consulted           The Module starts with an assorted group of functions providing simple but important additions to the  native function set     2 1 1  Elementary Math functions    Even the most complex project has its basis     simple enough but reliable  so that it can be used as  solid foundation for the more complex parts  The following functions extend the HP 41 Math function  set  and many of them will be used either as MCODE subroutines or directly in FOCAL programs      _  Function   Author   Description  __    O    O Z O       2 X 1_   Angel Martin __  Self descriptive  faster and better precision than FOCAL        Z1 N______  Angel Martin _  Harmonic Number H n       ATAN2   AngelMartin _  Two argumentarctangent _ _ O    o Z o              2 X 1 provides a more accurate result for smaller arguments than the FOCAL equivalents  It will be  used in the ZETAX program to calculate the Zeta function using the Borwein algorithm      1 N calculates the Harmonic number of the argument in X  as is the sum of the reciprocals of the  natural numbers lower and equal than n        1  k i       It will be used to calculate the Bessel functions of the second kind  K n x  and Y n x      Also related to the same problem  and in general relevant to the summation of alternating series  is the  function CHSYX   an extension of CHS but dependent of the number in Y  Its expression is     CHS Y X   x   1  y  retu
25.  kind F is defined as           P   p da  F y k    F p  k     F sing k            which in terms of the Carlson Symmetric form Re  it results     F     k    singAp  cos   1     k  sin  D  1         c    ngel M  Martin Revision 44_E Page 77    SandMath_44 Manual       ELIPF is implemented as a MCODE function which simply calls CRG with the appropriate input  parameters  All the heavy lifting is thus performed by CRG  which together with CRJ do all the hard  work in the calculation for the Elliptic Integrals if first  second and third kinds     The figure below shows the first and third kinds in comparison       Elliptic Of the First Kind Elliptic Of the Third Kind       0 5       n 0 o 1 25       0 75     n 0 5 m 1 25        1 25     n 0 25 p n 2      p n 2        n 0 75 p n 2          ellint_1 k  phi   ellint_3 k  n  phi                 This is a perhaps a good moment to define the Carlson symmetric forms  The Carlson symmetric forms  of elliptic integrals are a small canonical set of elliptic integrals to which all others may be reduced   They are a modern alternative to the Legendre forms  The Legendre forms may be expressed in terms  of the Carlson forms and vice versa     The Carlson Symmetric Elliptic integrals of the First and Third kinds are defined as     7 a  Re 2z y  z           t L x  t   yit T z     R3 x  Y  z  p       t p  t a     y    z     CRF and CRJ are the functions in the SandMath that calculate their values  The arguments are  expected to be in the stack r
26.  of sets from a sample of 335 objects taken in quantities of 167     Type  335  ENTERN  167  XEQ    NCR    gt   3 0443587 99    Example  How many different arrangements are possible of five pictures which can be hung on the  wall three at a time     Type  5  ENTER     3  XEQ    NPR   gt   60 00000000    The execution time for these functions may last several seconds  depending on the magnitude of the  inputs  The display will show    RUNNING       during this time         c  Angel M  Martin Revision 44_E Page 33    SandMath_44 Manual       Linear Regression     Let   s not digress     The following four functions deal with the Linear Regression  the simplest type of the curve fitting  approximations for a set of data points  They complement the native set  which basically consists of  just MEAN and SDEV     Function Author Description     f z    CORR   IM Baillard   Correlation Coefficient of an X Y sample  Covariance of an X Y sample     sx   LR   JM Baillard __  Linear Regression of an X Y sample  Y  value for an X point       Linear regression is a statistical method for finding a straight line that best fits a set of two or more  data pairs  thus providing a relationship between two variables  By the method of least squares  LR will  calculate the slope A and Y intercept B of the linear equation  Y   Ax   B     se  15 r    5      a   5 tat  10  i k  4     fie TO     e    da ra        d  as   a ke a  atta     oe C   a  ie P a  i        The results are placed in Y and X reg
27.  of the associated Legendre  functions respectively  Legendre polynomials are the associated Legendre functions of order  O     These functions may actually be defined for general complex parameters and argument     1  z  AOD     pie l z    2fi    A  A  1  1  u  5   for  l   z   lt  2    The figures below give a couple of graphical plots for the Legendre Polynomials     Associated Legendre Polynomials    Pix        Pii    r i i       z Paix  Pix  Pal           REGISTERS  ROO thru R05  FLAGS    Stack Input Output       Examples     0 4 ENTER   1 3 ENTER   0 7 XFL   ALF    gt  P1 3 0 4 0 7    0 274932821   0 6 ENTER   1 7 ENTER     4 8 XFL   ALF    gt  P1 7  0 6 4 8    10 67810281    Or   Sig    H    SHIFT    L  instead        c    ngel M  Martin Revision 44_E Page 90    SandMath_44 Manual       Toronto Function     In mathematics  the Toronto function T m n r  is a modification of the confluent hypergeometric  function defined by Heatley  1943  as      pen mt oT 2i s m    gt    T n   1     Which to untrained eyes just appears to be a twisted cocktail of the Kummer function  adding the  exponential tot he mix and scaling it with Gamma     T m  n  T 1F   m 3 n4 l r         DATA REGISTERS  ROO thru R04  Stack Input Output  Flags  none     Barok  Se ra    2 SQRT  3 SQRT  PI  XFL  TMNR   gt  gt  gt  gt  T  sqrt 2  sqrt 3   n    0 963524225       Or   Sig    H    SHIFT    R  instead    Poisson Standard Distribution         PSD is another Statistical function  which calculates the Po
28.  polling points     SEEDT will take the fractional part of the number in X as seed for RNG  storing it into the buffer  If  x 0 then a new seed will taken using the Time Module     really the only real random source within the  complete system     RAND will compute a RNG using the current seed  using the same popular algorithm described in the  PPC ROM   and incidentally also used in the CCD module   s function RNG     Both functions were written by Hakan Thorngren  an old hand and MCODE expert   and published in  PPC V13N4 p20    PRIME  Determines whether the number in the X register is Prime  i e  only divisible by itself and  one   If not   t returns the smallest divisor found and stores the original number into the LASTX  register  PRIME  Also acts as a test  YES or NO are shown depending of the result in RUN mode   When in a program  the execution will skip one step if the result is false  i e  not a prime number    enabling so the conditional branching options     This gem of a function was written by Jason DeLooze  and published in PPCCJ V11N7 p30     Example program   The following routine shows the prime numbers starting with 3  and using diverse  Sandbox Math functions     01 LBL    PRIMES    05 PRIME  09 INCX  02 3 06 VIEW X  lt yes gt  10 GTO 00  03 LBL 00 07 X Y   lt no gt  11 END  04 RPLX 08 LASTX    See other examples later in the manual  relative to prime factorization programs           Fa s  gur Fa w pa dA    D m eai    i 7 n Tos ma Fi y   i 1 F Wit     if y
29.  reset counter 69 MSUA  25 RDN 70 CLA  27 RCL 01 previous prime factor 72  28 X lt  gt Y 73  29 PRIME  74  30 SF 00 75  31 X Y  different PF  76  32 TO 02 YES 77  33 ISG 00 increase counter 78  34 NOP SAME pf 79  35 FS C 00 was it prime  80  36 GTO 03 skip if Prime 81  37 ST L 82  38 LASTX 83 ST  00  39 GTO 00 84 FC  10  40 85 mp     41 86 FC  10  42 87 GTO 06  43 88 RCL 00  44 f 89 PROMPT  45 STO 01 90 END        c  Angel M  Martin Revision 44_E Page 39    SandMath_44 Manual       Distance between two points     The Euclidean distance between points p and q is the length of the line segment connecting them  In  the Euclidean plane  if p    p1  p2  and q    q1  q2  then the distance is given by       d p q    vy  pi     q1      pe     g2         PP2 expects the coordinates of the two points stored in the stack   y1 x1    y2 x2  in T Z Y  and X  or  vice versa   The distance will be placed in X upon completion     Example  Calculate the distance between the points a  3 5  and b 6  2  from the figure below     s Type  5  ENTER      3  ENTER       2  ENTER  6  ENTER      XEQ    PP2      gt  9899494937    E   3  5     Note  A similar function exists in the 41Z module      ZWDIST  which basically calculates the same thing  albeit      done in a complex number context        Note  PP2 is the only geometry function within the SandMath  The VECTOR ANALYSIS module  contains many more  as well as a full featured 3D Vector Calculator  see overlay below   It is a 4k   module that can be 
30.  s reused by both modules  so far         Its hot keys and actions are listed below      R S   halts the enumeration    SST BST   moves the listing one function up down    SHIFT   sets the direction of the listing forwards backwards    XEQ   direct execution of the listed function     or entered in a program line   ENTER       moves to the next previous section depending on SHIFT status    lt     back arrow cancels the catalog    One limitation of the sub functions scheme that you ll soon realize is that  contrary to the standard  functions  they cannot be assigned to a key for the USER keyboard  Typing the full name  or entering  its index at the XFL  prompt  is always required  This can become annoying is you want to repeatedly  execute a given sub  function     A work around this consists of writing a micro FOCAL program with just the sub function as a single  pair of program lines  and then assign it to the key of choice  Not perfect but it works     Note  Make sure the revision    G     or higher  of the Library 4 module is installed         c  Angel M  Martin Revision 44_E Page 14    SandMath_44 Manual       2  Lower Page Functions in detail    The following sections of this document describe the usage and utilization of the functions included in  the SandMath_44 Module  While some are very intuitive to use  others require a little elaboration as to  their input parameters or control options  which should be covered here  Reference to the original  author or publication
31.  when the solution is a complex number   like J  0 5   0 5  or I  0 5   0 5   There   s no way around that save in some particular cases of the order   You can always use the versions available in the 41Z Module for a full complex range        OUT OF RANGE   when the calculator numeric range is exceeded  This typically occurs for large  indexes  during the power exponentiation step        ALPHA DATA    indicates alphabetic data in registers X or Y  May also trigger    DATA ERROR      iP            c  Angel M  Martin Revision 44_E Page 62    SandMath_44 Manual       Appendix 7   FOCAL program used to calculate the Bessel Functions of the second kind  As you can  see it   s just a simple driver of the MCODE functions  with the additional task of orchestrating the logic  for the different cases     Note the usage of the sub functions from the auxiliary FAT   as well as other SandMath functions     01  02  03  04  05  06  07  08  09  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50    b a e  a     J  O  O O O  O  J     o Ss  a  s O I     O O O     LBL KBS       BL YBs       g    CF 01       LBL 00  X 0   RTN single case x 0  e    HALFX  x 2  swap things  n  CTO 02 ___ __ yes _divert to section _____  F  CHS  n  X lt  gt Y x 2  RAD  SPFC  Multi Function Launcher  1 Recurrence Sum  BS  CHS  J  n x   STO 02 partial result  RCL 01 n  RCL 03 x 2  SPFC    Multi Function Lau
32.  with the standard function but here returns 1  This has  practical applications in FOCAL programs where the all zero case is just to be ignored and not the  cause for an error     2 1 2  Number Displaying and Coordinate Conversions     A basic set of base conversions and diverse number displaying functions round up the elementary set     Author _   Description  MANTEXP       AINT elegantly solves the classic dilemma to append an index value to ALPHA without its radix and  decimal part   eliminating the need for FIX 0  and CF 29 instructions  taking extra steps and losing the  original calculator settings  Note that HP added AIP to the Advantage module  and the CCD has ARCLI  to do exactly the same     MANTEXP and VMANT are related functions that deal with the mantissa and exponent parts of a  number  MANTEXP places the mantissa in X and the exponent in Y  whereas VMANT shows the full  mantissa for a few instants before returning to the normal display form   or permanently if any key Is  pressed and held during such time interval  similar to the HP 42S implementation of    SHOW        R gt P and P gt R are modified versions of the mainframe functions R P and P R  The difference lies in  the convention used for the arguments in Polar form  which here varies between 0 and 360  as  opposed to the    180  180 convention in the mainframe     Continuing with the coordinate conversion  R gt S and  S gt R can be used to change between rectangular  and spherical coordinates     The co
33. 0521E 10   4 17535E 10       0  0  0  0  0  0  0  0  0  0  0  0  0       0  0  0  0        c  Angel M  Martin Revision 44_E    SandMath_44 Manual       3 3 2  Reciprocal Gamma function     y  L igamma s   oie 2      The reciprocal Gamma function is the function al  fe        l  Ar  2   D z     where   z  denotes the Gamma function  Since the  Gamma function is meromorphic and nonzero 4  everywhere in the complex plane  its reciprocal is  an entire function  The reciprocal is sometimes  used as a Starting point for numerical computation  of the Gamma function  and a few software    libraries provide it separately from the regular E F  ry F 4  Gamma function                          Plot of Tix  along the real axis     Taylor series expansion around 0 gives        zp yzi   fO ee eT  eer 2 12         T z     The SandMath however uses the expression based in continuous fractions  according to which     r x     x  x 1 2   sqrt  2r  exp    x    1 12   x        1 30   x    53 210   x   195 371   x              Comparing the results obtained by GAMMA  using Lanczos  and continuous fractions it appears that  the precision is generally better in the Lanczos case      which also happens to be faster due to its  polynomial like form and the absence of loops to adjust the result for smaller arguments     Note the special case for x 0  which is not a pole for this function but it is a singularity for all the  others that used the common subroutines     therefore the dedicated check in the 
34. 29    Page 3    SandMath_44 Manual       3 2  Factorials    A timid foray into Number Theory 41  Pochhammer symbol  rising and falling empires 42  Multifactorial  Superfactorial and Hyperfactorial 43  Logarithm Multi Factorial 45  Appendix 5   Primorials  a primordial view  46    3 3  High Level Math    The case of the Chameleon function in disquise 49  Gamma Function and associates 50  Lanczos Formula 51  Appendix 6  Comparison of Gamma results 52  Reciprocal Gamma function 53  Incomplete Gamma function 53  Logarithm Gamma function 54  Digamma function 55  Euler   s Beta function 56  Incomplete Beta function 56  Bessel Functions and Modified 57  Bessel functions of the 1  Kind 57  Bessel functions of the 2    Kind 58  Getting Spherical  are we  59  Programming Remarks 60  Appendix 7  FOCAL program for Yn x   Kn x  63  Riemann Zeta Function 64  Appendix 8   Putting Zeta to work  Bernoulli numbers 66  Lambert W Function 67    3 4  Remaining Special Functions in Main FAT    Exponential Integral and associates 69  Errare humanum est    71  The unsung Hero 71  Appendix 9   Inverse Error function  coefficients galore 72  How many logarithms  say what  73  Fourier Series 74  Appendix 10  Fourier Coefficients by brute force 76    3 5  More Special Functions in Secondary FAT    3 5 1  Carlson Integrals and associates  The Launcher    The Elliptic Integrals 77  Carlson Symmetric Form 78  Airy Functions 79  Fresnel integrals 80  Weber and Anger Functions 81        c    ngel M  Martin R
35. 4 3  x   9     The           below shows Ai and Bi                       for 15 lt x lt 5    tet  MANNA NS  eal AVN AV   fe       0 30          REGISTERS  ROO thru R04    FLAGS  none Stack Output  Example     0 4 EFL   AIRY    gt  Ai 0 4    0 254742355   or   Mal    H    Y   X lt  gt Y   gt  Bi 0 4    0 801773001        c    ngel M  Martin Revision 44_E Page 79       SandMath_44 Manual       Fresnel Integrals     Fresnel integrals  S x  and C x   are two transcendental functions named after Augustin Jean Fresnel  that are used in optics  They arise in the description of near field Fresnel diffraction phenomena  and  are defined through the following integral representations     S x    l  sin t2  dt  C x      cos t2  dt     The function CSX will calculate both S x  and C x  for the argument in X  returning the results in Y and  X respectively  It is a short FOCAL program that uses  yes you guessed it  the Generalized Hyper   geometric function  according to the expressions     S x     1 x   6   1Fa  3 4   3 2   7 4   n   x  16    and    C x   x  F   1 4  1 2   5 4   n   x7 16      The figure below shows both functions plotted for 0 lt x lt 5       REGISTERS  ROO thru R04    FLAGS  none  Stack Output  n a S x   X X C x   Examples   1 5 XFL   CSX    gt  C 1 5    0 445261176 X lt  gt Y  S 1 5    0 697504960  4 XFL   CSX    gt  C 4    0 498426033 X lt  gt Y  S 4    0 420515754  Or   al    H    C         c  Angel M  Martin Revision 44_E Page 80    SandMath_44 Manual       Weber and
36. 628800     1 66667E 10  4 16667E 10  0  1 11111E 09  3 96825E 10  7 44048E 10  5 591146E 10  2  5573E 10   2 50521E 10   1 04384E 09  4 81771E 10    1 000000001  1 000000001  2 000000001  6 000000002   24   120  720 0000001   5040   40319 99999  362879 9998  3628800 018  39916800 01  479001598 3  6227020798    1E 09  1E 09  5SE 10  3 33333E 10  0  0  1 38889E 10  0   2 4802E 10   5 0115E 10  4 96032E 09  2 00521E 10   3 549E 09   3 2118E 10    Enhanced 13 digit Implementation    error    O    1 000000001  2  6 000000004  24  120  720    5039 9999990    40 320 00001  362880  3628800    error    0       1E 09  0  6 66667E 10     1 9841E 10  2 48016E 10  0       1 000000012  1 000000012  2 000000024  6 000000071  24 00000028  120 0000014  720 0000087  9040 00006  40320 00048  362879 9988  3628800 05  39916800 9  479001580 2  6227020957      Result  1  1  1 999999999  9 999999997  23 99999999  120 0000014    719 9999996  9 039 999998    40 319 99998  362 880  3 628 800    1 2E 08   1 2E 08   1 2E 08  1 18333E 08  1 16667E 08  1 16667E 08  1 20833E 08  1 19048E 08  1 19048E 08   3 30688E 09  1 37787E 08  2 20469E 08   4 1336E 08  2 92127E 08       Lanczos  k 6  Continuous Fractions Windschitl  Stirling     Result error  1    0  0   5E 10   5E 10   4 16667E 10  1 16667E 08   5 55556E 10   3 96825E 10   4 96032E 10  0  0    39916800  479001600  6227020800    39916800  479 001 600  6 227 020 800    39916800  479001600  6227020800    39 916  99 99  479 001 599 8  6 227 020 800     2 5
37. 98  an error of err  4 E 10    where  FL  can be called using the main launcher   gl    ALPHA     Example 2   calculate the Omega constant       W 1     1    gt     RUNNING         followed by 0 567143290    Example 3  Calculate both branches of W for x  1 2e    1  EX  CHS  ST  X  1 X    gt  Wo   1 2e     0 231960953  LASTX  XEQ   WL1    gt  W    1 2e     2 678346990       And here   s a 3D representation of the complex  Lambert to end this section with a graphical  splash  Enough to make you want to start using  your 41Z Module  isn   t it         c  Angel M  Martin Revision 44_E Page 68    SandMath_44 Manual       3 4  Remaining Special Functions in the Main FAT     The third and last chapter of the Special functions in the main FAT comprises other Hyper geometric  derived functions  plus a couple of notable exceptions not easy to associate  FFOURN and LINX     __  Function   Author   Description              o  gt Z o oO  Di  CI  M Baillard   Cosine Integral ooo  Di  EI  M Baillard   Exponential Integral O S   RF    ELIPF     ngel Martin _  Eliptic Integral ooo   Ai  ERF  M Baillard   Error Function  _ _ SSS        FFOUR   Angel Martin _  Fourier coefficientsfor x           o        o       H    HCI   MM Baillard _  Hyperbolic Cosine Integral           o     HGF    MM Baillard _  Generalized Hyper geometric Function __ _      H    HSI   M Bailard_______  Hyperbolic Sine Integral _    o o       LINX   AngelMartin ____  Dilogarithmfunction _ _ _ _     A SI  M Baillard   Sine
38. DATA ERROR      05   1   2 0 671 30 431   Z 0 671 J0 431 Z 0 552 J0 979 Z 0 552 J0 979    Z 0 541 J0 990   Z 0 541 J0 990 Z 0 429 J2 608 Z 0 429 J2 608  05   1   Z 0 431 J0 671   Z 0 431 J0 671 Z 0 959 J0 111 Z 0 959 J0 111     0 5 EE DATA ERROR    O o oaao OOOO OOOO  Sm   Se A Me       Where we see that for negative arguments  integer and non integer orders both   the result of the  Bessel function of the second kind is itself a complex number  therefore the DATA ERROR message   Note also the symmetric nature of the values for each of the function pairs  H1 with H2  and SH1 with  SH2         c  Angel M  Martin Revision 44_E Page 84    SandMath_44 Manual       Struve functions   Struve functions are solutions y x  of the non homogenous Bessel s differential equation     2 o l  ty dy 2 n 42 2   vag tts    2     OW   Frag hy  Ge T mIa   3   Struve functions H n x   and Modified Struve Functions L n x   have the following power series forms   in     1     r 2mt oatl  H   2        gt      Bpi    L    L a ep a    etl   1 wy 2k  L   3  Xerar la   a B 3    2 er eg ea ee  The figure below shows a few Struve functions or integer order  n 1 to 5  for  10 lt x lt 10  7 y L    x   n 3 H       100 nan    x e   i         ad      gt           L f ae   j    EE er  ee El AO A a N  Up   ta  5 10   iia   ee i  Tp 210 oe 5 10     1  25   50    fd 4    n 4  Struve functions of any order can be expressed in terms of the Generalized Hypergeometric function  1F2  which is not the Gauss Hypergeometri
39. Dig  PSI   Angel Martin ____  Digamma  Psi  function   o   Dia    PSIN   JM Bailard   Polygamma function __ SSS       In mathematics  the Gamma function  represented by the capital Greek letter    is an extension of the  factorial function  with its argument shifted down by 1  to real and complex numbers     If n is a positive integer  then    T n    n   1    showing the connection to the  factorial function     For a complex number z with positive    real part  the Gamma function is  defined by      z   J  tte  dt    BATATA en eeene    Things become much more  interesting in the negative semi   plane  as can be seen in the plot on  the right for real arguments        The Gamma function has become standard in pocket calculators  either as extended factorials or as  proper gamma definition  It   s already available in the HP 11C and of course on the 15C  and that has  continued to today   s models  Implementing it isn   t the issue  but achieving a reasonable accuracy is the  challenge     A popular method uses the Stirling approximation to compute Gamma  This is relatively simple to  program  but its precision suffers for small values of the argument  A version suitable for calculators is  as follows        Valid for Re z  gt 0  and with reasonable precision when Re z  gt 8         c  Angel M  Martin Revision 44_E Page 50    SandMath_44 Manual       For smaller values than that it   s possible to use the recurrence functional equation  taking it to the     safe    region and 
40. Integral  also a quick application of the EI function  using the formula  Li x    Ei    In x    see description for EI before   Note how LI starts as a MCODE functions that transfers into  the FOCAL code calculating EI  so strictly speaking it   s a sort of    hybrid    natured function     SAE is a direct application of th Carlson Symmetric Integral of second kind  RG to calculate the surface  aerea of an escalene ellipsoid  i e  not of revolution    r  y  z2    etet         which formula is        Area   470 Rc  ab   a  c      be          c  Angel M  Martin Revision 44_E Page 92    SandMath_44 Manual       Let   s now continue with the not so simple functions left  where some of them will     not surprisingly        be based on the Hyper geometric functions again     Debye Function   The family of Debye functions is defined by     nm fe t     dt   j  et           pn  The functions are named in honor of Peter Debye  who came across this function  with n   3  in 1912    when he analytically computed the heat capacity of what is now called the Debye model        The formula used for n positive integers and X gt 0 is     n  k           db x n    E po e       x   k   n x     k     pe ix             40         N  N       w   ee aii    _           40    Despite being a FOCAL program  DEBYE pretty much behaves like an MCODE function  no data  registers are used  only the stack and ALPHA   and the original argument preserved in LASTx      credit    is due to JM Baillard once more   
41. It also uses a few others SandMath functions as additional 37  RCLM  bonus  33 CHS  34    35 END        c  Angel M  Martin Revision 44_E Page 66    SandMath_44 Manual       3 3 10  Lambert W function     The last function deals with the implementation of the Lambert W function  Oddly enough its definition  is typically given as the inverse of another function  as opposed to having a direct expression  This  makes it a bit backwards looking initially but in fact it is significantly easier to implement than the  Riemann Zeta seen before     The Lambert W function  named after Johann Heinrich Lambert  also called the Omega function or  product log  is the inverse function of f w    w exp w  where exp w  is the natural exponential  function and w is any complex number  The function is denoted here by W     gE 4 For every complex number z            z         i 0 5 a _ The Lambert W function cannot be expressed in      terms of elementary functions  It is useful in  P Lo         combinatory  for instance in the enumeration of  far 7    i   trees    Fi     a   It can be used to solve various equations    involving exponentials and also occurs in the  SL nn eee eee   solution of delay differential equations    The graph of W x  for  Aes xs 4      The Taylor series of W    around 0 can be found using the Lagrange inversion theorem and is given by     oo   n     Wolz    5         2     nl  a   TL     where n  is the factorial  However  this series oscillates between ever larger positi
42. M  13 17    221  LCM 12 18    36  LCM 15 33    165    RGSORT sorts the contents of the registers specified in the control number in X  defined as  bbb eee   where    bbb    is the begin register number and    eee    is the end register number  If the control  number is positive the sorting is done in ascending order  if negative it is done in descending order   This function was written by HaJo David  and published in PPCCJ V12N5 p44     STSORT sorts in descending order the contents of the four stack registers  X  Y  Z and T  No input  parameters are required  This function was written by David Phillips  and published in PPCCJV12N2 p13    RGMAX finds the maximum within a block of consecutive registers     which will be placed in X   returning also the register number to Y  The register block is defined with the control word in X as  input  with the same format as before  bbb eee  It was written by Jean Marc Baillard     ST lt  gt z  exchanges the contents of the statistical registers and the stack  Use it as a convenient method  to review their values when knowing their actual location is not required     ODD  And EVEN  are simple tests to see is the number in X is odd or even  The answer is YES   NO   and in program mode the following line is skipped it the test is false  The implementation is based on  the MOD function  using MOD x 2    0 as criteria for evenness     INCX  DECX  INCY and DECY are convenient substitutes for 1   and 1   These functions will  decrement or incr
43. M prize      so adjust your expectations accordingly     The Riemann zeta function is a function of complex argument s that analytically continues the sum of  the infinite series    Bia 1 _      wt        R s    1  rosz          du   n   Dix  b e l  n 1 or the integral form     The Riemann zeta function satisfies the functional equation    1S  C  s    2a   sin     r 1   s     1   s    valid for all complex numbers s  excluding 0 and 1   which relates its values at points s and 1 s     The plots below of the real Zeta function show the negative side with some trivial zeros  as well as the  pole at x 1       ir  etx    itl   at ih  EA   i     x   e ne     1f  Hi  lTi       The direct implementation in the SandMath module uses the alternative definitions shown below  in a  feeble attempt to get a faster convergence  which in theory it does although not very noticeably given  the long execution times involved   The summations are called the Dirichlet Lambda and Eta functions  respectively       1 B Io Sen     T   IEF ir a Ft      _ i l  il   re  x   2    n  ly i  s     ls L p          7       H     Go ahead and try ZETA with FIX 9 set in the calculator     you ll see the successive iterations being  shown for each additional term  until the final result doesn   t change  Be aware than MCODE or not   t7   take a very long time for small arguments  approaching infinite as x approaches zero     For values lower than 1 we make use of the following  x    relationship     a sort of    
44. Number from Seed  in buffer    RGMAX   JM Baillard                Maximum ina register block  Sorts a block of registers  SEED with Timer  il sre gt z   Neon  amp  ome   SREG exchange whs      STSORT   David Phillips _  Stack Sort ooo O       Statistical Menu   Another type of Launcher     Pressing  ae  twice will present the STAT PROB functions menu  allowing access to 10 functions using  the top row keys  A   J   Two line ups are available  toggled by the  SHIFT  key      xx  Default Lineup  Linear Regression  xx  Shifted Lineup  Probability    i wa FW FF  oa   LR fa  L   wi  Es p        USER SHIFT O12 4    Note the inclusion of the mainframe functions MEAN and SDEV in the menus  for a more rounded  coverage of the statistical scope  With the manus up you just select the functions by pressing the key  under the function abbreviated name  Use  SHIFT  to toggle back and forth between both lineups  and  the back arrow key to cancel out to the OS     Obviously the data pairs must be already in the XREG registers for these functions to operate  meaningfully         c  Angel M  Martin Revision 44_E Page 31    SandMath_44 Manual       Alea jacta est       It   s a little known fact that the SandMath module also uses a buffer to store the current seed used for  random number generation  The buffer id  is 9  and it is automatically created by SEEDT or RAND  the first time any of them is executed  and subsequently upon start up by the Module during the  initialization steps using the
45. Output  Y  n   n  db n x   Lb  a    DB  0 7   3    6 406833597       Example     3 ENTER   0 7  XFL   DEBYE    gt     Page 93    Revision 44 E        c  Angel M  Martin    SandMath_44 Manual       Dawson Integral     The Dawson function or Dawson integral  named for John M  Dawson  is either     F  z   D x    e    e  dt    or     D_ z    e f e dt   0    DAW computes F x  by a series expansion   F x   e       x  x3 3   x5  5 2     x7  7 3             The figures below show both functions in graphical form        TE oT oT TA TO       Here as well no data registers are used        X x  aS  Examples   1 94  XFL   DAW    gt  F 1 94     0 3140571659  10  R S   gt  F 10    0 05025384716  15  R S   gt  F 15    0 03340790676    For x  gt  15   there will be an OUT OF RANGE condition      c  Angel M  Martin Revision 44_E    ng E ee       D  x        Page 94    SandMath_44 Manual       Hyper geometric Functions     HGF and RHGF are the ordinary and the Regularized Hyler geometric functions     The Gaussian or ordinary hypergeometric function 2F1 a b c  z  is a special function represented by the  hypergeometric series  that includes many other special functions as specific or limiting case  It is  defined for  z   lt  1 by the power series        a nlb n z     2Fi a  bcz       oe   nl  o  Ch 7   provided that c does not equal 0     1     2      Here  q n is the Pochhammer symbol  which is defined by   fil tn   0   a n      g g 1       q n   1  ifn  gt 0    Many of the common mathematica
46. SandMath_44 Manual    INIMATH HY    Moth Extensions for the HFH i       aa    User   s Manual and Quick Reference Guide    PRGM ALPHA    xi o yttx LOGYx    ej   ely LOS   ENII Aa   p C M G Ey  S pee  sin l Hcos   vtan  li ba a  E   J kr      SIN 4 COS   TAN J   Ss a  H     c  ka pe     GRT SEED      STO    RCL   SST    L a     e   CAT WMT CHS  x  ENTER     CHS p  i oO      T BS D H    Written and programmed by   ngel M  Martin    F WIEW November 2012  R S       HP 41SandMath m  E  Ssh EEE   Revision 44_E Page 1       SandMath_44 Manual       This compilation revision 4 44 44  really      Copyright    2012 Angel Martin    Acknowledgments      Documentation wise  this manual begs  steals and borrows from many other sources     in particular  Jean Marc Baillard   s program collection on the web  Really both the SandMath and this manual would  be a much lesser product without Jean Marc   s contributions     There are multiple graphics and figures taken from Wikipedia and Wolfram Alpha  notably when it  comes to the Special Functions sections  I   m not aware of any copyright infringement  but should that  be the case I ll of course remove them and create new ones using the SandMath function definition and  PRPLOT  Just kidding       Original authors retain all copyrights  and should be mentioned in writing by any party utilizing this  material  No commercial usage of any kind is allowed     Screen captures taken from V41  Windows based emulator developed by Warren Furlow   See ww
47. T     67 RCLO03 cbrt  x R3 2    05   ST  Z 1  a 1 a 3 inZ f eB      06     69  2      07 STO 00 a0  a 0 a 3 70 V      08 RDN     71 CHS      09 STO 01 a1  a 1 a 3 F 72 RCL 02 a2 3  F 10 RDN a2  a 2 a 3 r 733 ee real part OOOO      11 3 r 74       12   f 75 ISTO T  0  flag it as Complex i  F 13 STO 02 a2 3     76 RDN Z 0 indicates it     14  xag  77   415 ST  X 3  2 q243 27     78 STO 01      16 RCL 01 a1 T 79 xo      17 RCL 02 a2 3     80 STO 02  T 18   a1 a2 3     81 RTN  T 19   2 a2 3 27   a1 a2 3 82 LBLO1 all real roots      20 83 DEG  r 21     84 LASTX  22       85 CHS      23 STO 03 a0 2   a2 3 27   a1 a2 6     86 SQRT  T 24 xm  a0 2   a2 3 27   a1 a2 6  2     87 ST  X  3   F 25 RCL 01 a1     88 X 0   F 26 RCL 02 a2 3     89 1 X   27 Xm a2 2 9     90 RCL 03 a0 2   a2 3 27   a1 a2 6   23 53 T 91 ST  X 3  a0   2 a243 27   a1 a2 3  T 29   a2 2 3     92 CHS  30 o  a1 a2 2 3 F 93  gt       31 STO 01 a1 a2 2 3   94 ACOS  r 32 l3  95 8  r Ba 1 3  a1   a242 3   96    T 34  xa      97 STO 03  r 35    1 27  al   a2 2 3  3    a0 2   a2 3 27   al a2    98 LASTX   36 Xss0 _ Pe     99   E3 E                             37  GTO 01____ yes  allrealroots_ __ _____        100 STO 05 1 003      38 SQRT         complexroots                 101 RCL Ol a1 a2 2 3  F 39  IENTERA   f 102  3      40 JENTERA O  ReX OOO       103   a1 3 a2 2 9  F 41 RCL 03 a0 2   a2 3 27   a1 a2 6     104 CHS a2 2 9   a1 3  a l      105 SQRT      43 a     106 ST  X  3   44 cbrt  x R3 2      107 2 SQR a2 2 9   a1 3 
48. The FOCAL programs below list the simple code snippets to program the three pairs of functions just  covered  as follows     1  Hankel functions  HK1 and HK2  2  Spherical Bessel functions  SJBS and SYBS  3  Spherical Hankel functions  SHK1 and SHK2     Note the symmetry in the code for the spherical programs  making good use of the stack efficiency  derived from the utilization of the MCODE JBS function     The plots on the left show the Spherical  Hankel 1 function for orders 1 and 2  for  a short range of the argument x      x from  10 to 10  Explicitly  the first few are      real part      imaginary part ni  1 i     j    ye ren es i  Ay l iz     g  o  ay  gb diz  lt 3  hi  z    ie    l  ix from  4 to 4  T  TP    2  6iz    152 151      real part h G    e              imaginary part        c    ngel M  Martin Revision 44_E Page 83    SandMath_ 44 Manual        i XEQ  SJBS   STO 04 STO 04    g RCL Z RCL 00 l  10 RCL Z  i 10 RCLO 10   neve  11   ST x xt 11 STAX 11 FC  03  12  YBS 12  AEG  SYBES  12 CHS  n  2   13 FO C 03 13 FC FC 04 13  Meo    14 CHS 14 CHS 14  JES  15 RCL O4 15 RCL O4 15 FO  03  16 ZAVIEW 16  ZAVIEW 16 GTO00        17 END 17 END 17 RCLOO H  18  INCX H   Plot of H  1H 1 x   19 CHSYX  feat    aS     x from    10 to 10            real part      imaginary part if       Examples       Calculate H1  H2  SH1  and SH2 for the following values in the table    Pon   x                 2 0 440 J0 781   Z 0 440 J0 781 Z 0 301 J1 382 Z 0 301 J1 382  pa ff __pav eexOR    
49. ags Used  FO1  Output   Z   m   fy  Example   2 SQRT  3 SQRT    PI XFL   LOML    gt  sil sqrt 2   sqrt 3   n    3 003060384    Or   gl    H    L  instead        c  Angel M  Martin Revision 44_E Page 86    SandMath_44 Manual       Lerch  Transcendent  Function     In mathematics  the Lerch zeta function  sometimes called the Hurwitz   Lerch zeta function  is a special  function that generalizes the Hurwitz zeta function and the polylogarithm  It is named after Mathias  Lerch     The Lerch zeta function L and a related function  the Lerch Transcendent     are given by       exp fmi An  L A 0 8  D E W 2 8 0     nao   a  nao  n  mar  Special cases   The Lerch Transcendent generates other special functions as particular cases  as it   s  shown in the table below     The Hurwitz zeta function C s a    _ qx  s    P 1 s          CE          1  5  1      The polylogarithm Li  z    zP z  s  1      n s          1 s 1      The figures below depict the representation for x  given the other two constant   Re Piz  1  0   Re P z  0  1      2   2  l   l  0   0   1    1   2   2 4     4 a3    2 4  4  9          z a    The SandMath implementation LERCH is for the Lerch Transcendent function  It is a short MCODE  routine originally written by Jean Marc Baillard  which calculates the series terms and adds them until  they don   t have a contribution to the final result  It is a slow converging series  and therefore the  execution time can be rather long  at normal CPU speeds      Data input follow
50. an independent life of their own in separate  modules   more on that to come     This manual is a more or less concise document that only covers the normal use of the functions         c  Angel M  Martin Revision 44_E Page 7    SandMath_44 Manual       Conventions used in this manual     All throughout this manual the following convention will be used in the function tables to denote the  availability of each function in the different function launchers     jat assigned to the keyboard by HMKEYS    is   direct execution from the main launcher  FL    H     executed from the hyperbolics launcher  HYP    F   executed from the fractions launcher  FRC    Xe   executed from the RCL  launcher   RCL    CR   executed from the Carlson Launcher  no separate function exists    HK   executed from the Hankel launcher  no separate function exists    xx   executed from the Statistics Menu     ST  PRB             sub function in the secondary FAT  LFL     HMKEYS uses the value in X as a flag to decide whether to assign or to remove the mass key  assignments  If x 0 the assignments will be removed  any other value will make them  There are a  total of 25 functions assigned  refer to the SandMath overlay for details     Note for Advanced Users     Even if the SandMath is an 8k module  it is possible to configure only the first  lower  page as an  independent ROM  This may be helpful when you need the upper port to become available for other  modules  like mapping the CL   s MMU to another modul
51. as there   s always a term for which   m n 1  equals zero or negative integers  all of them being problematic     To avoid this  we use the following expression for negative integer orders     E si    J alz        1  J   2    Whilst   _  x   I  x   for every real number order   This definition is also valid for negative values for X  as there   s no singularity for any x value   The SandMath implementation uses a recurrence formula instead of the one shown above  It has the  clear advantage of not having to calculate Gamma for each term in the sum  contributing to a much    faster and robust algorithm     The iterative relationships are as follows   J n x    X U k  k 1 2        x 2    T n 1   where     U k      U k 1     x 2 42   k k n   with U 0    1         c  Angel M  Martin Revision 44_E Page 57    SandMath_ 44 Manual       The graphics below plot the Bessel functions of the first kind  J  x   and their modified  I  x   for  integer orders a 0 1 2        10            Note that for large values of the argument  the order or both these algorithms will return incorrect  results for J n x   This is due to the alternating character of the series  which fools the convergence  criteria at premature times and fouls the intermediate results  Unfortunately there isn   t an absolute  criteria for validity  but a practical rule of thumb is to doubt the result if  n x  it greater than 20     Bessel functions of the Second kind     K n x  and Y n x     The formulae used are as follows
52. back calculating the result with the appropriate adjusting factor     C z 1    zT z   Incidentally  this method can be used for any approximation method  not only for Stirling   s     The method used on the SandMath is the Lanczos approximation  which lends itself better to its  implementation and can be adjusted to have better precision with careful selection of the number of  coefficients used  For complex numbers on the positive semi plane  Re z  gt 0   the formula used is as  follows     go    75122 6331530   q    80916 6278952   oa q    36308 2951477   T z     g  5 5 pre g    8687 24529705     e   v0  qa    1168 92649479   gs    83 8676043424    qgs    25066282        Although the formula as stated here is only valid for arguments in the right complex half plane  it can  be extended to the entire complex plane by the reflection formula     on  T  oh ila ial das sin wz    An excellent reference source is found under http   www rskey org gamma htm  written by Viktor T   Toth        Let   s mention that this method yields good enough a precision that doesn   t require using the functional  equation to adjust it for small values of the argument  The obvious advantage is that without the  required program loop  the execution time is shorter and constant for any input  This becomes of  extreme importance when Gamma is used as a subroutine of more complex cases  like the Bessel J and  I functions     where the cumulative additional time is very noticeable     Ir         c    ng
53. benefits  from faster execution on the calculator  Non integer orders utilize the special MCODE function   GAMMA  with shorter execution times than equivalent FOCAL programs     but still longer than FACT  when integers     Besides that  for integer orders the execution time is further reduced by ca culating simultaneously  the two infinite sums involved in the first kind and the second kind terms  This assumes that the  convergence occurs at comparable number of terms  which fortunately is the case   given their relative  fast convergence     Note that in order to obtain similar expressions for both Yn and Kn     and so getting simpler program  code   we can re write Kn as follows       1     2 Ky x   2 Ly   Ln x 2  LA      Df fk n x       CD   CD gx n x      Dedicated MCODE Functions     To further decrease the execution time of the programs  two dedicated functions have been written   implemented as MCODE routines as follows     Function Flag 00 Clear Flag 00 Set   BS 2 Ux n x    K 0 1 2 where Uk    Ux     x 2 2   k k n    BS2 V fk n x    K 0 1 2   or  LDLi gy n x    K 0 1     n 1     The first function  BS is used equally in the calculation of the first kind and the second kind of non   integer orders       Function   Integer Non integer  JBS  IBS       YBS 2x  BS2  KBS    As it was said before  the summation will continue until the contribution of the newer term is negligible  to the total sum value  All calculations are done using the full 13 digit precision of the calc
54. c function 2F1       This is the expression used in the    SandMath implementation      2 24 ay  Hal     ara 43 0 sie   8 2  fA      in other words  referred to the Rationalized Generalized Hypergeometric function  which with such a  long name it definitely must be a formidable function    but it   s just the same divided by Gamma     H x     x 2     F    1   3 2   n   3 2     x  4   Li x     x 2    F 1   3 2  n   3 2   x7 4     Examples  Compute H 1 2 3 4  and L 1 2  3 4   1 2 ENTER     3 4 XxXFL   HNX    gt  H 1 2   3 4     1 113372657    gt  L 1 2  3 4    4 649129471    1 2 ENTER     3 4 EFL   LNX   and   Ma1    H    SHIFT    H  for LNX    Or  Ma1    H    H  for HNX   Revision 44_E Page 85        c    ngel M  Martin    SandMath_44 Manual       Lommel functions   The Lommel differential equation is an inhomogeneous form of the Bessel differential equation     d 2 2 p   2S tz   lz y  2   vs vs    Two solutions are given by the Lommel functions su v z  and Su v z   introduced by Eugen von Lommel   1880      E   a Y     2    z  Jaz  dz     JL z    z Y  z  dz     Sp  2    spr  2      A  Jol2      c0s n u       2   2      where Jv z  is a Bessel function of the first kind  and Yv z  a Bessel function of the second kind        Using the Generalized Hypergeometric function the expressions for s1 m n x  is   sh n x    x            m 1   n     Fz  1   m n 3  2    m n 3  2    x7 4      LOMMEL calculates s1  m n x    here are the specifics        DATA REGISTERS  ROO thru ROY  temp  Fl
55. chers and their  interconnectivity  For the most part it is always possible to return to the main launcher pressing the  back arrow key  improving so the navigation features     rather useful when you re not certain of a  particular function   s location     The first one is the Main SandMath Launcher     The first mapping doesn   t show all the direct execute function keys  Use the SandMath overlay as a  reference for them  names written in BLUE aside the functions         Launchers invoked trom the Main FL    Note that XFL  will require pressing ALPHA a second time in order to type the sub function name     And here   s the Enhanced RCL MATH group        RCL Math Launchers    Here all the prompts expect a numeric entry  The two top rows keys can be used as shortcuts for 1 10   Note that No STK functionality is implemented     even if you can force the prompt at the IND step   Typically you ll get a DATA ERROR message   Rather not try it             c  Angel M  Martin Revision 44_E Page 11    SandMath_44 Manual       Function index at a glance     And without further ado  here   s the list of functions included in the module  First the main functions             0  1  2  3  4  5  6  7  8  9    10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51    Name Description  2 X 1 Powers of 2    1 N Harmonic Numbers  ZDGT Sum of mantissa digits  2 N X Geometric Sums  AINT
56. creen  keeping the choices constant regardless     HK  INH LIRIK   GHK E INIH LIRIK    USER USER SHIFT          The table below shows in the first column the letter used for each of the functions within this group      HK    Function   Author   Description O Z o O S   1   HK1   Angel Martin   Hankel Function o S   2   HK2   Angel Martin   Hankel2 Function  _       o S   w    WOL   AngelMartin   LambertWO __ S   H    HNX    MBailard_   Struve H Function _ __ SSS   L   LOML    MBailard_   Lommel s4 function _ ___ S   R   LERCH    M Baillard   Lerch Transcendental function _          BE ESS SEE SSS       4   SHK2   Angel Martin   Spherical Hankelt S   2   SHK2   AngelMartin   SphericalHankel2 __ oo   Ww   WiL   AngelMartin   Lambet Wi S   H   LNX_   MBailard_   Struve Ln Function __ S   L    ALF    MBaillard_______  Associated Legendre function 1st kind   Pam x    R   TMNR_    MBailard   Toronto function _ __ SSS   K    KUMR   AngelMartin   Kummer Function _ _ _ _   S       Here we finally find both branches of the Lambert W function  WOL and W1L  described previously in  thie manual  Observant users would have noticed that the name in the previous section was WLO  instead     this is not a dyslexya induced error  but an intended difference to tell both FAT entries apart     That and also the limitation in the secondary FAT to have function names ending with numeric  characters  but that   s another story     So your several choices in terms of launchers are as follows    a  Fun
57. ction WLO in main FAT   sat    WLO     the ordinary method   page    M   shortcut using the main launcher    XFL     WLO     since XFL  also finds functions in the main FAT  Mal   ALPHA      WLO       b  Functions WOL and W1L in secondary FAT    Dae    H    W   pial    H    SHIFT    W   ZFL  032  ZFL  033    FL     WOL    SFL     WIL      PAi    ALPHA      WOL    PAi    ALPHA      WiL       Now that   s what I d call both a digression and multiple ways to skin this cat         c  Angel M  Martin Revision 44_E Page 82    SandMath_44 Manual       Hankel functions     yet a Bessel third kind     Another important formulation of the two linearly independent solutions to Bessel s equation are the  Hankel functions Ha 1  x  and Ha 2  x   defined by     H  x    Jol    iYa a   H    x    Jaz      iYa 2     where i is the imaginary unit  These linear combinations are also known as Bessel functions of the third  kind  and it   s just an association of the previous two kinds together     This definition allows for relatively simple programming only using the real domain Bessel programs      assuming the individual results for J and Y are not complex  The small program in the next page shows  the FOCAL code to just drive the execution of both JBS and YBS  piercing them together via ZOUT  or  ZAWIEW in the 41Z module      Getting Spherical  are we    Finally  there are also spherical analogues of the Hankel functions  as follows   py  x  z Jn X  ar 1Yn  T   i  x      Jn x     _ 1Yn X      
58. d with the same decimal number after the two executions     T gt BS  Ten to Base  is the MCODE equivalent to D gt BS  much faster and more elegant due to its  prompt     where in RUN mode you input the destination base  The result is show in the display and also  left in ALPHA  so it could be also used by BS gt D  once the base is in X   Note that the original  argument  decimal value  is left in X unaltered  so you can use T gt BS repeated times changing the  base to see the results in multiple bases without having to re enter the decimal value     T gt BS is programmable  In PRGM mode the prompt is ignored and the base is expected to be in the Y  register  much the same as its FOCAL counterpart D gt BS  Obviously using zero or one for the base will  result in DATA ERROR  The maximum base allowed is 36     and the  SASE gt 36    error message will be  shown it that   s exceeded  note that larger bases would require characters beyond    Z         The maximum decimal value to convert depends on the destination base  since besides the math  numeric factors  it   s also a function of the Alpha characters available  up to    Z     and the number of  them  length  in the display  12   For b 16 the maximum is 9999 E9  or 0x91812D7D600    T gt BS is an enhanced version of the original function  also included in Ken Emery   s book    MCODE for  Beginners     The author added the PRGM compatible prompting  as well as some display trickery to  eliminate the visual noise of the original
59. dMath_44 Manual       Kummer Function     Kummer s equation has two linearly independent solutions M a b z  and U a b z    dw  dz     Kummer s function of the first kind M  also called Confluent Hypergeometric function  is a generalized  hypergeometric series introduced in  Kummer 1837   given by             dap    b   z            aw   0     ge   M a b z    gt   in    i F a  b  z     nO    Where a    is the rising factorial  defined as   a      ala   Ij a 2     a n   1     The figures below depict two particular cases for  a 2  b 3  and  a  2  b  3     Re  A  2  3  2   Re  F     2     3  2      20     10       The SandMath implementation is got to be one of the simplest application ot HGF  possible  which  renders acceptable accuracy to the results    DAT REGISTERS     a  R00  b RO1 Stack  X X M a b x   Examples     Compute M 2 3  r  and M 2 3  7     2 STO01  3 STO02  PI CHS  XFL   KUMR    gt  M 2 3  n    0 166374562  2 STOO01  3 STO02  PI XFL   KUMR    gt  M 2 3 n    10 24518011    Or   Sig    H    SHIFT    K  instead        c    ngel M  Martin Revision 44_E Page 89    SandMath_44 Manual       Associated Legendre Functions     In mathematics  the Legendre functions P A   Q A  and associated Legendre functions Pu A  and Qu A   are generalizations of Legendre polynomials to non integer degree  Associated Legendre functions are  solutions of the Legendre equation      1     2   y      Qey    past    74S y  0     where the complex numbers A and u are called the degree and order
60. e all in MCODE   Functions in black are MCODE entries to FOCAL programs     52  53  54  55  56  57  58  59  60  61  62  63    NPR  ODD   PDF  PFCT  PRIME   RAND  RGMAX  RGSORT  SEEDT  ST lt  gt     STSORT  XFACT    Combinations   Is X Odd    Probability Distribution Function  Prime Factorization in Alpha  Is X Prime    Random Number   Block Maximum   Register Sort   Stores Seed for RNDM  Exchange ST  amp  XREG   Stack Sort   Extended FACTorial    And now the sub functions within the Special Functions Group     deeply indebted to Jean Marc   s  contribution  and not the only section in the module   Note there are two sections within this auxiliary  FAT     you can use the FCAT hot keys to navigate the groups        Description  Cat header   does FCAT  Aux routine  All Bessel  Aux routine 2nd  Order  Integers  Airy Functions Ai x   amp  Bi x     Author  Angel Martin  Angel Martin  Angel Martin  JM Baillard    Associated Legendre function 1st kind   Pnm x  JM Baillard    Inverse Lambert   Carlson Integral 1st  Kind  Carlson Integral 2nd  Kind  Carlson Integral 3rd  Kind  Fresnel Integrals  C x   amp  S x   Dawson integral   Debye functions   Eliptic Integral  Hypergeometric function  Hankel1 Function   Hankel2 Function   Struve H Function   Integral if IBS   Integral of JBS   Kelvin Functions 1st kind  Kummer Function   Lerch Transcendent function  Logarythmic Integral   Struve Ln Function   Lommel s1 function  Regularized hypergeometric function  Surface Area of an Ellipsoid  S
61. e force and use PFD in an INTEG like scenario  or course  The relation to use is     F x  1 07              gt  1er       ER     Example program  The routine below calculates CDF  Enter u  o  and x values in the stack        01 LBL    CDF    08     02 RCLZ 09 ERF  03   11 INCX  04 X lt  gt Y 12 2   05   13     06 2 14 END  07 SQRT    PDF expects the mean and standard deviation in the Z and Y stack registers  as well as the argument x  in the X register  Upon completion x will be saved in LASTx  and f u o x  will be placed in X  It has an  all MCODE implementation  using 13 digit routines for increased accuracy     PDF is a function borrowed from the Curve Fitting Module  which contains others for different  distribution types  With the Normal distribution being the most common one  it was the logical choice  to include in the SandMath         c    ngel M  Martin Revision 44_E Page 36    SandMath_44 Manual       And what about prime factorization     Function PFCT will do a very fast and simple prime factorization of the number in X  using PRIME  To  look for the successive divisors until 1 is found  PFCT uses the ALPHA registers to present the results   grouping the repetitions of a given factor in its corresponding exponent     For example  for x 126 the three prime factors are 2  3  and 7  with 3 repeated two times        For large numbers or when many prime factors exist  the display will scroll left to a maximum length of  24 characters  This is sufficient for the majorit
62. e found  6 AINT 37 RCL 00  T    38 K 1    B PRIME    9 SF 00   10 AINT first prime factor   11 K 17   12 GTO 01   13 FS 7C O0 if prime  we re done   14 GTO 01   15 STO 01 save for grouping   16 ST  L   17 LASTX reduced number   18   19 E  20 STO 00 reset counter  21 RDN  22  23 RCL 01 previous prime factor  24 KY  25 PRIME   26 SF 00  27 MAY  different PF   28 GTO 02 YES  29 ISG 00 increase counter 60 AVIEW  30 NOP SAME pf 61 ANUM  31 FS 7C 00 Was it prime  62 END        c  Angel M  Martin Revision 44_E Page 38    SandMath_44 Manual       Below is the Enhanced version  allowing for any number of different prime factors and repetition indices      all stored in a  n x 2  matrix file in extended memory     PRMF        Note how the program structure is basically the same  despite the addition of the matrix handling   Since the Advantage module is required we ve used AIP instead of AINT  totally interchangeable as  they   re basically the same function                                       LBL PRMF    46 RCLOO  2  PRMF  47 MSE         3 48 RDN  4 49 ST  L  5 50 LASTX  6 CLX 51  7 MSA O 52  8 RDN 53  9 CF 00 54 X lt  gt Z  10 INT 55 MSRt OO  11 ABS 56 FS C 00 was it prime   12 PRIME  57 GTO 01 yes  wrap up  13 SF 00 58 X lt  gt Y no  swap things  14 59 GTO 05 and do next PF  16 GTO 01 61 SF 04  17 FS C 00 if prime  we re done 62 SF 10  18 GTO 01 63  PRMF   19 STO 01 save for grouping 64  20 ST L 65 E  21 LASTX reduced number 66 FC  10  23 E 68 STO 00 re build the number  24 STO 00
63. e others only perform a  FAT entry placeholder function  and could be removed  replaced by others  in future versions of the  module        5288    Z  J33 14e       USER RAD    USER RAD 01 4        c  Angel M  Martin Revision 44_E Page 22    SandMath_44 Manual     FRE    USER RAD          2 2 1  Fraction Arithmetic and Displaying     A rudimentary set of fraction arithmetic functions is included in the SandMath  including the four basic  operations plus a fraction viewer and two test functions     Function   Author__   Description  Fractions Launcher  Calculates a fraction that gives the number in X  Fraction addition  Fraction subtraction    Angel Martin Fraction multiplication  Angel Martin Fraction division  FRC      ngel Martin Is X a fractional number     Is X an integer number       D gt F is the key function within this group  Shows in the display the smallest possible fraction that  results in the decimal number in X  for the current display precision set  Change the display precision as  appropriate to adjust the accuracy of the results     This means the fraction obtained may be different depending on the settings  returning different  results  For example  the following approximations are found for n     m   104348 33215 in FIX 9  FIX 8 and FIX 7    m  355 113 in FIX 6  FIX 5 and FIX 4  m   333 106 in FIX 3  m  22 7 in FIX 2  FIX 1 and FIX 0    This function was written by Frans de Vries  and published in DataFile  DF V9N7 p8  It uses the same  algorithm as the PPC
64. e temporarily   or permanently if you don t care  about the High Level Math  Special Functions  and Statistics sections     Think however that the FAT entries for the Function launchers are in the upper page  so they ll be gone  as well if you use the reduced foot print  4k  version of the SandMath     Upper Pad    High Level Math  Stats   pP ge  Function Launchers    Lower Page        tower Page  SandMath_44  FRC  HYP     RCL  Math    Note that it is not possible to do it the other way around  that is plugging only the upper page of the  module will be dysfunctional for the most part and likely to freeze the calculator    do not attempt     Final Disclaimer      With    just    an EE background the author has had his dose of relatively special functions  from college  to today  However not being a mathematician doesn   t qualify him as a field expert by any stretch of the  imagination  Therefore the descriptions that follow are mainly related to the implementation details   and not to the general character of the functions  This is not a mathematical treatise but just a  summary of the important aspects of the project  highlighting their applicability to the HP 41 platform         c  Angel M  Martin Revision 44_E Page 8    SandMath_44 Manual       Getting Started  Accessing the Functions     There are about 160 functions in the SandMath Module  With each of its two pages containing its own  function table  this would only allow to index 128 functions   where are the others a
65. e user needn t remember where a  specific function sought for was located  In fact  XFL  will also    find    a function from any plugged in  module in the system  even outside of the SandMath module     Main Launcher and Dedicated Launchers     The Module   s Main launcher is DAAI   Think of it as the trunk from which all the other launchers stem   providing the branches for the different functions in more or less direct number of keystrokes  With a  well thought out logic in the functions arrangement then it   s much easier to remember a particular  function placement  even if its exact name or spelling isn   t know  without having to type it or being  assigned to any key     Despite its unassuming character  the XFL prompt provides direct access to many functions  Just press  the appropriate key to launch them  using the SandMath Overly as visual guide  the individual functions  are printed in BLUE  with their names set aside of the corresponding key  They become active when the      F _    prompt is in the display     HLPHH       Besides providing direct access to the most common Special Functions  XFL will also trigger the  dedicated function launchers for other groups  like  HYP   FRC  CR  HK   STAT  and  lt FL  itself   Think of these groupings as secondary    menus    and you ll have a good idea of their intended use  The  following keys activate the secondary menus      A   activates the STAT PRB menus     H   activates the HK _ launcher    O   activates the CR _ lau
66. ecution form of this is  BT x         04 Number in Egg is divided by the number in the X register  and the    quotient is placed mto Rog  The display execution form of this is  st            c  Angel M  Martin Revision 44_E Page 29    SandMath_44 Manual       Primary Data Storage Registers  The standard HP AIC has 63 registers that can be allocated to  data storage or program memmory in ary combination  As you  add HP memory Modules  up to four   the total number of  registers can increase to 319 64 registers for each memory module   When allocated  data storage registers numbered Ro through Roo  are Primary Data Storage Registers       J i  i  i  i       oe A ee ee ee i ee ee M    M O     ea    Extended Data Storage Registers    When allocated  data storage registers numbered Ryj99  through  Rgn are extended Data Storage Registers     tow         Program Memory    All registers that are not allocated as Primary of Extended data   J storage registers are part of program memory  When allocated as  i pro memory  the standard HP 41C registers provide space for   3 200400 fully merged lines of programs  When allocated as  z program memory  each memory module adds 200 400 limes  The  E total can be 1000 2000 lines when alle 319 registers are allocated  z J as program memory  Variations in storage capacity depend on the   kinds of functions stored in program memory                    Note  Make sure the revision    G     or higher  of the Library 4 module is installed      c  Angel
67. ed with the indirect  comparison functions of the CX model  XK gt  NN7    but unfortunately not quite the same     X 1  is a quick and simple way to check whether the value in X equals one  As usual  program  execution skips one step if the answer is false     X YR  establishes the comparison of the rounded values of both X and Y  according to the current  decimal digits set in the calculator  Use it to reduce the computing time  albeit at a loss of precision   when the algorithms have slow convergence or show unstable results for larger number of decimals     INT  and FRC  are two more test functions which criteria is the integer or fractional nature of the  number in X  Having them available comes very handy for decision branching in FOCAL programs  The  Fractions section of the module is the natural placement for them     The remaining functions shown in the table below really are    displaced     in that their entries are in the  upper page but certainly have nothing to do with High Level math  Call it a misdemeanour if you want   and allow me to include them now and get them out of the way      _  Function   Author   Description    O        O          OZ oO O     INCX   Ken  mery _  Increases X by one   __  INCY Angel Martin Increases Y by one    Angel Martin Decreases X by one      DECY Angel Martin Decreases Y by one      ZOUT Angel Martin Combines the values in Y and X into a complex result    Of these only ZOUT has been used in FOCAL programs in the SandMath    so th
68. egisters  and the result will be placed in x upon completion     The term symmetric refers to the fact that in contrast to the Legendre forms  these functions are  unchanged by the exchange of certain of their arguments  The value of Rf is the same for any    permutation of its arguments  and the value of Ry is the same for any permutation of its first three  arguments     The Carlson Symmetric Elliptic integral of the 2    Kind is defined as              1 f  t r n z    And is calculated using the following expression involving CRF and CRJ     2 Re 3 y 2    Z Re x 5y 2     X 2  y Z  3 Ro xsy3z      x y z           c    ngel M  Martin Revision 44_E Page 78       SandMath_44 Manual       Airy Functions     For real values of x  the Airy function of the first kind is defined by the improper integral      Ip     Ailt        cos  4t    at  dt   0           which converges because the positive and negative parts of the rapid oscillations tend to cancel one  another out  as can be checked by integration by parts      The Airy function of the second kind  denoted Bi x   is defined as the solution with the same amplitude  of oscillation as Ai x  as x goes to    oo which differs in phase by n   2     Bi a        lexp      3t      at    sin  3t   at    dt     The expressions used to program them are again based on HGF   as follows     Ai x     3 7    T  2 3    oF 1   2 3  x9    x  37    T 1 3    oF 1   4 3  x  9      Bi x     37    T  2 3    oF 1   2 3  x   9    x  3  8  T 1 3   oF  3 
69. el M  Martin Revision 44_E Page 51    SandMath_44 Manual       Appendix 6   Accuracy comparison of different Gamma implementations     The tables below provide a clear comparison between three methods used to calculate the Gamma  function    1  Lanczos formula  with k 6   2  Continuous fractions  and   3  Windschitl  Stirling      Each of them implemented using both standard 10 digit and enhanced 13 digit precision routines     The results clearly show that the best implementation is Lanczos  and that the 13 digit routines provide  a second order of magnitude improvement to the accuracy  or in other words  that it cannot  compensate for the deficiencies of the used method  We re lucky in that the more accurate method is  faster that the second best  albeit not as fast as Stirling   s     Obviously the extrapolation from integer case to the general case for the argument is assumed to  follow the same trend  albeit not shown in the summary tables     Standard 10 digit Implementation    Lanczos  k 6  Continuous Fractions Windschitl  Stirling     Result error Result error Result    Reference   x 1                120  720  5040  40320  362880  3628800    39916800  479 001 600  6 227 020 800    Reference   x 1       120  720    5040  40320  362880  3628800    CON OOF WD       K    CON OOF WD      1 000000001   1   2  9 999999999  24 00000001   120   720 0000008  9040 000002  40320 00003  362880 0002  3628800 001  39916799 99  479001599 5  6227020803    120    5040  40320  362880  3
70. ement by one the current content of the X or Y registers  Also used instead of ISG X  and DSE X  when there   s no desire to branch the program execution even if the boundary condition is  reached  this saves a NOP line placed right after the conditional instruction     DSP  returns in X the number of decimal places currently set in the display mode 0 regardless  whether it   s FIX  SCI   or END  Little more than a curiosity  it can be used to restore the initial settings  after changing them for displaying or formatting purposes         c  Angel M  Martin Revision 44_E Page 35    SandMath_44 Manual        Normal  Probability Distribution Function     In probability theory  the normal  or Gaussian  distribution is a continuous probability distribution that  has a bell shaped probability density function  Known as the Gaussian function or informally as the bell  curve     1  f z  1 07      oyr    The parameter u is the mean or expectation  location of the peak  and o 2 is the variance  o is known  as the standard deviation  The distribution with u   O and o 2   1 is called the standard normal  distribution or the unit normal distribution    Ey    Probability density function Cumulative distribution function       The read curve is the standard normal disinbution    The figure above shows both the density functions as well as the cumulative probability function for  several cases  The Error function ERF in the SandMath can be used to calculate the CDF     no need to  apply brut
71. engthener to three fields for registers over 99  albeit this is de facto limited to 128 as we ll see later  on      The keyboard mapping for  RIAT  is as follows     Numeric keypad  or Top rows  to perform the standard RCL   SHIFT  for Indirect register addresses    EEX  for the prompt lengthener to three places   Math keys               and    to invoke the RCL Match functions  Back arrow to cancel out to the OS    Note that  RIAT  is not programmable  This is done by design  so that  t can be used in a program to  enter any of the RCL Math functions directly as a program line  ignoring the corresponding prompt      The drawback is of course that the standard RCL operation won t be registered in a program  you must  use the standard RCL function instead     Notice also that indirect addressing is indeed supported by this scheme  just add hex 80  that  is decimal 128  to the register number you want to use as indirect register  As simple as that  So RCL   IND 25 will be entered as the following two program lines  RCL   followed by 153     This however effectively limits the usefulness of the prompt lengthener to the range R100 to R127      because from R128 and on the index is interpreted as an indirect register address instead  However   the function will allow pressing SHIF and EEX  for a combination of IND and prompt lengthener  which will work as expected provided that the 128 limit isn t reached     enough to make your head spin  a little bit     Example  Store 5 in regi
72. evant integral in the definition  are as follows     z sinht    Shi x    f     dt  0 i         T    x    F  1 2  3 2  3 2   x   4   x   4F   1 2   3 2   3 2  x 4       cost     1   cosht     1  oy     ine  f     dt Chi x   7  Ina   f              i  0 i         x   4  2F 3  1  1   2  2  3 2    x7 4   x  4  oF3 1  1  2  2 3 2   x7 4        Examples     1 4 XEQ SI    gt   Si 1 4   1 256226733   or   B5    Z   1 4 XEQ CI    gt   Ci 1 4    0 462006585   or   iz    V   1 4 XEQ  SHI    gt      Shi 1 4    1 561713390   or   ois      1 4 XEQ CHI   gt   Chi 1 4    1 445494076   or  Daal            1   Z   1   V     SiG    l   ga i ee  amm a   l  Ci x       NS 5 10 IS     a ee eee    i    Even if it   s not covered by the SandMath  the following relation between the Exponential and  Trigonometric Integrals is available     E   ix   i  3r   Si ax       Cile   2  gt  0         c  Angel M  Martin Revision 44_E Page 70    SandMath_44 Manual       Errare humanum est     In mathematics  the error function  also called the Gauss error function  is a special function  non   elementary  of sigmoid shape which occurs in probability  statistics and partial differential equations  Its    definition and the expression based on the Hyper geometric function  via ascending series  are given in  the table below     erf x    2x n   exp  x     1Fi  1  3 2  x         The complementary error function  denoted erfc  is defined as  erfc   1     erf  x     Both functions are shown below for an overview     er
73. evision 44_E Page 4    SandMath_44 Manual       3 5 2  Hankel  Struve and others  The Launcher       A Lambert relapse 82  Hankel functions     yet a Bessel 3   Kind 83  Getting Spherical  are we  83  Struve Functions 85  Lommel functions 86  Lerch Trascendent function 87  Kelvin functions 88  Kummer Functions 89  Associated Legendre functions 90  Toronto Function 91  Poisson Standard Distribution 91    3 5 3  Orphans and Dispossessed     Tackle the Simple ones First 92  Debye Function 93  Dawson Integral 94  Hypergeometric Functions 95  Integrals of Bessel functions 96  Appendix 11   Looking for Zeroes 97   END  98                          c  Angel M  Martin Revision 44_E Page 5    SandMath_44 Manual       Note  Make sure the revision    G     or higher  of the Library 4 module is installed      c  Angel M  Martin Revision 44_E Page 6       SandMath_44 Manual       SandMath_44 Module   Revision E  Math Extensions for the HP 41 System    1  Introduction     Simply put  here   s a compilation of  mostly MCODE  Math functions to extend the native function set of  the HP 41 system  At this point in time   way over 30 years after the machine s launch   it   s more than  likely not realistic to expect them to be profusely employed in FOCAL programs anymore   yet they ve  been included for either intrinsic interest  read  challenging MCODE or difficult to realize  or because of  their inherent value for those math oriented folks     This module is an 8k implementation  The first 4k
74. f  x   erfc x         lt 3   zl O 1 2 3  The unsung hero  HGF     If we re to believe that behind a great man there is often an even greater woman  then the greatest  idea behind all these functions is the implementation of the Generalized Hyper geometric function  A  general purpose definition requires the use of data registers for the parameters  al    am  and  b1       bn    and expects the argument x in the X register  and the number of parameters m and n is stored in  Z and Y  for the generic expression     mrp Aig doesn  bj bo      b    x         01 2     arx ar ceee  Am id     b1 k b2 k     Dp x    x7     Ifm  p  0  HGF  returns exp x    The program doesn t check if the series are convergent or not    Even when they are convergent  execution time may be prohibitive  press any key to stop  Stack register T is saved and x is saved in L register    ROO is unused    The alpha  register  is cleared     The original HGF  was written by Jean Marc Baillard  Only small changes have been made to the    version in the SandMath  optimizing the code and checking for ALPHA DATA in all registers used  as  well as for the argument x         c  Angel M  Martin Revision 44_E Page 71    SandMath_44 Manual       Appendix 9   Inverse Error Function   coefficients galore       The inverse error function can be defined in terms of the Maclaurin series    20o 2k 1  17  Ck va  af  2   ty  Se   k 0  Where c0   1 and        Coy Ck   il   m T 127  a  2 ea e   hha gore     This really is a bear to
75. first of the polygamma functions        Its relationship to the harmonic numbers is shown in that for natural numbers     T n    H      i    where Hn is the n th harmonic number  and y is the Euler Mascheroni constant       As can be seen in the figure on  the left plotting the digamma  function  it   s an interesting  behavior showing the same  poles and other singularities to  worry about  It should be  possible to find an  approximation valid for all the     definition range of the function     It has been implemented on the  SandMath using the formulas  derived from the called Gauss  digamma theorem  although  further simplified in the  following algorithm     1 4 1 1 1  W x    log z      5       7553   aon 25275  P        programmed as  uA2   u 2 20 1 21 u 2   1 10 u 2    1  12      Ln u   u 2      The implementation also makes use of the analytic continuation to take it to arguments greater than 9   same as it   s done for LogGamma   using the following recurrence relation to relate it to smaller values     Wir 1   V x    7    Which naturally can be applied for negative arguments as well         c  Angel M  Martin Revision 44_E Page 55    SandMath_44 Manual       3 3 6  Euler   s Beta function   The beta function  also called the Euler integral of the first kind  is a special function defined by    1  B    y     ey tdt Rela   Re y   gt  0   ri     The beta function was studied by Euler and Legendre and was given its name by Jacques Binet   The most common way to formula
76. hallenged by the available space in  ROM  the internal accuracy and the speed of the CPU  It is therefore understandable that more    commonality and re usable components identified will make it more self contained and powerful   overcoming some of the inherent design limitations     The Generalized Hyper geometric function is one of those rare instances that works in our favor  as  many of the special functions can be expressed as minor variations of the general case  Indeed there  are no less than 20 functions implemented as short FOCAL programs  really direct applications of the  general case   saving tons of space and contributing to the general consistency and common approach  in the SandMath     We have Jean Marc Baillard to thank for writing the original HGF   the Generalized Hyper geometric  function   real cornerstone of the next two sections  The SandMath has an enhanced MCODE  implementation that optimizes speed and accuracy thanks again to internal usage of 13 digit OS  routines  The reuse made of it more than pays off for its lengthy code     A few examples will illustrate this      Af    erf x    VA iF   4 8     r     dalt    a5 oFi a   1     iz     H  z    Chibi  Fy 1 3 2 a   3 2     z  4        2a  a  3 2     Naturally this is not the case for any special function  and even it there   s such an expression it may be  more appropriate to use the direct definition instead     or an alternative one     for the implementation   This is the case of the Bessel functi
77. hree roots of the equation      CVIETA Driver program for CROOT    STLINE is a simple function to calculate the straight line coefficients from two of its data points   P  x1 y1  and P2 x2 y2   The formulas used are     Y   ax  h  with  a   Y2 y1   X2    X1   and b   y       4a X1   It is trivial to obtain the root once a and b are known  using  Xo    b a  Example  Get the equation of the line passing through the points  1 2  and   1 3   3   ENTER    1   ENTER  2    ENTER   1    gt  Y  2 500  X   0 500  and to obtain its root  I        gt  X  5 000       I     will be shown in RUN mode only    For the second and third degree equations use functions QROOT and CROOT  The general forms are   2  ax     bx ec 0   witha o     Given the quadratic equation above  QROOT calculates its two solutions  or roots   Input the  coefficients into the stack registers  Z  Y  X using  a  ENTER     b  ENTER   c    The roots are obtained using the well known formula  X1 2    b 2a    sqrt   b 2a    2     c a   Upon execution  x1 will be left in Y and x2 will be left in X     If the argument of the square root is negative  then the roots z  and z  are complex and conjugated   symmetrical over the X axis   with Real and Imaginary parts defined by     Re Z     b 2a Z    Re z    i Im z   Im Z    sqrt abs   b 2a  2    c a   Z2   Re z      i Im z     Upon execution  Im z  will be left in Y and Re z  will be left in X   2 2 m  axt      br   ecr  d       witha 0    For the cubic equation case  input the fo
78. ial function  defined by the infinite sum  or power series   2 z  zt    iis  gt   is z     ks Js 3s    Only for special values of the order s does the polylogarithm reduce to an elementary function such as  the logarithm function  The above definition is valid for all complex orders s and for all complex  arguments z with  z   lt  1  it can be extended to  z    1 by the process of analytic continuation     For particular cases  the polylogarithm may be expressed in terms of other functions  see below      Particular values for the polylogarithm may thus also be found as particular values of these other  functions  For integer values of the polylogarithm order  the following explicit expressions are known     Li  z       In 1     z     mo   z  7 0 m      j  iW                    1     si o  H    Lia 2    Gaya  3  _ 2 1 2  i  Li_a z           z   7 a 0 5 l  z 1 4z 4 z   o  Li_3 z   1     z  o 4       z  14  231141024 z   oe oe   Li_4 z    a Ea ea   Lita  Liste    The SandMath implementation is a direct series summation  adding terms until their contribution to the  sum is negligible  Convergence is very slow  especially for small arguments  Its usage expects n to be  in register Y and x in register X  The result is saved in X  and X is moved to LastX     The program below gives a FOCAL equivalent     note the clever programming done by JM Baillard to  only do one Y X to reduce the execution times significantly     01 LBL  LIN  13 STO 03  02 STOO1 14 ISG 00  03 X lt  gt Y 15 CLX
79. ich uses the same formula but with  different    steps     subtracting    k     instead of    2     from the original number  thus     n   n  n   l  a    2     2 1  n     n  n    2  n     4      n    nin  3 in  0      where the products run through positive integers  Obviously for k 1 we have the standard FACT   One can define the k th factorial  denoted by nu  recursively for non negative integers as     1  FUS nk     nE        p  nin     k   ifn gt k     Another extension to the factorial is the Superfactorial  It doesn   t use any step size as variant  rather  it follows a similar formula but using the factorial of the numbers instead of the numbers themselves     Th    sf n       k     KE   1  2  1  3      n   1   ent   k       k         Both the multifactorial and  specially   the superfactorial will exceed the  o i calculator numeric range rather quickly   m  f so the SandMath functions use a  E i separate mantissa and exponent  ale f approach  using registers X and Y  respectively     Gin   2     i     4 i fo    Pi Nevertheless the functions will put up a   Lag Pa consolidated  combined  representation   a in the display  using the letter    E    to   E    a separate both amounts  Make sure to  pe adjust the FIX settings as approriate     484689 E3928    USER RAD 4        c    ngel M  Martin Revision 44_E Page 43    SandMath_ 44 Manual       Examples  _ Calculate the multi  and superfactorials given below     234511111  type  6  ENTER     XEQ MFCT      gt     1234 type
80. isson Standard Distribution  In probability  theory and statistics  the Poisson distribution is a discrete probability distribution that expresses the  probability of a given number of events occurring in a fixed interval of time and or space if these  events occur with a known average rate and independently of the time since the last event    A discrete stochastic variable X is said to have a Poisson distribution with parameter A gt 0  if for k   0   1  2      the probability mass function of X is given by        ee  fik  A    Pr  X   k       kl  Poisson distribution   A   3  Its inputs are k and A in stack registers  f Y and X  PSD   s result is the probability  aiii corresponding to the inputs   020  0 15  0 7190  gg  DAD e ee es     1 Fa 3 4 5 i f  i      1m 1 Fs        Note that this function is not in the Hankel launcher  technically it belongs to the Statistics section         c  Angel M  Martin Revision 44_E Page 91    SandMath_44 Manual       3 4 3  Orphans and dispossessed     The last group of sub functions include those not belonging to any particular launcher     for no other  particular reason that there   s no more available space in the ROM      Keep in mind that the only way to  execute them is using the   FL  and XFL  launchers      _  Function   Author _   Description O    O        i   i      SC s s sCSCSC sS       SPFNC_     ngelMartin   Cat header   does FCAT i    Z o o        BS_     ngelMartn   Aux routine  All Bessel     O Z O Z O O i y O    ngel Marti
81. isters respectively  When executed in RUN mode the display will  show the straight line equation  similar to the STLINE function described before        e     COV will calculate the sample covariance  CORR will return the correlation coefficient  and YLR the  linear estimate for a given x     Example  find the y intercept and slope of the linear approximation od the data set given below     x p    w   o w    Assuming all data pairs values have been entered using Y value  ENTER     X value    s    we type     XEQ    LR      gt  0 038650000 and X lt  gt Y   gt  0 038650000 producing the following output in FIX 2         c  Angel M  Martin Revision 44_E Page 34    SandMath_44 Manual       Ratios  Sorting and Register Maxima     T is a miniature function to calculate the percent of a number relative to another one  its reference    The formula is  T y x    100 x   y   Example  the relative percent of 4 over 25 is 16     GCD and LCM are fundamental functions also inexplicably absent in the original function set  They are  short and sweet  and certainly not complex to calculate  The algorithms for these functions are based    on the PPC routines GC and LM     conveniently modified to get the most out of MCODE environment     If a and b are not both zero  the greatest common divisor of a and b can be computed by using least  common multiple  Icm  of a and b       a  b  cd a  b              ian lem a  b   Examples  GCD 13 17    1  primes   GCD 12 18    6  GCD 15 33    3  Examples  LC
82. known and  don t require any special consideration to  program       e    e     sinh z    2   i  ete    Vie EO AAE  cosh               _   ji  2  et        tanhzr   er  eT y     The SINH code is also used as a  subroutine for the Digamma function            c    ngel M  Martin Revision 44_E Page 25    SandMath_44 Manual             The direct functions are basically exponentials     _ 3  whilst the inverses are basically logarithms  arsinh x   In  2   VE    1   Both cases are well covered with the mainframe arcoshz   ln  z  Vx     1  2x  gt  1  internal math routines without any need to worry    about singularities or special error handling  1 l z  artanha     In be     1  2 l r    For all hyperbolic functions the input value is expected in X  and the return value will also be left in X   The original argument is saved in LASTx  No data registers are used     Examples     Complete the table below  calculating the inverses of the results to compare them with the original  arguments  Use FIX 9 to see the complete decimal range     SIN    SIN     HCEODS  L WHTAN I  SIN H COS    TAN   i   HMKEYS assigns to the  SHIFT  key for convenience      x   HSIN   HASIN   HCOS   HACOS   HTAN HATAN  1 175201194   1 000000000   1 543080635   1 000000000   0 761594156   0 761594156  1 001   1 176744862   1 001000000   1 544256608   1 001000000   0 762013811   1 001000000       0 010000167   0 010000000   1 000050000   0 009999958   0 009999667   0 010000000  0 0001   0 000100000   0 000100000 
83. l functions  Jn and Yn by     jal    Y  Jale    yale    Y3 Yarla     1  naa      Which graphical representation  naturally very JBS ish looking  is show below        xX X  spherical Bessel functions of 1st kind  JC   for   0 1  h  Spherical Bessel functions of 2nd kind  y  x   for    0 1   a    Notice that there really isn   t any Spherical i n x  properly defined     but there   s one in the SandMath just  the same  using the same relationship as for j n x  and y n x      Once again  remember than as  n x  increases the accuracy of the results decreases     specially for    J n x   Y n x  and the spherical counterparts  where the returned value can be completely incorrect if   n x   gt  20  a practical rule  not an absolute criterion       c  Angel M  Martin Revision 44_E Page 59          SandMath_44 Manual       Programming Remarks     The basic algorithms use the summation definition of the functions  calculating the successive values of  the sum until there   s convergence for the maximum precision  10 decimal places on the display    Therefore the execution time can take a little long     a fact that becomes a non issue on the CL  Or  when using 41 emulator programs  like V41  setting the turbo mode on     There are different algorithms depending on whether the order is integer or not  This speeds up the  calculations and avoids running into singularities  as mentioned before      Note that for integer indexes the gamma function changes to a factorial calculation  which 
84. l functions can be expressed in terms of the hypergeometric  function  or as limiting cases of it  Some typical examples are     In 1   z    z9F  1 1 2    z    1    z      2F  a 1 1  z     2  arcsin z   Zof   5   gt   2  z      The relation 2F   a b c x     1 x  a 2F   a  c b  c   x  1 x   is used if x  lt  0    The Regularized Hypergeometric function has a similar expression for each summing term  just divided  by Gamma of the corresponding Pochhamer symbol plus the index n     REGISTERS  RO1 thru R03  They are to be initialised before executing HGF or RGHF   ROO is not used     RO1   a  R02   b  R03     01   a  R02   b  R03   c Stack Output  2F   a b c x    HGF Examples     e 1 2 STOO1  2 3 STO02  3 7 STO 03    0 4 XFL   HGF    gt  1 435242953   3 XFL   HGF    gt  0 309850661    RHGF Examples   e 2 STOOI  3 STO02   7 STO 03    0 4  XFL   RHGF     gt  5353330 290   3  XFL   RHGF    gt  2128 650875        c  Angel M  Martin Revision 44_E Page 95    SandMath_44 Manual       Integrals of Bessel Functions     One of the usual approaches is to use the following recurrent relations for the calculation    T  i  f J L t  di   25  Fuvtor  i le       I  kool  With Re n  gt 0  More specifically  for positive integer orders n 1 2      we have    T 7 m    Ja  t  dt   hdt  2V Jona   2    j aie  gt     and also    T i   Jan    tf  dt   n Jal  o 2 Jo   2   3    2     c      There   s however another approach based  yes  here as well   on the Generalized Hypergeometric  function HGF   In fac
85. lot   For the nth prime  number pn the primorial pn  is defined as the  product of the first n primes  where pk is the    kth prime number   primes  lt  n   ls mn   Pn   I  Pr np   I  Pi Prin  FF  k l i 1    The FOCAL programs below can be used to calculate both flavors of primorials  Note the primordial   pun intended  role of function PRIME   which effectively makes this a simple application as opposed  to a full fledge program from the scratch     Examples  Calculate both primorials for the first 20 natural numbers         c  Angel M  Martin Revision 44_E Page 46    SandMath_44 Manual       Table of primorials    n n  Pn Pn      0 1 no prime i  l l 2   2 2 3   3 6 5 30  4 6 7 210  5 30 11 2310  6 30 13 30030  7 210 17 510510  8 210 19 9699690  9 210 23 223092870  10 210 29 6469693230  11 2310 31 200560490130  12 2310 37 7420738134810  13 30030 41 304250263527210  14 30030 43 13082761331670030  15 30030 47 614889782588491410  16 30030 53 32589158477190044730  17 510510 59 1922760350154212639070  18 510510 61 117288381359406970983270  19 9699690 67 7858321551080267055879090  20 9699690 71 557940830126698960967415390  01 LBL  NPRML  01 LBL  PPRML   02 ABS 02 ABS   03 INT 03 INT   04 E 04 E   05 X gt Y  05 X gt Y    06 RTN 06 RTN   07 X lt  gt Y 07 STO Z          LBL 00  09 PRIME     LBL 00  INCX                   10 GTO 01 10 PRIME     1 X lt  gt  L li GTO 01  GTO 03 12 X lt  gt  L   1 GTO 00       gi   7 GTO 00 17 GTO 00  18 X lt  gt Y 18 RCL Z   19 RTN  19 END    Both routi
86. ls for n  0 1 2 3 4   and  2 lt x lt 2    im     A n 4 n 3 n         Function POCH calculates the rising factorial  It expects n and x to be in the Y and X registers  respectively  i e  the usual convention   For large values of n the execution time may be very long     you  can hit any key to stop the execution at any time     The falling factorial is related to it  a k a  Pochhammer symbol  by     xn     1       x       The usual factorial n  Is related to the rising factorial by  n              Whereas for the falling factorial the expression is  n    py    Examples  Calculate the rising factorial for n 7  x 4  and the falling factorial for n 7  x 7    7  ENTER     4  XEQ    POCH      gt  604 800 0000   7  ENTER   7  CHS  XEQ    POCH     7  XEQ    CHSYX      gt  5 040 000000        c  Angel M  Martin Revision 44_E Page 42    SandMath_44 Manual       Multifactorial  Superfactorial and Hyperfactorial     This section covers the main extensions and generalizations of the factorial  There are different ways to  expand the definition  depending on the actual sequences of numbers used in the calculation     The double factorial of a positive integer n is a generalization of the usual factorial n   defined by     ne a   2    5  3 1 n gt 0odd  nlledn  n    2    60 4 2 n gt Oeven  l n      0     Even though the formulas for the odd and even double factorials can be easily combined into     nll      r 2i      i hian    The double factorial is a special case of the multifactorial  wh
87. n Aux routine   2nd  kind  Integer orders       AWL     ngelMartin   Inverse Lambert O       O Z S       DAW   mM Baillard   Dawson integral oo       DBY   Ballard   Debye functions           gt Z o O o o        HGF   sMBaillard   Hyper geometricfunction O Z         ITI Angel Martin    Integral if IBS     ITJ Angel Martin    Integral of IBS   LE Angel Martin   Logarithmic Integral S      PSD     ngel Martin __      Poisson Standard Distribution        RHGF   JM Baillard _      _     Regularized Hyper geometric function  _        SAE   JMBaillard   Surface Area of an Ellipsoid     FCAT    AngelMartin   Function Catalogue O S    Let   s tackle the simpler ones on the list first        FCAT  and    SP FNC  are usability enhancements for the admin and housekeeping  It invokes the sub   function CATALOG  with  ot keys for individual function launch and general navigation  Users of the  POWERCL Module will already be familiar with its features  as it   s exactly the same code     which in fact  resides in the Library 4 and it   s reused by both modules  so far          BS and  BS2 are auxiliary functions used in the FOCAL programs for the Bessel functions of 2   Kind  KBS and YBS  They were explained in more detail in the Bessel Functions paragraph     AWL is the Inverse Lambert W function  an immediate application of the W definition involving just the  exponential     but with additional accuracy when using the 13 digit routines in MCODE   AWL   W   exp W     LI is the Logarithm 
88. n XFL prompt  and  offers the following seven choices        The table below shows in the first column the letter used for each of the functions within this group      CR    Author   Description  __       O Z o   E    ELIPF   AngelMartin   Elliptic Integral      F   CRF   JMBailard___  Carlson Integral ist Kind _ _ ooo o   G   CRG   IM Baillard   Carlson Integral 2nd  Kind _ __ _ _    o            CRJ   JMBailard___  Carlson Integral 3rd  Kind _ ___   C    CSX_   JMBaillard________  Fresnel Integrals  C x   amp  S x     W   WEBAN   JmBaillard   Weber and Anger functions                   Airy Functions Ai x   amp  Bi x        The Elliptic Integrals   In integral calculus  elliptic integrals originally arose in connection with the problem of giving the arc    length of an ellipse  They were first studied by Giulio Fagnano and Leonhard Euler  Modern  mathematics defines an  elliptic integral  as any function f which can be expressed in the form       f a    f R t  PE  dt   C       where R is a rational function of its two arguments  P is a polynomial of degree 3 or 4 with no repeated  roots  and c is a constant    The most common ones are the incomplete Elliptic Integrals of the first  second and third kinds   Besides the Legendre form given below  the elliptic integrals may also be expressed in Carlson  symmetric form     which has been the basis for the implementation in the SandMath     completely    based on the JMB_MATH ROM     The incomplete elliptic integral of the first
89. n precision for calculations  significant decimal places        FFOUR is a rather large FOCAL program  despite having a MCODE FAT entry  It calculates all integrals  internally  not making use of general purpose numeric integrators like INTEG  IG  etc     so it   s totally  self contained     The function must be programmed in main memory under its own global label  The program prompts  for the first index to calculate  and the number of desired coefficients     The program also calculates the approximate value of the function at a given argument applying the  Summation of the terms  using the obtained coefficients             if  T          nx A wy   anx      x     ag   Ty COS      Dy  in     f  iat a  n tA      To use it simply enter the value of x and press    A     XEQ A  in user mode on     this assumes that no  function is assigned to the key  The approximation will be more correct when a sufficient number of  terms is included  The goodness is also dependent on the argument itself         c  Angel M  Martin Revision 44_E Page 74    SandMath_44 Manual       Example  calculate the first six coefficients for F x    x  2  assuming     a period T 2pi  centered in x0   0  As it   s known   XA2   4 3 n 2   XL 4 cos nx   n 2   4r sin nx   n    n 0 1        Using an accuracy of 6 decimal places the program returns the following results     p   a0   13 1595 b0   0  al 4 b1    12 566  a2   1 b2    6 5797  a3   0 4444 b3    4 1888    a4   0 250 b4    3 1415  a5  0 160 b5    2 513 
90. n the program    9 STO 00    10 FIX 4 ST  X l l l  ii   Simply enter the information asked at  T  NDEN F   the prompts  including the precision  13           desired  number of decimal digits    T STO 0  RER function name and its chosen period  15 CF 00  27    16 AEG 00 SIN     P    E The screenshot below shows the  19  FEN  ILPER output of the process   20 0  21 RCL 00  22 INTEG  23 RCL OO  24    25 ST  XK  26  g   27 FS  OO    28  h  Example  f x    x 3 141593      79    nf    2 000000    31 AINT 2 END RUN  33 op jo  PREC      33 ARCLY P a RUN  34 PROMPT    35 FC  OO 7 000000 RUN  36 RTN  37 GTO E       Using this program we ll calculate the coeffcients for the 7  and 9  terms for f x    x 2     a7   0 081633  b7   1 795196  and   a9   0 049383  b9    1 396263        c  Angel M  Martin Revision 44_E Page 76    SandMath_44 Manual       3 5   More Special Functions in the Secondary FAT   We ve finally come to the last part of the manual  covering those functions included in the Sub   functions group with entries in the secondary  hidden  FAT  Go ahead and review the accessibility  information from the introduction for a quick refresher if needed     Let   s divide and conquer     using the Carlson and Hankel launchers as grouping criteria      3 5 1  Carlson Integrals and associates     The first sub function launcher is the Carlson group  It   s loosely centered on the Carlson   s integrals   plus related functions  The launcher prompt is activated by pressing  O  at the mai
91. nals of  BS2 perform quite an involved procedure  utilizing multiple resources within  the SandMath module     Furthermore   BS2 is called twice within the FOCAL program to calculate KBS or YBS     once for the  first  infinite summation and a second time for the second  finite sum  The status of User Flag 00  controls the calculation made  That was done to save one FAT entry  when the limiting factor was the  maximumm nuber of functions per page  i e  64 functions   Now they have been pushed eveh further  off  to the secondary FAT used for the sub functions group     Bessel Function Summed Functions by  BS2   Flag00   FlagO1    Set       Yn x  fk n x  cear      DE gK N x           e cia    Note also that for this case  integer orders  there   s two infinite summations involved for the Bessel  functions of the second kind  This is done simultaneously within  BS2 when user flag 02 is set  as  both series converge in very similar conditions  i e  with the same number of terms         Main functions  IBS  JBS  KBS  and YBS     The first kind pair  IBS and JBS  are 100  written in MCODE      including exception handling and  special cases  This is the only version known to the author of a full MCODE implementation on the 41  platform  and it is however a good example of the capabilities of this machine     No data registers are used for IBS and JBS     but both the stack and the Alpha registers are used  The  number of terms required for the convergence is stored in register N up
92. ncher         radix activates the FRC launcher     switches into the hyperbolic choices  Use  SHIFT  to toggle direct inverse        SHIFT   ALPHA  activates the XFL  sub functions launcher      lt     back arrow cancels it or returns to it from a secondary menu         c  Angel M  Martin Revision 44_E Page 9    SandMath_44 Manual       Like the native implementation  the name of the launched function will be shown in the display while  you hold the corresponding key     and NULLED if kept pressed  This provides visual feedback on the  action for additional assurance     Typically the secondary launchers have the possible choices in their prompt  we ll see them later on   The STAT menu differs from the others in that it consists of two line ups toggled with the  SHIFT  key      providing access to 10 functions using the keys in the top row directly below the function symbol     This is a good moment to familiarize yourself with the  3g  launcher  Go ahead and try it  using it also  in PRGM mode to enter the functions as program lines  Note that when activating XFL  you ll need to  press  ALPHA  a second time to spell the sub function name     Direct access function keys  in alphabetical order      A   Stat Prob MENUS   B   Euler   s Beta    C   Digamma  PSI    D   Rieman   s Zeta     E   Gamma Natural log   F   Inverse Gamma   G   Euler s Gamma   H   Hankel   s Launcher   I   Bessel I n x      J   Bessel J n x     Hyperbolics Launcher   K   Bessel K n x    L   Bessel Y n x   
93. ncher  1 Recurrence Sum  BS  STO 00 save J n x  here   used by Hankel  FC  0t _ fis KBS  Z LLun J  IGTO 01 TT   eee ee    RCL 01 n  PI     COS     LBL 01  RCL 02 partial result  4  RCL 01 n  PI     SIN     FS  0t jis VBS   IGTO03      gt  i  2 AA RC TE OA ERM ek ee OO E E RN ND    HALFX  PI     CHS    51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99  100        101    bo n a  a    a  O O  O O O O  O O      o O a  I  O a O  a S O O  O O O O  O      a 43 Y 1 J    ST  X 3   ST  02  RCL 02          orden argument swapped  default case  is it negative     reset counter  and partial sum    skip if n 0    selects  B2     amp  gk n x     k 0 1    n 1    BS2    abs n    x 2   selects  B1   DL  fk n x     k 0 1 2        BS2  partial result     showing off          partial result    is it YBS         c  Angel M  Martin    Revision 44 E    Page 63    SandMath_44 Manual       3 3 9  Riemann Zeta function     Perhaps one of the most studied functions in mathematics  it owes its popularity to its deep rooted  connections with prime numbers theory  Not having an easy approximation to work with  its  implementation on the 41 will be a bit of a challenge     mainly due to the very slow convergence of the  series representation used to program it  Be assured that this numeric calculation won t help you prove  the Riemann hypothesis  and collect the  1
94. nd how can they be  accessed  The answer is called the    Multi Function    groups     Multi Functions XFL  and xFL  provide access to an entire group of sub functions  grouped by their  affinity or similar nature  The sub functions can be invoked using either its index within the group   using XFL   or its direct name  using XFLS  This is implemented in such a way that they are also  programmable  and can be entered into a program line using a technique called    non merged  functions        You may already be familiar with this technique  originally developed by the HEPAX programmers  In  the HEPAX there were two of those groups  one for the XF M functions and another for the HEPAX A  extensions  The PowerCL Module also contains its own  and now the SandMath joins them     this time  applied to the mathematical extensions  particularly for the Special Functions group     A sub function catalog is also available  listing the functions included within the group  Direct execution   or programming if in PRGM mode  is possible just by stopping the catalog at a certain entry and  pressing the XEQ key  The catalog behaves very much live the native ones in the machine  you can  stop them using R S  SST BST them  press ENTER  to move to the next    sub section     cancel or  resume the listing at any time     As additional bonus  the sub function launcher XFL  will also search the    main    module FAT if the sub   function name is not found within the multi function group     so th
95. nes only use the stack     no data registers or user flags are used  Clearly the numeric range  will again be the weakest link  reaching it for n 54 for PPRML and n 251 for NPRML         c  Angel M  Martin Revision 44_E Page 47    SandMath_44 Manual       A glimpse of what   s ahead     sil       Hy  f  oF A N      C S    7       Relationship between common special functions     Taken from John Cook   s web site   http   www johndcook com special_ function diagram html        c  Angel M  Martin Revision 44_E Page 48    SandMath_44 Manual          A word about the approach  The Hyper Geometric Function as a generic function generator   or    the case of the chameleon function in disguise         Special functions are particular mathematical functions which have more or less established names and  notations due to their importance in mathematical analysis  functional analysis  physics  or other  applications  frequently as solutions to differential equations  There is no general formal definition  but  the list of mathematical functions contains functions which are commonly accepted as special  Some  elementary functions are also considered as special functions     The implementations described in this manual do nothing but scratching the surface  or more  appropriately     gingerly touching it     of the Special Functions field  where one can easily spend several  life times and still be just half way through     Implementing multiple special functions in a 41 ROM is clearly c
96. ngel Martin _  RCL Math Launcher        RCL _   Angel Martin _  RCL Plus        RCL __   Angel Martin _  RCL Minus    R   ike    RCL __   Angel Martin   RCL Division o    e    RCL __   Angel Martin   RCL Power SS    ike    AIRCL__   Angel Martin _  ARCL integer Part of number in Register nn _ __       2 4 1  Individual Recall Math functions     The five RCL Math new functions cover the range of four arithmetic operations  like STO does  plus a  new one added for completion sake  The functions would recall the number in the register specified by  the prompt  and will perform the math using the number in register X as first argument and the  recalled number as the second argument     Design criteria for these were     1  should be prompting functions  2  should support indirect addressing  SHIFT   3  should utilize the top 2 rows for index entry shortcut    The first condition is easy to implement in RUN mode  as it   s just a matter of selecting the appropriate  prompting bits in the function MCODE name  But gets very tricky when used under program mode  This  has been elegantly resolved using a method first used by Doug Wilder  by means of using the program  line following the instruction as the index argument  Somewhat similar to the way the HEPAX  implemented it  although here there   s some advantages in that the length of the index argument  doesn t need to be fixed  dropping leading zeroes and even omitting it altogether if it   s zero  assuming  the following line isn t
97. nvention used is shown in the figure below   defining the origin and direction of the azimuth and  polar angles as referred to the rectangular axis    The SandMath implementation makes use of the fact  that appropriate dual P R conversions are equivalent  to Spherical  and vice versa            c  Angel M  Martin Revision 44_E Page 17    SandMath_44 Manual       HMS  and HMS  complement the arithmetic handling of numbers in HMS format  adding to the native  HMS  and HMS  pair  As it   s expected  the result is also put in HMS format as well     xDGT is a small divertiment useful in pseudo random numbers generation  It simply returns the sum of  the mantissa digits of the argument     at light blazing speed using just a few MCODE instructions     More about random numbers will be covered in the Probability Stats section later on     Entering the base conversion section   The following functions are available in the SandMath     Author   Description  George Eldridge Base to Decimal  George Eldridge Decimal to base in Y    William Graham   Decimal to Hex  William Graham Hex to Decimal  T gt BS__ Base Ten to Base  prompting version        The first two are FOCAL programs  taken from the PPC ROM  They are the generic base b to from  Decimal conversions  The Direct conversion D gt BS expects the base in Y and the decimal number in X   returning the base b result in Alpha  The inverse function BS gt D uses the string in Alpha and the base  in X as arguments  You can chain them to en
98. on limit  Granted it isn   t the fastest one in town but  such isn   t an issue on a modern day emulator  and the economy of code cannot be stronger     EAG dt  a Cl    w  OO    EAG dt  sri    Which allegedly satisfies the equation    o   Jn t  dt   2   Jn  2    Jni3 X    Jn 5 X    seeeso         c    ngel M  Martin    Revision 44_E    SandMath_ 44 Manual       This completes this manual     Don t forget to check Jean Marc Baillard extensive and authoritative references on the web  despite its    unassuming web site name   located at  http   hp41programs yolasite com     A treasure chest awaits you    enjoy the ride                        c  Angel M  Martin Revision 44_E Page 98    
99. on termination     The second kind pair  KBS and YBS  is implemented using a FOCAL driver program for  BS and   BS2  Notably more demanding than the previous two  their expressions require additional  calculations that exceed the reasonable MCODE capabilities     Although they re not normally supposed to be used outside of the Bessel program   BS and  BS2  could be called independently  Both use the same input parameters  index in Y and half of the  argument in X  Pay close attention to the status of user flags 00 and 01 as they directly influence their  result         c  Angel M  Martin Revision 44_E Page 61    SandMath_44 Manual       Other functions used in the Bessel calculations  which aren t part of the native HP 41 function set  are  as follows     GEU Euler   s constant   0 577215665   CHSYX CHS repeated n times  in X register  multiplied by Y register   INT  and FRC  Conditional based on value in X being integer or fractional  E3 E  Self explanatory  divides X by 1 000  then adds one   Examples    J 1 1    0 440050586 I 1 1    0 565159104   J  1  1    0 440050586 I  1  1     0 565159104   J 0 5 0 5    0 540973790 I 0 5 0 5    0 587993086   J  0 5  0 5    0 990245881 I  0 5 0 5    1 272389647   Y 1 1     0 781212821 K 1 1    0 601907230   Y  1 2    0 107032431 K  1 2    0 139865882   Y 0 5 0 5     0 990245881 K 0 5 0 5    1 075047604   Y  0 5 0 5    0 540973790 K  0 5 0 5    1 075047604    Error Messages     Note that the functions will return a    DATA ERROR  message
100. ons  which use the series definition in the SandMath  the Gamma  function using the Lanczos formula  etc     With that said  let   s delve into the individual functions comprising the High Level Math group  First off  come those more frequently used so that they have gained their place in the ROM   s main FAT  Looking  at the authorship you ll see the tight collaboration between JM and the author  as stated in the opening  statements of this manual         c  Angel M  Martin Revision 44_E Page 49    SandMath_44 Manual       3 3 1  Gamma function and associates     Let   s further separate these by logical groups  depending on their similarities and applicability  The first  one is the GAMMA and related functions  1 GM  PSI  PSIN  LNGM  ICGM  BETA  and ICBT   all of  them a Quantum leap from the previous functions described in the manual  both in terms of the  mathematical definition and as it refers to the required programming resources and techniques      __  Function   Author   Description                o Z o O ooo  Di   a GMF   JM Baillard _  Reciprocal Gamma  Continuous fractions   TAg  BETA   Angel Martin _  Euler s Beta function _ _                   o  Z   o  TAJ  GAMMA   Angel Martin __  Euler s Gamma function  Lanczos            TAJ    ICBT_   JM Baillard   Incomplete Beta function __   _      o      o                 Pi  IcemM   JM Baillard ______  Incomplete Gamma function __            o       TA   LNGM   Angel Martin _  Logarithm Gamma function _ _ _ _          
101. ordinary factorial  and its value is therefore  closer to the square root of the factorial   It is denoted by n    For an odd positive integer n   2k   1  k   gt  1  itis  k    2k     1        2i    1    z 1  A common related notation is to use multiple exclamation points to denote a multifactorial  the product  of integers in steps of two  n     three  n      or more  The double factorial is the most commonly used  variant  but one can similarly define the triple factorial  n     and so on  One can define the k th  factorial  denoted by n         recursively for non negative integers as     wie      2 if0 lt n lt k       nf n  k   ifn gt k     The figures below show the plots for X    right   a comparison with log abs gamma    red   versus log abs doublegamma    green     left        Using the Logarithm is helpful to deal with large arguments  as these functions go beyond the  calculator numeric range very quickly  Also ran out of space in the module to have more than one  function on this subject  thus LGMF was chosen given its more general purpose character     The implementation is thru an all MCODE function  yet execution times may be large depending on the  arguments     LGMF may also be used to compute factorials  use n 1 and then E X on the result  Obviously the  accuracy won t be the greatest  but it   s a reasonable compromise    Output  pf         LGMF x        Examples     2 ENTER     100 XEQ LGMF    gt  Log 100      79 53457468  999 ENTER     123456 XEQ LGMF    g
102. pherical Hankel1   Spherical Hankel2   Toronto function   Weber and Anger functions  Lambert WO   Lambert W1    Angel Martin  JM Baillard  JM Baillard  JM Baillard  JM Baillard  JM Baillard  JM Baillard  Angel Martin  JM Baillard  Angel Martin  Angel Martin  JM Baillard  Angel Martin  Angel Martin  JM Baillard  Angel Martin  JM Baillard  Angel Martin  JM Baillard  JM Baillard  JM Baillard  JM Baillard  Angel Martin  Angel Martin  JM Baillard  JM Baillard  Angel Martin  Angel Martin        c  Angel M  Martin    Revision 44 E    Page 13    SandMath_44 Manual       The last section groups the factorial functions  circling back from the special functions into the number  theory field   a timid foray to say the most     Name Description Author   Section Header   Falling Factorial Angel Martin  Pochhammer symbol Angel Martin  Multi Factorial JM Baillard  Logarithm Multi Factorial JM Baillard  Poisson Standard Distribution Angel Martin  Super Factorial JM Baillard    Extended Factorial Angel Martin  FCAT     Function Catalogue Angel Martin           The best way to access FCAT is through the main launcher DAAI    then pressing ENTERN CN        FCAT  and    SP FNC  are usability enhancements for the admin and housekeeping  It invokes the sub   function CATALOG  with  ot keys for individual function launch and general navigation  Users of the  POWERCL Module will already be familiar with its features  as it   s exactly the same code     which in fact  resides in the Library 4 and it  
103. reflection formula    if you wish          The interesting fact about this is how it has been 2 5    implemented  if x lt 1 then the MCODE function branches to    a  a FOCAL program that  as part of the calculations  calls the  MCODE function after doing the change  x    1 x   which  obviously is  gt 1     perx  gt      2  a  gin    he Le    perz  lt 1        c  Angel M  Martin Revision 44_E Page 64    SandMath_44 Manual       Really the direct method isn   t very useful at all  and it   s more of an anecdotal implementation with  academic value but not practical  The Borwein algorithm provides an iterative alternative to the direct  method  with a much faster convergence even as a FOCAL program  and more comfortable treatment   It is implemented in the SandMath as a courtesy of JM Baillard  in the function ZETAX     For example  using ZETAX to calculate Z 1 001  returns the correct solution is a few seconds   See the appendices for a FOCAL listing of the program if interested     Examples       Complete the table below for C x   using both the direct method and the Borwein algorithm  Use the  result in WolframAlfa as reference to also determine their respective errors     Borwein     5  0 0039682539682  0 003968254 8 0136E 09   0 003968254  8 0136E 09  5 1 036927755 1 03692775  4 96019E 09   1 036927755    1 38255E 10    1 202056903 1 20205676  1 19096E 07   1 202056903    1 32764E 10  1 6449340668482 1644934066    5 15644E 10  10 58444846 10 58444847   4 77115E 10       We 
104. rning     X  depending on whether the number in Y is even or odd  respectively         c    ngel M  Martin Revision 44_E Page 15    SandMath_44 Manual       ATAN2 is the two argument variant of arctangent  Its expression is given by the following definitions     arctan  4   rz  gt   m   arctan    y gt  0 r lt 0     m   arctan    y lt O0 2  lt 0  atan2 y r7      _ _  z y  gt  0z        y  lt  0 2  0  undefined y   0  z        E3 E  does just what its name implies  adds one to the result of dividing the argument in x by one   thousand  Extensively used throughout this module and in countless matrix programs  to prepare the  element indexes     FLOOR and CEIL  The floor and ceiling functions map a real number to the largest previous or the  smallest following integer  respectively  More precisely  floor x     x  is the largest integer not greater  than x and ceiling x     x  is the smallest integer not less than x     The SandMath implementation uses the native MOD function  through the expressions   CEIL  x     x   MOD x  1    and FLOOR  x     x     MOD x  1       GEU is a new constant added to the HP 41  the Euler Mascheroni constant  defined as the limiting  difference between the harmonic series and the natural logarithm     oe    y  lim       In n  f Eare 2 i       The numerical value of this constant to 10 decimal places is  y   0 5772156649    The stack lift is    enabled  allowing for normal RPN style calculations  It appears in formulas to calculate the  Psi   function 
105. routine listing     3 3 3   Lower  Incomplete Gamma function     In mathematics  the upper and the lower incomplete gamma functions are respectively as follow     C s  x     Et e  dt  ylas  T     t e  dt   T  E    Connection with Kummer s confluent hypergeometric function  when the real part of z is positive   ya  z    s tze 7 M 1 8s  1 2   which is the expression used in the SandMath     The Upper incomplete Gamma function can be easily obtained from the relationship     y s z  T s  x   T 8          c    ngel M  Martin Revision 44_E Page 53    SandMath_44 Manual       3 3 4  Log Gamma function     Many times is easier to calculate the Logarithm of the Gamma function instead of the main Gamma  value  This could be due to numeric range problems  remember that the 41 won t support numbers  over E100   or due to the poles and singularities of the main definition     The SandMath uses the Stirling approximation to compute LogGamma  as given by the following  expression  directly obtained from the formula in page 27              1  2n T z    n 27      Inz   z  21n z   In  zsinh     z  2   z  8l  z  This approximation is also good to more than 8 decimal digits for z with a real part greater than 8  For  smaller values we ll use the functional equation to extend it to the region where it   s accurate enough  and then back calculate the result as appropriate        tu     The picture on the left shows the    LogGamma function for _ positive  b arguments  Interestingly it has a negati
106. s the usual conventions for the stack registers  entering x as the last parameter  in    register X      despite the written form   Output       2 ee  T         Examples      PI ENTER     0 6 ENTER   0 7  FL   LERCH    gt   0 7  7  0 6    5 170601130  3 ENTER   4 6 ENTER     0 8  FL  LERCH    gt    0 8 3  4 6    3 152827048    Or  a1    H    R  instead        c    ngel M  Martin Revision 44_E Page 87    SandMath_44 Manual       Kelvin Functions       In applied mathematics  the Kelvin functions of the first kind  Berv x  and Beiv x    and of the Second  kind   Kerv x  and Keiv x    are the real and imaginary parts  respectively  of    Si  4 P f mifa  dy  re   for the ist  Kind Ky  ze   for the 2nd  Kind     These functions are named after William Thomson  ist Baron Kelvin  For integers n  Bern x  and Bein x  have the following series expansion    Ber  x        con    7         2  L kIT n k 1   4   and    on k     Beno     2  onl Dl  2     2  Z kT  n  k 1   4    The figure below shows Ber n x  and Ker n x  for the first 4 integer orders and real arguments        Ber n X  and Bei n x  are available in the SandMath  implemented as FOCAL programs written by JM  Baillard  Both values are calculated simultaneously by KLV  and left in X Y registers as follows     Stack Output    Example     2 SQRT  PI   FL   KLV    gt  ber  sqrt 2   x     0 674095951  X lt  gt Y   gt  bei  sqrt 2   n     1 597357210    Or   ml    H    K  instead        c  Angel M  Martin Revision 44_E Page 88    San
107. s wasted by eGObEEP and W    instead  This  method is used in several functions of the SandMath module  like the RCL math functions just  described     Appendix 3   A trip down to Memory Lane  From the HP 41 User   s Handbook      Automatic Primary Extended  Memory Data Storage Data Storage  Stack Registers Registers  T Foo  Roo  Fd ALPHA Ra  The standard Raon  Y Roo HP 41  0 has a You can add up to four memory modules   X LAST X o  f 83 Rag Red   bringing the total te 100 primary and 219  Pall memeryniodulas whe primary storage   extended storage registers   allocated to storage registers  m PGE  each additional module would Rea  account for the following register R  addresses  S    The Function     Rej US    The Indirect Address Register    Ros 10 0000    The Desired Register   Recalled into the   reqister      Rio 2 3400     Storage Register Arithmetic    Arithmetic can be pertormed upon the contents of all storage registers by executing followed by the  artthmetic function followed in tum by the register address  For example     Opertion Result   O1 Number tn X register is added to the contents of register Eoi  and the  sum is placed into Eoi  The display execution form of this is  sT          02 Number in A register is subtracted from the contents of register Rios   and the difference is placed into Ros  The display execution form of  this is  5T      1E Number in X resister is multiphed by the contents of register Ros  and  the product is placed into Ros  The display ex
108. scovery was posthumously published in 1712 in his work Katsuyo Sampo  Bernoulli s  also  posthumously  in his Ars Conjectandi of 1713  Ada Lovelace s note G on the analytical engine from  1842 describes an algorithm for generating Bernoulli numbers with Babbage s machine  As a result  the  Bernoulli numbers have the distinction of being the subject of the first computer program        I 01 LBL   BN2       i TE ob   Barnaulli numi iwib If   r3 oz K 1   TA Beare a i 03 GTOO1  1 4 o4 x 0   p N 05 INCX    06 X 1   a2     07 RIN  kN ne 08 ODD   T a p all w oo  CLX  ks 10  X 0 7  0 25       11  RTN  i 3 G   12 l2 2  il  r  13 M lt      14  GTO 00  15  6  There are several  or rather many   algorithms and approaches to l6  1 X  the calculation of Bn  In this particular example we ll use the 17 RIN  expression based on the Riemann   s Zeta function  according to l1 amp  LBL OO a  which the values of the Riemann zeta function satisfy 19 Si  X  20 M lt        21  GTOOO  n  1      n  Bn ae  l     23  1 X  for all integers n20  The expression n     1     n  for n   0 is to be ca  lie  understood as the limit of x     1     x    when x  gt 0    aa F  26 XoY  Sanaan oo 27    LBLO1  The FOCAL program on the right is a super short application of the 36 STOM  ZETA function  even if it s used for negative arguments  Obviously 39 CHS  we ve single cased the troublesome points to avoid execution times 30 INCX  unreasonably long  but apart from that it   s quite generic in its 31 ZETA  approach  
109. see that not only is the Borwein algorithm faster and more capable in range  but also their results  are more accurate than the direct approach  MCODE or not  13 digit internal subroutines  notwithstanding      02     j       DRO    So    oLa X    Note  The following links to the MAA and the  now defunct  Zetagrid make fascinating reading on the  Zeta zeros current trends and historic perspective     make sure you don   t miss them   http  www maa org editorial mathgames mathgames_10_18_04 html   http   www zetagrid net         c  Angel M  Martin Revision 44_E Page 65    SandMath_44 Manual       Appendix 8   Putting Zeta to work  Bernoulli numbers     In mathematics  the Bernoulli numbers Bn are a sequence of rational numbers with deep connections  to number theory  The values of the first few Bernoulli numbers are    BO   1  B1    1 2  B2   1 6  B3   0  B4      1 30  B5   0  B6   1 42  B7   0  B8    1 30     If the convention B1    1 2 is used  this sequence is also known as the first Bernoulli numbers  with the  convention B1  1 2 is known as the second Bernoulli numbers  Except for this one difference  the first  and second Bernoulli numbers agree  Since Bn 0 for all odd n gt 1  and many formulas only involve  even index Bernoulli numbers  some authors write Bn instead of B2n     The Bernoulli numbers were discovered around the same time by the Swiss mathematician Jakob  Bernoulli  after whom they are named  and independently by Japanese mathematician Seki Kowa   Seki s di
110. ster R101  and 55555 000 in register R5    This requires some indirect addressing as well  say using register Y the sequence would be     101  ENTER     5  STO IND Y  and then  55555  STO 5    Then execute RCL    IND 101  press RAM    SHIFT     EEX      0     1      gt  to obtain 55555 00 in X       Note  general purpose prompt lengtheners are a better alternative to the  EEX  implementation used  here  Their advantage of course is that they are applicable to all mainframe prompting functions  not  only to the enhanced RCL  Thus for instance  you could use it with STO as well  removing the need for  indirect addressing to store 5 in R101  The AMC_OS X module has a general purpose prompt  lengthener  activated by pressing the  ON  key while the function prompt is up         c  Angel M  Martin Revision 44_E Page 28    SandMath_44 Manual       Pressing  ALPHA  at the RCL prompt will invoke function AIRCL _ _  This will in turn prompt for a data  register number  and once filled it ll append the integer part of the value stored in that register to the  ALPHA register     thus equivalent to what AINT does with the x register     Note that AIRCL _ _ is fully programmable  When entered in a program you d ignore the prompts   and the program step following it will be used to hold the register number to be used by ARCLI when  the program runs  This technique is known as     non mergea  functions  to work around the limitation of  the OS     Too bad we can t use the Byte Table location
111. t  Log   123456               578 0564932    And now lets move to something completely unrelated  Fourier Series representation of a given  function  f x          c  Angel M  Martin Revision 44_E Page 45    SandMath_44 Manual       Appendix 5   Primorials     a primordial view     Welcome to the intersection between factorials and prime numbers       In number theory primorial is a function from natural numbers to natural numbers similar to the  factorial function  but rather than multiplying successive positive integers  only successive prime  numbers are multiplied  The name  primorial   attributed to Harvey Dubner  draws an analogy to  primes the same way the name  factorial  relates to factors     There are two conflicting definitions that differ in the interpretation of the argument  the first interprets  the argument as an  ndex into the sequence of prime numbers  so that the function is strictly  increasing   while the second interprets the argument as a bound on the prime numbers to be  multiplied  so that the function value at any composite number is the same as at its predecessor      The figures below plot both definitions  comparing their shape and slopes         Of as a function of n  plotted logarithmically  fy  m as a function of n  red dots   compared to nl  Both plots      are logarithmic     Natural primorial  right plot   In general  for a  positive integer n such a primorial n  can also  be defined  namely as the product of those    Prime primorial  left p
112. t are not counted separately  The formula is     nl    kl n     k      The general operation include the following enhanced features     Gets the integer part of the input values  forcing them to be positive    Checks that neither one is Zero  and that n gt r   Uses the minimum of  r   n r   to expedite the calculation time   Checks the Out of Range condition at every multiplication  so if it occurs its determined as soon   as possible   The chain of multiplication proceeds right to left  with the largest quotients first    e The algorithm works within the numeric range of the 41  Example  nCr 335 167  is calculated  without problems    e It doesn t perform any rounding on the results  Partial divisions are done to calculate NCR  as   opposed to calculating first NPR and dividing it by r     Provision is made for those cases where n 0 and r 0  returning zero and one as results respectively   This avoids DATA ERROR situations in running programs  and is consistent with the functions  definitions for those singularities     Note as well that there is no final rounding made to the result  This was the subject of heated debates  in the HP Museum forum  with some good arguments for a final rounding to ensure that the result is an  integer  The SandMath implementation however does not perform such final    conditioning     as the  algorithm used seems to always return an integer already  Pls  Report examples of non conformance if  you run into them     Example  Calculate the number
113. t the applicability of this method extends to the Integro Differential forms of the  Bessel functions  and so could be used to calculate second primitives or derivatives as well     The expressions used in the SandMath for functions ITJ and ITI are as follows   D  L x    K x   Tm  2F3  n 1  2   n 2  2    n 1   2   n 2 p  2  n 1   x    4    D  Ja    K x   T  m   oF 3  n 1  2   n 2  2    nt1 p  2   n 2 p  2  nt     x    4      Where K  2 7 sqrt z   and u    1 for the integral  primitive     Just in case you don t believe it  take a look at this WolframAlpha   s link   http   www  wolframalpha com input 7i integrate   2 amp 8bessell  28N Y2CX  29 29           1  2fnt l1  3 x    300 dx   gmt tty 2S  A  H  l  k 5 i        1  2 f n 1  3 x   moo ax   2 7 tt  AS ha  ntl      E           1 1    4  Nothing short of magical if you ask me     what I d call    going out with a bang      Examples   1 4 ENTER     3  XFL   ITJ    gt     0 3 J 1 4 x  dx   1 049262785  1 4 ENTER     3  SFL   ITI    gt     0 3 1 1 4 x  dx   2 918753200  1 ENTER     3   FL   ITJ    gt     0 3 J 1 x  dx   1 260051955  0 ENTER     10  XFL   ITJ      gt      0 10 J 0 x  dx   1 067011304    50 ENTER     30   FL   ITJ      gt     0 30 J 50 x  dx  1 478729947 E 8        c  Angel M  Martin Revision 44_E Page 96    SandMath_44 Manual       Appendix 11  Looking for Zeros     Once again just connecting the dots  a brute force crude implementation of a root finder for Bessel  functions  made possible once the major task  i
114. te it refers to its relation to the Gamma function  as follows      2  Uy   SDS Tety     As a graphical example  the picture below shows B X 0 5  for values of x between    4 and 4  As it   s  expected  the same Gamma problem points are inherited by the Beta function     Betaly  5     15    10    Biy z        The implementation on the SandMath makes no attempt to discover new approaches or utilize any  numeric equivalence  it simple applies the definition formula using the Gamma subroutine  Obvious  disadvantages include the reduced numeric range     aggravated by the multiplication of gamma values  in the numerator     Execution time corresponds to three times that of the Gamma function  plus the small overhead to  perform the Alpha Data checks and the arithmetic operations between the three gamma values   3 3 7  Incomplete Beta Function     The incomplete beta function  a generalization of the beta function  is defined as     B x  a b      1 1  1     t     dt   0    For x   1  the incomplete beta function coincides with the complete beta function  The relationship  between the two functions is like that between the gamma function and its generalization the  incomplete gamma function     And it   s given in terms of the Hypergeometric function the expression by     Bizi a b         F a  1    b a  1  z     iT        c  Angel M  Martin Revision 44_E Page 56    SandMath_44 Manual       3 3 8  Bessel functions and Modified     The next logical group would be the Bessel functions
115. tory to make it all fit in an 8k footprint factor   and to allow reuse with other modules  This is  totally transparent to the end user  just make sure it is installed in your system and that the revisions  match  See the relevant Library 4 documentation if interested     Function Launchers and Mass key assignments     As any good    theme    module worth its name  the SandMath has its own mass Key assignment routine   Use it to assign the most common functions within the ROM to their dedicated keys for a convenient  mapping to explore the functions  Besides that  a distinct feature of this module is the function  launchers  used to access diverse functions grouped by categories  These include the Hyperbolic  the  Fractions  the RCL Math  and the Special Function groups  This saves memory registers for key  assignments  whilst maintaining the standard keyboard available also in USER mode for other purposes     This is the fourth incarnation of the SandMath project  which in turn has had a fair number of revisions  and iterations on its own  7he new distinct addition has been a secondary Function address Table  FAT   to provide access to more functions  exceeding the limit per page imposed by the operating system   Some other refinements consisted in a rationalization of the backbone architecture  as well as a more  modular approach to each of pages of the module  Gone are the    8k    vs     12k    distinctions of the past      as now the Matrix and Polynomial functions have 
116. ulator  No  rounding is made until the final comparison  which is done on 10 digit values     From the definition above it   s clear that  BS coincides with either Jn x  or In x  depending on the  status of the CPU flag 9  and for positive orders  The functions JBS and IBS are just MCODE  extensions of  BS that set up the specific settings prior to invoking it  and  depending on the signs of  the orders and the arguments  possibly adjust the result after it   s completed         c  Angel M  Martin Revision 44_E Page 60    SandMath_44 Manual       The second function  BS2 is only used for second kind functions with integer orders  It   s a finite sum   and not an infinite summation  Its contribution to the final result grows as the function order increases   Its main goal was to reduce execution time as much as possible  derived from the speed gains of  MCODE versus FOCAL     The definition of f  n x  is as follows    f   n x      x 2         k   n k       H k    H ntk     k 0 1 2     The definition of gk n x  is as follows    g n x     x 2       n k 1    k  3 k 0 1     n 1     The calculation of Gamma uses the Lanczos approximation implemented in the GAMMA function of the  SandMath  Despite being reasonably fast  its execution time is noticeably longer than that of the  Factorial for integer indexes     therefore  BS2 will use FACT instead for integer orders     The Harmonic Numbers H n  are obtained using another SandMath function as subroutine  21 N  You  see that the inter
117. uperfactorial in green   hyperfactorial in purple      eee ee ee ee m        mxi    fo Dont expect quantum leaps in number theory  A ee eer erent eens eee   here  it is after all one of the most difficult  branches of math         c  Angel M  Martin Revision 44_E Page 41    SandMath_44 Manual       Pochhammer symbol  Rising and falling empires     In mathematics  the Pochhammer symbol introduced by Leo August Pochhammer is the notation  x      where n is a non negative integer  Depending on the context the Pochhammer symbol may represent  either the rising factorial or the falling factorial as defined below  Care needs to be taken to check    which interpretation is being used in any particular article   The symbol x  is used for the rising factorial  Sometimes called the  Pochhammer function       Pochhammer polynomial    ascending factorial      rising sequential product  or  upper factorial       a      o 2 1  2  2     2 n   1      The symbol  X n is used to represent the falling factorial  sometimes called the  descending  factorial    2   falling sequential product    lower factorial        1     u x    1  a   2     2 n 1   These conventions are used in combinatory  However in the theory of special functions  in particular  the hypergeometric function  the Pochhammer symbol  x n is used to represent the rising factorial     Extreme caution is therefore needed in interpreting the meanings of both notations      The figures below show the rising  left  and falling factoria
118. ur coefficients in the stack registers T  Z  Y  X using   a  ENTER     b  ENTER   c  ENTER   d  ENTER     CROOT uses the well known Cardano Vieta formulas to obtain the roots  The highest order coefficient  doesn t need to be equal to 1  but errors will occur if the first term is zero  for obvious reasons          c    ngel M  Martin Revision 44_E Page 19    SandMath_44 Manual       The SandMath implementation does reasonably well with multiple roots  but sure enough you can find  corner cases that will make it fail   yet not more so than an equivalent FOCAL program  Appendix 2  lists the code  as well as an equivalent FOCAL program to compare the sizes  much shorter  but surely  much slower and with data registers requirements    Both cases can return real or complex roots  If the roots are complex  the functions will flag it in the  following manners     1  QROOT will clear the Z register  indicating that X and Y contain the real and imaginary parts of  the two solutions  Conversely  if Z 0 then X and  amp  contain the two real roots     2  CROOT will leave the calculator in RAD mode in CROOT  indicating that X and Y contain the  real and imaginary parts of the second and third roots  The real root will always be placed in  the Z register  Conversely  if the calculator is set in DEG mode then registers Z Y  and X have  the three real roots     QROUT outputs the contents of the X and Y registers to the display  interpreted by the value in Z to  determine whether there are to
119. used independently from the SandMath  but sure it is a powerful complement for  these specific subjects     VCALC    Vera    VSTO__    VADST           c  Angel M  Martin Revision 44_E Page 40    SandMath_44 Manual          Quick recap  a summary table of the different factorial functions available in the SandMath       _  Function   Author   Description _ _ _ _    O Z o O o   _  MFCT Multifactorial    Logarithm Multifactorial  SFCT Superfactorial  XFCT Extended FACT    POCH Angel Martin Pochhammer symbol    FFACT Falling factorial       Large numbers in a calculator like the HP 41 represent a challenge  Not only the numeric range  represents a problem  but also the reduced accuracy limits the practical application of the field   Nevertheless the few functions that follow contribute to add further examples of the ingenuity and  what s possible using this venerable platform     This was the last section added to the SandMath  in revision    E     It also required compacting the few  gaps available  and transferring some code to the last available space in the Library 4 module  Make  sure you have matching revision of those two     The functions in the table above operate only on integers  i e  no extension to real numbers using  GAMMA  Below one of such extensions  the Hyperfactorial in a 3D visualization from WolframWorld     Re H iz  Irna Aez  A z        The figure on the left shows a plot of the four  functions on the real line  Fibonacci in blue   double factorial in red  s
120. ve  results region between 1 and 2     so it  isn t always positive     Note also the asymptotic behavior near  3 the origin     due to the Gamma function  pole        The implementation on the SandMath uses the analytical continuation to calculate LogGamma for  arguments less than 9   ncluding negative values  Obvious problems  like the poles at negative integer   will yield DATA ERROR messages  but outside that the approximation should hold     since  I  z n    T z    X z i    i 1 2  n    it follows  Ln F  z n    Ln T z    Ln  X z i    i 1 2  n     Notice also that the same error will occur when trying to calculate LogGamma when Gamma is  negative  which occurs between even negative numbers and their immediately lower  inferior  one      see the plot in page 27      See the following link for a detailed description of another implementation  using Lanczos for both  cases  to calculate Gamma and LogGamma on the 41 by Steven Thomas Smith   http   www  homuseum  org cai sys cqiwrap hpmuseunrvarticles  cgi read 941       An excellent implementation of Gamma and related functions for the 41 is available on the following  link  written by Jean Marc Baillard  very complete and detailed      Attp   www hpmuseum  org sottware 41 4lgamdgm htm        c  Angel M  Martin Revision 44_E Page 54    SandMath_44 Manual       3 3 5  Digamma function     In mathematics  the digamma function is defined as the logarithmic derivative of the gamma function     P r    z log T x    rae    It is the 
121. ve and negative  values for real z gt  0 4  and so cannot be used for practical numerical computation     The W function may be approximated using Newton s method  with successive approximations to w    W z   so z   w e   being     wje        7  ut   TT      A         __    tae s eva   wens    The implementation in the SandMath uses this iterative method to solve for W z  the roots of its  functional equation  given the functions argument z  An important consideration is the selection of the  initial estimations  For that the general practice is to start with Ln x  as lower limit  and 1 Ln x  as  upper value     Another aspect of the W function is the existence of two branches  The second branch is defined for  arguments between    1 e and 0  with function values between    1 and    infinite     The    lower    branch is also available in the SandMath as the function WL1  In fact the MCODE  algorithm is the same one  with just different initial estimations depending on the branch to calculate          c  Angel M  Martin Revision 44_E Page 67    SandMath_ 44 Manual       Example 1  calculate W for x 5   5   WLO   gt     RUNNING        followed by 1 326724665   We can use the inverse Lambert function AWL to check the accuracy of the results  simply executing it  after WLO and comparing with the original argument  Note the AWL will be seen later on  in the  Secondary FAT  Sub functions  group  This it requires  FL  to call it  not XEQ    5    WLO   EFL     AWL      gt  4 9999999
122. w hp41 org    SandMath Overlay    2009 Lujan Garcia    Published under the GNU software licence agreement         c  Angel M  Martin Revision 44_E Page 2    SandMath_44 Manual       Table of Contents    Revision E     1  Introduction     Function Launchers and Mass key assignments  Used Conventions and disclaimers   Getting Started  Accessing the functions    Main and Dedicated Launchers  the Overlay  Appendix 1   Launcher Maps   Function index at a glance     2  Lower Page Functions in Detail    2 1  SandMath44 Group    Elementary Math functions     Number Displaying and Coordinate conversions  Base Conversions    First  Second and Third degree Equations    Appendix 2   FOCAL program listing  Additional Test Functions  rounded and otherwise    2 2  Fractions Calculator    Fraction Arithmetic and displaying    2 3  Hyperbolic Functions    Direct and Indirect Hyperbolics  Errors and Examples    2 4  Recall Math    Individual RCL Math functions  RCL Launcher     the    Total Rekall       Appendix 3   A trip down memory lane    3  Upper Page Functions in Detail    3 1 Statistics   Probability    Statistical Menu     Another type of Launcher  Alea jacta est      Combinations and Permutations   Linear Regression     Let s not digress  Ratios  Sorting and Register Maxima  Probability Distribution Function    And what about Prime Factorization     Appendix 4  Prime Factors decomposition  Distance between two Points         c  Angel M  Martin Revision 44_E    23    25  26    27  28  
123. w real roots or the Real  amp  Imaginary parts of the complex roots  It will  be automatically invoked by QROOT  always  and by CROOT  real roots  when they are executed in  RUN mode  Note that CROOT will not display the  first  real root  which will be located in Z     CVIETA is a driver program for CROOT  including the prompts for the equation coefficients  The  results are placed in the stack  following the same conventions as for CROOT explained above     Example _1   Calculate the roots of the equation  AX   2     3X   3x 2     2   ENTER  3   ENTER      ENTER     2   CROOT   gt  Z  0 500  Y   1 000  X  2 000          f x  2x 3  3x2  3x 2    From the final prompt you know all roots  are real  The value in Z blinks briefly in the  display before the final prompt above is  presented  use RCL Z  or RDN  RDN  to  retrieve it  No user registers are used        X        ri    tt   1         H1 4  1 13           reor pm    i         mH       N             Tm    Example 2  Calculate the three solutions of  the equation  xX    x7 x 1 0    1  LENTER   ENTER   ENTER     CROOT   gt  Z   1 000  Y  1 000  X  1 E 10        d  Shown as rounded number for the real part         c    ngel M  Martin Revision 44_E Page 20    SandMath_44 Manual       Appendix 2   CVIETA equivalent FOCAL program  replaced now with an all MCODE implementation                                         01 LBL  CVIETA  r ea N2  02     6   imaginary part  F 03 R      66 RCLO01 cbrt  x R3 2    04   ST  T 0  q 2 a 3 in 
124. y of cases  and only runs into limiting situations in very  few instances  if at all     remember that exceeding 24 characters will shift off the display the left  characters first  that is the original number   which doesn   t result into any data loss     Obviously prime numbers don   t have any other factors than themselves  For instance  for x 17777  PFCT will return        J  which indeed is hardly debatable     Note that only the last two prime factors found will be stored in Y and Z  and that the original number  will remain in X after the execution terminates  A more capable prime factorization program is available  in the ALGEBRA module  using the matrix functions of the Advantage and Advanced Matrix ROMs to  save the solutions in a results matrix  See the appendices for a listing of the program used in the  SandMath and the more comprehensive one     ema    Dp RAE      Shown on the left there s an even simpler version  that doesn t  7 INT consolidate the multiple factors     which will aggravate the length   Fa limitation of the ALPHA registers of 24 chrs max  The core of the action   FA is performed by PRIME   therefore the fast execution due to the   res MCODE speed     6    7   ros See the appendix in the next pages  with both the actual code for PFCT   F g in the SandMath   and for PRMF   a more capable implementation using   F 40 the Matrix functions from the HP Advantage to store the prime factor   Fal PRIME  and their repetition indexes     really the best wa
125. y to present the results     12 SF OO        13 AINT   For that second case the function PF gt X restores the original argument   F 44 FS2C 00 from the matrix values  Also function TOTNT is but a simple extension    r 45 GTO 01 using the same approach     16    7   18   F   F   F   F   F   F   F           c    ngel M  Martin Revision 44_E Page 37    SandMath_44 Manual       Appendix 4  Prime factor decomposition     The FOCAL programs listed below are for PFCT     included in the SandMath     and PRMF  a more  capable implementation that uses the Matrix functions from the HP Advantage  or the AVD_MATRIX  ROM     PRMF stores all the different prime factors and their repetition indices in a  n x 2  matrix  The matrix is  re dimensioned dynamically each time a new prime factor is found  and the repetition index is  incremented each time the same prime factor shows up     A matrix is a much better place than the ALPHA register for sure     as is done in PFCT  The drawback is  of course the execution speed  much faster in PFCT     PF gt X is the reverse function that restores the original number from the values stored in the matrix   TOTNT  Totient function  is but a simple extension  also shown in the listings below     PRMF  PC gt X and TOTNT are included in the Advanced MATRIX ROM     Below is the program listing implemented in the SandMath           1 LBL    PRIME      32 GTO 03 skip if Prime  2 CF OO 33 ST  L   3 INT 34 LASTX reduced number    ABS 35 GTO 00  5   CLA   36 Prim
    
Download Pdf Manuals
 
 
    
Related Search
 SandMath  sandmath  sandmatthof  sandmatthof aristau  sin math formula  sin maths  sin math definition  sin mathematica  sin math calculator  sin math term  sin math symbol  sin math equation 
    
Related Contents
iSound HM-260  Manual de instrucciones Equipo de audioconferencia Konftel 200W  EFI Laser Matt 162M  EXSYS EX-47995  StartUp Herbicide  Trumatic E 2400 - T3  MVI56-MCMR User Manual  ABCD...123    Copyright © All rights reserved. 
   Failed to retrieve file