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

How to define a long symbolic vector using for loop with Symbolics.jl #767

Open
xiang-yu opened this issue Oct 26, 2022 · 2 comments
Open

Comments

@xiang-yu
Copy link

How to define a symbolic vector using for loop with Symbolics.jl?
For example, x=[x1, x2, x3, x4, …, x100], where xi are all variables defined using @variables.
It can be easily done using sympy.jl as
julia> N=100, x = [symbols(“x$i”) for i in 1:N].

For short vector, x = @variables x1, x2, x3 work. However for, 100 or even 1000 long vectors, a for loop would be useful.

Please note that I must use Symbolics.jl for the sake of speed and complicated matrix manipulation.
I am aware of the symbolic arrays introduced at Symbolic arrays · Symbolics.jl 1,
but it does not work for my purpose.

@bowenszhu
Copy link
Member

See #694 (comment)

@xiang-yu
Copy link
Author

Thank you. x = Symbolics.variables(:x, 1:N) works well. Any chance these functions can be added in the manual https://symbolics.juliasymbolics.org/dev/ or Symbolics wiki so that they can be easily searchable?

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

2 participants