PhySO: Physical Symbolic Optimization

Φ-SO : Physical Symbolic Optimization

The physical symbolic regression ( Φ-SO ) package physo is a symbolic regression package that fully leverages physical units constraints. For more details see: [Tenachi et al 2023].


Virtual environment

The package has been tested on Unix and OSX. To install the package it is recommend to first create a conda virtual environment:

conda create -n PhySO python=3.8

And activate it:

conda activate PhySO


From the repository root:

Installing essential dependencies :

conda install --file requirements.txt

Installing optional dependencies (for advanced debugging in tree representation) :

conda install --file requirements_display1.txt
pip install -r requirements_display2.txt

Side note regarding CUDA acceleration:

$\Phi$-SO supports CUDA but it should be noted that since the bottleneck of the code is free constant optimization, using CUDA (even on a very high-end GPU) does not improve performances over a CPU and can actually hinder performances.

Installing $\Phi$-SO

Installing physo (from the repository root):

pip install -e .

Testing install

Import test:

>>> import physo

This should result in physo being successfully imported.

Unit tests:

From the repository root:

python -m unittest discover -p "*"

This should result in all tests being successfully passed (except for program_display_UnitTest tests if optional dependencies were not installed).

Getting started

Symbolic regression with default hyperparameters

[Coming soon] In the meantime you can have a look at our demo folder ! :)

Symbolic regression

[Coming soon]

Custom symbolic optimization task

[Coming soon]

Using custom functions

[Coming soon]

Open training loop

[Coming soon]

About performances

The main performance bottleneck of physo is free constant optimization, therefore, performances are almost linearly dependent on the number of free constant optimization steps and on the number of trial expressions per epoch (ie. the batch size).

In addition, it should be noted that generating monitoring plots takes ~3s, therefore we suggest making monitoring plots every >10 epochs for low time / epoch cases.

Summary of expected performances with physo:

Time / epochBatch size# free constfree const 
opti steps
~20s10k215eg: demo_damped_harmonic_oscillatorCPU: Mac M1 
RAM: 16 Go
~30s10k215eg: demo_damped_harmonic_oscillatorCPU: Intel W-2155 10c/20t 
RAM: 128 Go
~250s10k215eg: demo_damped_harmonic_oscillatorGPU: Nvidia GV100 
VRAM : 32 Go
~3s1k215eg: demo_mechanical_energyCPU: Mac M1 
RAM: 16 Go
~3s1k215eg: demo_mechanical_energyCPU: Intel W-2155 10c/20t 
RAM: 128 Go
~4s1k215eg: demo_mechanical_energyGPU: Nvidia GV100 
VRAM : 32 Go

Please note that using a CPU typically results in higher performances than when using a GPU.


Uninstalling the package.

conda deactivate
conda env remove -n PhySO

Citing this work

       author = {{Tenachi}, Wassim and {Ibata}, Rodrigo and {Diakogiannis}, Foivos I.},
        title = "{Deep symbolic regression for physics guided by units constraints: toward the automated discovery of physical laws}",
      journal = {arXiv e-prints},
     keywords = {Astrophysics - Instrumentation and Methods for Astrophysics, Computer Science - Machine Learning, Physics - Computational Physics},
         year = 2023,
        month = mar,
          eid = {arXiv:2303.03192},
        pages = {arXiv:2303.03192},
          doi = {10.48550/arXiv.2303.03192},
archivePrefix = {arXiv},
       eprint = {2303.03192},
 primaryClass = {astro-ph.IM},
       adsurl = {},
      adsnote = {Provided by the SAO/NASA Astrophysics Data System}

Download Details:

Author: WassimTenachi
Source Code: 
License: MIT license

#python #symbol #optimization 

PhySO: Physical Symbolic Optimization

Symata.jl: Language for Symbolic Mathematics


Symbolic mathematics language

Examples and help

Static snapshots of Symata tutorial notebooks at These are the same notebooks found in the TutorialNotebooks directory in this repositoy. But the rendering at nbviewer is better.

Symata-language test directory (note this is symata_test, not test)

Symata functions written in Symata.

When running Symata

  • TAB completion
  • ? Topic (with completion)
  • h"word" regular expression search
  • Help() and Help(topic)

NumericalMethodsforEngineers.jl uses Symata. Example code is found in

If you have a question or a request, or want to contribute, please open an issue here on github.

What is Symata?

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

a language based mostly on expressions, on "evaluating" and rewriting them, like Wolfram, Maple, or Maxima. It is neither a language, nor an extension of a language, that is mostly procedural, or designed around data types and functions, or a hierarchy of classes, etc., like C or Python or Java. Nor is it language like Sage; that is, one meant to provide a unifying interface to a number of mathematics languages with various programming models.

meant to be useful to people who do not like to program computers, as well as those who do. The former includes people who prefer not to think about classes, methods, objects, dispatch, stack traces, etc.

Symata is largely modeled on the pattern matching and evaluation sequence of Mathematica. Evaluation, pattern matching, flow control, etc. are written in Julia. Much of the mathematics and symbolic manipulation is achieved by wrapping SymPy. There are more than 600 functions implemented, including integration, transformation of special functions, expression manipulation, writing and reading expressions to and from a file etc.


Symata is a registered module. It can be installed like this

(v0.7) pkg> add Symata
julia> using Symata
symata> Help()    # type '=' alone on a line to enter symata mode

Symata can be installed on Linux, OSX, and Windows.

Symata depends on the PyCall package and the python SymPy module. You can install SymPy via pip install sympy. Symata is compatible with SymPy v1.0 and v1.2 (and probably v1.1).

Alternatively, you may install SymPy via Conda.jl. When you load Symata with using Symata, sympy is installed automatically via PyCall, which uses Conda. However, to do this, PyCall must be configured to not use you system version of python. If you do not have PyCall installed, do this

julia> ENV["PYTHON"]=""
julia> Pkg.add("PyCall")

If you do have PyCall installed, but it is configured to use your system python, reconfigure it like this.

julia> ENV["PYTHON"]=""

If you use linux, you may have your distribution's sympy package installed and it may be out of date. In this case, try the procedure above, and/or try removing your distribution's sympy package.


SymPy, or sympy, here refers to the python SymPy distribution (sometimes called sympy), not the Julia package SymPy. Symata does not require the Julia package SymPy.jl, which has a different goal.

Symata requires mpmath package for python. This should be automatically installed when installing sympy via PyCall as described above. This also works on OSX. However, if you use pip, you should just be able to run pip install mpmath.

Running Symata

See below for instructions on precompiling Symata to get more-or-less instant start up and many precompiled function calls.

Three environments for running Symata are supported: the Julia REPL, Jupyter, and a dumb terminal.

Symata REPL mode

A Symata mode is added to the Julia REPL. Enter the mode by typing = as the first character. Exit the mode by typing backspace as the first character.

julia> using Symata

symata 1>     # after entering `=`

Under some circumstances, e.g. when using PackageCompiler, the Symata repl is not initialized after the module is loaded. You can initialize it with the exported Julia command run_repl. After this, the repl is entered with the = key. An executable ./scripts/symata is included. It is a (UNIX sh) shell script that just starts julia, loads the module, and enters Symata mode. There is also a script ./scripts/symatap for starting from an image with Symata precompiled. (See below.) Switch between Julia and Symata modes by typing =, or backspace, as the first character on a line. You can do tab completion to see a list of functions and symbols.

Jupyter / IJulia

In [1]:  using Symata

In [2]:  Expand((a+b)^2)

Out[2]:  a^2 + 2a*b + b^2

In [3]:  Julia()   # return to Julia mode

In Jupyter, the Symata expressions In(n) and Out(n) reevaluate the input and output cells. TAB completion works in Jupyter. To see a list of all possible completions, type *[TAB].

Dumb terminal

If you do using Symata in a dumb terminal, the Symata prompt should appear automatically.

sympy shell

From the julia prompt, type isympy() to enter the sympy shell.

NEW! Instant Symata

You can precompile Symata. It will load very quickly and be generally much more responsive. The script ./scripts/ writes a Julia image. The shell script ./scripts/symatap runs Julia with this image and immediately enters the Symata repl. See the contents of these files if you can't run shell scripts on your platform.

Instant Symata with Jupyter

You can install a Jupyter kernel using the precompiled image. You must not insert any whitespace between -J and the path to the image.

julia> using IJulia
julia> installkernel("Symata", "-J/home/username/path/to/")


Run the test suite from the symata prompt with Tests(). This runs tests in the symata_test directory Pkg.test("Symata") runs the same test suite from Julia and some Julia-level unit tests, as well.

Download Details:

Author: jlapeyre
Source Code: 
License: View license

#julia #language #symbol 

Symata.jl: Language for Symbolic Mathematics

SymDict.jl: Dictionaries with Symbol Keys


Convenience functions for dictionaries with Symbol keys.

Create a Dict{Symbol,}:

@SymDict(a=1, b=2)


Capture local variables in a dictionary:

a = 1
b = 2

a = 1
b = 2


Capture varags key,value arguments in a dictionary:

function f(x; option="Option", args...)
    @SymDict(x, option, args...)

f("X", foo="Foo", bar="Bar")


Merge new entries into a dictionary:

d = @SymDict(a=1, b=2)
merge!(d, c=3, d=4)


Convert to/from `Dict{AbstractString,}:

d = @SymDict(a=1, b=2)
d = stringdict(d)


d = symboldict(d)


Download Details:

Author: JuliaCloud
Source Code: 
License: View license

#julia #symbol #key 

SymDict.jl: Dictionaries with Symbol Keys

OpenSoundControl.jl: Open Sound Control for Julia

OSC.jl -- Implementation of the Open Sound Control Serialization Format

OSC.jl provides an implementation of the OSC binary format commonly used in networked control of musical applications. The code is based on a relatively straightforward translation of librtosc(

Sample Usage

i = Int32(          42         ); #integer
f = Float32(        0.25;      ); #float
s =                "string"       #string
b =                 s;            #blob
h = Int64(          -125;      ); #long integer
t = UInt64(         22412;     ); #timetag
d = Float64(        0.125;     ); #double
S =                 "Symbol"      #symbol
c = Char(           'J'        ); #character
r = Int32(          0x12345678 ); #RGBA
m = Array{UInt8,1}( [0x12,0x23,   #midi

msg = OscMsg("/dest", "[ifsbhtdScrmTFNI]", i,f,s,b,h,t,d,S,c,r,m);

This produces:

OSC Message to /dest
    # 1 i:Int32 - 42
    # 2 f:Float32 - 0.25
    # 3 s:String - string
    # 4 b:Blob - Uint8[115 116 114 105 110 103]
    # 5 h:Int32 - -125
    # 6 t:Uint64 - 22412
    # 7 d:Float64 - 0.125
    # 8 S:Symbol - Symbol
    # 9 c:Char - J
    #10 r:RBG - 305419896
    #11 m:Midi - Uint8[18 35 52 69]
    #12 T: - true
    #13 F: - false
    #14 N:Nothing - nothing
    #15 I:Inf - nothing

Accessing the fields is done via the [] operator.

Networked Usage

Most of the usage is going to involve sending the OSC messages over UDP to another program. To do this, first start two julia instances. In the first one run

using Sockets
using OpenSoundControl
sock2 = UDPSocket()
bind(sock2, ip"", 7777)
msg2 = OscMsg(recv(sock2))

The first instance will now wait for the second to send an OSC message. To send the an OSC message, in the second window type.

using Sockets
using OpenSoundControl
sock1 = UDPSocket()
msg1 = OpenSoundControl.message("/hello world", "sSif", "strings", "symbols", Int32(234), Float32(2.3))
send(sock1, ip"", 7777,


  • Port bundle message support from librtosc

Download Details:

Author: fundamental
Source Code: 
License: LGPL-3.0 license

#julia #open

OpenSoundControl.jl: Open Sound Control for Julia

SymbolicUtils.jl: Expression Rewriting and Simplification


SymbolicUtils.jl provides various utilities for symbolic computing. SymbolicUtils.jl is what one would use to build a Computer Algebra System (CAS). If you're looking for a complete CAS, similar to SymPy or Mathematica, see Symbolics.jl. If you want to build a crazy CAS for your weird Octonian algebras, you've come to the right place.

Symbols in SymbolicUtils carry type information. Operations on them propagate this information. A rule-based rewriting language can be used to find subexpressions that satisfy arbitrary conditions and apply arbitrary transformations on the matches. The library also contains a set of useful simplification rules for expressions of numeric symbols and numbers. These can be remixed and extended for special purposes.

If you are a Julia package develper in need of a rule rewriting system for your own types, have a look at the interfacing guide.

Go to the manual

SymbolicUtils.jl is on the general registry and can be added the usual way:

pkg> add SymbolicUtils


julia> using Pkg; Pkg.add("SymbolicUtils")

"I don't want to read your manual, just show me some cool code"

julia> using SymbolicUtils

julia> SymbolicUtils.show_simplified[] = true

julia> @syms x::Real y::Real z::Complex f(::Number)::Real
(x, y, z, f(::Number)::Real)

julia> 2x^2 - y + x^2
(3 * (x ^ 2)) + (-1 * y)

julia> f(sin(x)^2 + cos(x)^2) + z
f(1) + z

julia> r = @rule sinh(im * ~x) => sin(~x)
sinh(im * ~x) => sin(~x)

julia> r(sinh(im * y))

julia> simplify(cos(y)^2 + sinh(im*y)^2, RuleSet([r]))


  • The pattern matcher is an adaption of the one by Gerald Jay Sussman (as seen in 6.945 at MIT), his use of symbolic programming in the book SICM inspired this package.
  • Rewrite.jl and Simplify.jl by Harrison Grodin also inspired this package.


Download Details:

Author: JuliaSymbolics
Source Code: 
License: View license

#julia #symbol #utils 

SymbolicUtils.jl: Expression Rewriting and Simplification

Symbolics.jl: A Fast and Modern CAS for A Fast and Modern Language


Symbolics.jl is a fast and modern Computer Algebra System (CAS) for a fast and modern programming language (Julia). The goal is to have a high-performance and parallelized symbolic algebra system that is directly extendable in the same language as the users.


To install Symbolics.jl, use the Julia package manager:

julia> using Pkg
julia> Pkg.add("Symbolics")


For information on using the package, see the stable documentation. Use the in-development documentation for the version of the documentation which contains the unreleased features.

Relationship to Other Packages

  • SymbolicUtils.jl: This is a rule-rewriting system that is the core of Symbolics.jl. Symbolics.jl builds off of SymbolicUtils.jl to extend it to a whole symbolic algebra system, complete with support for differentiation, solving symbolic systems of equations, etc. If you're looking for the barebones to build a new CAS for specific algebras, SymbolicUtils.jl is that foundation. Otherwise, Symbolics.jl is for you.
  • ModelingToolkit.jl: This is a symbolic-numeric modeling system for the SciML ecosystem. It heavily uses Symbolics.jl for its representation of symbolic equations along with tools like differentiation, and adds the representation of common modeling systems like ODEs, SDEs, and more.


julia> using Symbolics

julia> @variables t x y
julia> D = Differential(t)

julia> z = t + t^2
julia> D(z) # symbolic representation of derivative(t + t^2, t)
Differential(t)(t + t^2)

julia> expand_derivatives(D(z))
1 + 2t

julia> Symbolics.jacobian([x + x*y, x^2 + y],[x, y])
2×2 Matrix{Num}:
 1 + y  x
    2x  1

julia> B = simplify.([t^2 + t + t^2  2t + 4t
                  x + y + y + 2t  x^2 - x^2 + y^2])
2×2 Matrix{Num}:
  t + 2(t^2)   6t
 x + 2t + 2y  y^2

julia> simplify.(substitute.(B, (Dict(x => y^2),)))
2×2 Matrix{Num}:
    t + 2(t^2)   6t
 2t + y^2 + 2y  y^2

julia> substitute.(B, (Dict(x => 2.0, y => 3.0, t => 4.0),))
2×2 Matrix{Num}:
 36.0  24.0
 16.0   9.0


If you use Symbolics.jl, please cite this paper (or see the free arxiv version)

author = {Gowda, Shashi and Ma, Yingbo and Cheli, Alessandro and Gw\'{o}\'{z}zd\'{z}, Maja and Shah, Viral B. and Edelman, Alan and Rackauckas, Christopher},
title = {High-Performance Symbolic-Numerics via Multiple Dispatch},
year = {2022},
issue_date = {September 2021},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
volume = {55},
number = {3},
issn = {1932-2240},
url = {},
doi = {10.1145/3511528.3511535},
abstract = {As mathematical computing becomes more democratized in high-level languages, high-performance symbolic-numeric systems are necessary for domain scientists and engineers to get the best performance out of their machine without deep knowledge of code optimization. Naturally, users need different term types either to have different algebraic properties for them, or to use efficient data structures. To this end, we developed Symbolics.jl, an extendable symbolic system which uses dynamic multiple dispatch to change behavior depending on the domain needs. In this work we detail an underlying abstract term interface which allows for speed without sacrificing generality. We show that by formalizing a generic API on actions independent of implementation, we can retroactively add optimized data structures to our system without changing the pre-existing term rewriters. We showcase how this can be used to optimize term construction and give a 113x acceleration on general symbolic transformations. Further, we show that such a generic API allows for complementary term-rewriting implementations. Exploiting this feature, we demonstrate the ability to swap between classical term-rewriting simplifiers and e-graph-based term-rewriting simplifiers. We illustrate how this symbolic system improves numerical computing tasks by showcasing an e-graph ruleset which minimizes the number of CPU cycles during expression evaluation, and demonstrate how it simplifies a real-world reaction-network simulation to halve the runtime. Additionally, we show a reaction-diffusion partial differential equation solver which is able to be automatically converted into symbolic expressions via multiple dispatch tracing, which is subsequently accelerated and parallelized to give a 157x simulation speedup. Together, this presents Symbolics.jl as a next-generation symbolic-numeric computing environment geared towards modeling and simulation.},
journal = {ACM Commun. Comput. Algebra},
month = {jan},
pages = {92–96},
numpages = {5}

Download Details:

Author: JuliaSymbolics
Source Code: 
License: View license

#julia #symbol #performance 

Symbolics.jl: A Fast and Modern CAS for A Fast and Modern Language

LinearExpressions.jl: Linear Symbolic Expressions for Julia Language


Linear symbolic expressions for the Julia language 


julia> using LinearExpressions

julia> a, b, c, d, w, x, y, z = map(RealVariable, [:a, :b, :c, :d, :w, :x, :y, :z])
8-element Array{TypedVariable{Real},1}:

julia> 2x

julia> 2x + 1
1 + 2x

julia> 4 * (3 + 2x)
12 + 8x

julia> x - x == 0

julia> le = x + y + 2.3 * (w + z) - 3.4 * (a + b) - c - d + 1.23
1.23 - d - 3.4b - 3.4a + y + 2.3w + 2.3z - c + x

julia> le + 3*le
4.92 - 4.0d - 13.6b - 13.6a + 4.0y + 9.2w + 9.2z - 4.0c + 4.0x

julia> [x y; y 1] + [1.5 2; 3 4] * [x 0; z 0]
2x2 Array{LinExpr{Float64,TypedVariable{Real}},2}:
 2.0z+2.5x    y
 y+4.0z+3.0x  1.0

julia> [1 2; 2 1] + [0.0 1.2; 1.2 0.0]*x + 4*eye(2)*y
1    2
2    1


4    0
0    4


0    1.2
1.2    0


Within Julia:


Download Details:

Author: cdsousa
Source Code: 
License: View license

#julia #symbol 

LinearExpressions.jl: Linear Symbolic Expressions for Julia Language

[Announcement] NEM is Launching The Symbol Blockchain with A Native Token (1 XEM = 1 XYM)

The NEM blockchain has come a long way since its launch back in 2015. As one of the earliest and most prominent blockchain platforms, it has built a solid community globally, with XEM.

Later this year, NEM is launching the highly anticipated Symbol public blockchain, and with it XYM, the native currency of the platform. Read this Hackernoon piece to find out more about Symbol’s features and network architecture.

What does this launch mean for those who want to participate in the launch of Symbol, and more specifically what is the migration process from NEM NIS1 to Symbol?

The technology stacks between NEM NIS1 and Symbol are not compatible, meaning the Symbol chain will be introduced in parallel with NIS1. In order to give XEM holders agency throughout the migration, the token allocation of the XYM tokens will be determined by an opt-in process.

By opting-in, XEM holders will obtain an XYM balance equal to that of their XEM balance at the time of the Snapshot.

This article will break down everything you need to know about the opt-in process, snapshot, and how to be an early participant in XYM and Symbol.

#nem #cryptocurrency #symbol #developer #github #react native

[Announcement] NEM is Launching The Symbol Blockchain with A Native Token (1 XEM = 1 XYM)
Rahul  Hickle

Rahul Hickle


Detailed Overview of Well-known Symbols

Detailed Overview of Well-known Symbols
These special symbols are important because they are system properties of objects that allow to define custom behavior. Sounds great, use them to hook into JavaScript!

#javascript #symbol #es2015 #js #development

Detailed Overview of Well-known Symbols