1 /*******************************************************************************
3 * License : GNU General Public License (GPL)
5 * Implementation of the Maxima user functions:
8 * antidiff (fn, var, unk)
10 * See the Maxima reference manual for a documentation.
12 * This file is part of Maxima -- GPL CAS based on DOE-MACSYMA
13 ******************************************************************************/
15 nonzeroandfreeof(xargumentx, eargumente) :=
16 is(eargumente # 0 and freeof(xargumentx, eargumente))$
18 matchdeclare(aargumenta,
19 nonzeroandfreeof(xargumentx),
23 defmatch(linear, aargumenta*xargumentx+bargumentb, xargumentx)$
25 antid(fn, var, unk) :=
26 block( [lclvariablelcl,
35 dvariabled : derivdegree(fn, unk, var),
36 if dvariabled = 0 then
38 tvariablet : integrate(fn, var),
39 if not freeof(nounify(integrate), tvariablet) then
42 return([tvariablet, 0])
44 uvariableu : diff(unk, var, dvariabled),
45 killer(eargumente) := if hipow(eargumente, uvariableu) <= 1 then
47 if linear(fn, uvariableu) = false then
49 tvariablet : expand(fn),
50 if part(tvariablet, 0) # "+" then
51 return([0, tvariablet]),
52 aargumenta : map(killer, tvariablet),
53 return (antid(aargumenta, var, unk)+[0, ratsimp(fn-aargumenta)])
55 tvariablet : subst(diff(unk, var, dvariabled-1), lclvariablelcl,
56 integrate(subst(lclvariablelcl, diff(unk, var, dvariabled-1),
57 expand(aargumenta)), lclvariablelcl)),
58 if not freeof(nounify(integrate), tvariablet) or
59 is(equal(fn,ratsimp(fn-diff(tvariablet,var)))) then
60 return([0, aargumenta*uvariableu]+antid(bargumentb, var, unk)),
61 return([tvariablet, 0]+antid(ratsimp(fn-diff(tvariablet, var)),var,unk))
64 antidiff(fn, var, unk) :=
66 tvariablet : antid(fn, var, unk),
67 return(part(tvariablet, 1)+'integrate(part(tvariablet, 2), var))