luchonacho
luchonacho

Reputation: 7167

Symbolic Math in Julia?

I use Mathematica for symbolic math calculations. I am planning to switch to another language. Matlab (which I use for standard computation stuff) includes this feature but I am looking at the possibility of using Julia, since it seems to be the future. Yet, there seems to be no symbolic tool available (no mention in official documentation). Apparently the only package available (SymPy) says "Test Failed" in the official website (http://pkg.julialang.org/).

Has anyone been able to do this in Julia?

Upvotes: 22

Views: 13717

Answers (4)

TheFibonacciEffect
TheFibonacciEffect

Reputation: 428

I can recommend Symbolics.jl Because it works nicely together with ModelingToolkit.jl, take a lookt at their beginner example:

using ModelingToolkit

@variables t x(t)   # independent and dependent variables
@parameters τ       # parameters
@constants h = 1    # constants have an assigned value
D = Differential(t) # define an operator for the differentiation w.r.t. time

# your first ODE, consisting of a single equation, the equality indicated by ~
@named fol = ODESystem([D(x) ~ (h - x) / τ])

using DifferentialEquations: solve

prob = ODEProblem(fol, [x => 0.0], (0.0, 10.0), [τ => 3.0])
# parameter `τ` can be assigned a value, but constant `h` cannot
sol = solve(prob)

using Plots
plot(sol)

it uses Symbolics.jl to define the variables and then solves the problem using DifferentialEquations.jl.

Upvotes: 0

Reza Afzalan
Reza Afzalan

Reputation: 5746

SymPy Package works fine, it brings Python's Sympy functionality into Julia via PyCall.

SymPy is a Python library for symbolic mathematics. It aims to become a full-featured computer algebra system (CAS) while keeping the code as simple as possible in order to be comprehensible and easily extensible. SymPy is written entirely in Python and does not require any external libraries.

Upvotes: 9

Brandon H. Gomes
Brandon H. Gomes

Reputation: 898

Also, consider the Nemo.jl library which they claim is faster than alternatives like SageMath.

Upvotes: 4

Reza Afzalan
Reza Afzalan

Reputation: 5746

Now, looking at http://pkg.julialang.org/ one could find more candidates to perform symbolic mathematics in julia:

  • SymEngine.jl

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

  • Symata.jl

    a language for symbolic computations and mathematics, where, for the most part, "mathematics" means what it typically does for a scientist or engineer.

  • SymPy.jl

    Julia interface to SymPy via PyCall

Also:

Upvotes: 23

Related Questions