You are absolutely right - RND is the round function, but that's not what the code says. D011 is not RND, but RDN. ;-)
Finally, here's a complete solution for zeros and extremes of a function. This time I tried the 35s emulator. Compared to the previous version the handling is much nicer and more comfortable.
Y001 LBL Y
Y002 RCL X
Y003 ...
Y004 < your function here >
Y005 ...
Ynnn RTN
F001 LBL F
F002 STO X
F003 XEQ Y001
F004 STO F
F005 VIEW F
D001 LBL D
D002 STO X
D003 XEQ M001
D004 STO D
D005 VIEW D
M001 LBL M
M002 RCL H
M003 x=0?
M004 1E-6
M005 STO H
M006 i
M007 *
M008 RCL+ X
M009 x<> X
M010 STO Y
M011 XEQ Y001
M012 x<> Y
M013 STO X
M014 RCL Y
M015 ENTER
M016 ARG
M017 COS
M018 RCL Y
M019 ABS
M020 *
M021 -
M022 ABS
M023 LASTx
M024 ARG
M025 SGN
M026 *
M027 RCL/ H
M028 RTN
Z001 LBL Z
Z002 -25 ; code for function Y
Z003 -26 ; code for variable Z
Z004 GTO E004
E001 LBL E
E002 -13 ; code for function M
E003 -5 ; code for variable E
E004 STO J
E005 Roll down
E006 STO I
E007 Roll down
E008 STO X
E009 x<>y
E010 FN=(I)
E011 SOLVE X
E012 RCL X
E013 STO(J)
E014 VIEW(J)
E015 RTN
And here's how to use it:
0. Enter program
1. Provide function y = f(x) at LBL Y. Assume x is stored in variable X.
If extremes have to be found, be sure that all operators and functions are defined in the complex domain.
GTO Y [ENTER]
[PRGM]
RCL X
...
RTN
2. Evaluate f(x)
<x> XEQ F [ENTER] => F= f(x)
3. Evalute the derivative f'(x)
Optional: provide a value for h
<h> STO H
If h = 0 the program assumes h = 1E-6
<x> XEQ D [ENTER] => D= f'(x)
4. Find zeroes of f(x)
Provide two guesses x1 and x2
<x1> [ENTER] <x2> XEQ Z [ENTER] => Z= <x_root>
5. Find potential extremes of f(x)
Provide two guesses x1 and x2
<x1> [ENTER] <x2> XEQ E [ENTER] => E= <x_extr>
Check f(x) near x_extr to see whether it's a minimum, a maximum or a saddle point
<x> XEQ F [ENTER] => F= f(x)
Here's an example:
y = x^3 - x^2 - x + 1/2
= ((x - 1)*x - 1)*x + 0,5
Y001 LBL Y
Y002 RCL X
Y003 1
Y004 -
Y005 RCL* X
Y006 1
Y007 -
Y008 RCL* X
Y009 0,5
Y010 +
Y011 RTN
Assume h = 1E-6
1E-6 STO H
Evaluate f(x)
-3 XEQ F [ENTER] => F= -32,5000
-2 XEQ F [ENTER] => F= -9,5000
-1 XEQ F [ENTER] => F= -0,5000
0 XEQ F [ENTER] => F= 0,5000
1 XEQ F [ENTER] => F= -0,5000
2 XEQ F [ENTER] => F= 2,5000
3 XEQ F [ENTER] => F= 15,5000
Find the three real roots in x = -1...0, x = 0...1 and x = 1...2
-1 [ENTER] 0 XEQ Z [ENTER] => SOLVING... Z= -0,8546
0 [ENTER] 1 XEQ Z [ENTER] => SOLVING... Z= 0,4030
1 [ENTER] 2 XEQ Z [ENTER] => SOLVING... Z= 1,4516
Find the two extremes between the roots
-0,9 [ENTER] 0,4 XEQ E [ENTER] => SOLVING... E= -0,3333
Check the derivative
XEQ D [ENTER] => D= -2,5560 E-12
-0,3 XEQ F [ENTER] => F= 0,6830
-0,3333 XEQ F [ENTER] => F= 0,6852
-0,4 XEQ F [ENTER] => F= 0,6760
So there is a maximum at x = -0,3333 and f(x) = 0,6852
Find the second extreme:
0,4 [ENTER] 1,5 XEQ E [ENTER] => SOLVING... E= 1,0000
Check the derivative
XEQ D [ENTER] => D= 0,0000
1 XEQ F [ENTER] => F= -0,5000
So there must be a minimum at x = 1 and f(x) = -0,5
And finally here's the function used in the May 2013 thread:
Y001 LBL Y
Y002 RCL X
Y003 -20
Y004 /
Y005 e^x
Y006 1
Y007 -
Y008 25
Y009 *
Y010 RCL+ X
Y011 -200
Y012 *
Y013 RTN
0 [ENTER] 12 XEQ E [ENTER] => SOLVING... E= 4,4629
XEQ F [ENTER] => F= 107,4258
4,4 XEQ F [ENTER] => F= 107,4060
4,5 XEQ F [ENTER] => F= 107,4189
=> maximum at x = 4,4629 and f(x) = 107,4258
Again, this program is a quick and dirty version that may have errors and other flaws. Use at your own risk, improve as you like and don't forget to share your improvements here. ;-)
Dieter
Edited: 15 Sept 2013, 10:07 a.m.