12
1
There are quite a few means in mathematics, such as the arithmetic mean, the geometric mean, and many others...
Definitions and Task
Note that these are the definitions for two positive integers*:
The root mean square is the square root of the sum of their squares halved (
).
The arithmetic mean is their sum, halved (
).
The geometric mean is the square root of their product (
).
The harmonic mean is 2 divided by the sum of their inverses (
=
).
Given two integers a and b such that a, b ∈ [1, +∞), sum the means mentioned above of a and b. Your answers must be accurate to at least 3 decimal places, but you do not have to worry about rounding or floating-point precision errors.
Test Cases
a, b -> Output 7, 6 -> 25.961481565148972 10, 10 -> 40 23, 1 -> 34.99131878607909 2, 4 -> 11.657371451581236 345, 192 -> 1051.7606599443843
You can see the correct results for more test cases using this program. This is code-golf, so the shortest valid submissions that follows the standard rules wins.
* There are many other means, but for the purposes of this challenge we'll use the ones mentioned in the "Definitions" section.
Related. – Martin Ender – 2017-10-15T12:18:19.557
10Must've asked to output the mean of means. -1 (not). – my pronoun is monicareinstate – 2017-10-15T12:21:01.417
9At least there is no Mathematica builtin for that. Right? – NieDzejkob – 2017-10-15T12:21:05.263
@NieDzejkob I don't think so :-) – Mr. Xcoder – 2017-10-15T12:21:24.317
@NieDzejkob Although I suspect there are builtins for each one of the means. – Erik the Outgolfer – 2017-10-15T12:25:00.900
@EriktheOutgolfer It's not the same – NieDzejkob – 2017-10-15T12:39:46.687
Can we take inputs as
7.0, 6.0
? – totallyhuman – 2017-10-15T13:58:53.887@icrieverytim yes, you can. – Mr. Xcoder – 2017-10-15T13:59:28.430