Geometric Mean is not calculated correctly.

Issue #112 closed
Former user created an issue

Originally reported on Google Code with ID 112

What steps will reproduce the problem?
1. geomean(4;64)
2.
3.

What is the expected output? What do you see instead?
Expected = sqrt(4*64) = 16.
But I see (4*64)/2 = 128 instead, which is wrong.

What version of the product are you using? On what operating system?
Source code for v0.8

Please provide any additional information below.
 Line 626 of functions.cpp currently reads:
result = result / Number(args.count());
This line should compute the Nth root instead of dividing by N.
Lines 628-629 should probably also go before line 626, since it's hard to
take the N'th root of a negative number.

Reported by therdtle on 2007-10-29 17:06:05

Comments (9)

  1. Former user Account Deleted

    ``` therdtle is right. bugfix submitted to trunk.

    ```

    Reported by `wolf.lammen` on 2007-10-29 20:39:53

  2. Former user Account Deleted

    ``` fixed in 0.9 as well. The evaluation of the hyperbolic functions sinh, cosh and tanh were dependent on the degree setting. Fixed that as well in trunk and 0.9. I leave this issue open, since function.cpp seems to need some proof reading. ```

    Reported by `wolf.lammen` on 2007-10-29 21:11:12 - Labels added: Milestone-0.9

  3. Former user Account Deleted

    ``` I did not extend GEOMEAN to negative values, because this is of no real use. So GEOMEAN(-1), GEOMEAN(-1; 2; 3) and so on still returns NaN

    ```

    Reported by `wolf.lammen` on 2007-10-29 21:17:10

  4. Former user Account Deleted

    ``` Wolf, I guess it's OK to close this issue. ```

    Reported by `helder.pereira.correia` on 2007-10-29 21:29:22 - Status changed: `Started`

  5. Former user Account Deleted

    ``` replaced test cases of GEOMEAN in testevaluator ```

    Reported by `wolf.lammen` on 2007-10-30 20:53:29

  6. Former user Account Deleted

    ``` review of function.cpp: reworked ROUND and TRUNC, because the limit of 150 digits had to be adjusted to the extended number range ```

    Reported by `wolf.lammen` on 2007-10-30 22:05:40

  7. Former user Account Deleted

    ``` Apart from a messy error reporting, my quick review of function.cpp revealed no fürther show-stopping bugs. ```

    Reported by `wolf.lammen` on 2007-10-31 16:08:16 - Status changed: `Fixed`

  8. Log in to comment