Question: Problem 3. (Geometric and Harmonic Means) Write a program means.py that reads in positive real numbers from standard input and writes their geometric and harmonic
Problem 3. (Geometric and Harmonic Means) Write a program means.py that reads in positive real numbers from standard input and writes their geometric and harmonic means. The geometric mean of n positive numbers x1,x2,...,xn is (x1 x2 xn)1/n and their harmonic mean is n/(1/x1 + 1/x2 ++ 1/xn). Hint: for the geometric mean, consider taking logarithms to avoid overow; if y = (abc)1/d, then lny = (1/d)(lna + lnb + lnc) = x (say), and y = ex. $ python3 means.py 1.0 2.0 3.0 4.0 5.0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
