hp41programs

Struve

Struve Functions for the HP-41


Overview
 

 1°)  Ascending Series
 2°)  Asymptotic Expansion
 

-The Struve function is defined by    Hn(x) =  (x/2)n+1 SUM k>=0  (-1)k(x/2)2k/ ( Gam(k+3/2).Gam(k+n+3/2) )
 and the modified Struve function:    Ln(x) =  (x/2)n+1 SUM k>=0  (x/2)2k/ ( Gam(k+3/2).Gam(k+n+3/2) )
 

1°)  Ascending Series
 

Data Registers:  /

Flag:              Clear flag F01 to compute  Hn(x)
                       Set flag F01 to calculate  Ln(x)

Subroutine:  "GAM" or "GAM+" ...  ( Gamma function )
 
 

01  LBL "HLNX"
02  2
03  /
04  STO M
05  X<>Y
06  STO N
07  STO O
08  1
09  +
10  Y^X
11  ST+ X
12  PI
13  SQRT
14  /
15  1.5
16  ST+ N
17  ST+ O
18  RCL Y          
19  ENTER^
20  LBL 01
21  X<> T
22  RCL M         
23  X^2
24  *
25  FC? 01
26  CHS
27  R^
28  /
29  RCL N          
30  /
31  1
32  ST+ T
33  ST+ N
34  RDN
35  STO T
36  X<>Y
37  ST+ Y
38  X#Y?
39  GTO 01
40  X<> O
41  XEQ "GAM"
42  ST/ O
43  RCL O
44  CLA
45  END

 
   ( 79 bytes / SIZE 000 )
 
 

      STACK        INPUTS     OUTPUTS
           Y             n    Gam(n+3/2)
           X             x   Hn(x) or Ln(x)

  X-output = Hn(x) if  CF 01 or  Ln(x) if  SF 01

Example:    Compute  H1.2 ( 3.4 )   and   L1.2 ( 3.4 )

          CF 01
  1.2   ENTER^
  3.4   XEQ "HLNX"  >>>>   1.113372654    ( in 12 seconds )

          SF 01
  1.2   ENTER^
  3.4   XEQ "HLNX"  >>>>   4.649129448    ( in 12 seconds )
 

Notes:

-Unlike Hn(x) , Ln(x) is accurately computed for large arguments by these series.

-The M-Code routine HGF+ ( cf "Hypergeometric Functions for the HP-41" )
  may also be used to compute Struve functions because:

         Hn(x) = (x/2)n+1 1F~2( 1 ; 3/2 , n + 3/2 ; - x2/4 )           where  1F~2  is a regularized hypergeometric function.
         Ln(x) = (x/2)n+1 1F~2( 1 ; 3/2 , n + 3/2 ;  x2/4 )

-Line  23 Y^X  is preferably an M-Code version that returns  0^0 = 1
 
 

01  LBL "HLNX"
02  2
03  /
04  STO 00
05  X<>Y
06  STO 04        
07  1.5
08  STO 02
09  +
10  STO 03
11  1
12  STO 01        
13  ST+ 04
14  2
15  CHS
16  RCL 00        
17  X^2
18  FC? 01
19  CHS
20  HGF+
21  RCL 00        
22  RCL 04
23  Y^X    
24  *
25  END

 
   ( 40 bytes / SIZE 005 )
 
 

      STACK        INPUTS     OUTPUTS
           Y             n            /
           X             x   Hn(x) or Ln(x)

  X-output = Hn(x) if  CF 01 or  Ln(x) if  SF 01

Example:

   CF 01   3    SQRT
               PI   XEQ "HLNX"   >>>>   Hsqrt(3) ( PI ) = 0.921143579      ---Execution time = 7s---

   SF 01   3    SQRT
               PI   XEQ "HLNX"   >>>>   Lsqrt(3) ( PI ) = 2.546553287      ---Execution time = 7s---
 

2°)  Asymptotic Expansion for Hn(x)
 

-We have:      Hn(x)  ~  Yn(x)  + [ 21-n xn-1 / sqrt(Pi) / Gam(n+1/2) ]  3F0( 1/2 , -n + 1/2 , 1 ; -4/x2 )          if  x >> n
 

Data Registers:  R00 thru R10: temp
Flags: /
Subroutines:   "AEJY" ( cf "Bessel Functions for the HP-41" ) and the M-Code routines  HGF+  &  1/G
 
 

01  LBL "AEH"
02  X<>Y
03  STO 10
04  X<>Y
05  XEQ "AEJY"
06  X<>Y
07  STO 09
08  .5
09  STO 01
10  RCL 10
11  -
12  STO 02
13  1
14  STO 03       
15  CLST
16  3
17  X<>Y
18  2
19  RCL 00
20  /
21  X^2
22  CHS
23  HGF+
24  2
25  RCL 03       
26  RCL 10
27  -
28  Y^X
29  RCL 00
30  LASTX
31  CHS
32  Y^X
33  *
34  *
35  RCL 01       
36  RCL 10
37  +
38  1/G
39  *
40  PI
41  SQRT
42  /
43  RCL 09       
44  +
45  END

 
   ( 61 bytes / SIZE 011 )
 
 

      STACK        INPUTS     OUTPUTS
           Y             n            /
           X             x        Hn(x)

 
Example:

     PI    ENTER^
   16.5  XEQ "AEH"   >>>>   13.35178333        ---Execution time = 16s---

Notes:

-If x is not large enough, there will be an infinite loop - for instance if n = PI and x = 16.4
-Press any key to stop it !
 

References:

[1]   Abramowitz and Stegun , "Handbook of Mathematical Functions" -  Dover Publications -  ISBN  0-486-61272-4
[2]   http://functions.wolfram.com/