필터 지우기
필터 지우기

Approximations of solution using Newton's Method

조회 수: 1 (최근 30일)
evi
evi 2013년 11월 14일
댓글: evi 2013년 11월 15일
I have to implement the Newton method in Matlab to plot the function,its tangent and the first 4 approximations. I would like to show how the algorithm works, that mean that the tangent of one approximation finds the next approximation. The code I have written is the following:
plot(x,f(x))
hold on
for j=1:4
x_1=x_0-f(x_0)/F(x_0);
tangent=@(x) F(x_0)*(x-x_0)+f(x_0);
line=@(x) (f(x_0)/(x_0-x_1))*(x-x_1);
plot(x_0,f(x_0),x,line(x),x_1,0)
x_0=x_1;
end
where F is the derivative of f and the function f is f(x)=e^x-x/2. Could you tell me if this is right? The plot I got is at the attachment.. Also at the plot the range of y is [-2000,3000], how could I make it smaller so that I can see the approximations better?
  댓글 수: 6
Walter Roberson
Walter Roberson 2013년 11월 15일
Set ylim after you plot.
evi
evi 2013년 11월 15일
Great now it shows only a specific range of y!! Could you also tell me how the x-axis & y-axis could be shown in the plot??

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by