联系方式

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

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

日期:2023-03-05 10:39

MATH4064 - COURSEWORK 1 — 20% —

Coursework 1 — Hand-in deadline: 3 pm Wednesday 08/Mar/2023

Your neat, clearly-legible solutions should be submitted electronically as a pdf file via the MATH4064 Moodle

page by the deadline indicated there. Your report should include discussions and comments on all your

results with reference to the underlying mathematical theory. Upload 2 files on Moodle: a PDF of your

coursework submission and a ZIP containing all the computer codes you used to do your coursework. Since

this work is assessed, your submissionmust be entirely your ownwork (see the University’s policy onAcademic

Misconduct). Submissions up to five working days late will be subject to a penalty of 5% of the maximum mark

per working day.

1. Problem set [2-Cubic B-spline Interpolation] [50 marks]

a Consider a function ∶ [, ] → ? has been sampled at + 1 ≥ 4 equally spaced points = 0 <

1 < … < = . Write a subroutine/function that will take as input the function values {()}


=0

and return the coefficients {}

+1

=?1 of the natural

2-Cubic B-spline 3 () that interpolates .

b Write a function that will take as input the coefficients {}

+1

=?1, and the nodes {}


=0 and output the

values of the spline 3 evaluated at 20+1 uniformly spaced points {}

20

=0 on the interval [, ]. Your

code should also output the evaluation points {}.

c Test your code for () = cos(6) on the interval [0, 1] for = 8, 16, 32, 64, 128. For each :

i Provide a plot of the spline 3 ().

ii Compute an approximation to the error ‖ ? 3 ‖∞,[0,1].

Plot log10(‖ ?


3 ‖∞,[0,1]) against log10(). Comment on these results.

d Now consider ∶ [, ] → ? is a periodic function with period ? and that has been sampled at

≥ 3 equally spaced points = 0 < 1 < … < ?1 = ? ?, where ? = ( ? )/.

i By exploiting periodicity, write down thematrix problem to find the coefficients { ?}

?1

=0 of the

2-Cubic

B-spline ?3 () that interpolates .

ii By suitably modifying the code from part a , write a function/subroutine that will take as input the

function values {()}1

=0 and return the coefficients { ?}

iii By suitably modifying the code from part b , write a function/subroutine that will take as input the

coefficients { ?}

=0 and output the values of the spline evaluated at 20+1

uniformly spaced points {}

20

=0 on the interval [, ].

e Test the code from part d for () = cos(6) on the interval [0, 1] for = 8, 16, 32, 64, 128. Again,

for each :

MATH4064 Turn Over

2 MATH4064

i Provide a plot of the spline ?3 ().

ii Compute an approximation to the error ‖ ? ?3 ‖∞,[0,1].

On the same set of axes as in part c , plot log10(‖ ? ?


3 ‖∞,[0,1]) against log10() and comment on

the results.

f Cubic B-splines can be used to plot smooth curves embedded in 2D, defined at only a small number

of points. Suppose that we have the set of points {(, )}


=0, then we can paramaterise a curve that

passes through these points with the parameter 0 ≤ ≤ 1. Let 0 = 0 < 1 < … < = 1 be equally

spaced points, then the spline ((), ()), should pass through the points ((), ()) = (, ) for

= 0,… , .

Consider the files spline_natural1.dat, spline_natural2.dat and spline_periodic.dat. These

files each define a set of points in 2D. Load these files and apply the code from part a and b to

spline_natural1.dat and spline_natural2.dat and the code from part d to spline_periodic.dat.

Hence, generate and plot the 3 2D cubic splines on the same set of axes.

2. Problem set [Root Finding] [50 marks]

a Write a function/subroutine that will implement Newton’s method for solving F(x) = 0, where F ∶ Your code should take as input a routine that implements F, a routine that implements the

Jacobian matrix JF, and an initial guess x

(0). The code should stop when

‖x() ? x(?1)‖2 ≤ 10

?12,

or when 100 iterations have been performed.

b Use the code from part a to find the 4 solutions to the system of equations:

2 + 2 + 2 = 1,

4(2 + 2) ? 2 = 0,

3 ? = 0.

For each solution, record the initial guess used and the number of Newton iterations required.

c Consider the problem of plotting a curve in 2D defined implicitly by the equation

(, ) = 0,

where (?, ?) is some nonlinear function.

One way of plotting an approximation is to choose various values of and use a root-finding algorithm

to find the corresponding , however, this is not robust, as some values of may have no corresponding

, while others may have more than one .

An alternative approach is to ‘follow’ the path of the curve, by starting at some initial (?1, ?1) that

lies on the curve, predicting a new point ( ?, ?) by moving in a tangential direction to the curve and

then correcting using Newton’s method to a point (, ) that does lie on the curve.

Suppose that we would like to move along the curve with a roughly constant arclength of . Letting

x = (, ), then at each step, the method amounts to solving the following problem

(, ) = 0, (1), (2)

where t1 is the unit tangent to the curve at x?1. This method is called pseudo-arclength continuation.

MATH4064

3 MATH4064


(0, 0)

(1, 1)

( 1, 1)

Write a code that will solve problem (1)-(2) using Newton’s method with an initial guess x1+t1.

Hence, draw an approximation to the ellipse

2 +

2

22

= 1,

using = 0.05.

[Hint: You should make sure that each new t points roughly in the same direction as t?1.]

MATH4064 End


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

python代写
微信客服:codinghelp