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