@@ -61,9 +61,9 @@ $(SIGNATURES)
61
61
62
62
TODO
63
63
"""
64
- function expand_derivatives (O:: Term , simplify= true ; occurances= nothing )
65
- if isa (O . op , Differential)
66
- @assert length (O . args ) == 1
64
+ function expand_derivatives (O:: Symbolic , simplify= true ; occurances= nothing )
65
+ if istree (O) && isa (operation (O) , Differential)
66
+ @assert length (arguments (O) ) == 1
67
67
arg = expand_derivatives (O. args[1 ], false )
68
68
69
69
if occurances == nothing
@@ -75,21 +75,21 @@ function expand_derivatives(O::Term, simplify=true; occurances=nothing)
75
75
76
76
(D, o) = (O. op, arg)
77
77
78
- if ! isa (o, Term )
78
+ if ! istree (o )
79
79
return O # Cannot expand
80
- elseif isa (o . op , Sym)
80
+ elseif isa (operation (o) , Sym)
81
81
return O # Cannot expand
82
- elseif isa (o . op , Differential)
82
+ elseif isa (operation (o) , Differential)
83
83
# The recursive expand_derivatives was not able to remove
84
84
# a nested Differential. We can attempt to differentiate the
85
85
# inner expression wrt to the outer iv. And leave the
86
86
# unexpandable Differential outside.
87
87
if isequal (o. op. x, D. x)
88
88
return O
89
89
else
90
- inner = expand_derivatives (D (o . args [1 ]), false )
90
+ inner = expand_derivatives (D (arguments (o) [1 ]), false )
91
91
# if the inner expression is not expandable either, return
92
- if inner isa Term && operation (inner) isa Differential
92
+ if istree ( inner) && operation (inner) isa Differential
93
93
return O
94
94
else
95
95
return expand_derivatives (o. op (inner), simplify)
@@ -187,7 +187,9 @@ sin(x())
187
187
```
188
188
"""
189
189
derivative_idx (O:: Any , :: Any ) = 0
190
- derivative_idx (O:: Term , idx) = derivative (O. op, (O. args... ,), Val (idx))
190
+ function derivative_idx (O:: Symbolic , idx)
191
+ istree (O) ? derivative (operation (O), (arguments (O)... ,), Val (idx)) : 0
192
+ end
191
193
192
194
# Indicate that no derivative is defined.
193
195
struct NoDeriv
0 commit comments