How to remove the multiple of a function in Sympy

Solution 1:

There are lots of ways depending on exactly what you are doing but e.g.:

In [124]: f = 2 * cos(x)

In [125]: f
Out[125]: 2⋅cos(x)

In [126]: c, m = f.as_coeff_Mul()

In [127]: c
Out[127]: 2

In [128]: m
Out[128]: cos(x)