Question

In: Computer Science

Write your own MATLAB code to solve the system 10 − x + sin(x + y)...

Write your own MATLAB code to solve the system

10 − x + sin(x + y) − 1 = 0

8y − cos2 (z − y) − 1 = 0

12z + sin(z) − 1 = 0

using a residual tolerance of 10^−6 and the initial guess, ~x 0 = [0.1, 0.25, 0.08]^T . Print out the values for x, y and z for each iteration in a table similar to the one you created for the problems of the previous homework. You should submit your code (which can again be organized as a function and the script calling this function) together with your output.

Solutions

Expert Solution

clc

clear all

close all

format long

ff=@(x,y,z) [10-x+sin(x+y)-1;8*y-cos(z-y)^2-1;12*z+sin(z)-1];

f=@(x) ff(x(1),x(2),x(3));

g=@(x,y,z) [cos(x + y) - 1, cos(x + y), 0;0, 2*cos(y - z)*sin(y - z) + 8, -2*cos(y - z)*sin(y - z);0, 0, cos(z) + 12];

J=@(x) g(x(1),x(2),x(3));

x0=[0.1;0.25;0.08];

for i=1:100

x1=x0-inv(J(x0))*f(x0);

fprintf('Iteration %d, x=%f, y=%f, z=%f\n',i,x1);

if(norm(x1-x0)<1e-6)

break;

end

x0=x1;

end


Related Solutions

2. Solve a function (e.g., y(x) = sin(x) / (sin(x/10) + x/10) for many different values...
2. Solve a function (e.g., y(x) = sin(x) / (sin(x/10) + x/10) for many different values of x between a user-defined min and max, and store the values in a list. Also, print the maximum value of y(x) for the given range.?
Write a MATLAB code for the conjugate gradient method and apply it to solve the system...
Write a MATLAB code for the conjugate gradient method and apply it to solve the system Hx = b, where H is the n×n Hilbert matrix, and b is A times the vector of all ones, for (a) n = 4; (b) n = 8. Compare your numerical solutions with the exact solution (which is the vector of all ones), and report your numerical errors.
Using matlab Find x and y that solve the following system: ln(x 2 + y) =...
Using matlab Find x and y that solve the following system: ln(x 2 + y) = 1 − y , xy = − √ x
Solve differential equation: y'+y=sin(x)
Solve differential equation: y'+y=sin(x)
Write a matlab code for given task Use your ‘sin’ or ‘cos’ function to generate a...
Write a matlab code for given task Use your ‘sin’ or ‘cos’ function to generate a sinusoid wave having two components as f1 = 3kHz and f2 = 5kHz and then sample it with fs = 10kHz. Calculate its fft with zero frequency component in the middle. Plot it on a properly scaled w-axis. Specify if there is aliasing or not? If there is aliasing specify which component is casing the aliasing
Using Matlab code, solve the following: (a) Consider first the undamped pendulum ? + sin ?...
Using Matlab code, solve the following: (a) Consider first the undamped pendulum ? + sin ? = 0, ?(0) = 0, ? (0) = b. Let x = ? and y = ? ; then x and y satisfy the system x = y y = ? sin x, x(0) = 0 y(0) = b. Solve this system numerically and plot, on a single graph, the resulting trajectories for the initial velocities b = 0.5, 1, 1.5, 2, 2.5. Use...
assume that the data are stored in variable names x and y. write a matlab code...
assume that the data are stored in variable names x and y. write a matlab code to plot the quadratic spline and along with the data points x= 1 2 3 4 5 6 y= 40 78 125 256 348 425
subject:engineering mathematics solve [cos(x+y)-sin(x+y)]dx-sin(x+y)dy=0,is the ODE exact?Find an integrating factor and solve the ODE.
subject:engineering mathematics solve [cos(x+y)-sin(x+y)]dx-sin(x+y)dy=0,is the ODE exact?Find an integrating factor and solve the ODE.
Use method of variation of parameters to solve y'' + y = sin^2(x)
Use method of variation of parameters to solve y'' + y = sin^2(x)
Solve the differential equation by variation of parameters. y''+ y = sin^2(x)
Solve the differential equation by variation of parameters. y''+ y = sin^2(x)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT