Professional Documents
Culture Documents
Problem Set 7TATATATA
Problem Set 7TATATATA
Problem Set 7TATATATA
TABASAN
1.
Use Code
% Define the matrix A and vector b
A = [5, 4, 1, 1; 4, 5, 1, 1; 1, 1, 4, 2; 1, 1, 2, 4];
b = [1; 2; 3; 4];
(See Data 1.3) The code successfully applies the pcg function to solve a linear system of equations.
It converges at the fourth iteration to a solution with a relative residual of 1.3e-15, indicating high
accuracy. The solution vector is displayed, showing the values for each variable in the system.
Additionally, the residual norm is calculated and found to be 7.351e-15, further confirming the
accuracy of the solution.
Use Code
% Define the objective function
fun = @(xy) (2*xy(1) - sin((xy(1) + xy(2))/2))^2 + (2*xy(2) - cos((xy(1) - xy(2))/2))^2;
MATLAB INPUT
(See Data 2.1) The code applies the minscg function to minimize the objective function. The
objective function is defined as a mathematical expression involving two variables (x and y). The
code specifies the starting point (x0) for the optimization. The minscg function utilizes the scaled
conjugate gradient method to iteratively minimize the objective function and find the solution. The
resulting solution vector (x) and the corresponding minimum value (z) of the function are then
displayed.
Data 2.2 MATLAB Workspace input