Skip to content

Commit 726aff0

Browse files
committed
Fix #688
1 parent 46b95cc commit 726aff0

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/differentials.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ function expand_derivatives(O::Term, simplify=true; occurances=nothing)
8787
if isequal(o.op.x, D.x)
8888
return O
8989
else
90-
return expand_derivatives(o.op(expand_derivatives(D(o.args[1]), false)), simplify)
90+
inner = expand_derivatives(D(o.args[1]), false)
91+
# if the inner expression is not expandable either, return
92+
operation(inner) isa Differential && return O
93+
return expand_derivatives(o.op(inner), simplify)
9194
end
9295
end
9396

test/derivatives.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,12 @@ test_equal(expand_derivatives(Differential(x)(L) - ∂ₜ(Differential(∂ₜ(x)
113113

114114
@variables x2(t)
115115
@test isequal(expand_derivatives(Differential(x)(2 * x + x2 * x)), 2 + x2)
116+
117+
@parameters x y
118+
@variables u(..)
119+
@derivatives Dy'~y
120+
@derivatives Dx'~x
121+
dxyu = Dx(Dy(u(x,y)))
122+
@test isequal(expand_derivatives(dxyu), dxyu)
123+
dxxu = Dx(Dx(u(x,y)))
124+
@test isequal(expand_derivatives(dxxu), dxxu)

0 commit comments

Comments
 (0)