Task 2 (3 points) The following equation, expl_ (x-1)21+ expl_ (x-291+ expl_ (x-
ID: 2261990 • Letter: T
Question
Task 2 (3 points) The following equation, expl_ (x-1)21+ expl_ (x-291+ expl_ (x-4%]-09-0, has four solutions within the interval of 0 sxs5. Suppose that Newton's method is used to seek the solutions, different choices of the initial guess would potentially lead to different solutions. Consider the 51 initial guesses, xo-(0, 0.1, 0.2, 0.3, , 49, 5). Use Newton's method to perform 100 iterations for each of those initial guesses. List the solutions (as obtained at the end of 100 iterations) and their corresponding initial guesses in the following format: Xp=0 solution= xo= 0.1 solution x0=0.2 solution If for a given xo the process of iteration diverges such that Matlab returns Inf or NaN at the end of 100 iterations, please list the "Inf" or "NaN" as the solution to indicate that Newton's method fails to converge. Briefly discuss the result. Focus on the following questions: Is there a general predictive relation between the given initial guess and the final solution? What happens when the initial guess is close to wheref(x) -0? (Here, "/(x)-0" describes the original equation and f'(x) is the derivative of j(x).) What happens when the initial guess is very close to a solution?Explanation / Answer
clc;
clear all;
format long
f=@(x)exp(-(x-1).^2)+exp(-(x-2).^2)+exp(-(x-4).^2)-0.9;%function
f1=@(x)-2*x.*(exp(-(x-1).^2)+exp(-(x-2).^2)+exp(-(x-4).^2)); %derivative of function
y=0:0.1:5;
for i=1:length(y)
x0=y(i);%initial guess
n=1;
erorr=0.1;
del=1e-8;
x(1)=x0;
m=2;
while (abs(erorr>del)& (n<=100))
y1=x0-(f(x0)/f1(x0));% Newton method
erorr(n+1)=abs((y1-x0)); %erorr
% if abs(erorr<1e-3)
% break
%end
n=1+n;
x0=y1; % update xold
x(n+1)=x0;
if (n>100)
fprintf('x0=%0.3f solution = NaN ',x(1))
end
end
fprintf('x0=%0.3f solution =%f ',x(1),x0)
end
x0=0.000 solution =NaN
x0=0.100 solution =NaN
x0=0.200 solution =NaN
x0=0.300 solution = NaN
x0=0.300 solution =2.623384
x0=0.400 solution =NaN
x0=0.500 solution =NaN
x0=0.600 solution = NaN
x0=0.600 solution =2.623383
x0=0.700 solution = NaN
x0=0.700 solution =2.623383
x0=0.800 solution = NaN
x0=0.800 solution =2.623383
x0=0.900 solution = NaN
x0=0.900 solution =2.623383
x0=1.000 solution = NaN
x0=1.000 solution =2.623383
x0=1.100 solution = NaN
x0=1.100 solution =2.623383
x0=1.200 solution = NaN
x0=1.200 solution =2.623383
x0=1.300 solution = NaN
x0=1.300 solution =2.623383
x0=1.400 solution = NaN
x0=1.400 solution =2.623383
x0=1.500 solution = NaN
x0=1.500 solution =2.623384
x0=1.600 solution = NaN
x0=1.600 solution =2.623384
x0=1.700 solution = NaN
x0=1.700 solution =2.623384
x0=1.800 solution = NaN
x0=1.800 solution =2.623384
x0=1.900 solution = NaN
x0=1.900 solution =2.623384
x0=2.000 solution = NaN
x0=2.000 solution =2.623384
x0=2.100 solution = NaN
x0=2.100 solution =2.623384
x0=2.200 solution = NaN
x0=2.200 solution =2.623384
x0=2.300 solution = NaN
x0=2.300 solution =2.623384
x0=2.400 solution = NaN
x0=2.400 solution =2.623384
x0=2.500 solution =2.623384
x0=2.600 solution =2.623384
x0=2.700 solution =2.623384
x0=2.800 solution = NaN
x0=2.800 solution =2.623384
x0=2.900 solution = NaN
x0=2.900 solution =2.623384
x0=3.000 solution = NaN
x0=3.000 solution =2.623384
x0=3.100 solution = NaN
x0=3.100 solution =2.623384
x0=3.200 solution = NaN
x0=3.200 solution =2.623384
x0=3.300 solution = NaN
x0=3.300 solution =2.623385
x0=3.400 solution = NaN
x0=3.400 solution =2.623386
x0=3.500 solution = NaN
x0=3.500 solution =2.623440
x0=3.600 solution = NaN
x0=3.600 solution =4.328213
x0=3.700 solution = NaN
x0=3.700 solution =4.330858
x0=3.800 solution = NaN
x0=3.800 solution =4.331442
x0=3.900 solution = NaN
x0=3.900 solution =4.331686
x0=4.000 solution = NaN
x0=4.000 solution =4.331817
x0=4.100 solution = NaN
x0=4.100 solution =4.331896
x0=4.200 solution = NaN
x0=4.200 solution =4.331948
x0=4.300 solution = NaN
x0=4.300 solution =4.331984
x0=4.400 solution = NaN
x0=4.400 solution =4.332010
x0=4.500 solution = NaN
x0=4.500 solution =4.332028
x0=4.600 solution = NaN
x0=4.600 solution =4.332042
x0=4.700 solution = NaN
x0=4.700 solution =4.332052
x0=4.800 solution = NaN
x0=4.800 solution =4.332060
x0=4.900 solution = NaN
x0=4.900 solution =4.332065
x0=5.000 solution = NaN
x0=5.000 solution =4.332069
>>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.