# Derivative in Symbolics.jl becomes zero?

**URL:** <https://discourse.julialang.org/t/derivative-in-symbolics-jl-becomes-zero/72491>\
**Category:** General Usage\
**Created:** [December 2, 2021, 8:51pm UTC](https://discourse.julialang.org/t/derivative-in-symbolics-jl-becomes-zero/72491 "2021-12-02T20:51:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [December 2, 2021, 8:51pm UTC](https://discourse.julialang.org/t/derivative-in-symbolics-jl-becomes-zero/72491/1 "2021-12-02T20:51:45Z")

</div>

Hi!

I am playing around with Julia 1.7.0.

I am using this piece of code:

```julia
using Symbolics

@variables x

z1(x) = x
z2 = x

Dx = Differential(x)

expand_derivatives(Dx(z1)) #Gives 0
expand_derivatives(Dx(z2)) #Gives 1, which is correct

```

Obviously I am doing something wrong, properly in the anonymous function. What I want to do is symbolically having a function as a function of x, say z(x), then do a differential and end up with a function I can evaluate dz/dx (x) - how would I go about that?

Kind regards

---

<div class="post-metadata">

**Author:** ![tomaklutfu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomaklutfu/32/2411_2.png) [@tomaklutfu](https://discourse.julialang.org/u/tomaklutfu)\
**Post date:** [December 3, 2021, 5:32am UTC](https://discourse.julialang.org/t/derivative-in-symbolics-jl-becomes-zero/72491/2 "2021-12-03T05:32:22Z")

</div>

> [@Ahmed\_Salih](#):
>
> `expand_derivatives(Dx(z1))`

Maybe you need to call with `x`, otherwise, it doesn’t know the argument to the function.

`expand_derivatives(Dx(z1(x)))`

---

<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:** [December 4, 2021, 2:47pm UTC](https://discourse.julialang.org/t/derivative-in-symbolics-jl-becomes-zero/72491/3 "2021-12-04T14:47:28Z")

</div>

```julia
using Symbolics
@variables x z1(x)
Dx = Differential(x)
expand_derivatives(Dx(z1)) # Differential(x)(z1(x))

```
