Post Reply 
Finding Min/Max of a function for HP-67
03-10-2014, 05:48 PM
Post: #1
Finding Min/Max of a function for HP-67
finding the minimmum/maximum of a function using Newton's method.

Memory Map

R0 = tolerance
R1 = x
R2 = h
R3 = f(x), f''(x)
R4 = f(x+h)
R5 = f(x-h)

HP-67 Implementation

Code:
1 LBL A
2 STO 1     # store guess for optimum x  
3 X<>Y
4 STO 0     # store tolerance
5 LBL 0
6 RCL 1     # display current guess for optimum x
7 PAUSE
8 ABS
9 1
10 +
11 EEX
12 CHS
13 3
14 *
15 STO 2     # calculate and store h
16 RCL 1
17 GSB E
18 STO 3     # Calculate and store f(x)
19 RCL 1
20 RCL 2
21 +
22 GSB E
23 STO 4     # Calculate and store f(x+h)
24 RCL 1
25 RCL 2
26 -
27 GSB E
28 STO 5     # Calculate and store f(x-h)
29 RCL 4
30 +
31 RCL 3
32 2
33 *
34 -
35 RCL 2
36 X^2
37 /
38 STO 3     # calculate and store f''(x)
39 RCL 4
40 RCL 5
41 -
42 RCL 2
43 /
44 2         
45 /         # calculate f'(x)
46 RCL 3
47 /         # calculate diff
48 STO- 1    # x = x - diff
49 ABS
50 RCL 0
51 X<=Y?
52 GTO 0
53 RCL 1
54 RTN
55 LBL E
56 EXP
57 LASTX
58 X^2
59 3
60 *
61 -
62 RTN

Usage

LBL E has the code for the function whose minimum or maximum you seek.

1) Enter the tolerance and press [ENTER].
2) Enter a guess for the minimum/maximum and pres [A].
3) The program pauses showing intermediate values for the refined min/max values. When the program has reached the tolerance level it displays the value of the X for the min/max value.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Finding Min/Max of a function for HP-67 - Namir - 03-10-2014 05:48 PM



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