代写 R C++ math compiler This question paper

This question paper
consists of 4 printed pages,
each of which is identified
by the Code Number MATH5360M01
UNIVERSITY OF LEEDS
Semester 1 2019/2020
Assessed Coursework 1 (15% of total module mark) MATH5360M Optimisation Methods for Finance
Submission deadline: 2pm on Thursday 14th of November 2019
Question 1 (20% marks)
Consider the following optimisation problem:
max4x1 +3×2 +4×3 +3×4 x
subjectto4x1−2×2+3×3+2×4 ≤110 6×1 +3×2 −2×3 −x4 ≥20
−x1 +3×2 +4×3 +3×4 ≤96 3×1 +4×2 −5×3 +2×4 ≥84 x1,x2,x3,x4 ≥0.
(a) Use AMPL to solve this optimisation problem, providing the optimal solution and the optimal value of the objective function.
(b) Use AMPL to compute the reduced cost for any of the variables if they exist. Compute the optimal solution and the optimal value if the objective function is changed to
(i) 4×1 +3×2 +10×3 +3×4 (ii) 4×1 + 3×2 + 14×3 + 3×4.
Comment on the results obtained, focussing your discussion on the reduced cost.
(c) Use AMPL to compute the shadow price, if it exists, for each of the inequality constraints. Explain why it does not exist for some constraints. Compute the optimal value if the right-hand side of the first inequality constraint is decreased from 110 to 104. Explain your result using your shadow price found.
Hint: Read Lecture 4 for more information on reduced cost and shadow price.
MATH5360M01
Page 1

Question 2 (80% marks)
Consider the function f (x) = x2 − 2cos(x + 2) − 30.
(a) Write a C++ programme that computes f(x) where x ranges over a sequence of n equidistant points in a given interval [a,b] with a,b ∈ R and displays a table of x against f(x). Your program should allow the user to input values for a, b and n.
The function f should be treated as a C++ function with the following definition: double function f(double x);
Include the output of your program with the interval [0, 10] and 10 data points in the report.
(b) It is given that the function f(x) is monotonically decreasing in the interval [−11,−1] and is monotonically increasing in the interval [0, 10]. Write a C++ programme that estimates at least one of the solutions to the equation of f (x) = 0 over a given interval [a, b] where a, b ∈ [−11, −1] or a, b ∈ [0, 10] if such a solution does exist, by a bisection method. Your programme should allow the user to input values for a and b.
The bisection method should be treated as a C++ function with the following definition:
double bisection method(double a, double b, int n);
Include the output of your programme with the interval [−11,−1] and [0,10] with n = 20
simulations in the report and give your answer to 3 decimal places.
Hint: The bisection method relies on the Intermediate Value Theorem. If you are not familiar with the Intermediate Value Theorem or if you are not certain how to carry out the bisection method, please use the available resources on the Internet or in the library to help.
(c) Write a C++ programme that estimates at least one of the solutions to the equation of f (x) = 0 with a given x0 if such a solution does exist, by rewriting the equation f(x) = 0 as an iterative formula
xn+1 = 􏰀30 + 2cos(xn + 2).
Your programme should allow the user to input values for x0 and the number of iterations n.
The iterative formula should be treated as a C++ function with the following definition:
double iterative formula(double x0 , int n);
Include the output of your programme with x0 = 2 with n = 10 simulations and give your answer to 3 decimal places.
MATH5360M01
Page 2

(d) It is given that the function f(x) > 0 in the interval [6,∞). Write a C++ programme that estimates the area under the curve f(x) where x ranges over a sequence of n equidistant points in a given interval [a, b] where a, b ∈ [6, ∞) using the trapezium rule . Your program should allow the user to input values for a, b and n.
The trapezium rule should be treated as a C++ function with the following definition:
double trapezium rule(double a, double b, int n);
Include the output of your programme with the interval [6, 11] with n = 10 equidistant points
in the report.
Hint: If you do not know how does the trapezium rule work, please use the available resources on the Internet or in the library to help.
MATH5360M01
Page 3

Directions for submission
Electronic submission only: You are required to submit two files electronically to the Assessment Area within the module resource on Minerva no later than 2pm on the deadline date. Failure to meet the initial deadline stated will result in a reduction of marks. The electronic submission should include:
• The report should contain the answers to the questions and any explanation you deem necessary. All C++ and AMPL code should be included as appendices. State the compiler you use to run your C++ code. Use the link “Coursework 1 Report” to upload the report.
• All C++ and AMPL code should also be submitted separately. Gather all your C++ files as they are stored by Visual C++ or other compilers (.cpp or .cc; NOT pdf, doc, ps, etc.) and your AMPL code files (.dat, .mod or .run), and store them in a zip file or some other common archive format (like rar or tar). Use the link “ Coursework 1 Code” to upload the archive file.
Please ensure that you leave sufficient time to complete the online submission process, as upload time can vary. Accessing the submission link before the deadline does not constitute completion of submission. You must click the “confirm” button for both files before 2pm for your assignment to be classified as submitted on time, if not you will need to submit to the Late Area and your assignment will be marked as late. It is your responsibility to ensure you upload the correct file to the Minerva, and that it has uploaded successfully.
It is important that any file submitted follows the conventions stated below:
• File name – The name of the file that you upload must be your student ID only.
• Assignment title – During the submission process the system will ask you to enter the title of your submission. This should also be your student ID only.
• Front cover – The first page of your report should always be the Assessed Coursework Coversheet (individual), which is available to download from the following location: https: //students.business.leeds.ac.uk/forms-guidance-and-coversheets/
• Student name – You should not include your name anywhere on your assignment (not in the report and not in the code).
Marking: The following aspects of your code are important in the marking: correctness (it does what it is supposed to do), robustness (poor input data is handled gracefully), quality of code (the code is easy to read and understand) and efficiency (it is quick to run and has no unnecessary parts).
END
Page 4
MATH5360M01