首页 > > 详细

MATH 3018代写、Python编程辅导

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 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
P (t; y步) = 汐 (y步)
2
+ 汕(t2 ? 1) (y步)3 ,
your task is to find the solution y(t) that maximizes the profit by minimizing
S =
÷ 1
0
(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 =
÷ 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 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) 汐 = 74 , 汕 = 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 (汐 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 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.

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!