2 - California State Polytechnic University, Pomona
EGR 511 NUMERICAL METHODS _______________________
LAST NAME, FIRST
Problem set #2
1. Use Newton’s method with x(0) = 0 to compute x(2) for each of the following nonlinear systems:
a. 4[pic]- 20x1 + [pic][pic]+ 8 = 0 b. sin(4(x1x2) – 2x2 – x1 = 0
[pic]x1[pic] + 2x1 – 5x2 + 8 = 0 [pic]([pic]- e) + 4e[pic] - 2ex1 = 0
>> s2p1a
x = 0.4958936 1.9834235
>> s2p1b
x = -0.5131616 -0.0183762
2. Use the method of Steepest Descent with x(0) = 0 to approximate the solutions for
4[pic]- 20x1 + [pic][pic]+ 8 = 0
[pic]x1[pic] + 2x1 – 5x2 + 8 = 0
Iterating until g = [pic]< 0.05
% Steepest Descent Method
% Set 2, problem 2
%
f1='4*x(1)^2-20*x(1)+.25*x(2)^2+8';
f2='.5*x(1)*x(2)^2+2*x(1)-5*x(2)+8';
% Initial guess
%
x=[0 0];
f=[eval(f1) eval(f2)];
g1=f*f';
for i=1:50
Jt=[8*x(1)-20 .5*x(2)
.5*x(2)^2+2 x(1)*x(2)-5];
% Gradient vector
%
delg=2*Jt*f';
zo=sqrt(delg'*delg);
% Unit vector in the steepest descent
%
z=delg/zo;
xs=x;a3=1;x=x-a3*z';
f=[eval(f1) eval(f2)];
g3=f*f';
while g3>g1
a3=a3/2;
x=xs-a3*z';
f=[eval(f1) eval(f2)];
g3=f*f';
end
a2=a3/2;x=xs-a2*z';
fsave3=f;
f=[eval(f1) eval(f2)];
g2=f*f';h1=(g2-g1)/a2;h2=(g3-g2)/(a3-a2);h3=(h2-h1)/a3;
% Choose a0 so that g will be minimum in z direction
%
a0=.5*(a2-h1/h3);
x=xs-a0*z';
f=[eval(f1) eval(f2)];
g0=f*f';fsave0=f;
if g0 s2p2b
x = -0.357926 0.000000 , g = 0.139390
x = -0.361009 0.057884 , g = 0.003316
3. Find the directional derivative of f(x, y) = 2x2 + y2 at x = 2 and y = 2 in the direction of h = 3i + 2j.
Ans: 8.875
4. Find the gradient vector and Hessian matrix for each of the following functions:
a) f(x, y) = 2xy2 + 3exy b) f(x, y, z) = x2 + y2 + 2z2
c) f(x, y) = ln(x2 + 2xy + 3y2)
Ans:
(a) (f = [pic], H = [pic]
(b) (f = [pic], H = [pic]
(c) (f = [pic][pic], H = [pic][pic]
5. a) Find the first two iterations of the Gauss-Seidel method for the following linear system using x(0) = 0;
i) 3x1 - x2 + x3 = 1, ii) 10x1 - x2 = 9,
3x1 + 6x2 + 2x3 = 0, - x1 + 10x2 - 2x3 = 7,
3x1 + 3x2 + 7x3 = 4. - 2x2 + 10x3 = 6.
b) Repeat Exercise (a) using the SOR method with relaxation factor = 1.1.
Gauss Seidel 0.1111111 -0.2222222 0.6190476
Gauss Seidel 0.9790000 0.9495000 0.7899000
SOR method 0.0541008 -0.2115435 0.6477159
SOR method 0.9876790 0.9784934 0.7899328
6. Solve the system
x2 + y2 + z2 = 9,
xyz = 1,
x + y - z2 = 0
by Newton's method to obtain the solution near (2.5, 0.2, 1.6).
% Newton Method
%
f1='x(1)^2+x(2)^2+x(3)^2-9';
f2='x(1)*x(2)*x(3)-1';
f3='x(1)+x(2)-x(3)^2';
% Initial guess
%
x=[2.5 0.2 1.6];
for i=1:20
f=[eval(f1) eval(f2) eval(f3)];
Ja=[2*x(1) 2*x(2) 2*x(3)
x(2)*x(3) x(1)*x(3) x(1)*x(2)
1 1 -2*x(3)];
%
dx=Ja\f';
x=x-dx';
if max(abs(dx)) ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- california state university system
- california state university second bachelor s
- california state university tuition
- california state university jobs
- california state university system schools
- california state university system wiki
- california state university application log in
- california state university campuses list
- california state university log in
- california state university application deadline
- california state university tuition fee
- california state university fees