-
Notifications
You must be signed in to change notification settings - Fork 1
/
jsops.lisp
221 lines (174 loc) · 8.86 KB
/
jsops.lisp
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
;;;;;;;;;;;;;;;;;
(defDifferentiation Differentiation-of-Constant
((|$Derivative| SIMP) ?t ?var)
:TEST (not (occurs-in? ?var ?t))
:RESULT (* 0 ?var))
;;;;;;;;;;;;;;;;;
(defDifferentiation Differentiation-of-Self
((|$Derivative| SIMP) ?exp ?exp)
:RESULT 1)
;;in case constant arrives before variable, (* $a $x) for x
(defDifferentiation Move-Constant-outside
((|$Derivative| SIMP) (* ?const ?nonconst) ?var)
:TEST (and (occurs-in? ?var ?const)
(not (occurs-in? ?var ?nonconst)))
:SUBPROBLEMS ((?int ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?const ?var))))
:RESULT (* ?nonconst ?int))
;;in case constant arrives after variable, (* $x $z) for x
(defDifferentiation Move-Constant-outside-1
((|$Derivative| SIMP) (* ?const ?nonconst) ?var)
:TEST (and (not (occurs-in? ?var ?const))
(occurs-in? ?var ?nonconst))
:SUBPROBLEMS ((?int ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?nonconst ?var))))
:RESULT (* ?const ?int))
;;;;;;;;;;;;;;;;
(defDifferentiation Differentiation-of-Product
((|$Derivative| SIMP) (* ?var1 ?var2) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?var1 ?var)))
(?int2 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?var2 ?var))))
:RESULT (+ (* ?var2 ?int1) (* ?var1 ?int2)))
;;;;;;;;;;;;;;;
(defDifferentiation Differentiation-of-Sum
((|$Derivative| SIMP) (+ ?t1 ?t2) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?t1 ?var)))
(?int2 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?t2 ?var))))
:RESULT (+ ?int1 ?int2))
;;;;;;;;;;;;;;;
(defDifferentiation Differentiation-of-Nary-Product
((|$Derivative| SIMP) (* ?t1 ?t2 . ?trest) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?t1 ?var)))
(?intr ((|$Differentiate| SIMP) ((|$Derivative| SIMP) (* ?t2 . ?trest) ?var))))
:TEST (not (null ?trest))
:RESULT (+ (* ?int1 (* ?t2 (car ?trest))) (* ?intr ?t1)))
;;;;;;;;;;;;;;;
(defDifferentiation Differentiation-of-Nary-sum
((|$Derivative| SIMP) (+ ?t1 ?t2 . ?trest) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?t1 ?var)))
(?int2 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?t2 ?var)))
(?intr ((|$Differentiate| SIMP) ((|$Derivative| SIMP) (+ . ?trest) ?var))))
:TEST (not (null ?trest))
:RESULT (+ ?int1 ?int2 ?intr))
;;;;;;;;;;;;;;;
(defDifferentiation Differentiation-of-uminus
((|$Derivative| SIMP) (* -1 ?term) ?var)
:SUBPROBLEMS ((?int ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?term ?var))))
:RESULT (* -1 ?int))
;;;;;;;;;;;;;;
(defDifferentiation Differentiation-of-minus
((|$Derivative| SIMP) (- ?t1 ?t2) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?t1 ?var)))
(?int2 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?t2 ?var))))
:RESULT (- ?int1 ?int2))
;;;;;;;;;;;;;;
(defDifferentiation Differentiation-of-log-base-power
((|$Derivative| SIMP) (expt (log ?v) ?n) ?var) ;;;?n * log(?v)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) (:EVAL `(log ,?v)) ?var)))
(?int2 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?n ?var))))
:RESULT (+ (* (log ?v) ?int2) (+ ?n ?int1)))
(defDifferentiation Differentiation-of-different-base-power
((|$Derivative| SIMP) (expt ?v ?n) ?var) ;;;(expt ?v ?n)*?n * log(?v)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) (:EVAL `(log ,?v)) ?var)))
(?int2 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?n ?var))))
:RESULT (* (expt ?v ?n) (+ (* ?int1 ?n) (* (log ?v) ?int2 ))))
(defDifferentiation Differentiation-e
((|$Derivative| SIMP) (exp ?a) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?a ?var))))
:RESULT (* (exp ?a) ?int1))
(defDifferentiation Log-of-self-Differentiation
((|$Derivative| SIMP) (log ?v) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?v ?var))))
:RESULT (* (/ 1 ?v) ?int1 ))
(defDifferentiation Differentiation-of-multiply-Bracketed
((|$Derivative| SIMP) (* ?t1) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?t1 ?var))))
:RESULT ?int1)
(defDifferentiation Differentiation-of-plus-Bracketed
((|$Derivative| SIMP) (+ ?t1) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?t1 ?var))))
:RESULT ?int1)
(defDifferentiation Differentiation-of-plus-Bracketed
((|$Derivative| SIMP) ((MPLUS SIMP) ?t1) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?t1 ?var))))
:RESULT ?int1)
(defDifferentiation Differentiation-of-times-Bracketed
((|$Derivative| SIMP) (* ?t1) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?t1 ?var))))
:RESULT ?int1)
(defDifferentiation Differentiation-of-times-Bracketed
((|$Derivative| SIMP) ((MTIMES SIMP) ?t1) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?t1 ?var))))
:RESULT ?int1)
;;;;;;;;;;;;;;;;;;;
;;Trignometric functions
(defDifferentiation sin-differentiation
((|$Derivative| SIMP) (sin ?a) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?a ?var))))
:RESULT (* (cos ?a) ?int1))
(defDifferentiation csc-differentiation
((|$Derivative| SIMP) (csc ?a) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?a ?var))))
:RESULT (* -1 (csc ?a) (cot ?a) ?int1))
(defDifferentiation asin-differentiation
((|$Derivative| SIMP) (asin ?a) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?a ?var))))
:RESULT (* (/ 1 (expt (+ 1 (* -1 (expt ?a 2))) (/ 1 2))) ?int1))
(defDifferentiation cos-differentiation
((|$Derivative| SIMP) (cos ?a) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?a ?var))))
:RESULT (* -1 (sin ?a) ?int1))
(defDifferentiation sec-differentiation
((|$Derivative| SIMP) (sec ?a) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?a ?var))))
:RESULT (* (sec ?a) (tan ?a) ?int1))
(defDifferentiation acos-differentiation
((|$Derivative| SIMP) (acos ?a) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?a ?var))))
:RESULT (* -1 (/ 1 (expt (+ 1 (* -1 (expt ?a 2))) (/ 1 2))) ?int1))
(defDifferentiation tan-differentiation
((|$Derivative| SIMP) (tan ?a) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?a ?var))))
:RESULT (* (expt (sec ?a) 2) ?int1))
(defDifferentiation cot-differentiation
((|$Derivative| SIMP) (cot ?a) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?a ?var))))
:RESULT (* -1 (expt (csc ?a) 2) ?int1))
(defDifferentiation atan-differentiation
((|$Derivative| SIMP) (atan ?a) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?a ?var))))
:RESULT (* (/ 1 (+ 1 (expt ?a 2))) ?int1))
(defDifferentiation acot-differentiation
((|$Derivative| SIMP) (acot ?a) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?a ?var))))
:RESULT (* -1 (/ 1 (+ 1 (expt ?a 2))) ?int1))
(defDifferentiation acsc-differentiation
((|$Derivative| SIMP) (acsc ?a) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?a ?var))))
:RESULT (* -1 (/ 1 (* (expt ?a 2) (expt (+ 1 (/ 1 (* -1 (expt ?a 2)))) (/ 1 2)))) ?int1))
(defDifferentiation asec-differentiation
((|$Derivative| SIMP) (asec ?a) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?a ?var))))
:RESULT (* (/ 1 (* (expt ?a 2) (expt (+ 1 (/ 1 (* -1 (expt ?a 2)))) (/ 1 2)))) ?int1))
(defDifferentiation sinh-differentiation
((|$Derivative| SIMP) (sinh ?a) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?a ?var))))
:RESULT (* (cosh ?a) ?int1))
(defDifferentiation cosh-differentiation
((|$Derivative| SIMP) (cosh ?a) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?a ?var))))
:RESULT (* (sinh ?a) ?int1))
(defDifferentiation tanh-differentiation
((|$Derivative| SIMP) (tanh ?a) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?a ?var))))
:RESULT (* (expt (sech ?a) 2) ?int1))
(defDifferentiation sech-differentiation
((|$Derivative| SIMP) (sech ?a) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?a ?var))))
:RESULT (* -1 (sech ?a) (tanh ?a) ?int1))
(defDifferentiation coth-differentiation
((|$Derivative| SIMP) (coth ?a) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?a ?var))))
:RESULT (* -1 (expt (csch ?a) 2) ?int1))
(defDifferentiation csch-differentiation
((|$Derivative| SIMP) (csch ?a) ?var)
:SUBPROBLEMS ((?int1 ((|$Differentiate| SIMP) ((|$Derivative| SIMP) ?a ?var))))
:RESULT (* -1 (csch ?a) (coth ?a) ?int1))