Professional Documents
Culture Documents
1 D Optimisation Soln
1 D Optimisation Soln
The user can be expected to provide a function which calculates the one dimensional function, and also a starting point, and any other parameters specified by the creator of the program.
Solution: As a minimum is bracketed by three points a, b, c, if: 1) b is between a and c 2) f(b) < f(a) and f(b) < f(c) In this situation, provided the function is continuous, there is guaranteed to be a local minimum in between a and c. As it is a simple case of finding the minimum, we will first define a delta with which the query will increase in order to find the a and c in between which the minima lies. We will then define two more points using delta and initial point and find the function values at each point. If the function is continuously going up or continuously going down or have a maxima between x3 and x1 the loop will be executed to find next x1,x2,x3 . When a minima is found the programme will break and the result displayed.\ Code (Scilab): Function file:
s2=x3; end printf ('The bracket lies between %f and %f',s1,s2) The program will provide us with the first minima that it encounters Shortcomings: I was not able to come up with a coding system to break the operation to avoid infinite loop in case no minima lies ahead of the starting point. Even using counters it will display the final values as the brackets instead of displaying an error message. It is assumed that only one point will be provided.
-Submitted by