Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ModelingToolkit"
uuid = "961ee093-0014-501f-94e3-6117800e7a78"
authors = ["Chris Rackauckas <accounts@chrisrackauckas.com>"]
version = "1.2.9"
version = "1.2.10"

[deps]
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
Expand Down
1 change: 1 addition & 0 deletions src/differentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ end

derivative(::typeof(+), args::NTuple{N,Any}, ::Val) where {N} = 1
derivative(::typeof(*), args::NTuple{N,Any}, ::Val{i}) where {N,i} = Operation(*, deleteat!(collect(args), i))
derivative(::typeof(one), args::Tuple{<:Any}, ::Val) = 0

function count_order(x)
@assert !(x isa Symbol) "The variable $x must have an order of differentiation that is greater or equal to 1!"
Expand Down
10 changes: 10 additions & 0 deletions test/derivatives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,13 @@ isequal(ModelingToolkit.derivative(Operation(+, [x*y, y, z]), 1), 1)
Expression[ModelingToolkit.Constant(1) ModelingToolkit.Constant(0)
Differential(t)(x) ModelingToolkit.Constant(1)
ModelingToolkit.Constant(0) ModelingToolkit.Constant(0)])

# issue 252
@variables beta, alpha, delta
@variables x1, x2, x3

# expression
tmp = beta * (alpha * exp(x1) * x2 ^ (alpha - 1) + 1 - delta) / x3
# derivative w.r.t. x1 and x2
t1 = ModelingToolkit.gradient(tmp, [x1, x2])
@test_nowarn ModelingToolkit.gradient(t1[1], [beta])