联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> Python编程Python编程

日期:2023-01-01 12:50


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 assignment 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 files

needed to produce the output specified in the tasks below is required.

1

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

your task is to find the solution y(t) that maximizes the profit by minimizing

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 =

Z b

a

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 Euler-Lagrange equation,

= 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

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

2

2 Task

1. Write an algorithm to solve the boundary value problem given by the EulerLagrange 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 algorithm.

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

(a) α = 5 = β;

(b) α =

7

4

, β = 5.

For the second case, give evidence that your solution is converging in an appropriate 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 (α 6= β) case, the price curve y(t) as a function of t;

3. For the second case (α 6= β), at least one figure 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;

3

• correct implementation and use of your chosen algorithm: this will be shown

through the tests above and the figures 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 comments 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.

4


相关文章

版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp