Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

BE 1500 - Homework 5 1. Write a function file that determines the following sum (for all odd n from 3 to 13) using a

BE 1500 - Homework 5 1. Write a function file that determines the following sum (for all odd n from 3 to 13) using a for loop: 2 +2 = 1 2. Repeat question 1 but us a while loop. 3. The nth Fibonacci number is defined by the following recursive equations: f(1) = 0; f(2) = 1; f(n) = f(n-1) + f(n-2) Therefore the 3rd Fibonacci number is calculated: f(3)=f(2)+f(1)=1+0=1, and so forth for higher numbers. Write a function file to calculate and write out the nth Fibonacci number; n is an integer input to the function file. Use a while loop to perform the calculation. 4. The geometric mean of a set of numbers x1 through xn is defined as the nth root of the product of numbers: Geometric mean = (x1*x2...xn)1/n Write a function file that will accept an arbitrary number of positive input values and calculate the average and the geometric mean of the numbers. Use a while loop to get the input values and terminate the input if the user inputs a negative number. Test your program by calculating the average and geometric mean of the four numbers 10, 5, 2, and 5. 5. Write your own code to perform matrix multiplication. Recall that to multiply two matrices, the inner dimensions must be the same. [A]mn[B]np = [C]mp Every element in the resulting C matrix is obtained by: Cij= aikbkj The sum is from k=1 to n. So three nested loops are required

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

Elementary Statisitcs

Authors: Barry Monk

2nd edition

1259345297, 978-0077836351, 77836359, 978-1259295911, 1259295915, 978-1259292484, 1259292487, 978-1259345296

More Books

Students also viewed these Mathematics questions