# Multiplying Functions and Operators with Symbolics.jl

Hello,
I am still new to Julia and the Symbolics.jl package.
I am trying to implement a poisson bracket operator :f: = \frac{\partial f}{\partial q} \frac{\partial }{\partial p} - \frac{\partial f}{\partial p} \frac{\partial }{\partial q}.
However, trying to implement this with the below code results in an error “MethodError: no method matching -(::ComposedFunction{Num, Differential}, ::ComposedFunction{Num, Differential})”. From this, I understand that when asked to multiply the Number expression of \frac{\partial f}{\partial q} with a Differential, Symbolics composes them.
Here is the code:

function poisson(f, vars)

pb = 0
indices = [i for i in 1:2:length(vars)]
for i in indices
dq = Differential(vars[i])
dp = Differential(vars[i+1])

dqf = expand_derivatives(dq(f))
dpf = expand_derivatives(dp(f))

pb += dqf * dp - dpf * dq
end
return pb

end


Does there exist a way to do a multiplication instead?
I also tried redefining the * operation as Base.:*(D1::Num, D2::Differential) = (function prod(g); return D1*g; end) ∘ D2, but this results in the same error that you cannot subtract composed functions.