Bug fix: Problems with D

When a function f is defined using a second user-defined function g , D(f) doesn't work: it returns unevaluated. It does work if the function g is undefined.

Here the function f is defined using the undefined function g .

> f:= x -> x + g(x); g:='g':
D(f);

f := proc (x) options operator, arrow; x+g(x) end p...

proc (x) options operator, arrow; 1+D(g)(x) end pro...

But now here it is after g has been defined.

> g:= x -> x^2; D(f);

g := proc (x) options operator, arrow; x^2 end proc...

D(f)

What Maple looks for is a procedure named `diff/g` that performs the differentiation of g .

The command makediff(g) produces the procedure `diff/g` , allowing D(f) to work for procedures f defined using g .

The command fixD(f) applies makediff to all user-defined procedures referenced in f , thus allowing D(f) to work.

This works only for global procedures, not local procedures or module exports.

This function is part of the Maple Advisor Database.

Examples:

Defining f using defined function g :

> f:= x -> x*g(x^2);
g:= x -> 1 + x^2;

f := proc (x) options operator, arrow; x*g(x^2) end...

g := proc (x) options operator, arrow; 1+x^2 end pr...

D(f) does not work:

> D(f);

D(f)

Using makediff(g) to make this work:

> makediff(g); D(f);

proc (x) options operator, arrow; g(x^2)+4*x^4 end ...

Another function h defined using both f and g .

> h:= (x,y) -> f(x) + g(y); D[1](h);

h := proc (x, y) options operator, arrow; f(x)+g(y)...

D[1](h)

Using fixD(h) to make D[1](h) work:

> fixD(h); D[1](h);

proc (x, y) options operator, arrow; 1+5*x^4 end pr...

See also:

D , diff , fixD , makediff

Maple Advisor Database R. Israel, 2001