Hi,

I seemed to have lost my reply to this post so; below is what I have tried to program by adapting an example we had in the notes. There is an issue in writing the formula (amongst other things). I did have it prompting me to input the initial guess and number of iterations however have seemed to have lost that and now get an error in the formula line. I have checked my indices and think they are now correct as pointed out above.

The question is

a) Without doing a sketch, show that the equation f(x) = x − e^(−x^2)

has at least one solution on the interval [0, 2].

[Hint: Use a theorem discussed in lectures, or see Section 1.8 of Calculus (8th ed) by Stewart.

Ensure the conditions of the theorem are satisfied.]

(b) Use Newton’s method to find this zero accurate to 3 decimal places. You should include a

sketch of the function, Newton’s iteration formula, and the list of iterates. [Use a computer

if possible, e.g. a spreadsheet or MatLab.]

and the script I am trying to enter currently looks like this:

%Use Newtton's Method to find a non-zero number such that f(x) =

%x-e(^(x^2);

clear;

x_=input ('Enter initial guess x_0):');

num = input ('Enter number of iterations');

x = -0.1:0.001:2;

k=0;

fprintf('x = %f\n', x);

for k=num

x = x-(x-e^(-x^2)/(1+2*x.e^(-x^2);

disp ('k num x')

end

Any help would be appreciated.

Cheers

Beetle