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

i need help with both MATLAB problems please 1. given an interger N it is requir

ID: 1920989 • Letter: I

Question

i need help with both MATLAB problems please

1. given an interger N it is required to compute the sum of the cubes of the numbers 1 to N.

2.solve eq (2) iteratively by replacing it by the following irteration, initialized at some arbitrary value .

1. Given an integer N, it is required to compute the sum of the cubes of the numbers from 1 to N. The sum can be computed directly or analytically by the following formula: S 13 +23 +33+...+ N3N2 (N 1) 4 a. Let N 20. Compute the sum by the following 5 methods, using: (1) a for-loop, (2) a conventional while-loop, (3) a forever while-loop, (4) the vectorized sum function, and, (5) the above analytical formula. b. Write a function, say, fsum.m, that employs a switch structure and evaluates the sum by any of the above 5 methods, with method 5 being the default method. It must have the following usage, where m is the method number, m = 1, 2, 3, 4, 5: S fsum(N , m); = c. The sum S grows with increasing N. Using your function fsum and a forever-while loop determine the smallest N such that S 106. Repeat using a conventional while-loop. 2. It is desired to solve the equation, xex 1. An equivalent equation is: x = exp (-x) a. Solve Eq. (2) iteratively by replacing it by the following iteration, initialized at some arbitrary value, Nk+1 = exp (-%) , k = 1,2,3, .. such as, Xxi1: Implement this iteration using a forever while-loop that exits when two successive iterates become closer to each other than some specified error tolerance such as, tol = 10-10, that is, the iteration terminates when, |xk+1 Xkl

Explanation / Answer

% 1. given an interger N it is required to compute the sum of the cubes of the numbers 1 to N.

function [sum]= cube_sum(N)
% find the given cube series of natural number up to N
% N= nos. of terms
sum=0;
if N>0
sum=(N*(N+1)/2)^2 ;
else
error('nos. of terms can not be negative');
end

% eq (2) iteratively by replacing it by the following irteration, initialized at some arbitrary value=1

tol=10^(-10);

xk = 1;

xk+1 =0;

while abs(xk+1 - xk) <tol

xk+1 = exp(-xk);

end

display(xk+1);