[HP 35s] Finding the minimum of a FCN
07-03-2015, 11:15 PM (This post was last modified: 07-04-2015 01:29 PM by Marcio.)
Post: #1
 Marcio Senior Member Posts: 438 Joined: Feb 2015
[HP 35s] Finding the minimum of a FCN
Hello all,

I've been trying to get the 35s to solve a program defined by a label but it just won't find any roots.

Would anybody be kind enough as to take a look at my codes?

This one calculates the derivative of a function using $$f'(x)=\frac{f(x+h)-f(x-h)}{2h}$$
Code:
LBL D
RCL D*
2E-3
STO H
-
XEQ F001
RCL D
RCL+ H
XEQ F001
REGZ
-
RCL H
2
*
/
RTN

This is the function being evaluated:
Code:
LBL F
STO X
X^2-5*X+6
RTN

Basically, what I am trying to do is to find a local minimum by solving f'(x)=0, which in this case is 5/2.

FN = D

3

SOLVE D.

Very much appreciated.

Marcio
07-04-2015, 08:21 AM
Post: #2
 Pascal Junior Member Posts: 7 Joined: Apr 2015
RE: [HP 35s] Finding the minimum of a FCN
Hi,

The Solver implicitly stores its guesses into variable D. So if you write "STO D", the guess will be overwritten by the current value of REGX. Try "RCL D" instead of "STO D".

Best regards,

Pascal
07-04-2015, 11:54 AM (This post was last modified: 07-04-2015 01:28 PM by Marcio.)
Post: #3
 Marcio Senior Member Posts: 438 Joined: Feb 2015
RE: [HP 35s] Finding the minimum of a FCN
(07-04-2015 08:21 AM)Pascal Wrote:  Hi,

The Solver implicitly stores its guesses into variable D. So if you write "STO D", the guess will be overwritten by the current value of REGX. Try "RCL D" instead of "STO D".

Best regards,

Pascal

That was precisely the problem. Fixed now! Thank you.
07-04-2015, 04:40 PM (This post was last modified: 07-04-2015 05:03 PM by Dieter.)
Post: #4
 Dieter Senior Member Posts: 2,398 Joined: Dec 2013
RE: [HP 35s] Finding the minimum of a FCN
(07-03-2015 11:15 PM)Marcio Wrote:  Basically, what I am trying to do is to find a local minimum by solving f'(x)=0, which in this case is 5/2.

You might be interested in another method of finding local extrema with a completely different approach. Take a look at this thread in the old forum, especially message #12.

In your function be sure to replace x² with x*x since on the 35s the x² function does not work in the complex domain. Or use Horner's method:

Code:
LBL Y
RCL X
5
-
RCLx X
6
+
RTN

Set a suitable h:
1 E-6 [STO] H

Find the minimum between x=1 and 5:

1 [ENTER] 5 XEQ E [ENTER]
SOLVING
E= 2,5000

BTW, the program will also find the two roots on both sides of the minimum:

0 [ENTER] 2,5 XEQ Z [ENTER]
SOLVING
Z= 2,0000

2,5 [ENTER] 5 XEQ Z [ENTER]
SOLVING
Z= 3,0000

Dieter
07-04-2015, 04:48 PM
Post: #5
 Marcio Senior Member Posts: 438 Joined: Feb 2015
RE: [HP 35s] Finding the minimum of a FCN
Bookmarked!

It's really nice to have this option to solve and integrate programs on the 35s.

Thanks

Marcio
 « Next Oldest | Next Newest »

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