1 (load(pdiff),kill(all), 0);
32 ''(diff(acos(x),x,2))$
34 pderivop(bessel_i,0,1)(n,x);
35 ''(diff(bessel_i(n,x),x))$
37 pderivop(bessel_j,0,1)(n,x);
38 ''(diff(bessel_j(n,x),x))$
40 pderivop(bessel_k,0,1)(n,x);
41 ''(diff(bessel_k(n,x),x))$
43 pderivop(bessel_y,0,1)(n,x);
44 ''(diff(bessel_y(n,x),x))$
46 makelist(pderivop('sqrt,k)(x),k,0,5);
47 ''(makelist(diff(sqrt(x),x,k),k,0,5))$
52 [pderivop("^",1,0)(a,b),pderivop("^",0,1)(a,b), pderivop("^",1,1)(a,b)];
53 ''([diff(a^b,a), diff(a^b,b),diff(a^b,a,1,b,1)])$
55 [pderivop("^^",1,0)(a,b),pderivop("^^",0,1)(a,b), pderivop("^^",1,1)(a,b)];
56 ''([diff(a^^b,a), diff(a^^b,b),diff(a^^b,a,1,b,1)])$
58 [pderivop(".",1,0)(a,b),pderivop(".",0,1)(a,b), pderivop(".",1,1)(a,b)];
59 ''([diff(a.b,a), diff(a.b,b),diff(a.b,a,1,b,1)])$
61 is(op(pderivop(lambda([[x]], x),1)) = 'pderivop);
64 (gradef(ff(a,b),a+b,a-b), [pderivop(ff,1,0)(x,y), pderivop(ff,0,1)(x,y), pderivop(ff,1,1)(x,y)]);
67 errcatch(pderivop(ff,1));
70 (remove(ff,gradef),0);
73 (gradef(ff(a), ff(a-1)), [pderivop(ff)(x), pderivop(ff,1)(x), pderivop(ff,2)(x)]);
74 [ff(x),ff(x-1),ff(x-2)]$
76 (remove(ff,gradef),0);
79 convert_to_diff(pderivop(f[5],1,1)(x,y));
80 ''(diff(f[5](x,y),x,1,y,1))$
82 errcatch(pderivop(f,1,2)(x));
85 errcatch(pderivop(f,1,2)());
88 errcatch(pderivop(f,1,2)(x,x,x));
91 (pderivop(f,x), subst(x = 5,%%));
94 (pderivop(f,x,y), ratsubst(5,x,%%), ratsubst(7,y,%%));
97 (clear_rules(), tellsimpafter(pderivop(f,1)(a),1), tellsimpafter(pderivop(f,2)(a),1),0);
100 subst(x=a, diff(f(x),x,2) + diff(f(x),x));
106 (commute_partial_derivatives : true,0);
109 pderivop(pderivop(f,1,0),0,1) - pderivop(f,1,1);
112 (commute_partial_derivatives : false,0);
115 is(pderivop(pderivop(f,1,0),0,1) = pderivop(f,1,1));
118 (reset(commute_partial_derivatives),0);
121 pderivop(lambda([s], s^2),1)(x);
124 pderivop(lambda([s], 42),1)(x);
127 pderivop(lambda([a,b], f(a,b)))(x,y);
130 pderivop(lambda([a,b], f(a,b)),1,0)(x,y) - diff(f(x,y),x);
133 pderivop(lambda([a,b], f(a,b)),1,1)(x,y) - diff(f(x,y),x,1,y,1);
136 (diff(f(x,y),x,1,y,1), subst([x=1,y=2],%%), %% - at(diff(f(x,y),x,1,y,1),[x=1,y=2]));
139 (f(x) := x^3, g : pderivop(f,1), [op(g), g(6)]);
142 (remfunction(f), remvalue(g),0);
145 (commute_partial_derivatives : true, pderivop(pderivop(f,0,1),1,0));
148 /* examples from pdiff-doc.pdf */
150 ratdisrep(taylor(f(x+x^2),x,0,2));
151 ''(f(0) + at(diff(f(x + x^2),x),x = 0) * x + at(diff(f(x + x^2),x,2),x = 0) * x^2/2)$
153 (f(x - c*t) + f(x + c * t), expand(diff(%%,t,2) - c^2 * diff(%%,x,2)));
156 (diff(f(x,y),x,1,y,1), subst(p(s),y, %%),
157 convert_to_diff(%%), ev(%%, 'diff, 'at));
158 ''(subst(p(s),y, diff(f(x,y),x,1,y,1)))$
160 (tellsimpafter(pderivop(f,1)(1),1),
161 tellsimpafter(pderivop(f,2)(1),2),
162 diff(f(x),x,2) + diff(f(x),x),
169 (tellsimpafter(pderivop(f,1,0)(0,0),a),
170 tellsimpafter(pderivop(f,0,1)(0,0),b),
171 sublis([x = 0, y = 0], diff(f(x,y),x) + diff(f(x,y),y)));
177 (commute_partial_derivatives : true, pderivop(pderivop(f,3,4),1,2));
180 (pderivop(f,1), apply(%%,[z]));
183 (f(x) := x^2, pderivop(f,2), apply(%%,[10]));
189 (pderivop(lambda([x],x^2),1), op(%%));
192 (de : 4*x^2 * 'diff(y,x,2) + 4*x * 'diff(y,x,1) + (x-1)*y = 0,
193 de : subst(g(x^n),y,de),
195 de : radcan(subst(x^(1/n),x, de)),
196 de : block ([ctxt:newcontext(), foo], assume(x >= 0), foo:subst(1/2,n, de), killcontext(ctxt), foo),
197 convert_to_diff(de)),logexpand;
198 x^2 * 'diff(g(x),x,2)+x*'diff(g(x),x,1)+(x^2-1)*g(x)=0$
203 /* end of examples from pdiff-doc.pdf */
205 convert_to_diff([-1,42, 123.0, -7.8b0, x, cos(q), a+b, [], a # b, f(x)]);
206 [-1,42, 123.0, -7.8b0, x, cos(q), a+b, [], a # b, f(x)]$
208 convert_to_diff(f[5](x));
211 convert_to_diff(f[g[5]](x));
214 convert_to_diff(pderviop(f,4,5));
217 convert_to_diff(diff(f(x),x));
220 convert_to_diff(diff(f(x),x,5));
223 convert_to_diff(42 + diff(f(x),x,5) + diff(g(x),x));
224 42 + 'diff(f(x),x,5) + 'diff(g(x),x)$
226 (diff(f(x),x), subst(x=10,%%), convert_to_diff(%%), ev(%%, f(x) := x^7, 'diff, 'at));
229 (diff(f(x),x), subst(x=a,%%), convert_to_diff(%%), ev(%%, f(x) := x^7, 'diff, 'at));
232 (diff(f(x,y),x,1,y,1), subst([x=a,y=b], %%), convert_to_diff(%%), ev(%%, f(x,y) := x^2 * y^2, 'diff, 'at));
238 (tellsimpafter(f(0),6),tellsimpafter(''(subst(x=0, diff(f(x),x))), 28), taylor(f(x),x,0,1));
244 /*chain rule tests */
245 is(equal(diff(f(g(x)),x), diff(g(x),x) * pderivop(f,1)(g(x))));
248 is(equal(diff(f(g(x), h(x)),x), diff(g(x),x) * pderivop(f,1,0)(g(x), h(x)) +
249 diff(h(x),x) * pderivop(f,0,1)(g(x), h(x))));
252 (diff(f(x^3),x), convert_to_diff(%%), ev(%%, f(x) := x^5, diff, at));
255 (diff(f(x^2,x*y),x), subst(x = 1, %%), ev(%%, f(x,y) := x^2 * y^2, diff, at));
256 ''(subst(x=1, diff((x^2)^2 * (x*y)^2,x)))$
258 /* subscripted functions */
266 (pderivop(f[2],1), %%(x), convert_to_diff(%%));
269 (pderivop(f[x],1), %%(x), convert_to_diff(%%));
272 (pderivop(f[2],1,1), %%(x,y), convert_to_diff(%%));
273 'diff(f[2](x,y),x,1,y,1)$
275 (pderivop(f,1,1), %%(x,y), subst(y=10,%%), convert_to_diff(%%), ev(%%, f(x,y) := x^2 * y^2, diff, at));
276 ''(subst(y=10, diff(x^2*y^2,x,1,y,1)))$
278 [pderivop(%pi)(), pderivop(%pi)(a), pderivop(%pi)(a,b,c)];
281 (diff(f(x^2),x), ev(%%, f = sin));
284 /* check that the default for use_pdiff is false */
285 (reset(use_pdiff),0);