-
Notifications
You must be signed in to change notification settings - Fork 0
/
pi.trig
55 lines (44 loc) · 1.16 KB
/
pi.trig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# ------------------------------------
# Calculate pi using Nilakantha series
# ------------------------------------
#
# See http://www.wikihow.com/Calculate-Pi
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix var: <http://www.w3.org/2000/10/swap/var#>.
@prefix : <http://example.org/#>.
# components
_:bng_1 log:isImpliedBy _:bng_2.
_:bng_1 {
(var:N var:Pi) :pi true.
}
_:bng_2 {
(1 var:N 0 var:P 1) :pi true.
(4 var:P) math:product var:A.
(3 var:A) math:sum var:Pi.
}
_:bng_3 log:isImpliedBy true.
_:bng_3 {
(var:N var:N var:P var:P var:S) :pi true.
}
_:bng_4 log:isImpliedBy _:bng_5.
_:bng_4 {
(var:K var:N var:P0 var:P var:S) :pi true.
}
_:bng_5 {
var:K math:notEqualTo var:N.
(var:K 1) math:sum var:K1.
(2 var:K) math:product var:K2.
(var:K2 1) math:sum var:A.
(var:K2 2) math:sum var:B.
(var:K2 var:A var:B) math:product var:C.
(var:S var:C) math:quotient var:D.
(var:P0 var:D) math:sum var:P1.
var:S math:negation var:S1.
(var:K1 var:N var:P1 var:P var:S1) :pi true.
}
# query
_:bng_6 log:query _:bng_6.
_:bng_6 {
(1000 var:Pi) :pi true.
}