You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Julia Wrappers for SymEngine, a fast symbolic manipulation library, written in C++.
Installation
You can install SymEngine.jl by giving the following command.
julia> Pkg.add("SymEngine")
Quick Start
Working with scalar variables
Defining variables
One can define variables in a few ways. The following three examples are equivalent.
Defining two symbolic variables with the names a and b, and assigning them to julia variables with the same name.
julia> a=symbols(:a); b=symbols(:b)
b
julia> a,b =symbols("a b")
(a, b)
julia>@vars a b
(a, b)
Simple expressions
We are going to define an expression using the variables from earlier:
julia> ex1 = a +2(b+2)^2+2a +3(a+1)
3*a +3*(1+ a) +2*(2+ b)^2
One can see that values are grouped, but no expansion is done.
Working with vector and matrix variables
Defining vectors of variables
A vector of variables can be defined using list comprehension and string interpolation.
julia> [symbols("α_$i") for i in1:3]
3-element Array{SymEngine.Basic,1}:
α_1
α_2
α_3
Defining matrices of variables
Some times one might want to define a matrix of variables.
One can use a matrix comprehension, and string interpolation to create a matrix of variables.
julia> W = [symbols("W_$i$j") for i in1:3, j in1:4]
3×4 Array{Basic,2}:
W_11 W_12 W_13 W_14
W_21 W_22 W_23 W_24
W_31 W_32 W_33 W_34
Matrix-vector multiplication
Now using the matrix we can perform matrix operations: