Problem 2: The Harmonic Mean Given a list (a1, 92, .., an), its harmonic mean is defined as Now define three functions h

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Problem 2: The Harmonic Mean Given a list (a1, 92, .., an), its harmonic mean is defined as Now define three functions h

Post by answerhappygod »

Problem 2 The Harmonic Mean Given A List A1 92 An Its Harmonic Mean Is Defined As Now Define Three Functions H 1
Problem 2 The Harmonic Mean Given A List A1 92 An Its Harmonic Mean Is Defined As Now Define Three Functions H 1 (63.87 KiB) Viewed 53 times
Problem 2: The Harmonic Mean Given a list (a1, 92, .., an), its harmonic mean is defined as Now define three functions hmean1, hmean2 and hmean3, all with the input as a given list and output the harmonic mean. The requirements are as follows: 1. hmean1 uses the combination of builtin Mathematica functions, and in the function you can only use Length, Total and division operator (/). 2. hmean2 uses functional programming, and in the function you can only use these elements: builtin-in functions of Length, Power, Times and Plus, operators of Map (/@) and Apply(@@), Pure Functions (#&), curly brackets {}, parenthesis (), and number -1. 3. hmean3 uses control flows, and you can pick Do/For/While as you like. After defining the function, do the followings: 1. Test the correctness of all your functions with some small list, say {a,b,c,d). 2. Compare the running times of different functions with a large list, for instance Range[10^5]. Also compare with running time the built-in Mathematica to calculate harmonic mean directly (Hint: find function name with natural language input). Insert the text cell to write down your observations.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply