Ask Question
3 February, 17:13

Recall that a geometric sum is a sum of the form a+ar+ar^2 + ar^3 + ... (a) Write a function file that accepts the values of r, a and n as arguments and uses a for loop to return the sum of the first n terms of the geometric series. Test your function for a = 3, r = 1/2 and n = 10. (b) Write a function file that accepts the values of r, a and n as arguments and uses the built in command sum to find the sum of the first n terms of the geometric series. Test your function for a = 3, r = 1/2 and n = 10. Hint: Start by defining the vector e=0:n-1 and then evaluate the vector R = r.^e. It should be easy to figure out how to find the sum from there.

+2
Answers (1)
  1. 3 February, 17:32
    0
    Given, a = 3, r = 1/2, n = 10

    %r is common ratio

    %n is number of terms

    %a is the first term of the series

    Sum = 0;

    a = 3;

    r = 1/2;

    for i = 0 : 1 : 10;

    Sum = Sum + a * r ^ i;

    end

    Sum
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Recall that a geometric sum is a sum of the form a+ar+ar^2 + ar^3 + ... (a) Write a function file that accepts the values of r, a and n as ...” in 📘 Engineering if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers