symengine/SymEngine.jl

Name: SymEngine.jl

Owner: symengine

Description: Julia wrappers of SymEngine

Created: 2015-06-07 17:41:32.0

Updated: 2018-01-16 11:04:52.0

Pushed: 2017-12-22 15:41:42.0

Homepage:

Size: 131

Language: Julia

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

SymEngine.jl

Build Status Build status

SymEngine SymEngine SymEngine

Julia Wrappers for SymEngine, a fast symbolic manipulation library, written in C++.

Installation

You can install SymEngine.jl by giving the following command.

a> 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.

a> a=symbols(:a); b=symbols(:b)


a> a,b = symbols("a b")
b)

a> @vars a b
b)
Simple expressions

We are going to define an expression using the variables from earlier:

a> ex1 = a + 2(b+2)^2 + 2a + 3(a+1)
+ 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 matricies 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.

a> W = [symbols("W_$i$j") for i in 1:3, j in 1:4]
Array{SymEngine.Basic,2}:
1  W_12  W_13  W_14
1  W_22  W_23  W_24
1  W_32  W_33  W_34
Matrix-vector multiplication

Now using the matrix we can perform matrix operations:

a> W*[1.0, 2.0, 3.0, 4.0]
ement Array{SymEngine.Basic,1}:
*W_11 + 2.0*W_12 + 3.0*W_13 + 4.0*W_14
*W_21 + 2.0*W_22 + 3.0*W_23 + 4.0*W_24
*W_31 + 2.0*W_32 + 3.0*W_33 + 4.0*W_34
Operations
expand
a> expand(a + 2(b+2)^2 + 2a + 3(a+1))
 6*a + 8*b + 2*b^2
subs

Performs subsitution.

a> subs(a^2+(b-2)^2, b=>a)
+ (-2 + a)^2

a> subs(a^2+(b-2)^2, b=>2)


a> subs(a^2+(b-2)^2, a=>2)
(-2 + b)^2

a> subs(a^2+(b-2)^2, a^2=>2)
(-2 + b)^2

a> subs(a^2+(b-2)^2, a=>2, b=>3)

diff

Peforms differentiation

a> diff(a + 2(b+2)^2 + 2a + 3(a+1), b)`
 + b)
License

SymEngine.jl is licensed under MIT open source license.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.