Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please solve using the MATLAB program. Please follow the same format underneath the question. Recall that a geometric sum is a sum of the form

Please solve using the MATLAB program.

Please follow the same format underneath the question.

image text in transcribedimage text in transcribed

Recall that a geometric sum is a sum of the form a+ar+ar2+ar3+ (a) Write a function file called geomsum1 which accepts the values of r,a and n (in that order) as input arguments and uses a for loop to return the sum of the first n terms of the geometric series. Test your function for r=1/8,a=8,n=10. (b) Write a function file called geomsum2 which accepts the values of r,a and n (in that order) as input 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 r=1/8,a=8,n=10. Hint: Start by defining the vector e=[0:n1] and then evaluate the vector R=re. It should be easy to figure out how to find the sum from there. Part (a) NOTE: We must create separate functioin M-files here. The function will require input variables. Therefore, you cannot use 'run' to execute the function. You must invoke it by providing values for the input variables. Name the function geomsum 1 , then complete the follwing. Display contents of geomsum1 M-file Assign values to input variables r=??;a=??;n=??; NOTE: Do NOT define r,a, or n inside the function file. This defeats the purpose of requiring input arguments. Delete this note before submitting. Compute geometric sum for specified values of r,a, and n. geomsum1(??) Part (b) NOTE: MATLAB has several built in functions. Here, we want to use the built-in function "sum" to compute the same geometric sum as computed in part (a). The "sum" function takes a vector as input and sums its elements. Hence, we must create a vector containing all the terms of the sum we wish to compute and pass that vector as input to the sum function. Type "help sum" in command window for more info. Don't forget: the name of your function should be geomsum2. Delete this note before submission

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions

Question

1. Explain the meaning of the term 'work'.

Answered: 1 week ago

Question

How are the securities lending market regulated?

Answered: 1 week ago

Question

love of humour, often as a device to lighten the occasion;

Answered: 1 week ago

Question

orderliness, patience and seeing a task through;

Answered: 1 week ago

Question

well defined status and roles (class distinctions);

Answered: 1 week ago