Saturday, March 14, 2015

3.14.15 Pi Day

Today we have Pi Day! As you probably know my favorite number is Pi and approximation of Pi number is my favorite activity on this blog. Lets focus on new version of groovy closure to count Pi:
Closure<BigDecimal> functionToIntegrate = { Math.sin(it) }
integrate(scale, sumToLimit, functionToIntegrate)  * 2 == expectedResult
Because we can't improve this API without groovy DSL someday I will get back to this  (when I will have to learn more about groovy DSL).
My colleague helped me with this improvement, but also he told me about groovy DSL. Now I can imagine API as beauty as:
integrate functionToIntegrate using scale untilReach sumToLimit andReturnX == expectedResult
This will be nice, but for now I have added a new library to show how long our tests lasted.
With this library we can profile our tests:
PiSpec  should converge to pi   9.252[s] on my laptop.
It's quite nice to achieve proper 3.1415 in 9 seconds.
I found very interesting article on wikipedia about pi approximation history:
http://en.wikipedia.org/wiki/Approximations_of_%CF%80

1 comment:

  1. Like most games, this offers gamers a more complex and wealthy experience than one that focuses merely on winning particular person matches or sessions. The real money on-line casinos we suggest are licensed and protected by advanced safety. So you can to|you presumably can} certain that|ensure that|make certain that} your private and payment knowledge is encrypted and private. The legit sites we 카지노사이트 record have additionally built a protected popularity and earned glorious critiques. They uphold knowledge safety and privateness policies and have exterior auditors checking the integrity and fairness of their games and payouts. There are different table games on the market that are be} based on poker.

    ReplyDelete