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





Post Reply 
16 Point Gaussian Quadrature for the HP-41C/CV/CX (updated)
11-09-2023, 09:23 PM (This post was last modified: 11-15-2023 10:42 PM by Namir.)
Post: #1
16 Point Gaussian Quadrature for the HP-41C/CV/CX (updated)
16 Point Gaussian Quadrature for the HP-41C/CV/CX (updated)

This program is a slightly enhanced version of the one posted by Tony Udell. The program includes LBL 00 that initializes the values for the quadrature nodes and weights. I have also remapped the memory registers into a contiguous sequence from 00 to 19.

You can download the .raw program file by clicking here.

To use the program:

1) Press [A] to perform a regular integration between A and B. The program prompts you for the values of A and B. Enter these values and press [R/S] to calculate the integral.

2) Press [B] to perform a special integration between A and infinity. The program prompts you for the value of A. Enter the value and press [R/S] to calculate the integral.

Notes:
1) Label "FX" (also label E) is where you enter the statements to evaluate the integrated function.
2) The program automatically calls subroutine at LBL 00 to initialize the nodes and weights for the quadrature.


Memory Map
==========

Code:
R00 = integral
R00 = integral
R01 = a
R02 = b
R03 to R18 x(1),w(1),x(2),w(2),...x(8),w(8)
R19 = index used to access x(i) and w(i)

Flags used 00 and 01

Program Listing
============

Code:
01 LBL "A-B"
02 LBL A
03 XEQ 00
04 FIX 05
05 "a?"
06 PROMPT
07 STO 01
08 "b?"
09 PROMPT
10 STO 02
11 0
12 STO 00
13 CF 00
14 LBL 01
15 18
16 STO 19
17 XEQ 15
18 XEQ 15
19 XEQ 15
20 XEQ 15
21 XEQ 15
22 XEQ 15
23 XEQ 15
24 XEQ 15
25 FS? 00
26 GTO 02
27 SF 00
28 GTO 01
29 LBL 02
30 RCL 02
31 RCL 01
32 -
33 2
34 ÷
35 RCL 00
36 ×
37 RTN
38 LBL 15
39 RCL IND 19
40 FS? 00
41 +/-
42 RCL 02
43 RCL 01
44 -
45 ×
46 RCL 02
47 +
48 RCL 01
49 +
50 2
51 ÷
52 XEQ "FX"
53 DSE 19
54 RCL IND 19
55 DSE 19
56 ×
57 STO+ 00
58 RTN
59 LBL "A-"
60 LBL B
61 XEQ 00
62 FIX 05
63 "a?"
64 PROMPT
65 STO 01
66 0
67 STO 00
68 CF 00
69 LBL 03
70 18
71 STO 19
72 XEQ 16
73 XEQ 16
74 XEQ 16
75 XEQ 16
76 XEQ 16
77 XEQ 16
78 XEQ 16
79 XEQ 16
80 FS? 00
81 GTO 04
82 SF 00
83 GTO 03
84 LBL 04
85 RCL 00
86 2
87 ×
88 RTN
89 LBL 16
90 RCL IND 19
91 FS? 00
92 CHS
93 1
94 +
95 2
96 X<>Y
97 ÷
98 RCL 01
99 +
100 1
101 -
102 XEQ "FX"
103 RCL IND 19
104 FS? 00
105 CHS
106 1
107 +
108 X^2
109 DSE 19
110 RCL IND 19
111 DSE 19
112 X<>Y
113 ÷
114 ×
115 STO+ 00
116 RTN
117 LBL 00
118 FS? 01
119 RTN
120 2.715245941E-2
121 STO 03
122 9.89400935E-1
123 STO 04
124 6.225352394E-2
125 STO 05
126 9.445750231E-1
127 STO 06
128 9.515851168E-2
129 STO 07
130 8.656312024E-1
131 STO 08
132 1.246289713E-1
133 STO 09
134 7.554044084E-1
135 STO 10
136 1.495959888E-1
137 STO 11
138 6.178762444E-1
139 STO 12
140 1.691565194E-1
141 STO 13
142 4.580167777E-1
143 STO 14
144 1.82603415E-1
145 STO 15
146 2.816035508E-1
147 STO 16
148 1.894506105E-1
149 STO 17
150 9.501250984E-2
151 STO 18
152 SF 01
153 RTN
154 LBL "FX"
155 LBL E
156 1/X
157 RTN

Example 1
=========

To calculate the integral of 1/x from 1 to 2 (which is equal to ln(2)):

1. In program mode insert the command 1/x after LBL E and make sure it is followed by RTN.
2. In run mode (user mode on) clear flag 1 using [f][CF][0][1]. Skip this step if you are not running the program the first time.
3. Press the [A] key.
4. The program prompts you to enter the value of "a". Enter 1 and press the [R/S] key.
5. The program prompts you to enter the value of "b". Enter 2 and press the [R/S] key.
6. The program displays 0.69315 (FIX 9 displays 0.693147181) as the value of the integral.

Example 2
========

To calculate the integral of exp(-x)*x^0.8 from 0 to inifinity (which is equal to gamma(1.8)):

1. In program mode insert the commands CHS, EXP, LASTX, CHS, 0.8, Y^X and, * after LBL E and make sure it is followed by RTN.
2. In run mode (user mode on) clear flag 1 using [f][CF][0][1]. Skip this step if you are not running the program the first time.
3. Press the [A] key.
4. The program prompts you to enter the value of "a". Enter 0 and press the [R/S] key.
5. The program displays 0.93138 (FIX 9 displays 0.931378447) as the value of the integral.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
16 Point Gaussian Quadrature for the HP-41C/CV/CX (updated) - Namir - 11-09-2023 09:23 PM



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