1 | initial version |

Ideally you should be able to do something like

```
Dh=h(x).diff(x).operator()
dg.substitute_function(Dh,f)
```

but unfortunately that doesn't work. I think it's a bug that it doesn't. Perhaps it can be fixed in the future.

A workaround is to define your function h so that it knows what its derivative is. For instance, you could just define h to be an antiderivative:

```
hprime=function('hprime')
h=hprime(x).integrate(x).function(x)
```

Then you can just execute your original code:

```
g=h(f(x,a,b));
dg=diff(g,x);
```

and then dg will be:

```
(a + b)*x^(a + b - 1)*hprime(x^(a + b))
```

Alternatively, you could define g as a symbolic function that knows what its derivative is called. This is a little technical and poorly documented, because it's probably intended for internal use:

```
hprime=function('hprime')
h=function('h',tderivative_func=lambda self,x,diff_param: hprime(x))
```

This produces the same result for dg, while preserving a concise form for g.

2 | No.2 Revision |

Ideally you should be able to do something like

```
Dh=h(x).diff(x).operator()
dg.substitute_function(Dh,f)
```

but unfortunately that doesn't work. I think it's a bug that it doesn't. Perhaps it can be fixed in the future.

A workaround is to define your function h so that it knows what its derivative is. For instance, you could just define h to be an antiderivative:

```
hprime=function('hprime')
h=hprime(x).integrate(x).function(x)
```

Then you can just execute your original code:

```
g=h(f(x,a,b));
dg=diff(g,x);
```

and then dg will be:

```
(a + b)*x^(a + b - 1)*hprime(x^(a + b))
```

Alternatively, you could define g as a symbolic function that knows what its derivative is called. This is a little technical and poorly documented, because it's probably intended for internal use:

```
hprime=function('hprime')
```~~h=function('h',tderivative_func=lambda self,x,diff_param: hprime(x))
~~h=function('h',derivative_func=lambda self,*args,**kwargs: hprime(*args))

This produces the same result for dg, while preserving a concise form for g.

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.