Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expand_derivatives fails on simple expression, with only one variable referenced #1262

Open
orebas opened this issue Sep 5, 2024 · 0 comments

Comments

@orebas
Copy link

orebas commented Sep 5, 2024

MWE:

using Symbolics

function main()
	@variables t  b(t)
	D = Differential(t)
	expr = b - ((D(b))^2) * D(D(b))
	expr2 = D(expr)
	display(expr)
	display(expand_derivatives(expr))
	display(expr2)
	display(expand_derivatives(expr2))
end
main()

Error:

ERROR: LoadError: BoundsError: attempt to access 1-element Vector{Any} at index [2]
Stacktrace:
  [1] throw_boundserror(A::Vector{Any}, I::Tuple{Int64})
    @ Base ./essentials.jl:14
  [2] getindex(A::Vector{Any}, i::Int64)
    @ Base ./essentials.jl:915
  [3] expand_derivatives(O::SymbolicUtils.BasicSymbolic{Real}, simplify::Bool; occurrences::SymbolicUtils.BasicSymbolic{Real}) (repeats 2 times)
    @ Symbolics ~/.julia/packages/Symbolics/zuLwn/src/diff.jl:257
  [4] expand_derivatives(O::SymbolicUtils.BasicSymbolic{Real}, simplify::Bool; occurrences::Nothing)
    @ Symbolics ~/.julia/packages/Symbolics/zuLwn/src/diff.jl:257
  [5] expand_derivatives(n::Num, simplify::Bool; occurrences::Nothing)
    @ Symbolics ~/.julia/packages/Symbolics/zuLwn/src/diff.jl:299
  [6] expand_derivatives
    @ ~/.julia/packages/Symbolics/zuLwn/src/diff.jl:298 [inlined]
  [7] expand_derivatives(n::Num)
    @ Symbolics ~/.julia/packages/Symbolics/zuLwn/src/diff.jl:298
  [8] main()
    @ Main ~/MWE-test/v6.jl:12
  [9] top-level scope
    @ ~/MWE-test/v6.jl:15
 [10] include(fname::String)
    @ Main ./sysimg.jl:38
 [11] top-level scope
    @ REPL[4]:1
in expression starting at /home/orebas/MWE-test/v6.jl:15

Using:

  [d1185830] SymbolicUtils v3.6.0
  [0c5d862f] Symbolics v6.6.0

This is probably related to #1126. I found this trying to debug that. However, this error seems to come from a much simpler expression, indeed there is only one variable referenced. So I am skeptical it has to do with variable ordering.

Note that replacing "t" with "x" everywhere eliminates the failure, but that is not a fix because "t" is used in a lot of places as the independent variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant