Math 373-Midterm Project

代做Math 373-Fall作业、代写Matlab语言作业、代写sup-norm作业、代做Matlab课程设计作业
Math 373-Fall 2018 Midterm Project 4 Due: 6:15pm, 12 December
Work through each of the following problems. Be sure to follow the midterm project
guidelines found in the resources section on sakai. Turn in all coding portions digitally and
the all analysis portions in class. Both portions must be turned in by the due date and
time.
Throughout this project the norm of a vector in R
n should be taken to mean the sup-norm i.e. if x ∈ R
n,
then
||x|| := ||x||∞ = max {|x1| , . . . , |xn|} .
1. (10 points) Further adventures in root finding
For this project you will need to expand your findroot function from previous projects to higher
dimensional vector fields. For a function, f : R
n → R
n with n ≥ 1, it should be capable of the following
calls (in addition to the functionality from previous projects).
findroot(f, Df, x0) ← x attempts to return x ∈ R
n satisfying  = ||Af(x)|| < 10?10 by Newton
iteration with initial guess, x0 ∈ R
n using no more than N = 100 iterations where A ≈ Df ?1
(x)
is nonsingular. Otherwise, it should return x = NaN. Here f and Df are function handles for a
function and its derivative. If an approximate root is found, it should do 5 additional iterations
before returning.
findroot(f, x0) ← x attempts to return a root as in the 1st case without supplying the derivative.
Instead, this should be approximated by finite differences.
Use findroot to answer the following questions. You may also use the builtin functions polyval, and
conv if needed.
(a) Write a script called check findroot which uses findroot to find the maximum value of the
function f(x) = x1 + 2x2 + 3x3 defined on R
3
, subject to the constraints:
x1 x2 + x3 = 1 x
2
1 + x
2
2 = 1.
For this example, you should specify the derivative in your calls to findroot. Then, find this
maximum value by hand to verify that findroot is implemented correctly.
(b) Write a MATLAB function called taylor step which uses the Taylor method to integrate the
following scalar differential equation
x˙ = x
2 2x x(0) = x0 ∈ R.
for a single time step. It should be capable of the following call
taylor step(x0, N) ← (a, tf ) returns the first N terms of the Taylor transform of x as a vector of
the form
a = (a0, a1, . . . , aN?1).
and tf is an estimate on the radius of convergence of this power series.
The value of t should be estimated using one of the following two methods
Let tf = max 
t > 0 : |aN1|t
N1 < μ(1)
where μ(1) denotes the machine unit.
Or tf is the slope of the line obtained by fitting {log(a0), log(a1), . . . , log(aN1)} by linear least
squares regression.
The integrator should use the recursive formula obtained from the differential equation to compute
the first 5 Taylor coefficients. These should be used as an initial guess for Newton’s method which
is used to compute the rest of the coefficients.
(c) Write a MATLAB script called taylor ivp which calls taylor step for multiple time steps to solve
the initial value problem on the interval t ∈ [0, 3] for x0 ∈ {1.99, 2.001} using N ∈ {5, 10, 20, 30, 50, 200}.
Plot each of these solution in the same axis. What impact does increasing N have on the solution?
(d) Write a MATLAB script called taylor ivp v2 which calls taylor step for multiple time steps to
solve the initial value problem on the interval t ∈ [0, 3] for x0 = 2.01 using N = 200. Analyze the
output of this script and the differential equation to explain mathematically what is happening.
2. (8 points) Numerical methods for Fourier series
For this exercise you will need to write MATLAB functions called FFT and iFFT which are capable of
the following calls.
FFT(x) ← X returns the discrete Fourier transform of the vector x ∈ C
n.
iFFT(X) ← x returns the inverse discrete Fourier transform of the vector X ∈ C
n.
Both algorithms should have computational complexity on order of O(n log n). Use these functions to
complete the following exercises.
(a) Fix a constant 0 < L < ∞ and define the set
B =

1
2L
, cos(πx
L
),sin(πx
L
), cos(2πx
L
),sin(2πx
L
), . . . , cos( jπx
L
),sin( jπx
L
), . . . 
.
Show that B is an orthonormal set of vectors in C
(0)([L, L]) with respect to the inner product
hf, gi =
1
L
Z L
?L
f(x)g(x) dx.
(b) Use the result in part (a) to compute the Fourier series for the function f(x) = x defined on [?π, π]
by hand. Then write a script called check FFT which uses this computation to verify that your FFT
and iFFT implementations are correct.
(c) Consider the following differential equation (known as the Vanderpol oscillator)
x˙ =

x2
μ(1 x
2
1
)x2 x1

x ∈ R
2
where μ > 0 is a parameter. This equation is well studied and it is known that for any choice of
μ, it has an unstable equilibrium at the origin and a globally attracting periodic orbit. For μ = 1,
this vector field is builtin to MATLAB in a function called vdp1.
Write a script called vdp periodic orbit which uses the functions FFT, iFFT, and findroot to
compute a trigonometric polynomial which approximates the Fourier series for this periodic orbit
when μ = 1. You may use any of the numerical methods implemented in previous projects to help
estimate the orbit, its period, or any other investigations which you may find helpful.
3. (7 points) A square root solver with verified error bounds
Let c be a positive real number and √
c denotes the unique positive root of the function f(x) = x
2 c.
(a) Show that the Newton map for f is Lipschitz with constant k < 1
2
on the domain D = (pc
2
, ∞).
Hint: Use the mean value inequality.
(b) Write a MATLAB function called verified sqrt which is capable of the following call
verified sqrt(c) ← (x, d) where x ≈

c is obtained by calling findroot and d is a number of
digits guaranteed to be correct via the contraction mapping theorem i.e. x satisfies the error
bound ≤ 10d
Write a script called check sqrt which uses this function to compute √
2 and compare it to the
MATLAB builtin value up to d decimal places. Then answer the following questions.
Assuming the MATLAB builtin is accurate to working precision, explain why these values must
match to at least d decimal places.
Is it possible for them to match to more than d decimal places? Explain why or why not.
(c) Write a MATLAB script called compare error which uses calls to verified sqrt to approximate

x for each x ∈

10k
: k = 1, 5, 10, 15, . . . , 50
. Compare the number of digits of accuracy
output by your function with the actual values output for √
x.http://www.6daixie.com/contents/12/2315.html
For which values of x does your function output an approximation and a “guaranteed” number of
decimal digits which is actually false. Explain why this does not violate the contraction mapping
theorem.

因为专业,所以值得信赖。如有需要,请加QQ99515681 或邮箱:[email protected] 

微信:codinghelp

猜你喜欢

转载自www.cnblogs.com/letsgoC/p/10078962.html