(34S) Function minimization (golden section)
|
03-24-2017, 02:56 AM
(This post was last modified: 06-15-2017 01:20 PM by Gene.)
Post: #1
|
|||
|
|||
(34S) Function minimization (golden section)
This program finds minimum of a given function on a given interval with given precision.
The function must be unimodal (first strictly decrease then strictly increase) on that interval. If function is not unimodal, program signals "Root not found". The program uses golden section method to narrow down on the minimum point. Input: LBL 99 -- user function eps [ENTER] a [ENTER] b XEQ 'UMΦ' (eps is required precision, a and b -- ends of the interval) Result: r01, r04 -- new interval (size less than eps) containing minimum Used registers: r00..r09 flag 00 Example: function at lbl 99 is x^2-5x 1e-6 [ENTER] 0 [ENTER] 5 XEQ 'UMΦ' Output: R01~R04~2.5 Code: 0001 LBL'UMΦ' |
|||
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 Or if you want to test if flag 1 or flag 2 is set, that's just two lines: Code: 0001 FC? 01 I assume this trick is as old as programmable calculators (> 40 years), but it still works today. ;-) Dieter |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)