1 | initial version |

You should use `substitute_function`

, not `subs`

, having first defined `g0*cos(th) + g2`

as a function of `(th, r)`

:

```
sage: G(r, th) = g0 + cos(th)*g2
sage: f = f.substitute_function(function('g'), G)
sage: f
cos(th)*g2(r) + cos(th)*diff(g2(r), r) + g0(r) + diff(g0(r), r)
```

Note that the first argument of `substitute_function`

has to be `function('g')`

because in the declaration `g = function('g')(r, th)`

, you have overwritten the Python variable `g`

by the expression `function('g')(r,th)`

. It would have been better to keep the Python name `g`

for `function('g')`

, i.e. to write

```
sage: g = function('g')
sage: f = g(r, th) + diff(g(r, th), r)
```

Then you can use simply `g`

as the first argument of `substitute_function:`

:

```
sage: f.substitute_function(g, G)
cos(th)*g2(r) + cos(th)*diff(g2(r), r) + g0(r) + diff(g0(r), r)
```

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.