Hacker Newsnew | past | comments | ask | show | jobs | submit | SPACECADET3D's commentslogin

Pure looks interesting!

You can also use Symbolica in Rust, which also has operator overloading so it will look quite similar. At some point I will also add Julia bindings.


Author of the blog post here. I am happy to answer any questions about the article, pattern matching in general or about Symbolica!


I believe there is a family of programming languages named OBJ that are known as "term re-writing" languages that operate at this symbolic/syntatic level.

Are you familiar with them? How does Symbolica compare/contrast with them?

https://en.m.wikipedia.org/wiki/OBJ_(programming_language)

(While OBJ is old, there are some newer /recent decendents from its family)


Not the author of Symbolica but I will take a stab at responding. Symbolica is fundamentally a CAS (computer algebra system) so it should be compared with other CAS. And compared with other CAS, Symbolica aims to provide much better performance. In addition it is much more hackable, being written from scratch in Rust.


What software did you use to generate the graphs?


I used mermaid, which gets live-compiled on the website, that is built using quarto. Here is an example:

```{mermaid} flowchart LR A -- 1 --- B B -- 2 --- C B -- 8 --- E C -- 3 --- D C -- 9 --- F D -- 10 --- E D -- 4 --- G G -- 5 --- H G -- 6 --- F E -- 9 --- F ```



I am using GMP indeed, through the Rust crate `rug`.


Thanks for the reply! If you don't mind asking more: what do you use for polynomial GCD? Apparently it is quite fast, do you use some standard algorithm implemented well or is there some kind of algorithmic improvement? Is it described somewhere, say a paper or a book? Have you tried to benchmark it against NTL, for example? Thanks again!


You can also just use

    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.


Thanks for the feedback! I will see if I can slow down the slideshow. You can see more demos in the docs and the live notebook.

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


Thanks for the quick answer! I had only looked at the python API docs, so I missed that. I’ve just been wrapping up learning a bunch of Lie theory and will keep symbolica in mind next time I want to play with some big nasty expressions!

> 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)


It's not a language specific feature, but you can do the bookkeeping yourself. In the simplest form you can write:

    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've actually been a developer of FORM since my PhD (which I did with the author of FORM, Jos Vermaseren)! In Symbolica, I am taking the best features of FORM, while making it easier to use.


Exciting! I've never been an active user, but I always appreciated it as a core tool in QFT calculations.

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 :)


I've never got to solve a simple equation under Form. Everything else looks easy, as most of the answers are either tautological or factor arrangements without stating explicit units or magnitudes; but I didn't know how to get numerical answers.

Even by defining functions equally to 0.


Symbolica is only a year old, however most features are already in there. What is a Sage feature you'd like to see in Symbolica?

Note that there are also features in Symbolica that are not in Sage, such as numerical integration, pattern matching and term streaming.


while i do not believe you have 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

so in a sense that's a 'sage feature i'd like to see'


I feel similarly. While I myself might gamble on learning a tool like this, I'd be reluctant to recommend it to students unless I was very confident that it would always be there when they reached for it. Source-available does scratch that itch more or less, but it creates some reluctance.


Thanks for reporting, I fixed the typo.

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 ^^


Author of Symbolica here: Symbolica is used in physics calculations to do arithmetic on rational polynomials that are hundreds of megabytes long.

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.


This is fascinating. What is the real-world application of these polynomials? I mean, what technical-scientific problems can only be solved with such large objects? I love the thought of "if I don't solve this enormous polynomial, this solar panel won't have very good efficiency" or something like that.


These polynomials appear when computing Feynman diagrams, which are used to make predictions for the Large Hadron Collider. The collider can measure collisions with such astonishing precision (<1% error) that predictions of the same order are also needed. The more precise you want to be, the more terms in a series approximation of the mathematical description of the collision you need to compute. For example, I computed the fifth-order approximation of the QCD beta function, which governs how intense the strong force affects matter. This takes 5 days of symbolic manipulations (pattern matching, substitutions, rational polynomial arithmetic, etc) on 32 cores.

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.


Is there a document/book you can recommend that includes a simplified example/tutorial of this computation process from beginning to end? (Or, what are the right keywords to search for such a thing?)

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


I like Peskin's Introduction to QFT, but Zee's QFT in a Nutshell is also good.


You can even make a toy-problem with large polynomials yourself.

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.


I used polynomials and specifically special symmetric polynomials extensively during my Phd research (mathematical physics).

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.


That an exercise on SICP, a Scheme learning book. And there are similar ones for Common Lisp.


Say what? I'm always astounded that people think everyone knows all the acronyms for whatever field they're working in.



By just googling 'SICP Scheme' the hints are pretty clear...


The book looks awesome, thanks for pointing out, I'll give it a read.


I forgot. You can do SICP over the web without installing an Scheme interpreter. The web has a complete enough Scheme interpreter to do and eval the whole book exercises.

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.


It will change your life. Did for all of us


While I agree with this attitude towards obscure acronyms, SICP is widely known among those who voluntary enter a site called Hacker News, and it's easily searchable too.


I love how merge-sort which was once used on punch cards because RAM was tight is still relevant. :)


Knuth's section on sorting data on tape drives is surprisingly relevant to big data running over S3 buckets and streaming into compute.


I can remember the days! I suppose as problems grow in size, it's not too surprising that older methods of coping with what seemed like lots of data are still applicable.


Author here: thanks for the feedback. I will add a price range soon. The reason why it is not there in the first place is because I am thinking about site-wide licenses, which are often quote-based (also for Mathematica). For universities site-wide licenses are common, but for industry maybe less so. For reference, a university site-wide license is about 6000 EUR per year at the moment.


6000 ... per month? Per Year? Lifelong?


I have updated the post. It's an annual site-wide license, so not per user.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: