Unable to expand derivatives in modelingtoolkit

using ModelingToolkit
 @variables x y Δy u μ # these are symbols, they are used in symbolic computing

@derivatives δx'~x δy'~y δu'~u δμ'~μ # these are derivatives, they are assigned with macros

expand_derivatives(δu(sqrt(u))δx(x^2+144)+δμ(sqrt(μ))δy(y^2+144)*Δy)

I get an error:

ERROR: MethodError: no method matching (::Differential)(::Num, ::Num)

I think it has something to do with how the brackets are arranged, I though I got it to work and had in save, but I dont’t know what I did different.

expand_derivatives(δu(sqrt(u))δx(x^2+144)+δμ(sqrt(μ))δy(y^2+144)*Δy)

The code you posted in your question works fine:


julia> using ModelingToolkit

julia> @variables x y Δy u μ # these are symbols, they are used in symbolic computing
(x, y, Δy, u, μ)

julia> @derivatives δx'~x δy'~y δu'~u δμ'~μ # these are derivatives, they are assigned with macros
((D'~x), (D'~y), (D'~u), (D'~μ))

julia> expand_derivatives(δu(sqrt(u))δx(x^2+144)+δμ(sqrt(μ))δy(y^2+144)*Δy)
2 * inv(2 * sqrt(u)) * x + 2 * inv(2 * sqrt(μ)) * y * Δy
1 Like

Ok, it might be my computer then, I got something about Julia crashing, and it’s trying to index Julia, but is stuck loading a C/C++ editor.