UNPKG

480 Btext/coffeescriptView Raw
1test_product = ->
2 run_test [
3
4 # compute pi using Viete's formula ------------
5
6 # note that this is not an array, this
7 # defines a recursive function
8 "a(n)=test(n=0,0,sqrt(2+a(n-1)))",
9 "",
10
11 # not very efficient because evaluation of
12 # a(n) is not memoized, so there
13 # is quadratic cost as n increases.
14 "float(2*product(2/a(k),k,1,9))",
15 "3.14159",
16
17 "a = quote(a)",
18 "",
19
20 # Wallis' product
21 "2*product(float(4*k^2/(4*k^2-1)),k,1,100)",
22 "3.13379",
23
24
25 ]