Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a Matlab code implementing the function which gets as an argument two vect

ID: 3854028 • Letter: W

Question

Write a Matlab code implementing the function which gets as an argument two vectors of scalar values X = [xi] and Y = [yi] for i=0, 1, 2, .., n, n+1, n+2, which returns as a result the value of the expression: Group A: v = Sigma^n + 1_i = -1 (pi^n_j = 0, j notequalto 1 sin (yi)x^2_i e^xj) Group B: z = pi^n + 1_j = -1(Sigma^n_i = 0, j notequalto 1sin(x^2_i)e^xj/y_i Write a Matlab script solving following nonlinear equation problem using Newton-Raphson method As a result print the sequence of solutions in each iteration - x_i. Group A: e^0.5x middot sin(x - 0.5) =?0.5: Group B: e^0.3x = -0.2/cos(x - 0.3) As initial value (starting point) use x_0 = 1.5. As initial value (starting point) use x_0 = -1.

Explanation / Answer

Question 5:

clear

clc

%Group A
xnew=1.5;%our initial guess
i=1;
f=@(x)sin(x - 1/2)*exp(x/2) + 1/2;%given function
ff=@(x)cos(x - 1/2)*exp(x/2) + (sin(x - 1/2)*exp(x/2))/2;%differentiating above function wrt x
disp("Group A")
while(abs(f(xnew))>10^-4)%the loop will break as soon as the value of function for calclated xnew becomes lesser than 10^-4
xnew=xnew-(f(xnew))/(ff(xnew));
fprintf('Iteration=%3i,Solution=%10f,Value=%10f ',i,xnew,f(xnew))
i=i+1;
end
%Group B
xnew1=-1;%our initial guess
i=1;
f1=@(x)exp((3*x)/10) + 1/(5*cos(x - 3/10));%given function
ff1=@(x)(3*exp((3*x)/10))/10 + sin(x - 3/10)/(5*cos(x - 3/10)^2);%differentiating above function wrt x
disp("Group B")
while(abs(f1(xnew1))>10^-4)%the loop will break as soon as the value of function for calclated xnew becomes lesser than 10^-4
xnew1=xnew1-(f1(xnew1))/(ff1(xnew1));
fprintf('Iteration=%5i,Solution=%10f,Value=%10f ',i,xnew1,f1(xnew1))
i=i+1;
end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote