# Multiplying Functions and Operators with Symbolics.jl

**URL:** https://discourse.julialang.org/t/multiplying-functions-and-operators-with-symbolics-jl/83406
**Category:** General Usage
**Tags:** symbolics
**Created:** [June 27, 2022, 2:42pm UTC](https://discourse.julialang.org/t/multiplying-functions-and-operators-with-symbolics-jl/83406 "2022-06-27T14:42:00Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![MattM](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@MattM](https://discourse.julialang.org/u/MattM)
#### Post date: [June 27, 2022, 2:42pm UTC](https://discourse.julialang.org/t/multiplying-functions-and-operators-with-symbolics-jl/83406/1 "2022-06-27T14:42:00Z")

</div>

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:

```julia
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.

Thank you for your help.
