Post Reply 
(34S) Function minimization (golden section)
03-24-2017, 07:40 AM
Post: #2
RE: (34s) Function minimization (golden section)
(03-24-2017 02:56 AM)nsg Wrote:  This program finds minimum of a given function on a given interval with given precision.

May I add a hint that can be useful for this and other programs?

The sequence starting at line 71 seems to use flag 0 as an error flag that is only cleared if X<R05 or X<R08. If the flag is still set an error message is generated.

You can do "or"-tests like these in a much more simple and elegant way by combining two consecutive test commands. Have the the inverse of the first condition followed by the second one. So if you want to test if X<R05 or X<R08, simply write

Code:
0071 X≥? 05
0072 X<? 08
0073 BACK 40
0074 ERR 20

Or if you want to test if flag 1 or flag 2 is set, that's just two lines:

Code:
0001 FC? 01
0002 FS? 02
0003 ...

I assume this trick is as old as programmable calculators (> 40 years), but it still works today. ;-)

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (34s) Function minimization (golden section) - Dieter - 03-24-2017 07:40 AM



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