0% found this document useful (0 votes)
23 views3 pages

Nama:Maulida Rahmi NIM:1604103010019 Subject: Komputasi Terapan 1)

This document contains the code and output of solving a system of nonlinear equations using fsolve in MATLAB. It defines two functions, x^2 + 2y^2 - 5x + 7y - 40 and 3x^2 - y^2 + 4x + 2y - 28, and uses fsolve to find the values of x and y that satisfy both equations simultaneously. The output shows that fsolve converged after 4 iterations and found the solutions to be x = 2.6963 and y = 3.3655.

Uploaded by

maulida rahmi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views3 pages

Nama:Maulida Rahmi NIM:1604103010019 Subject: Komputasi Terapan 1)

This document contains the code and output of solving a system of nonlinear equations using fsolve in MATLAB. It defines two functions, x^2 + 2y^2 - 5x + 7y - 40 and 3x^2 - y^2 + 4x + 2y - 28, and uses fsolve to find the values of x and y that satisfy both equations simultaneously. The output shows that fsolve converged after 4 iterations and found the solutions to be x = 2.6963 and y = 3.3655.

Uploaded by

maulida rahmi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Nama :Maulida Rahmi

NIM :1604103010019
Subject: Komputasi Terapan

1)

File utama
clc
clear all

%tebakan awal
x0 = 2
y0 = 3
z0 = [x0 y0]

[z,fval,exitflag,output] = fsolve('fungsi_xy',z0)

x = z(1)
y = z(2)

nilai_fungsi = fungsi_xy([x y])

File fungsi
function f = fungsi_xy(z)
x = z(1);
y = z(2);

f(1) =x.^2 + 2*y.^2 - 5*x + 7*y - 40;


f(2) =3*x.^2 - y.^2 + 4*x + 2*y - 28;

Solution :
x0 =
2

y0 =
3
z0 =

2 3

Equation solved.

fsolve completed because the vector of function values is near


zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.

<stopping criteria details>

z =

2.6963 3.3655

fval =

1.0e-12 *

0.1421 0.2487

exitflag =

output =

iterations: 4
funcCount: 15
algorithm: 'trust-region-dogleg'
firstorderopt: 5.0738e-12
message: [1x691 char]

x =

2.6963

y =
3.3655

nilai_fungsi =

1.0e-12 *

0.1421 0.2487

2) Soal 2

You might also like