You are on page 1of 5

TECHNOLOGICAL INSTITUTE OF THE PHILIPPINES

938 Aurora Blvd., Cubao, Quezon City

CE 007 (Numerical Solutions for CE Problems)

Machine Exercise 3

Submitted by:
Group 5
Pagador, Charlene Ivy
San Gabriel, Bambi
Tiu, Drexie Dee Mae
Villaflor, James
Villa, Frelyn

ACADEMIC INTEGRITY PLEDGE

I swear on my honor that I did not use any inappropriate aid, nor give such to others, in accomplishing this
coursework. I understand that cheating and/or plagiarism is a major offense, as stated in TIP Memorandum
No. P-04, s. 2017-2018, and that I will be sanctioned appropriately once I have committed such acts.
The group was charged with finding and solving the unknowns known as x and y given the following system
of equations for exercise number three (3). An initial estimation of on the first issue is (x, y) = (1.5, 3.5)
was given a tolerance of 10-5. After comprehending the issue and the system. The students used the
Newton Raphson technique to solve the equations x2 + xy -10 = 0 and y + 3xy2-57 = 0, and the first step
was to plot the ellipse and parabola based on the supplied. The The equation would then be transformed
into a Jacobian matrix of [ 2𝑥1 + 𝑥2 𝑥1

3𝑥2 2 6𝑥2𝑥1 + 1 ].

Script/Code:

close all;

t = 0:0.01:2*pi; x = 2*cos(t);

y = sin(t);

plot(x,y,'k','LineWidth',1.2); hold on;

x = -0.5:0.01:2.5; y = x.^2 - 2*x + 0.5;

plot(x,y,'k','LineWidth',1.2); grid on;

F = @(x) [x(1)^2 + x(1)*x(2) - 10; ...

x(2) + 3*x(1)*x(2)^2 - 57];

J = @(x) [2*x(1)+1, 1; 3, 1+6*x(2)];

x = [inf inf; 1.5 3.5]; k = 2;

fprintf('Iter 0: %.6f %.6f\n',x(end,:));

while norm(x(k,:) - x(k-1,:),2) > 1e-5;

k = k + 1;

x(k,:) = x(k-1,:) - (inv(J(x(k-1,:)))*F(x(k-1,:)))';

fprintf('Iter %d: %.6f %.6f\n',...

k-2,x(k,:));

end

plot(x(2:end,1),x(2:end,2),'b-o','MarkerSize',3); hold off;

fprintf('The root is: %.6f %.6f\n',x(end,:));


Answer:

Iter 301: 2.000000 3.000005

The root is: 2.000000 3.000005

Script/Code:

a)

F = @(x) [x(1)^2+x(2)^2-2022; 5*x(1)^2-10*x(1)*x(2)-2022];

J = @(x) [2*x(1), 2*x(2); 10*x(1)-10*x(2), -10*x(1)];

x = [inf inf; -1 1]; k = 2;

fprintf('Iter 0: %.3f %.3f\n',x(end,:));

while norm(x(k,:) - x(k-1,:),2) > 1e-5

k = k + 1;

x(k,:) = x(k-1,:) - (inv(J(x(k-1,:)))*F(x(k-1,:)))';

fprintf('Iter %d: %.3f %.3f\n',k-2,x(k,:));

end

plot(x(2:end,1),x(2:end,2),'b-o','MarkerSize',3); hold off;

fprintf('The root is: %.3f %.3f\n',x(end,:));

Answer:

Iter 11: -4.310 44.760

The root is: -4.310 44.760


Graph:

b)

F = @(x) [1+x(1)+2*x(2)-exp(x(1)-x(2)); 2+x(1)-x(2)-exp(x(1)+2*x(2))];

J = @(x) [1-exp(x(1)-x(2)), 2+exp(x(1)-x(2)); 1-exp(x(1)+2*x(2)), -1-2*exp(x(1)+2*x(2))];

x = [inf inf; -1 1]; k = 2;

fprintf('Iter 0: %.3f %.3f\n',x(end,:));

while norm(x(k,:) - x(k-1,:),2) > 1e-5

k = k + 1;

x(k,:) = x(k-1,:) - (inv(J(x(k-1,:)))*F(x(k-1,:)))';

fprintf('Iter %d: %.3f %.3f\n',k-2,x(k,:));

end

plot(x(2:end,1),x(2:end,2),'b-o','MarkerSize',3); hold off;

fprintf('The root is: %.3f %.3f\n',x(end,:));

Answer:

Iter 5: -1.292 0.253

The root is: -1.292 0.253


Graph:

You might also like