










Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!











Dr. Muhammad Hanif DuradDepartment of Computer and Information SciencesPakistan Institute Engineering and Applied [email protected]
docsity.com
Dr. Hanif Durad^
2
Lecture Outline (1/2) Plotting a function in MATLAB Function Evaluation in MATLAB(Anonymous) Interval Bisection Method Fixed-Point Problems Newton’s Method Secant Method Multidimensional Newton’s Method Multidimensional Broyden’s Method
docsity.com
Function Evaluation inMATLAB (Anonymous)>> f=@(x) x^2-4sin(x)f = @(x)x^2-4sin(x)>> f(1)ans =-2.3659>> format long>> feval(f,1)ans =-2.
Dr. Hanif Durad^
(^4) docsity.com
Dr. Hanif Durad^
Fixed-Point Problems (2/2)
Dr. Hanif Durad^
7
xm =demoFixedPoint(0,-2,2,10 )left hand boundary is
-2.0000 and g`(x) =
right hand boundary is
2.0000 and g`(x) =
k^ x^ g(x)
abs(x(k+1)-x(k)) 0 0.^
0.300000^ 3.00000e- 1 0.^
0.313500^ 1.35000e- 2 0.^
0.315406^ 1.90574e- 3 0.^
0.315688^ 2.82662e- 4 0.^
0.315731^ 4.22170e- 5 0.^
0.315737^ 6.31181e- 6 0.^
0.315738^ 9.43816e- 7 0.^
0.315738^ 1.41134e- 8 0.^
0.315738^ 2.11045e- 9 0.^
0.315738^ 3.15588e- xm =0.
( )^5
10 3 f^ x^
x^ x ^
docsity.com
Dr. Hanif Durad^
Newton’s Method -2nd Prg. (2/2)>> [p1,err,k,y]=newton(f,df,3,10^-6,10^-6,20)p1 =1.933753788557627err =2.177441944430925e-004k = (^4) y =1.360549464202165e-
Dr. Hanif Durad^
10
docsity.com
Secant Method (1/2)>> f=@(x) x^2 -4sin(x)f = @(x)x^2-4sin(x)>> format long
Dr. Hanif Durad^
11
docsity.com
Multidimensional Newton’sMethod (1/3)>> x0 =[1;1]; tol=1e-5; maxiter =10;>> [x,F,iter] = newtonsys(@Ffun,@Jfun ,x0 ,tol ,maxiter )The method converged at iteration 8 with residual 2.235421e-011x =0.4761-0.8794F =2.2354e-011iter = 8
Dr. Hanif Durad^
13
docsity.com
Multidimensional Newton’sMethod (2/3)>> [x,F,iter] = newtonsys(@Ffun,@Jfun ,x0 ,tol ,1 )Fails to converge within maximum number of iterations.The iterate returned has relative residual 4.722222e+000x =-0.83331.4167F =4.7222iter = 1
Dr. Hanif Durad^
(^14) docsity.com
Multidimensional Broyden’sMethod>> broyden2(3,[1;2],[2;1])ans =1.89320.0989>> broyden2(5,[1;2],[2;1])ans =2.4093-0.
Dr. Hanif Durad^
16
MATLAB Built-in Functions-fzero (1/2)>> f=@(x) x^2-4sin(x)f = @(x)x^2-4sin(x)>> x=fzero(f,[1 3])x =1.
Dr. Hanif Durad^
(^17) docsity.com