Symbolica Computer Algebra System
symbolica.io
symbolica.io
On my machine, I managed to get a ~300KB long solution from SymPy in under a minute, and a comparable solution from Maxima in a few seconds. Symbolica found a ~84K long solution in about a second... in Colab. That's impressive.
Could you share the equation/code you worked on?
I can't imagine a mathematical object being 84KB long, that's insanely huge
It's not even a particularly large system. Only 6 linear equations.
For my physics research I have worked with expressions that was just shy of a terabyte long and had > 100M terms. The way that works is that you stream terms from disk, perform manipulations on them and write them to disk again. Using a mergesort, terms that add up can be identified by sorting them to be adjacent.
The large polynomials appear in the middle of the computation, often referred to as intermediate expression swell. This also happens when you do a Gaussian elimination or compute greatest common divisors: the final result will be small, but intermediately, the expressions can get large.
I'm looking for something like: here's the particle interaction we will work on, this is a very simple Feynman diagram, and here's the simplified data the LHC gave us about it, here's the resulting equation from which we'll derive a series, etc.
Not looking for how to program it, but actually for seeing the problem structure, and the solution design from beginning to end. (Familiar with high level physics concepts, and comfortable with any math).
For instance symmetric polynomials (x_1^2 + x_2^2 + ...) can describe the state of a system of particles where exchanging any 2 particles does not change the system at all (exchange x_1 and x_2 in the previous expression, same polynomial = same system & state).
If you have a system of equation that you can solve exactly with special polynomials, you can approximate real world system governed by similar equations by using your special polynomials as a starting point and adding a correction to your solution.
There's so much to say about polynomials, but I'll leave you with a basic example that shows how multiplying infinite polynomials allow you to count the number of ways there are to hand you back your change at the till:
The basic units of change are 0.01$, 0.05$, 0.10$, 0.25$, 1$, 5$, 10$, ... For example, you can always give exact change back with only 0.01$.
So the set of all the different amount of change you can produce with 0.01$ is given by the exponents in the following
sum_n>=0 (q^(0.01))^n = q^0 + q^0.01 + q^0.02 + ... q^348.47 + ...
Now we can get all the amounts you can generate with 5 cents:
sum_k>=0 (q^(0.05))^k = q^0 + q^0.05 + q^0.10 + .... and so on for 25cents, 1$, ...
Notice now that given the multiplication properties of polynomials, that multiplying:
(sum_n (q^0.01)^n) * (sum_k (q^0.05)^k) * (sum_l (q^0.10)^l) Will give you all the different amounts you can generate with 0.01, 0.05 and 0.10.
For instance with n=5, k=1, l=0 you get 0.10$
q^(0.01 ^ 5) * q^(0.05 * 1)
You can get 0.10$ with n=10
q^(0.01 * 10)
You can get 0.10$ with l=1
q^(0.10 * 1)
Finally you can get 0.10$ with k=2 q^(0.05 * 2)
So when you multiply
(sum_n (q^0.01)^n) * (sum_k (q^0.05)^k) * (sum_l (q^0.10)^l)
altogether, you get
1 + ... + q^(0.01 * 5) * q^(0.05 * 1) + q^(0.01 * 10) + q^(0.10 * 1) + q^(0.05 * 2) + ... = ... + 4 q ^ (0.10)
There are thus 4 ways of handing back exactly 10 cents.
So for any amount, you take the following: product(c in (0.01, 0.05, 0.10, 0.25,...) (sum_n (q^c)^n) = sum_(a >= 0.01) [Number Of Way To Give Back Change for amount `a`] * q^(a)
So that would be the "generating series" of the number of ways to hand back change.
In this context, polynomials bridge the gaps between combinatorics and analytical computation.
http://xuanji.appspot.com/isicp/
Enjoy.
If you want something offline, I can help you to set Chicken (the interpreter), the depending libraries for SICP and Emacs in no time.
Just make a Taylor approximation of some e.g. transcendental function like sin(x) around some point, and use more and more terms to get a higher precision.
- immediately converges to zero - immediately heads to infinity - is dominated by only a few terms (thus obviating the needs for the other X million terms)
https://link.springer.com/chapter/10.1007/978-3-030-51074-9_...
The proof is 200Gb large. I am quiet sure now even larger proof exists, in particular thet exhaust some combinatorial property on graphs.
Because Symbolica is in early development and the work of a single person for now, one great benefit for us is the dedicated attention we receive. Any bug or feature we're particularly interested in gets immediate attention.
And despite the product being licensed, Symbolica's source-available nature gives us full confidence in the author's long-term intent. We therefore trust that accepting Symbolica as a dependency of the framework we are building will never constitute a point of failure.
Supporting Symbolica's nascent effort and having a direct line of contact with its single author also means it is easy to discuss particular arrangements specific to our use case, such as end-user license requirements.
I expect to see std:: types for everything, proper namespaces, ranges,... not C strings, C arrays, and extern "C".
See CUDA and SYCL.
Also the API reference for C++ is missing in most places.
We should encourage this original approach of licensed source available software, otherwise you end up with either black-boxy Mathematica-like software of xzlib disasters and nothing in between.
Tell it is a C library, and announce C++ support when it is actually available.
It is like shipping JavaScript libraries, and then letting Typescript users having to create .d.ts files by themselves.
In my case, I only care about GPGPU, HLSL and CUDA cover that.
The idea of Symbolica is that you can use it as a library inside your existing projects, which is harder to do with MM since it is its own ecosystem.
Moreover, for personal projects Symbolica is free.
from symbolica import Expression
x = Expression.var('x')
f = Expression.fun('f')
e = x + f(x) + 5
e = e.replace_all(x, 6)
print(e)
In Mathematica, the same thing is e = x + f[x] + 5
e /. x -> 6
What I find striking is that, we know that Python is the most popular language because you don't have to declare your variables or your function headers, and can just start writing the logic of your computation. Then, people keep inventing these mathematics programs in Python, that need you to declare your variables before using them. Set[e,Plus[5,x,f[x]]]
ReplaceAll[e,Rule[x,6]] Expression.parse('x+f(x)+5')
Of course, to refer to a specific variable of the CAS in Python, you need to bind it to a Python variable. There is no way around this.In the end most of the time of the user is not spent on syntax, but on designing algorithms. With Mathematica, you are locked into the Mathematica ecosystem. With Symbolica / sympy and other CASs that are libraries, you can use all the familiar data structures of the language you are coding in.
https://github.com/vermaseren/form
https://en.wikipedia.org/wiki/FORM_(symbolic_manipulation_sy...
I even created a simple tool for squaring matrix elements based on FORM:
https://github.com/vindex10/form-square
Thank you for staying creative, for thinking big and expanding beyond HEP :)
Even by defining functions equally to 0.
But the price is "Contact us for a quote"
Can't they at least give a ballpark number of what the price is? Matlab and Mathematica are about $1000-3000 per year for commercial license, they aren't hiding their price.
https://en.wikipedia.org/wiki/The_Open_Source_Definition
This software is "Source Available":
I used HP 48 (Erable) extensively in college for physics, math, chemistry, and electrical engineering courses. It could simplify systems of equations, symbolically integrate, and solve ordinary and partial diff eqs. Not quite Mathematica or Maple, but Erable was portable before laptops or smartphones were widely available.
If you want to push a CAS, try deriving a general time-dependent for the Schrödinger wave equation (PDF) for hydrogen (1s1). ;)
0. https://en.wikipedia.org/wiki/List_of_computer_algebra_syste...
* Wikipedia is wrong. Erable is included in 48G/GX by default, but it might've been an add-on for 48S/SX.
And for a small team (in this case, one person), getting rid of assholes who just want to rip the project off with minimal effort is a big win.
After all, if you just want to play around with the system you are a hobbyist and can get it for free anyway. Why go to the extra effort of stealing the code?
And if you actually are creating value with the system, don't you think you might want some support?
If your answer in either case is that you would rather cheat the author then there is nothing tangible stopping you, but you just defined who you are and selected yourself out of the class of people the maintainer has to deal with.
I read somewhere here that the free version is restricted (single thread only?). Also the mechanism for offline work sounds like a pain, so if multithreaded and offline is your use case, the case for getting a license key just got murky.
I am wondering about this because it just seems hard to sell source available software. Everybody is complaining about price and license keys. But if you put the software behind an SaaS, and go the subscription way, you avoid all of this trouble. Of course, in this case, that just doesn't seem possible.
Personally, I'd like to sell my software source available and without an SaaS indirection, but I am wondering how to get paid in that scenario.
License keys make the software worse, so there just seems to be a logical problem here in the case of source available software: Why pay for worse software? In case of closed-source software, no such logical problem exists: license keys make the software infinitely better, because otherwise it wouldn't work at all.
> Get a license key for offline use, generated from a licensed Symbolica session. The key will remain valid for 24 hours.
lmao
This is a really impressive project, but the practically always-on requirement - including an internet connection to go offline - is absolutely hilarious.
Also, the requirement for me to "get a quote" to get an idea of how much it'll cost me? I'm not going to even bother trying the free trial. I can tell you how much MatLab cost me for my personal projects - $149.
Now I'm not saying MatLab and this are an apples to apples comparison (not even close), but y'all are chopping yourselves off at the knees.
Symbolica is developed by only one person, so forgive me if I can't get every aspect of the project right on the first try (especially the non-technical part) :) I will see about removing the online on start-up part. It's essentially the only anti-piracy step that I have.
At the moment there is no fixed cost for use in industry, since the price will vary based on the amount of users and other factors.
If he advertises a single-user license for €200, let's say, then each site has to have at least 30 users to make the same kind of money. Unlikely each current site has that many users, so it doesn't make sense to offer single-user licenses if there is the danger that sites will jump to that.
Unfortunately, pirates almost always have it easier than paying customers, since license checks will probably be removed. Though this is hearsay (anyone?), there was "legal piracy" (no, there's no such thing :P) in the license-via-printer-port-dongle-era, since the dongles sometimes failed at the worst of times (e.g. live recording at a studio). So some users/studios bought a license to be legally covered on paper, but used a pirated version.
I live in a "well-connected" country, but a traveling a few kilometers in the wrong direction leaves me in complete radio silence, and sometimes work (academia) has required me to stay at such places for a couple of days. Since you know Rust, I can (and have had the need to) add `--offline` when building, with required crates locally cached. I know many researchers with the need to bring high-tech equipment + software to remote locations for work over many weeks, sometimes months. The need to find a city just to do a software license check would be crazy.
Unfortunately, I also don't have a good solution, other than trying to trust your customers. An online check once, at install, I can possibly live with, even if I've had to do reinstalls from local files in the field as well...
Most people at a university who want to run a computation for a few days will do it on a computer that's permanently connected to the net, I think. Not their laptop.
An exact answer is desired since the final result reveals some structure that can be studied, and because it is very hard to get a numerical result due to the occurrence of spurious poles. For example, evaluating
(1-x)/x - 1/x
numerically is challenging around x=0 even though symbolically it can be made regular.
Evaluating the expression naively near zero you're going to get wild numerical errors, but if you do the symbolic manipulation you're going to notice that it's just equal to -1.
Edit: e.g. consider this interaction I just had with the python interpreter
>>> x=1e-15
>>> (1-x)/x - 1/x
-1.0
>>> x=1e-16
>>> (1-x)/x - 1/x
0.0
you get completely the wrong answer when x = 1e-16 y = Expression.var('y')
e = 1/(x*y+1)
e = e.derivative(x)
md(e.to_latex())
I suppose, the first line should be: x, y = Expression.var('x', 'y') x, y = Expression.vars('x', 'y')
indeedNote that there are also features in Symbolica that are not in Sage, such as numerical integration, pattern matching and term streaming.
so in a sense that's a 'sage feature i'd like to see'
I also can’t quickly find any details about what field/algebra/whatever these cover. If I make a Expression.var, what structure is it assumed to have?
Great job on this project :)
An expression is very general. Each variable and function is commutative and should hold for the complex numbers. For functions you can set if they are symmetric, linear or antisymmetric. Non-commutativity can be emulated by adding an extra argument that determines the ordering or by giving them different names.
If you use the Polynomial class instead of Expression, you can choose the field yourself. This is especially the clear in Rust where most structures are generic over the field. For example:
MultivariatePolynomial<AlgebraicNumberRing<RationalField>>
or
UnivariatePolynomial<FiniteField<u64>>> Non-commutativity can be emulated by adding an extra argument that determines the ordering or by giving them different names.
Would you mind giving an example? (or just tell me it’s in the docs and i’ll look deeper)
f(1,...)*f(2,...)
Then when you do pattern matching with wildcards x_ and y_ you can do f(x_,...)*f(y_,..)
with the requirement that x_ < y_. This way you will know you match them in the expected order and not the other way around.I learned about Monte Carlo integration when looking through the codebase, though, so that was cool!
Some details on this are at https://symbolica.io/docs/pattern_matching.html
By the way, `Cargo.toml` example in the installation section has a significant typo:
symbolica = { "*" } # Should have been just `symbolica = "*"`.I actually had an idea to do an OEM license check in build.rs that compiles out all license checks so that this version can be included in customers' software ^^
Deep down every CAS is about manipulating polynomials :)
Maxima is a system for the manipulation of symbolic and numerical expressions, including differentiation, integration, Taylor series, Laplace transforms, ordinary differential equations, systems of linear equations, polynomials, sets, lists, vectors, matrices and tensors.It is not just a matter of whether a feature is there, it needs to be usable in practice. You cannot use Maxima to do computation with large rational polynomials as this paper shows:
https://arxiv.org/pdf/2304.13418
Symbolica is 10 times faster and uses 60 times less memory than Maxima on a medium-sized problem. The larger sized problem does not run with Maxima. Note that this is tested with an older version of Symbolica, the latest version is even faster.
Sith SBCL, open maxima and run:
load("maximalocal.mac");
:lisp (sb-ext:save-lisp-and-die "maxima-optimised" :toplevel #'run :executable t)
Then you sould run maxima-optimized as the new executable image.Hah...change "Maxima" to "Macsyma" and "Symbolica" to "SMP" and that is close to a slide I remember seeing around 1980 in a presentation by Wolfram and Cole explaining why they had developed a new computer algebra system, SMP, instead of using one of the already available systems.
I don't remember the exact numbers on their slide, but same situation. Existing systems could handle the medium problems that came up in their physics research but were slow and used a lot of memory, and could not do the large problems.
Even Mathematica doesn't pull shit like that.
from symbolica import \*
set_license_key('YOUR_KEY')
print(get_offline_license_key())I make closed-source commercial software at my dayjob, I understand you want to get paid. The trouble is that a featureful CAS either takes decades to build by hand (e.g. Axiom) it relies on a huge amount of FOSS libraries (e.g. Sage), or both (e.g. Mathematica).
Making me "phone home" to check I'm up to date on my subscription to some algebra manipulation algorithms is a non-starter, especially when even a PhD student has to pay. (I know you have a single-threaded free version, but that didn't make much sense when your USP is speed.)
Promises, promises. I don't doubt the author's intentions, but then later the owner(s) get bought out and the new owner doesn't honor that promise. We've seen this kind of stuff way too often in the past.
while i do not believe the author has any obligation to license it under an open-source license, i think people who use it under a proprietary license are being foolish. a cas is an essential tool for day-to-day work, and becoming dependent on a proprietary software vendor for that usually ends badly
(repost from elsethread)
(Not sure though why you mention this Khosla guy, should I even know him?)