UNPKG

15.1 kBtext/coffeescriptView Raw
1###
2 Table of integrals
3
4The symbol f is just a dummy symbol for creating a list f(A,B,C,C,...) where
5
6 A is the template expression
7
8 B is the result expression
9
10 C is an optional list of conditional expressions
11###
12
13itab = [
14 # 1
15 "f(a,a*x)",
16 # 9 (need a caveat for 7 so we can put 9 after 7)
17 "f(1/x,log(x))",
18 # 7
19 "f(x^a,x^(a+1)/(a+1))",
20 # 12
21 "f(exp(a*x),1/a*exp(a*x))",
22 "f(exp(a*x+b),1/a*exp(a*x+b))",
23 "f(x*exp(a*x^2),exp(a*x^2)/(2*a))",
24 "f(x*exp(a*x^2+b),exp(a*x^2+b)/(2*a))",
25 # 14
26 "f(log(a*x),x*log(a*x)-x)",
27 # 15
28 "f(a^x,a^x/log(a),or(not(number(a)),a>0))",
29 # 16
30 "f(1/(a+x^2),1/sqrt(a)*arctan(x/sqrt(a)),or(not(number(a)),a>0))",
31 # 17
32 "f(1/(a-x^2),1/sqrt(a)*arctanh(x/sqrt(a)))",
33 # 19
34 "f(1/sqrt(a-x^2),arcsin(x/(sqrt(a))))",
35 # 20
36 "f(1/sqrt(a+x^2),log(x+sqrt(a+x^2)))",
37 # 27
38 "f(1/(a+b*x),1/b*log(a+b*x))",
39 # 28
40 "f(1/(a+b*x)^2,-1/(b*(a+b*x)))",
41 # 29
42 "f(1/(a+b*x)^3,-1/(2*b)*1/(a+b*x)^2)",
43 # 30
44 "f(x/(a+b*x),x/b-a*log(a+b*x)/b/b)",
45 # 31
46 "f(x/(a+b*x)^2,1/b^2*(log(a+b*x)+a/(a+b*x)))",
47 # 33
48 "f(x^2/(a+b*x),1/b^2*(1/2*(a+b*x)^2-2*a*(a+b*x)+a^2*log(a+b*x)))",
49 # 34
50 "f(x^2/(a+b*x)^2,1/b^3*(a+b*x-2*a*log(a+b*x)-a^2/(a+b*x)))",
51 # 35
52 "f(x^2/(a+b*x)^3,1/b^3*(log(a+b*x)+2*a/(a+b*x)-1/2*a^2/(a+b*x)^2))",
53 # 37
54 "f(1/x*1/(a+b*x),-1/a*log((a+b*x)/x))",
55 # 38
56 "f(1/x*1/(a+b*x)^2,1/a*1/(a+b*x)-1/a^2*log((a+b*x)/x))",
57 # 39
58 "f(1/x*1/(a+b*x)^3,1/a^3*(1/2*((2*a+b*x)/(a+b*x))^2+log(x/(a+b*x))))",
59 # 40
60 "f(1/x^2*1/(a+b*x),-1/(a*x)+b/a^2*log((a+b*x)/x))",
61 # 41
62 "f(1/x^3*1/(a+b*x),(2*b*x-a)/(2*a^2*x^2)+b^2/a^3*log(x/(a+b*x)))",
63 # 42
64 "f(1/x^2*1/(a+b*x)^2,-(a+2*b*x)/(a^2*x*(a+b*x))+2*b/a^3*log((a+b*x)/x))",
65 # 60
66 "f(1/(a+b*x^2),1/sqrt(a*b)*arctan(x*sqrt(a*b)/a),or(not(number(a*b)),a*b>0))",
67 # 61
68 "f(1/(a+b*x^2),1/(2*sqrt(-a*b))*log((a+x*sqrt(-a*b))/(a-x*sqrt(-a*b))),or(not(number(a*b)),a*b<0))",
69 # 62 is the same as 60
70 # 63
71 "f(x/(a+b*x^2),1/2*1/b*log(a+b*x^2))",
72 #64
73 "f(x^2/(a+b*x^2),x/b-a/b*integral(1/(a+b*x^2),x))",
74 #65
75 "f(1/(a+b*x^2)^2,x/(2*a*(a+b*x^2))+1/2*1/a*integral(1/(a+b*x^2),x))",
76 #66 is covered by 61
77 #70
78 "f(1/x*1/(a+b*x^2),1/2*1/a*log(x^2/(a+b*x^2)))",
79 #71
80 "f(1/x^2*1/(a+b*x^2),-1/(a*x)-b/a*integral(1/(a+b*x^2),x))",
81 #74
82 "f(1/(a+b*x^3),1/3*1/a*(a/b)^(1/3)*(1/2*log(((a/b)^(1/3)+x)^3/(a+b*x^3))+sqrt(3)*arctan((2*x-(a/b)^(1/3))*(a/b)^(-1/3)/sqrt(3))))",
83 #76
84 "f(x^2/(a+b*x^3),1/3*1/b*log(a+b*x^3))",
85 # float(defint(1/(2+3*X^4),X,0,pi)) gave wrong result.
86 # Also, the tests related to the indefinite integral
87 # fail since we rationalise expressions "better", so I'm thinking
88 # to take this out completely as it seemed to give the
89 # wrong results in the first place.
90 #77
91 #"f(1/(a+b*x^4),1/2*1/a*(a/b/4)^(1/4)*(1/2*log((x^2+2*(a/b/4)^(1/4)*x+2*(a/b/4)^(1/2))/(x^2-2*(a/b/4)^(1/4)*x+2*(a/b/4)^(1/2)))+arctan(2*(a/b/4)^(1/4)*x/(2*(a/b/4)^(1/2)-x^2))),or(not(number(a*b)),a*b>0))",
92 #78
93 #"f(1/(a+b*x^4),1/2*(-a/b)^(1/4)/a*(1/2*log((x+(-a/b)^(1/4))/(x-(-a/b)^(1/4)))+arctan(x*(-a/b)^(-1/4))),or(not(number(a*b)),a*b<0))",
94 #79
95 "f(x/(a+b*x^4),1/2*sqrt(b/a)/b*arctan(x^2*sqrt(b/a)),or(not(number(a*b)),a*b>0))",
96 #80
97 "f(x/(a+b*x^4),1/4*sqrt(-b/a)/b*log((x^2-sqrt(-a/b))/(x^2+sqrt(-a/b))),or(not(number(a*b)),a*b<0))",
98
99 # float(defint(X^2/(2+3*X^4),X,0,pi)) gave wrong result.
100 # Also, the tests related to the indefinite integral
101 # fail since we rationalise expressions "better", so I'm thinking
102 # to take this out completely as it seemed to give the
103 # wrong results in the first place.
104 #81
105 #"f(x^2/(a+b*x^4),1/4*1/b*(a/b/4)^(-1/4)*(1/2*log((x^2-2*(a/b/4)^(1/4)*x+2*sqrt(a/b/4))/(x^2+2*(a/b/4)^(1/4)*x+2*sqrt(a/b/4)))+arctan(2*(a/b/4)^(1/4)*x/(2*sqrt(a/b/4)-x^2))),or(not(number(a*b)),a*b>0))",
106 #82
107 #"f(x^2/(a+b*x^4),1/4*1/b*(-a/b)^(-1/4)*(log((x-(-a/b)^(1/4))/(x+(-a/b)^(1/4)))+2*arctan(x*(-a/b)^(-1/4))),or(not(number(a*b)),a*b<0))",
108 #83
109 "f(x^3/(a+b*x^4),1/4*1/b*log(a+b*x^4))",
110 #124
111 "f(sqrt(a+b*x),2/3*1/b*sqrt((a+b*x)^3))",
112 #125
113 "f(x*sqrt(a+b*x),-2*(2*a-3*b*x)*sqrt((a+b*x)^3)/15/b^2)",
114 #126
115 "f(x^2*sqrt(a+b*x),2*(8*a^2-12*a*b*x+15*b^2*x^2)*sqrt((a+b*x)^3)/105/b^3)",
116 #128
117 "f(sqrt(a+b*x)/x,2*sqrt(a+b*x)+a*integral(1/x*1/sqrt(a+b*x),x))",
118 #129
119 "f(sqrt(a+b*x)/x^2,-sqrt(a+b*x)/x+b/2*integral(1/x*1/sqrt(a+b*x),x))",
120 #131
121 "f(1/sqrt(a+b*x),2*sqrt(a+b*x)/b)",
122 #132
123 "f(x/sqrt(a+b*x),-2/3*(2*a-b*x)*sqrt(a+b*x)/b^2)",
124 #133
125 "f(x^2/sqrt(a+b*x),2/15*(8*a^2-4*a*b*x+3*b^2*x^2)*sqrt(a+b*x)/b^3)",
126 #135
127 "f(1/x*1/sqrt(a+b*x),1/sqrt(a)*log((sqrt(a+b*x)-sqrt(a))/(sqrt(a+b*x)+sqrt(a))),or(not(number(a)),a>0))",
128 #136
129 "f(1/x*1/sqrt(a+b*x),2/sqrt(-a)*arctan(sqrt(-(a+b*x)/a)),or(not(number(a)),a<0))",
130 #137
131 "f(1/x^2*1/sqrt(a+b*x),-sqrt(a+b*x)/a/x-1/2*b/a*integral(1/x*1/sqrt(a+b*x),x))",
132 #156
133 "f(sqrt(x^2+a),1/2*(x*sqrt(x^2+a)+a*log(x+sqrt(x^2+a))))",
134 #157
135 "f(1/sqrt(x^2+a),log(x+sqrt(x^2+a)))",
136 #158
137 "f(1/x*1/sqrt(x^2+a),arcsec(x/sqrt(-a))/sqrt(-a),or(not(number(a)),a<0))",
138 #159
139 "f(1/x*1/sqrt(x^2+a),-1/sqrt(a)*log((sqrt(a)+sqrt(x^2+a))/x),or(not(number(a)),a>0))",
140 #160
141 "f(sqrt(x^2+a)/x,sqrt(x^2+a)-sqrt(a)*log((sqrt(a)+sqrt(x^2+a))/x),or(not(number(a)),a>0))",
142 #161
143 "f(sqrt(x^2+a)/x,sqrt(x^2+a)-sqrt(-a)*arcsec(x/sqrt(-a)),or(not(number(a)),a<0))",
144 #162
145 "f(x/sqrt(x^2+a),sqrt(x^2+a))",
146 #163
147 "f(x*sqrt(x^2+a),1/3*sqrt((x^2+a)^3))",
148 #164 need an unexpanded version?
149 "f(sqrt(a+x^6+3*a^(1/3)*x^4+3*a^(2/3)*x^2),1/4*(x*sqrt((x^2+a^(1/3))^3)+3/2*a^(1/3)*x*sqrt(x^2+a^(1/3))+3/2*a^(2/3)*log(x+sqrt(x^2+a^(1/3)))))",
150 # match doesn't work for the following
151 "f(sqrt(-a+x^6-3*a^(1/3)*x^4+3*a^(2/3)*x^2),1/4*(x*sqrt((x^2-a^(1/3))^3)-3/2*a^(1/3)*x*sqrt(x^2-a^(1/3))+3/2*a^(2/3)*log(x+sqrt(x^2-a^(1/3)))))",
152 #165
153 "f(1/sqrt(a+x^6+3*a^(1/3)*x^4+3*a^(2/3)*x^2),x/a^(1/3)/sqrt(x^2+a^(1/3)))",
154 #166
155 "f(x/sqrt(a+x^6+3*a^(1/3)*x^4+3*a^(2/3)*x^2),-1/sqrt(x^2+a^(1/3)))",
156 #167
157 "f(x*sqrt(a+x^6+3*a^(1/3)*x^4+3*a^(2/3)*x^2),1/5*sqrt((x^2+a^(1/3))^5))",
158 #168
159 "f(x^2*sqrt(x^2+a),1/4*x*sqrt((x^2+a)^3)-1/8*a*x*sqrt(x^2+a)-1/8*a^2*log(x+sqrt(x^2+a)))",
160 #169
161 "f(x^3*sqrt(x^2+a),(1/5*x^2-2/15*a)*sqrt((x^2+a)^3),and(number(a),a>0))",
162 #170
163 "f(x^3*sqrt(x^2+a),sqrt((x^2+a)^5)/5-a*sqrt((x^2+a)^3)/3,and(number(a),a<0))",
164 #171
165 "f(x^2/sqrt(x^2+a),1/2*x*sqrt(x^2+a)-1/2*a*log(x+sqrt(x^2+a)))",
166 #172
167 "f(x^3/sqrt(x^2+a),1/3*sqrt((x^2+a)^3)-a*sqrt(x^2+a))",
168 #173
169 "f(1/x^2*1/sqrt(x^2+a),-sqrt(x^2+a)/a/x)",
170 #174
171 "f(1/x^3*1/sqrt(x^2+a),-1/2*sqrt(x^2+a)/a/x^2+1/2*log((sqrt(a)+sqrt(x^2+a))/x)/a^(3/2),or(not(number(a)),a>0))",
172 #175
173 "f(1/x^3*1/sqrt(x^2-a),1/2*sqrt(x^2-a)/a/x^2+1/2*1/(a^(3/2))*arcsec(x/(a^(1/2))),or(not(number(a)),a>0))",
174 #176+
175 "f(x^2*sqrt(a+x^6+3*a^(1/3)*x^4+3*a^(2/3)*x^2),1/6*x*sqrt((x^2+a^(1/3))^5)-1/24*a^(1/3)*x*sqrt((x^2+a^(1/3))^3)-1/16*a^(2/3)*x*sqrt(x^2+a^(1/3))-1/16*a*log(x+sqrt(x^2+a^(1/3))),or(not(number(a)),a>0))",
176 #176-
177 "f(x^2*sqrt(-a-3*a^(1/3)*x^4+3*a^(2/3)*x^2+x^6),1/6*x*sqrt((x^2-a^(1/3))^5)+1/24*a^(1/3)*x*sqrt((x^2-a^(1/3))^3)-1/16*a^(2/3)*x*sqrt(x^2-a^(1/3))+1/16*a*log(x+sqrt(x^2-a^(1/3))),or(not(number(a)),a>0))",
178 #177+
179 "f(x^3*sqrt(a+x^6+3*a^(1/3)*x^4+3*a^(2/3)*x^2),1/7*sqrt((x^2+a^(1/3))^7)-1/5*a^(1/3)*sqrt((x^2+a^(1/3))^5),or(not(number(a)),a>0))",
180 #177-
181 "f(x^3*sqrt(-a-3*a^(1/3)*x^4+3*a^(2/3)*x^2+x^6),1/7*sqrt((x^2-a^(1/3))^7)+1/5*a^(1/3)*sqrt((x^2-a^(1/3))^5),or(not(number(a)),a>0))",
182 #196
183 "f(1/(x-a)/sqrt(x^2-a^2),-sqrt(x^2-a^2)/a/(x-a))",
184 #197
185 "f(1/(x+a)/sqrt(x^2-a^2),sqrt(x^2-a^2)/a/(x+a))",
186 #200+
187 "f(sqrt(a-x^2),1/2*(x*sqrt(a-x^2)+a*arcsin(x/sqrt(abs(a)))))",
188 #201 (seems to be handled somewhere else)
189 #202
190 "f(1/x*1/sqrt(a-x^2),-1/sqrt(a)*log((sqrt(a)+sqrt(a-x^2))/x),or(not(number(a)),a>0))",
191 #203
192 "f(sqrt(a-x^2)/x,sqrt(a-x^2)-sqrt(a)*log((sqrt(a)+sqrt(a-x^2))/x),or(not(number(a)),a>0))",
193 #204
194 "f(x/sqrt(a-x^2),-sqrt(a-x^2))",
195 #205
196 "f(x*sqrt(a-x^2),-1/3*sqrt((a-x^2)^3))",
197 #210
198 "f(x^2*sqrt(a-x^2),-x/4*sqrt((a-x^2)^3)+1/8*a*(x*sqrt(a-x^2)+a*arcsin(x/sqrt(a))),or(not(number(a)),a>0))",
199 #211
200 "f(x^3*sqrt(a-x^2),(-1/5*x^2-2/15*a)*sqrt((a-x^2)^3),or(not(number(a)),a>0))",
201 #214
202 "f(x^2/sqrt(a-x^2),-x/2*sqrt(a-x^2)+a/2*arcsin(x/sqrt(a)),or(not(number(a)),a>0))",
203 #215
204 "f(1/x^2*1/sqrt(a-x^2),-sqrt(a-x^2)/a/x,or(not(number(a)),a>0))",
205 #216
206 "f(sqrt(a-x^2)/x^2,-sqrt(a-x^2)/x-arcsin(x/sqrt(a)),or(not(number(a)),a>0))",
207 #217
208 "f(sqrt(a-x^2)/x^3,-1/2*sqrt(a-x^2)/x^2+1/2*log((sqrt(a)+sqrt(a-x^2))/x)/sqrt(a),or(not(number(a)),a>0))",
209 #218
210 "f(sqrt(a-x^2)/x^4,-1/3*sqrt((a-x^2)^3)/a/x^3,or(not(number(a)),a>0))",
211 # 273
212 "f(sqrt(a*x^2+b),x*sqrt(a*x^2+b)/2+b*log(x*sqrt(a)+sqrt(a*x^2+b))/2/sqrt(a),and(number(a),a>0))",
213 # 274
214 "f(sqrt(a*x^2+b),x*sqrt(a*x^2+b)/2+b*arcsin(x*sqrt(-a/b))/2/sqrt(-a),and(number(a),a<0))",
215 # 290
216 "f(sin(a*x),-cos(a*x)/a)",
217 # 291
218 "f(cos(a*x),sin(a*x)/a)",
219 # 292
220 "f(tan(a*x),-log(cos(a*x))/a)",
221 # 293
222 "f(1/tan(a*x),log(sin(a*x))/a)",
223 # 294
224 "f(1/cos(a*x),log(tan(pi/4+a*x/2))/a)",
225 # 295
226 "f(1/sin(a*x),log(tan(a*x/2))/a)",
227 # 296
228 "f(sin(a*x)^2,x/2-sin(2*a*x)/(4*a))",
229 # 297
230 "f(sin(a*x)^3,-cos(a*x)*(sin(a*x)^2+2)/(3*a))",
231 # 298
232 "f(sin(a*x)^4,3/8*x-sin(2*a*x)/(4*a)+sin(4*a*x)/(32*a))",
233 # 302
234 "f(cos(a*x)^2,x/2+sin(2*a*x)/(4*a))",
235 # 303
236 "f(cos(a*x)^3,sin(a*x)*(cos(a*x)^2+2)/(3*a))",
237 # 304
238 "f(cos(a*x)^4,3/8*x+sin(2*a*x)/(4*a)+sin(4*a*x)/(32*a))",
239 # 308
240 "f(1/sin(a*x)^2,-1/(a*tan(a*x)))",
241 # 312
242 "f(1/cos(a*x)^2,tan(a*x)/a)",
243 # 318
244 "f(sin(a*x)*cos(a*x),sin(a*x)^2/(2*a))",
245 # 320
246 "f(sin(a*x)^2*cos(a*x)^2,-sin(4*a*x)/(32*a)+x/8)",
247 # 326
248 "f(sin(a*x)/cos(a*x)^2,1/(a*cos(a*x)))",
249 # 327
250 "f(sin(a*x)^2/cos(a*x),(log(tan(pi/4+a*x/2))-sin(a*x))/a)",
251 # 328
252 "f(cos(a*x)/sin(a*x)^2,-1/(a*sin(a*x)))",
253 # 329
254 "f(1/(sin(a*x)*cos(a*x)),log(tan(a*x))/a)",
255 # 330
256 "f(1/(sin(a*x)*cos(a*x)^2),(1/cos(a*x)+log(tan(a*x/2)))/a)",
257 # 331
258 "f(1/(sin(a*x)^2*cos(a*x)),(log(tan(pi/4+a*x/2))-1/sin(a*x))/a)",
259 # 333
260 "f(1/(sin(a*x)^2*cos(a*x)^2),-2/(a*tan(2*a*x)))",
261 # 335
262 "f(sin(a+b*x),-cos(a+b*x)/b)",
263 # 336
264 "f(cos(a+b*x),sin(a+b*x)/b)",
265 # 337+ (with the addition of b)
266 "f(1/(b+b*sin(a*x)),-tan(pi/4-a*x/2)/a/b)",
267 # 337- (with the addition of b)
268 "f(1/(b-b*sin(a*x)),tan(pi/4+a*x/2)/a/b)",
269 # 338 (with the addition of b)
270 "f(1/(b+b*cos(a*x)),tan(a*x/2)/a/b)",
271 # 339 (with the addition of b)
272 "f(1/(b-b*cos(a*x)),-1/tan(a*x/2)/a/b)",
273 # 340
274 "f(1/(a+b*sin(x)),1/sqrt(b^2-a^2)*log((a*tan(x/2)+b-sqrt(b^2-a^2))/(a*tan(x/2)+b+sqrt(b^2-a^2))),b^2-a^2)", # check that b^2-a^2 is not zero
275 # 341
276 "f(1/(a+b*cos(x)),1/sqrt(b^2-a^2)*log((sqrt(b^2-a^2)*tan(x/2)+a+b)/(sqrt(b^2-a^2)*tan(x/2)-a-b)),b^2-a^2)", # check that b^2-a^2 is not zero
277 # 389
278 "f(x*sin(a*x),sin(a*x)/a^2-x*cos(a*x)/a)",
279 # 390
280 "f(x^2*sin(a*x),2*x*sin(a*x)/a^2-(a^2*x^2-2)*cos(a*x)/a^3)",
281 # 393
282 "f(x*cos(a*x),cos(a*x)/a^2+x*sin(a*x)/a)",
283 # 394
284 "f(x^2*cos(a*x),2*x*cos(a*x)/a^2+(a^2*x^2-2)*sin(a*x)/a^3)",
285 # 441
286 "f(arcsin(a*x),x*arcsin(a*x)+sqrt(1-a^2*x^2)/a)",
287 # 442
288 "f(arccos(a*x),x*arccos(a*x)-sqrt(1-a^2*x^2)/a)",
289 # 443
290 "f(arctan(a*x),x*arctan(a*x)-1/2*log(1+a^2*x^2)/a)",
291 # 485 (with addition of a)
292 "f(log(a*x),x*log(a*x)-x)",
293 # 486 (with addition of a)
294 "f(x*log(a*x),x^2*log(a*x)/2-x^2/4)",
295 # 487 (with addition of a)
296 "f(x^2*log(a*x),x^3*log(a*x)/3-1/9*x^3)",
297 # 489
298 "f(log(x)^2,x*log(x)^2-2*x*log(x)+2*x)",
299 # 493 (with addition of a)
300 "f(1/x*1/(a+log(x)),log(a+log(x)))",
301 # 499
302 "f(log(a*x+b),(a*x+b)*log(a*x+b)/a-x)",
303 # 500
304 "f(log(a*x+b)/x^2,a/b*log(x)-(a*x+b)*log(a*x+b)/b/x)",
305 # 554
306 "f(sinh(x),cosh(x))",
307 # 555
308 "f(cosh(x),sinh(x))",
309 # 556
310 "f(tanh(x),log(cosh(x)))",
311 # 560
312 "f(x*sinh(x),x*cosh(x)-sinh(x))",
313 # 562
314 "f(x*cosh(x),x*sinh(x)-cosh(x))",
315 # 566
316 "f(sinh(x)^2,sinh(2*x)/4-x/2)",
317 # 569
318 "f(tanh(x)^2,x-tanh(x))",
319 # 572
320 "f(cosh(x)^2,sinh(2*x)/4+x/2)",
321 # ?
322 "f(x^3*exp(a*x^2),exp(a*x^2)*(x^2/a-1/(a^2))/2)",
323 # ?
324 "f(x^3*exp(a*x^2+b),exp(a*x^2)*exp(b)*(x^2/a-1/(a^2))/2)",
325 # ?
326 "f(exp(a*x^2),-i*sqrt(pi)*erf(i*sqrt(a)*x)/sqrt(a)/2)",
327 # ?
328 "f(erf(a*x),x*erf(a*x)+exp(-a^2*x^2)/a/sqrt(pi))",
329
330 # these are needed for the surface integral in the manual
331
332 "f(x^2*(1-x^2)^(3/2),(x*sqrt(1-x^2)*(-8*x^4+14*x^2-3)+3*arcsin(x))/48)",
333 "f(x^2*(1-x^2)^(5/2),(x*sqrt(1-x^2)*(48*x^6-136*x^4+118*x^2-15)+15*arcsin(x))/384)",
334 "f(x^4*(1-x^2)^(3/2),(-x*sqrt(1-x^2)*(16*x^6-24*x^4+2*x^2+3)+3*arcsin(x))/128)",
335
336 "f(x*exp(a*x),exp(a*x)*(a*x-1)/(a^2))",
337 "f(x*exp(a*x+b),exp(a*x+b)*(a*x-1)/(a^2))",
338
339 "f(x^2*exp(a*x),exp(a*x)*(a^2*x^2-2*a*x+2)/(a^3))",
340 "f(x^2*exp(a*x+b),exp(a*x+b)*(a^2*x^2-2*a*x+2)/(a^3))",
341
342 "f(x^3*exp(a*x),exp(a*x)*x^3/a-3/a*integral(x^2*exp(a*x),x))",
343 "f(x^3*exp(a*x+b),exp(a*x+b)*x^3/a-3/a*integral(x^2*exp(a*x+b),x))",
344 0
345
346]
347
348
349#define F p3
350#define X p4
351#define N p5
352
353Eval_integral = ->
354 i = 0
355 n = 0
356
357 # evaluate 1st arg to get function F
358
359 p1 = cdr(p1)
360 push(car(p1))
361 Eval()
362
363 # evaluate 2nd arg and then...
364
365 # example result of 2nd arg what to do
366 #
367 # integral(f) nil guess X, N = nil
368 # integral(f,2) 2 guess X, N = 2
369 # integral(f,x) x X = x, N = nil
370 # integral(f,x,2) x X = x, N = 2
371 # integral(f,x,y) x X = x, N = y
372
373 p1 = cdr(p1)
374 push(car(p1))
375 Eval()
376
377 p2 = pop()
378 if (p2 == symbol(NIL))
379 guess()
380 push(symbol(NIL))
381 else if (isnum(p2))
382 guess()
383 push(p2)
384 else
385 push(p2)
386 p1 = cdr(p1)
387 push(car(p1))
388 Eval()
389
390 p5 = pop()
391 p4 = pop()
392 p3 = pop()
393
394 while (1)
395
396 # N might be a symbol instead of a number
397
398 if (isnum(p5))
399 push(p5)
400 n = pop_integer()
401 if (isNaN(n))
402 stop("nth integral: check n")
403 else
404 n = 1
405
406 push(p3)
407
408 if (n >= 0)
409 for i in [0...n]
410 push(p4)
411 integral()
412 else
413 n = -n
414 for i in [0...n]
415 push(p4)
416 derivative()
417
418 p3 = pop()
419
420 # if N is nil then arglist is exhausted
421
422 if (p5 == symbol(NIL))
423 break
424
425 # otherwise...
426
427 # N arg1 what to do
428 #
429 # number nil break
430 # number number N = arg1, continue
431 # number symbol X = arg1, N = arg2, continue
432 #
433 # symbol nil X = N, N = nil, continue
434 # symbol number X = N, N = arg1, continue
435 # symbol symbol X = N, N = arg1, continue
436
437 if (isnum(p5))
438 p1 = cdr(p1)
439 push(car(p1))
440 Eval()
441 p5 = pop()
442 if (p5 == symbol(NIL))
443 break; # arglist exhausted
444 if (isnum(p5))
445 doNothing = 1 # N = arg1
446 else
447 p4 = p5; # X = arg1
448 p1 = cdr(p1)
449 push(car(p1))
450 Eval()
451 p5 = pop(); # N = arg2
452 else
453 p4 = p5; # X = N
454 p1 = cdr(p1)
455 push(car(p1))
456 Eval()
457 p5 = pop(); # N = arg1
458
459 push(p3); # final result
460
461integral = ->
462 save()
463 p2 = pop()
464 p1 = pop()
465 if (car(p1) == symbol(ADD))
466 integral_of_sum()
467 else if (car(p1) == symbol(MULTIPLY))
468 integral_of_product()
469 else
470 integral_of_form()
471 p1 = pop()
472 if (Find(p1, symbol(INTEGRAL)))
473 stop("integral: sorry, could not find a solution")
474 push(p1)
475 simplify(); # polish the result
476 Eval(); # normalize the result
477 restore()
478
479integral_of_sum = ->
480 p1 = cdr(p1)
481 push(car(p1))
482 push(p2)
483 integral()
484 p1 = cdr(p1)
485 while (iscons(p1))
486 push(car(p1))
487 push(p2)
488 integral()
489 add()
490 p1 = cdr(p1)
491
492integral_of_product = ->
493 push(p1)
494 push(p2)
495 partition()
496 p1 = pop(); # pop variable part
497 integral_of_form()
498 multiply(); # multiply constant part
499
500integral_of_form = ->
501 push(p1) # free variable
502 push(p2) # input expression
503 transform(itab, false)
504 p3 = pop()
505 if (p3 == symbol(NIL))
506 push_symbol(INTEGRAL)
507 push(p1)
508 push(p2)
509 list(3)
510 else
511 push(p3)
512
513