# Substitute multiplication of sine and cosine for a symbolic function

I have one variable and two functions:

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

and the following equation (this is an example, my actual equation has more terms such as +cos(th)+sin(th)):

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

Now, I want cos(th)*sin(th) to be substituted for 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 * pi * cos(th) * sin(th) * diff(omega(th), th)

How can I do it? It should also work for different permutations of the individual components of the equation. For example:

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

I have found that a similar question was asked a long time ago, 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.