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

I need help in this question!! This is written in matlab by the way. Thank you!

ID: 3762521 • Letter: I

Question

I need help in this question!! This is written in matlab by the way. Thank you!

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= 1^3+ 2^3+ 3^3+…+N^3=1/4xN^2(N+ 1)^2

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 >10^6. Repeat using a conventional while-loop.

Explanation / Answer

function fsum
i=1;
sum=0;
while (i < 10)
cube = i * i * I;
sum = sum + cube;
i++;
end


function fsum
while(true)
cube = i * i * I;
sum = sum + cube;
i++;
end

function fsum
for a = 10:20
sum += (a*a*a);
end


function fsum
n=15;
sum = pow(((n * (n + 1) ) / 2),2);

function fsum
for n = 1:15
V(n) = pow(((n * (n + 1) ) / 2),2);
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