I have the following variable and functions:

```
th = var('th')
f = function('f')(th)
omega = function('omega')(th)
```

and the equation:

```
eq = 2*pi*cos(th)*sin(th)*diff(omega,th,th)
```

Now, I want cos(th)*sin(th) to be substituted by f. I have tried the following:

```
eq = eq.substitute(cos(th)*sin(th)==f)
```

and also,

```
expression = cos(th)*sin(th)
eq = eq.substitute_function(expression,f)
```

but when I print eq, I still get:

2

picos(th)sin(th)diff(omega(th), th)

How can I do it then?

I have found that a similar question was asked a long time ago:

https://ask.sagemath.org/question/29349/substitute-expressions-with-cos-and-sin/

where the author commented that maxima.fullratsubst did the job. However, I am not capable of working with it. I have run

```
eq = maxima.fullratsubst(f,cos(th)*sin(th),eq)
```

directly on SageMath, but I guess I am doing something wrong since it does not work.