Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The geometric mean of n positive numbers x 1 , . . . , xn is given by n n i = 1 xi .
The geometric mean of n positive numbers x xn is given by
n
n
i
xi
This quantity can be computed in a running fashion similar to a running sum, but
using multiplication instead, by computing the product of the values in the radical
using a running product. By doing this, you can easily produce geometric mean values
as new numbers are discovered.
geomean Function:
Input variables:
none
Keyboard inputsscreen outputs:
prompts the user times for separate numbers and after each number
outputs the geometric mean of the numbers so far
Output variables:
a vector of the numbers input
A possible sample case is:
nums geomean
Enter a number:
The geometric mean after numbers is
Enter a number:
The geometric mean after numbers is
Enter a number:
The geometric mean after numbers is
Enter a number:
The geometric mean after numbers is
nums
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started