Comments for "Math_AP"

» Submit Your Comment
Comments are only accepted during the "Proposal" phase. This proposal is currently in the "Finished" phase.
» Comments
  • Stefano F. Rausch  [2006-01-12 20:37 UTC]

    Please be so kind to adhere to the PCS!
  • Etienne Kneuss  [2006-01-12 20:38 UTC]

    (I thought it would be better to make it a comment instead of a simple reply)

    Hello,

    After a quick look into the code, I would like to make some suggestions/remarks :


    1) Where is my_pi() defined?? (used line 137)

    2) There could be some improvements in the algorithms, like:
    - You should save the result of "bcpow($num, 2)" and using only multiplications instead of "bcpow($num,2 * $i + 1,$sc)"
    - The exp algorithm is highly divergent for negative input, you'll need some tricks( e^-x = 1/e^x and e4.8 = (((e^0.6)^2)^2) for example).
    - don't use "($i/2 != floor($i/2))" but ($i & 1) -> much faster
    - you should warn the user about invalid input: acos(), asin(), ln()...
    - the atan() taylor's developpement only works with input in the interval [-1;1], you'll need some tricks (trigonometric transformations) to allow a wider range.
    - some algorithms **need** at lot of loops to become relevant, I don't see the point using $scale as a brake condition, you should break the loop on a relative error basis.

    3) I don't really like the way you get the Pi value, especially if its the only reason to have zlib in dependencies. There is also a way to calculate this value.

    4) Applying P.C.S would make the code much more readable.

    5) I can imagine unexpected results, because of the intermediary simplifications using $scale+<arbitrary number>. There's probably a better way to do it.

    Kind regards