Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CSC336H1

Homework 4

2022

1.  (50 points) Consider the Gaussian function

1       t2

f (t) = σ ^2π e 2σ2  .

Let F denote the Fourier transform, so that

o

F[f](w) =         f (x)e2πiw dx.

o

(1)

(2)

It is known that, when f is given by the formula (1),

F[f](w) = e2π2 σ 2 w2 .

(3)

Let σ = 0.01. Note that, since f (x) decays so quickly for large |x|, the integral (1) can be approximated as an integral over [_1/2, 1/2] instead of (_o, o). Let the sequence x0 , x1 , . . . , x2N  be defined by

xj  = ,    j = 0, 1, . . . , 2N.                      (4)

Compute F[f] from this sequence by  (if you are using MATLAB) first apply- ing  the  fftshift  function  and  then  applying  the  fft.    In  NumPy,  use  the numpy .fft .fftshift and numpy .fft functions.

(a) What do the fftshift and numpy .fft .fftshift functions do? Why are they

necessary?

(b)  Set N  =  200 and plot the output sequence X0, X1 , . . . , X2N ,  before and

after applying fftshift to it (plot both the real and imaginary parts on the same plot).  Why do the plots look this way?  How is the output sequence X0, X1 , . . . , X2N  related to F[f](w)?

(c) Use formula (3) to check your numerical solution. What is the smallest number N such that F[f] is computed to machine precision?

(d) What happens to f and F[f] when you change σ to 0.005?  What about 0.0005? How big must N be in each case to give an accurate calculation of F[f]?

(e)  Apply fft to the sequence x0 , x1 , . . . , x2N , without rst applying fftshift.

Plot the resulting sequence sequence X0, X1 , . . . , X2N . Why does the plot look this way? How is this sequence related to F[f](w)?

2.  (50 points) Consider the function

f (x) = J3(x),                                                   (5)

where Jν(x) is the Bessel function of order ν, implemented in the besselj function in MATLAB and the scipy .special .jv function in SciPy. It is known that

f\ (x) =  (J2(x) _ J4(x)).                                         (6)

(a)  Plot f (x) on the interval [0, 30].  Sample f (x) at 1000 equispaced points xi , i = 1, 2, . . . , 1000, on this interval, and plot a marker at each xi  for which f (xi)f (xi1) < 0. Hint: Use the linspace and find functions in MATLAB, or the numpy .linspace and numpy .nonzero functions NumPy.

(b)  Use the bisection method to nd an approximation xn to the root of f (x) in the interval [5, 7], where xn  denotes the approximation after n steps. Fill in the following table:

f (xn)  

0

5

.

10

30

50

(c)  Use Newton’s method to nd an approximation xn to a root of f (x), starting with the initial guess x0  = 6, where xn  denotes the approximation after n steps. Fill in the following table:

 f (xn)  

(8)

Why do you see these results?

(d)  Repeat part (c) using the secant method, starting with initial guesses x0 = 5, x1 = 6. Why do see these results?

(e)  Suppose that m is a positive integer, and let g(x) be the function defined by g(x) = (f (x))m . Apply Newton’s method to nd an approximation xn  to a root of g(x), starting with the initial guess x0 = 6. Let x denote the accurate approximation to the root obtained from part (c). Fill in the following table:

 |x50 _ x | 

(9)

4

Why do you see these results?