Section 14: Numerical Integration 197

Before calling the subroutine you provide to evaluate f(x), the f algorithm – just like the _ algorithm – places the value of x in the X-, Y-, Z-, and T-registers. Because every stack register contains the x-value, your subroutine can calculate with this number without having to recall it from a storage register. The subroutines in the next two examples take advantage of this feature. (A polynomial evaluation technique that assumes the stack is filled with the value of x is discussed on page 79.)

Note: Since the calculator puts the value of x into all stack registers, any numbers previously there will be replaced by x. Therefore, if the stack contains intermediate results that you'll need after you calculate an integral, store those numbers in storage registers and recall them later.

Occasionally you may want to use the subroutine that you wrote for the f operation to merely evaluate the function at some value of x. If you do so with a function that gets x from the stack more than once, be sure to fill the stack manually with the value of x, by pressing vvv, before you execute the subroutine.

Example: The Bessel function of the first kind of order 1 can be expressed as

 

 

π

π

 

 

 

0

 

 

J1(x) =

1

 

cos (θ - x sin θ) .

Find

 

 

 

 

 

 

 

 

 

 

 

 

 

π

 

 

 

 

π 0

 

 

J1(1) =

1

cos (θ - sin θ) .

 

 

Key in the

following subroutine

that evaluates the function

f(θ) = cos (θ - sin θ).

 

 

Keystrokes

Display

 

 

¥

000-

 

 

 

 

Program mode.

´ b 1

001-42,21, 1

Begin subroutine with a label.

Page 197
Image 197
HP 15c Scientific manual Begin subroutine with a label