Symbolic Math in Julia?
Asked Answered
R

4

23

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?

Radon answered 1/7, 2015 at 8:3 Comment(4)
The test failed is due to the underlying reliance on Python and SymPy. The package works just fine if you have that set up properly.Nevertheless
What a weird categorization system then... any intuition behind it?Radon
Well the tests fail, but in general it is nice to know when they pass. In this instance, they fail as there is a dependency on mpmath that isn't installed in the testing framework. However, the tests also fail on travis. There for the reason that the test environment installs an older version of SymPy, so the matrix features don't work. Even with the public failures, for developing it is nice to have tests to make sure things are working as expected. Would a heads up on the githup page make a difference?Nevertheless
Out of curiosity what other symbolic tools have use used and are familiar with?Lichtenfeld
M
23

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:

Marketa answered 12/10, 2016 at 10:56 Comment(0)
M
9

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.

Marketa answered 1/7, 2015 at 8:4 Comment(0)
A
4

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

Aubergine answered 19/4, 2019 at 2:56 Comment(0)
U
0

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.

Udine answered 16/4, 2023 at 7:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.