程序代写代做 algorithm Homework 2

Homework 2
Numerical Analisys 1 – Elena Queirolo
You are allowed to use or modify any code uploaded to Canvas. Remem- ber to refer to the original author if you do.
You must hand in a computer typed report of up to 3 pages (excluding figures), showing the matematical background used, the coding choices you made and testing the results of your code. It must be a pdf.
You also must hand in (at least) two functions and two scripts, (at least) one for each exercise.
1 Exercise
Consider a function f : R2 → R2. Applying the Newton’s method to this function with different initial points will result in Newton converging to different zeros of f. Write a Matlab-function that produces a figure showing which initial points converge to the same zero.
The Matlab-function should take four inputs: f, [x0, x1] and [y0, y1], indicating the coordinates to consider, and N, the refinement of the axes,
The Matlab-function should have no output but create a plot indicating which areas in the rectangle [x0, x1] × [y0, y1] converged to the same zero under the Newton’s algorithm. The results should be based on N2 points in the rectangle [x0, x1] × [y0, y1].
• Store the intial points. You should consider the combination bewteen N points in the interval [x0, x1] and N points in the interval [y0, y1].
• Run the Newton’s method on the initial points and store the approx- imation of the zero it converged to.
• Use these results to create a plot:
– determine the number of different zeros,
– determine which approximations of the zeros are the same,
– color boxes that converged to the same zero with the same color, – you can use the function fill or patch to color the plot.
1

2 Exercise Modified Newton
Write a Matlab-function which determines the zero of a function using the modified Newton’s method.
The Matlab-function takes three inputs: a function, its derivative, and a starting point. The outputs are an approximation of zero, an estimate of the order of the zero, and a vector of all the iterations. The Matlab-function takes two optional inputs: a measure for the precision and the maximum number of iterations.
• You can start out from the function newton.m on Canvas.
• Estimate the order of the zero from the sequence of values in the
iterations.
• Can you, based on an example, say something about the order of convergence?
• Test your Matlab-function on different functions.
2