summaryrefslogtreecommitdiff
path: root/rules.txt
blob: 9a005ee5f8c636dac13505c4043f6546ed40f64f (plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
## general
#+ to_internal
#+ fraction_identities
#+ identities
#+ uncollect_sums
#+ differentiation
#+ sanitise_epowers


## display
#+ to_display
#+ fraction_identities
#+ collect
#+ identities


## general_display
#+ general
#+ display


## sanitise
#+ sanitise_epowers
#+ collect_numbers


## collect
Sum [{{x}},{{x}},{rest}] | Sum [Product [Number 2,{x}],{rest}]
Sum [{{x}},Product [{{n:Number}},{x}],{rest}] | Sum [Product [Sum [Number 1,{n}],{x}],{rest}]
Sum [Product [{{n1:Number}},{x}],Product [{{n2:Number}},{x}],{rest}] | Sum [Product [Sum [{n1},{n2}],{x}],{rest}]

Product [{{x}},{{x}},{rest}] | Product [:pow:[{x},Number 2],{rest}]
Product [{{x}},:pow:[{{x}},{{n}}],{rest}] | Product [:pow:[{x},Sum [{n},Number 1]],{rest}]
Product [:pow:[{x},{a}],:pow:[{x},{b}],{rest}] | Product [:pow:[{x},Sum [{a},{b}]],{rest}]


## uncollect_sums
Product [Sum [{{a}},{rest}],{prod}] | Sum [Product [{a},{prod}],Product [{rest},{prod}]]


## identities
:pow:[:pow:[{{x}},{{n}}],{{m}}] | :pow:[{x},Product [{n},{m}]]
:pow:[{{x}},Number 1] | {x}

-- Guarding necessary for x != 0
:pow:[{x},Number 0] | Number 1

Product [Number 0,{rest}] | Number 0
Product [Number 1,{rest}] | {rest}


## fraction_identities
Reciprocal (Product [Reciprocal {{x}},{rest}]) | Product [{x},Reciprocal {rest}]
Product [{{x}},Reciprocal {{x}},{rest}] | {rest}
Product [{{x}},Reciprocal (Product [{{x}},{rrest}]),{rest}] | Product [{rest},Reciprocal {rrest}]


## to_internal
Reciprocal {a} | :pow:[{a},Number (-1)]
Negative {a} | Product [Number (-1),{a}]
:pow:[Product [{{a}},{b}],{exp}] | Product [:pow:[{a},{exp}],:pow:[{b},{exp}]]
:tan:[{x}] | Product [:sin:[{x}],Reciprocal (:cos:[{x}])]


## differentiation
:d:[{{n:Number}},{x}] | Number 0

-- these two differentiation rules should be tried in THIS order.
-- Better: guard for d(x,y) that x!=y...
:d:[{{x:Variable}},{{x}}] | Number 1
:d:[{{x:Variable}},{{y}}] | Number 0

:d:[Sum [{{a}},{b}],{{x}}] | Sum [:d:[{a},{x}],:d:[{b},{x}]]
:d:[Product [{{n:Number}},{a}],{x}] | Product [{n},:d:[{a},{x}]]
:d:[Product [{{a}},{b}],{x}] | Sum [Product [:d:[{a},{x}],{b}],Product [{a},:d:[{b},{x}]]]
:d:[:pow:[Variable "E",{ex}],{x}] | Product [:pow:[Variable "E",{ex}],:d:[{ex},{x}]]

-- Guarding probably necessary for a != E
-- Cannot be generally applied, because {a} may be negative; for differentiation, however, that doesn't matter
-- :d:[:pow:[{a},{b}],{x}] | :d:[:pow:[Variable "E",Product [{b},:ln:[{a}]]],{x}]
:d:[:pow:[{a},{b}],{x}] | Product [:pow:[{a},{b}],:d:[Product[{b},:ln:[{a}]],{x}]]

:d:[:ln:[{args}],{x}] | Product [Reciprocal {args},:d:[{args},{x}]]
:d:[:sin:[{a}],{x}] | Product [:cos:[{a}],:d:[{a},{x}]]
:d:[:cos:[{a}],{x}] | Product [Number (-1),:sin:[{a}],:d:[{a},{x}]]


## sanitise_epowers
:pow:[Variable "E",:ln:[{arg}]] | {arg}
:pow:[Variable "E",Product [:ln:[{arg}],{rest}]] | :pow:[{arg},{rest}]


## collect_numbers
Sum [Product [{{n1:Number}},{x}],Product [{{n2:Number}},{x}],{rest}] | Sum [Product [Sum [{n1},{n2}],{x}],{rest}]


## to_display
:pow:[Variable "E",:ln:[{arg}]] | {arg}
:pow:[Variable "E",Product [:ln:[{arg}],{rest}]] | :pow:[{arg},{rest}]
:pow:[{x},Number (-1)] | Reciprocal {x}
Product [:sin:[{x}],Reciprocal (:cos:[{x}]),{rest}] | Product [:tan:[{x}],{rest}]