%Matlab code for Newton method
clear all
close all
%nonlinear function to be solved
syms x1 x2 x3
f1(x1,x2,x3)=6*x1-2*cos(x2*x3)-1;
f2(x1,x2,x3)=9*x2+sqrt(x1.^2+sin(x3)+1.06)+0.9;
f3(x1,x2,x3)=60*x3+3*exp(-x1*x2)+10*pi-3;
%displaying the function
fprintf('The 1st function is f1(x1,x2,x3)=\n')
disp(f1)
fprintf('The 2nd function is f2(x1,x2,x3)=\n')
disp(f1)
fprintf('The 3rd function is f3(x1,x2,x3)=\n')
disp(f1)
%finding the Jacobian matrix
f1_x1(x1,x2,x3)=diff(f1,x1);
f1_x2(x1,x2,x3)=diff(f1,x2);
f1_x3(x1,x2,x3)=diff(f1,x3);
f2_x1(x1,x2,x3)=diff(f2,x1);
f2_x2(x1,x2,x3)=diff(f2,x2);
f2_x3(x1,x2,x3)=diff(f2,x3);
f3_x1(x1,x2,x3)=diff(f3,x1);
f3_x2(x1,x2,x3)=diff(f3,x2);
f3_x3(x1,x2,x3)=diff(f3,x3);
jac1=[f1_x1 f1_x2 f1_x3;...
f2_x1 f2_x2 f2_x3;...
f3_x1 f3_x2 f3_x3];
fprintf('The Jacobian Matrix is\n')
disp(jac1)
%All initial guess for x y z
x11=0;x22=0;x33=0;
fprintf('For initial condition x1=%f, x2=%f,
x3=%f \n',x11,x22,x33)
kmax=1000; %maximum number of iterations
fprintf('\tk\t X_1 \t X_2 \t X_3 \t
|X_k-X_k-1|\n\n')
fprintf('\t%d\t %2.5f \t %2.5f \t %2.5f
\t%2.2e\n',0,x11,x22,x33,NaN)
%loop for Newton method
for i=1:kmax
jac=jac1(x11,x22,x33);
ijac=inv(jac);
xx=double([x11;x22;x33]-ijac*[f1(x11,x22,x33);f2(x11,x22,x33);f3(x11,x22,x33)]);
err=norm(xx-[x11;x22;x33]);
x11=double(xx(1));
x22=double(xx(2));
x33=double(xx(3));
fprintf('\t%d\t %2.5f \t
%2.5f \t %2.5f \t%2.2e\n',i,x11,x22,x33,err)
result(i,1:3)=[x11,x22,x33];
if err<10^-9
break
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Compute the error of each approximation, and then determine which form fits the data the best 3. ...
4. (20 pts) In this problem, we combine the Steepest Descent method with Newton's method for solving the following nonlinear system. en +en-13 = 0, 12-2113 = 4. Use the Steepest Descent method with initial approximation x0,0,0 three iterations x(1), x(2), and x(3) to find the first ·Use x(3) fron the above the result as the initial approximation for Newton's iteration. Use the stopping criteria X(k)-s(k 1) < tol = 10 9 Display the results for each iteration in the...
please show me a Matlab script that will compute the total errors of the approximation due to the given function, also include the panel plot as well, thank you. 1) This problem studies the errors due to the approximation of the first derivative of a given function f(x) using the forward and centered difference methods. For this problem, we consider f(x)=sin(x). a) First, we will investigate the effect of the step size h on the first derivative approximation. Set h=10',...
Please do question 5 for me. Thanks Question 1 (10 marks) For a linear system Ax- b with 1 0 -1 A-1 2-1 2 -1 3 b=14 18 and compute by hand the first four iterations with the Jacobi method, using x()0 Hint: for the ease of calculation, keep to rational fractions rather than decimals Question 2 For the same linear system as in Question 1, compute by hand the first three iterations (10 marks) with the Gauss Seidel method,...
in matlab -Consider the equation f(x) = x-2-sin x = 0 on the interval x E [0.1,4 π] Use a plot to approximately locate the roots of f. To which roots do the fol- owing initial guesses converge when using Function 4.3.1? Is the root obtained the one that is closest to that guess? )xo = 1.5, (b) x0 = 2, (c) x.-3.2, (d) xo = 4, (e) xo = 5, (f) xo = 27. Function 4.3.1 (newton) Newton's method...
(b) . Write the k-th step of the trapezoidal method as a root-finding problem Ğ = is Y+1 where the unknown (e)Find the Jacobian matrix of the vector function from the previous part. (dWrite a function in its own file with definition [Y] dampedPendulum(L, T) function alpha, beta, d, h, that approximates the solution to the equivalent system you derived in part (a) with L: the length of the pendulum string alpha: the initial displacement beta: the initial velocity d:...
Please offer the Matlab code.Answer the question b.c.f.g. 5. (12.5%) The ideal D/A converter described by equation (6.25), equation (6.20), and equation (6.24) cannot be constructed because they require an infinite number of past and future samples of c(t) for the interpolation. However they can be approximated by using only a finite number of terms. Here we consider 2 methods Method I is to use only (N 1) terms of the sum in equation (6.25) as: sin IT(t nT)/T] T(t...
Need the following question answered, the subject is Mathematical Methods 2 (Mechanical Engineering). This is a University style question/practice paper with sections and I want the solutions to it, this comes with a formula sheet and if possible, use the formula sheet to answer the question. Need Calculations shown to each part of the question, My Teacher hasn't got back to me regarding the solutions so here I am, Thank you. Note: Please answer the question in UK style format...
please answer all prelab questions, 1-4. This is the prelab manual, just in case you need background information to answer the questions. The prelab questions are in the 3rd photo. this where we put in the answers, just to give you an idea. Lab Manual Lab 9: Simple Harmonic Oscillation Before the lab, read the theory in Sections 1-3 and answer questions on Pre-lab Submit your Pre-lab at the beginning of the lab. During the lab, read Section 4 and...
I need help with question 30d 16. y = 0 (that is, y(x) = 0 for all x, also written y(x) = 0) is a solution of (2) (not of (1) if (x) • o , called the trivial solution 17. The sum of a solution of (1) and a solution of (2) is a solution of (1). 18. The difference of two solutions of (1) is a solution of (2). 19. If yı is a solution of (1), what...