Question: CS319 - Scientific Computing Lab 2: An optimization problem (and functions in C++) You will develop an algorithm for solving an optimis- tion problem. This

CS319 - Scientific Computing Lab 2: An optimization problem (and functions in C++) You will develop an algorithm for solving an optimis- tion problem. This will give a context in which to study some of the intricacies of functions in C++, including global and local variables; pass-by-reference functions as arguments to other functions 2. Take c to be the midpoint of a and b. 3. Take I to be the midpoint of the left interval, a,c. andr to be the milpoint of the right interval, 4, 5]. 4. Compare () Fle) and f(r), and if f(c) is largest set a l, and buri . if f() is largest keep a, and set b = c. . if f(n) is largest keep 5, and set a = c. 5. Repeat the algorithm until b-a is less than some prescribed tolerance. The first step is illustrated in Figure 2. In this case, since fle) > >f(r), for the wond step we will set a=! and b=r. 1 Optimization For the purposes of this lab, "optimisation" means find- ing the point at which a given function achieves its max- imum value. Typical optimization problems you might be familiar with include at what speed does my car have the best fuel effi- ciency? . what is the maximum height a ball will reach if thrown with particular initial velocity? The problems can be posed in a mathematical frame- work. We'll take a given function, J. which we call the objective function. We find the value of m that max- imises f in a given interval, [4, 5]. That is, find m such that a
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
