Question: This is a maximizing problem that i have for my introductory C++ course. For this problem im NOT allowed to use arrays, functions, or calculus



This is a maximizing problem that i have for my introductory C++ course. For this problem im NOT allowed to use arrays, functions, or calculus because we have not gone over how that works in this class yet. Im essentially just supposed to use
In this problem, you will be a maximizing cubic polynomial on a user spec- ified interval [a,b]. You will assume that your polynomial has the form f(x) = czx + c2x2 +212 + Co. You will do this by asking the user for the left end point a, the right end point b, the coefficients, C3, C2,C1,Co, and also a "grid-size" h. Then you should use the following method. 1. Initially set largest = f(a) 2. Check if f(a+h) > f(a). If so, update largest to be f(a+h). 3. Next check f(a + 2h).... 4. Keep going an appropriate number of times 5. After your loop is done, compare f(b) to the largest so far and if needed update largest. (Depending on how you did the previous steps, this part might be unncessary, but sometimes the right end-point doesn't get checked because of weird rounding errors.) At the start of the problem, your program should ask the user for the left end point a and the right end point b. Then it should ask the user to input the coefficients C3, C2, C and co. Then it should ask the user for a grid size. Example output Left end point: 3 Right end point: 5 Coefficients: 1 2 3 4 Grid size: .01 The largest value of 1*x^3+2*x^2+3x+4 on [3,5] is 194. If the user enters the input shown above, the output of your code should match the example output exactly. You are allowed to assume that the user enters a b that is greater than a but your code should work even if a and b are not whole numbers. So for example, the user is allowed to input a = 3.0,b= 3.1, h = .001. Likewise, Co, C1, C2, and c3 are allowed to have decimal parts. If you have taken calculus, you should NOT use knowledge from calculus to solve this problem. Pay attention to the order we put the Hint: It may be helpful to first solve a similar, but easier problem. The easier problem is to assume that f(x) = sin(x) + cos(x), set a = 0, b = 100, h = 1. In otherwords, you are finding the largest value of f(n) where n is a whole number between 0 and 100. The answer is approximately the square root of two. This is 100% optional and should not be turned in. 93 Note: In the example output, things like "Left end point: or "Right end point: are output by the program. Things like 3 and 5 are entered by the user. In the above example, the user enters the 3, the 5, the 1 2 3 4 and the .01. When you enter this, your code should match the example exactly
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
