# Is there a shortcut to construct derivatives of a product using Symbolics?

**URL:** <https://discourse.julialang.org/t/is-there-a-shortcut-to-construct-derivatives-of-a-product-using-symbolics/79144>\
**Category:** Numerics\
**Tags:** symbolics\
**Created:** [April 7, 2022, 6:42am UTC](https://discourse.julialang.org/t/is-there-a-shortcut-to-construct-derivatives-of-a-product-using-symbolics/79144 "2022-04-07T06:42:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Post date:** [April 7, 2022, 6:42am UTC](https://discourse.julialang.org/t/is-there-a-shortcut-to-construct-derivatives-of-a-product-using-symbolics/79144/1 "2022-04-07T06:42:54Z")

</div>

This is a rather basic question, as I’ve just started using `Symbolics.jl` and couldn’t find this in the docs after a brief glance. What I want to do is evaluate `f -> (d/dx)(x * f)`. I have figured out one way to achieve this:

```julia
julia> @variables x
1-element Vector{Num}:
 x

julia> D = Differential(x)
(::Differential) (generic function with 2 methods)

julia> f = y -> D(x*y)
#1 (generic function with 1 method)

julia> f(x)
Differential(x)(x^2)

julia> expand_derivatives(f(x))
2x

julia> expand_derivatives(f(x^3))
4(x^3)

```

I was wondering if there’s a short-cut to construct this operator? Initially, I had assumed that it’ll be something like

```julia
julia> D * x
Differential(x) ∘ x

```

but this doesn’t seem to be what I’m after:

```julia
julia> (D * x)(x)
ERROR: Sym x is not callable. Use @syms x(var1, var2,...) to create it as a callable.

```

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [April 7, 2022, 11:47am UTC](https://discourse.julialang.org/t/is-there-a-shortcut-to-construct-derivatives-of-a-product-using-symbolics/79144/2 "2022-04-07T11:47:53Z")

</div>

I don’t think there’s a shortcut. What you showed is a good way to do that, and you can just define a Julia function that creates that if you’re using it a lot.
