Skip to content

Commit 0c262d7

Browse files
Fix differentiation of variables
1 parent e01456a commit 0c262d7

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/differentials.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ function expand_derivatives(O::Operation)
2121
if O.op isa Differential
2222
D = O.op
2323
o = O.args[1]
24+
isa(o, Variable) && return O
2425
return simplify_constants(sum(i->Derivative(o,i)*expand_derivatives(D(o.args[i])),1:length(o.args)))
2526
end
2627

test/derivatives.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,5 @@ jac = ModelingToolkit.calculate_jacobian(sys)
4040
@Unknown a(t) b(a)
4141
@test D(b) Constant(0)
4242

43+
@test expand_derivatives(D(x * y)) == simplify_constants(y*D(x) + x*D(y))
44+
@test_broken expand_derivatives(D(x * y)) == simplify_constants(D(x)*y + x*D(y))

0 commit comments

Comments
 (0)