首页 > > 详细

讲解data留学生编程、辅导Python,Java,c++程序语言 辅导Web开发|讲解留学生Processing

项目预算:   开发周期:  发布时间:   要求地区:
A5 - Jupyter Notebook 2020/11/20, 12:07 PM
Before you turn this problem in, make sure everything runs as expected. First,
restart the kernel (in the menubar, select Kernel Restart) and then run all cells (in
the menubar, select Cell Run All). Or, alternatively, Restart & Run All.
Make sure you fill in any place that says YOUR CODE HERE or "YOUR ANSWER
HERE".
You can always add additional cells to the notebook to experiment, to test your
answers, or to provide additional support for your answers.
You should not need to install new packages to complete an assignment. If you use
any packages not available via the MATH405 Project.toml then your
assignment will likely not be graded correctly.
Submissions are only accepted via CANVAS!
Late submissions: within 24h I will reduce the grade to 70%. I will not accept
submissions after 24h. Please manage your time well and complete the assignments
with plenty of buffer time.
By entering your name below you confirm that you have completed this assignment
on your own and without (direct) help from your colleagues. Plagiarism / copying will
be checked by comparing assignments and by by testing understanding in
workshops and the oral exam (final). I reserve the option to downgrade an
assignment at any point.


In [ ]:
MATH 405/607
Numerical Methods for Differential
Equations
Assignment 5: Spectral Methods
Notes
Due date: Wed Dec 2, 2020, 1200 noon
This assignment will be worth 10% of the overall grade.
Answer only question 3 or question 4 but not both.
1 NAME = ""
A5 - Jupyter Notebook 2020/11/20, 12:07 PM
http://localhost:8888/notebooks/Desktop/math405_2020W/A5/A5.ipynb#q3 Page 2 of 7
Question 1 : Approximation vs Regularity
Question 2 : Trapezoidal Rule
Question 3 : Fourth order bvp
Question 4 : Advection Problem
Question 5 : Eigenvalue Problem
In [ ]: include("math405.jl")
# Here are the codes you need to construct and evaluate trigonometric interpolants
using FFTW
"construct a real-space grid - use FFT convention"
xgrid(N) = range(0.0, stop=2π-2π/2N, length=2N)
"construct the reciprocal space grid assumed by `fft` - carefully use FFT convention"
kgrid(N) = [0:N; -N+1:-1]
"compute the fourier coefficients of I_N"
fouriercoeffs(f::Function, N) = fouriercoeffs(f.(xgrid(N)))
fouriercoeffs(F::Vector) = fft(F) / length(F)
"evaluate a trigonometric polynomial"
eval_trig(F::Function, N, Z) = eval_trig(fouriercoeffs(F, N), Z)
eval_trig(F̂::Vector, Z) = real(sum( f̂k * exp.((im * k)*Z) for (f̂k
# To evaluate the trigonometric interpolant of a function F
# at several points Zs::AbstractVector use the following function
eval_trig(F::Function, N::Integer, Zs::AbstractVector) = eval_trig
1
A5 - Jupyter Notebook 2020/11/20, 12:07 PM
http://localhost:8888/notebooks/Desktop/math405_2020W/A5/A5.ipynb#q3 Page 3 of 7
Question 1: Approximation vs Regularity [15]
Let be continuous and -periodic and let denote its degree
trigonometric interpolant.
In class we have proven (mostly) that if is analytic and bounded, , in the strip
then
Similarly, the Jackson Theorem(s) state that, if is -periodic, times continuously
differentiable and the th derivative is -Hölder continuous, , i.e.
then
The prototype of an -Hölder continuous function is . A piecewise smooth function
with finitely many singularities is also -H"{o}lder continuous in the sense defined
above.
The factor is a technicality, very difficult to see numerically (if it is indeed sharp),
and should simply be ignored for this Question.
Following the Model solution, produce figures demonstrating the algebraic or exponential
convergence rates stated in the above estimates. As in the model solution in addition to
plotting the convergence, also print your predicted rate of convergence.
A5 - Jupyter Notebook 2020/11/20, 12:07 PM
http://localhost:8888/notebooks/Desktop/math405_2020W/A5/A5.ipynb#q3 Page 4 of 7
Question 2: Periodic Trapezoidal Rule [3 + 5 + 3 + 4]
Let be continuous and -periodic, then we can represent it in terms of its
Fourier series,
We are interested in approximating the integral
by the trapezoidal rule
In the following tasks you may interchange limits freely without rigorous justification, in
particular summation and integration.
(a) Prove that .
(b) Prove that
and use this to deduce that
REMARK: means that for some integer .
(c) Deduce from (a, b) that
(d) Suppose that (i) ; or (ii) . In each case deduce from (c)
a sharp (up to constants) estimate on the error .
HINT: If is non-negative and monotonically decreasing then
otherwise.
YOUR ANSWER HERE
Solve either Q.3 (theoretical) or Q.4 (computational).
A5 - Jupyter Notebook 2020/11/20, 12:07 PM
http://localhost:8888/notebooks/Desktop/math405_2020W/A5/A5.ipynb#q3 Page 5 of 7
Question 3: Fourth-order BVP [5 + 5 + 5]
Consider the periodic boundary value problem for the differential equation
(a) Prove that, if solves the above DE, then
where .
*[HINT: multiply the DE by , then integrate over , integrate by parts, then use the
Cauchy-Schwarz inequality on the right-hand side.]*
(b) Derive the canonical Fourier spectral method for this problem, providing both the realspace
formulation as well as the fully discrete formulation in reciprocal space. Briefly
specify all your terms.
(c) Suppose that is analytic and bounded in the strip , prove that
where denotes the solution to the Fourier-spectral method from (a) and the exact
solution of the DE.
YOUR ANSWER HERE
BONUS [NO CREDIT]
Q3(d) Employing the method of manufactured solutions, confirm your prediction Question
3a-c.
In [ ]:
Question 4: transport equation [5+5+5]
Consider the advector equation with periodic boundary conditions and non-constant
advection speed, which is analytic and -periodic:
(a) Discretise in space using a Fourier spectral method and write down the resulting ODE
for the Fourier coefficients, in terms of the following operators:
: discrete Fourier transform
: inverse discrete Fourier transform
: trigonometric interpolant
1 # YOUR CODE HERE
A5 - Jupyter Notebook 2020/11/20, 12:07 PM
http://localhost:8888/notebooks/Desktop/math405_2020W/A5/A5.ipynb#q3 Page 6 of 7
YOUR ANSWER HERE
(b) Implement a practical scheme (you will need to discretise in time by implementing a
suitable time-stepping yourself or using a suitable solver from OrdinaryDiffEq.jl )
and compute the solution at time to within five digits absolute real-space
accuracy in the max-norm. Store it as
Uhat1 = ...
where Uhat1::Vector should be a vector containing the Fourier coefficients of the
solution at time .
HINT: If you are unsure about the correctness of your implementation, you could try
first. In this case you can compare against an exact solution.
푡 = 1.0
푡 = 1.0
푐 = const
In [ ]:
In [ ]:
In [ ]:
(c) Demonstrate the convergence rate of your scheme by comparing a sequence of
numerical solutions against another numerical solution computed to very high accuracy.
cfun = x -> 3 * (1 + sin(x)^2)
u0fun = x -> 1 + sin(x)
# YOUR CODE HERE
;
# To check correctness of your code you can check the convergence rate in
# part (c) but an addtional consistency check is the following:
# You can modify this code block to create an animatino of your solution
# You can check whether the solution is sensible?
# Note that larger values of c lead to faster advection, while smaller values
# lead to slower advection.
# xp = range(0, 2*pi, length=200)
# c_xp = cfun.(xp) / 3
# @gif for t = 0.0:0.01:1.0
# Û = ... # get the solution at time t
# u = eval_trig.(Ref(Û), xp)
# plot(xp, c_xp, lw=2, c=2, label = "c/3")
# plot!(xp, u, lw=2, c=1, label = "t = $t", size = (400, 250), ylims = (0.0, 4.0))
A5 - Jupyter Notebook 2020/11/20, 12:07 PM
http://localhost:8888/notebooks/Desktop/math405_2020W/A5/A5.ipynb#q3 Page 7 of 7
In [ ]:
Question 5: Eigenvalue problem [10]
Find all eigenpairs , , smooth and -periodic, satisfying
and such that . Plot them in a scatter plot and store them (unordered) in a
variable
Lambda = ...
where Lambda::AbstractVector containing precisely the required set of
eigenvalues.
HINT: The code required to complete this problem is only about 5 lines.
If you wish you may add any additional comments or notes in this box:
In [ ]:
In [ ]:
# YOUR CODE HERE
# YOUR CODE HERE

软件开发、广告设计客服
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 9951568
© 2021 www.rj363.com
软件定制开发网!