关键词 > MATH3018/MATH6141

Coursework 2: MATH 3018/MATH 6141 - Numerical methods

发布时间:2023-01-05

Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Coursework 2:  MATH 3018/MATH 6141 - Numerical methods

Due: Monday 9th January 2023

In this coursework you will implement given numerical algorithms.  The assessment will be based on

•  sensible choice and explanation of the algorithms – 4 marks

• correct implementation of chosen algorithms 5 marks

documentation of code – 3 marks

 appropriate convergence tests – 3 marks.

The deadline is noon, Monday 9th January 2023 (week 12). For late submissions there is a penalty of 10% of the total marks for the assignment per day after the assign- ment is due, for up to 5 days. No marks will be obtained for submissions that are later than 5 days.

Your work must be submitted electronically via Blackboard. Only the Python les needed to produce the output specified in the tasks below is required.

1    Political pricing

The government has told a monopoly company that it must reduce prices by 10% over the next year or receive crippling fines.  The company wants to do this as slowly as possible to maximize profits, but realizes that its customers will put off buying its goods, despite the monopoly, if they think they can get a better deal by waiting. The company assumes that it therefore wants to set its prices (in dimensionless units) so that y(0) =  1, y(1) = 0.9 (a 10% decrease over one year), and so that their profit (which is modelled as the charge y minus a penalty due to customers waiting for the future) is as large as possible.

Assuming the penalty is

P (t; y˙) = α (y˙)2 + β(t2 _ 1) (y˙)3 ,

S = 0 1 (P _ y) dt                                          ( 1)

subject to the boundary conditions y(0) = 1, y(1) = 0.9.

This problem is in the form of a variational problem for which the action

S = ab L (t, y(t), y˙(t)) dt.                                     (2)

is to be minimized subject to the boundary conditions

y(a) = A,       y(b) = B .

Here L (the Lagrangian) is some function of t, y and its derivative.  A function y(t) that minimizes the action S satisfies the Etl如g.Leigeni如 ater)on,

 _  / = 0,       y(a) = A,    y(b) = B .                    (3)

On application of the chain rule to the Euler-Lagrange equation it is possible to show that it can be rewritten in the form

 _ / L + y˙L + y¨L = 0,       y(a) = A,    y(b) = B .    (4)

2    Task

1. Write an algorithm to solve the boundary value problem given by the Euler- Lagrange equation (4). If your algorithm is not completely general you should state the restrictions required in order for the algorithm to work. Your algorithm should take as input the function L and the boundary values y(a), y(b) but must compute all derivatives in equation (4) numerically. Justify your choice of algo- rithm.

2. Maximize the profit for the company for the two models

(a)  α = 5 = β;

(b)  α =  , β = 5.

For the second case, give evidence that your solution is converging in an appro- priate sense. Also state if the mathematical problem has been posed correctly to solve the original problem.

2.1    Summary and assessment criteria

You should submit the code electronically as noted above.

2.1.1    Python

As Python allows for many function definitions in one file, you may submit as many Python files as necessary to solve the problem. However, one file should clearly be the master script that when run (eg from the console inside spyder), produces all the plots required.

2.1.2    Plots

The code you submit will, if it answers all the tasks, produce at least 3 (three) figures:

1. For the first (α = β) case, the price curve y(t) as a function of t;

2. For the second (α  β) case, the price curve y(t) as a function of t;

3. For the second case (α  β), at least one gure showing evidence that your algorithm is converging to some solution as you vary its accuracy.

Plots should be displayed to the screen.

2.1.3    Assessment criteria

The primary assessment criteria will be the

• choice and justification of the algorithm: this must be explained and documented in comments within the code, preferrably at the start of the main file;

• correct implementation and use of your chosen algorithm: this will be shown through the tests above and the gures produced.

The secondary assessment criteria will be the clarity and robustness of your code. Your functions and scripts must be well documented with appropriate internal com- ments describing inputs, outputs, what the function does and how it does it. The code should also be well structured to make it easy to follow.  Input must be checked and sensible error messages given when problems are encountered. Unit tests of individual functions may also be used to show the correctness of the code.  The clarity of the output (such as plots or results printed to the command window) is also important.

Code efficiency is not important unless the algorithm takes an exceptional amount of time to run. As an indication, the model implementation runs all tasks in a maximum of 2 minutes.