[HP 35s] Finding the minimum of a FCN - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: General Forum (/forum-4.html) +--- Thread: [HP 35s] Finding the minimum of a FCN (/thread-4290.html) [HP 35s] Finding the minimum of a FCN - Marcio - 07-03-2015 11:15 PM 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 RE: [HP 35s] Finding the minimum of a FCN - Pascal - 07-04-2015 08:21 AM 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 RE: [HP 35s] Finding the minimum of a FCN - Marcio - 07-04-2015 11:54 AM (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. RE: [HP 35s] Finding the minimum of a FCN - Dieter - 07-04-2015 04:40 PM (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 RE: [HP 35s] Finding the minimum of a FCN - Marcio - 07-04-2015 04:48 PM Bookmarked! It's really nice to have this option to solve and integrate programs on the 35s. Thanks Marcio