Derivative in Symbolics.jl becomes zero?

Hi!

I am playing around with Julia 1.7.0.

I am using this piece of code:

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

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

expand_derivatives(Dx(z1(x)))

1 Like
using Symbolics
@variables x z1(x)
Dx    = Differential(x)
expand_derivatives(Dx(z1)) # Differential(x)(z1(x))
1 Like