Introducing SymJul: Symbolic Analysis for Differential Equations

Dear all,

I’d like to introduce: SymJul (not married to the name)

I’m working on a lot of theory for new nonlinear systems. Sometimes, discretization of the full ODE or PDE works but takes too many computational resources when you only need some information rather than all. For example, dumbing down Maxwell’s equations to the Slowly Varying Envelope Approximation, or using the Chapman-Enskog method or moments method rather than the full Boltzmann equation.

I ran into the efficiency/speed limit with Sympy, and Symengine is just not there yet and in C++ so contributions are limited.

Unfortunately, Symbolics.jl was also lacking and far too difficult to be able to modify and get to work on complex PDEs.

So I decided to use SymbolicUtils.jl as the base and started from there.

As of now, I just have a notebook and functions for differentiation and integration including full evaluation and unevaluated derivatives and integrals.

I’m hoping to others will help out on creating a more robust system.

A couple of things:

  • Not married to the name so we can come up with a better one
  • Converting expressions to latex and displaying has been a struggle
  • I have no idea if my differentiation and integration functions can be more optimized or efficient
  • Not sure how to save expressions or equations in Julia
  • There are some things I haven’t figured out because there’s not enough documentation for SymbolicUtils

My end goal is to be able to do Multiple Scales Perturbation Theory, Homotopy Analysis, Adomian Decomposition Methods , and finally Deep Learning for PDEs

If anyone is interested or thinks they can lead this effort, feel free to start a new repository and take my stuff.

9 Likes

I hate to do this but, have you seen the docs of Symbolics and ModelingToolkit? Build whatever you want but if you’re asking “If anyone is interested or thinks they can lead this effort”, we have a whole MIT lab and a few companies working together on this effort, and we’d love to have any open source contributions.

So basically, ModelingToolkit.jl? Plus some NeuralPDE.jl / MethodOfLines.jl

We have a Mixed Symbolic-Numeric Perturbation Theory · Symbolics.jl .

It has homotropy solvers ModelingToolkit.jl/ext/MTKHomotopyContinuationExt.jl at baefe858e9f34c57c67b0053227ab82e420e98ea · SciML/ModelingToolkit.jl · GitHub and the benchmarks will go up on that soon.

NeuralPDE is deep learning PDE solvers based on the MTK form.

Adomain methods I’m leaving as a GSoC project for a student, but we have other decomposition solvers.

Which PDEs? We already use it for things like multidomain battery models (DFN types of equations). See tutorials like:

That’s already in Symbolics

Is there a reason to not use Symbolics for this?

That is in Symbolics

2 Likes

@ChrisRackauckas no worries! You’re more than welcome to criticize.

Like I said in the post, I’m not interested in mixed Symbolic-Numeric methods. From what I’ve seen in ModelingToolkit.jl, it’s all with the end goal of numerical calculations (which again I’m not interested in).

Which PDEs? We already use it for things like multidomain battery models (DFN types of equations). See tutorials like:

I’m pretty sure I put in an issue on symbolics about it not capable of doing substitutions of symbolic functions. That right there makes it impossible to do analytical methods. Additionally, symbolics handles real and complex numbers separately which again makes it almost impossible to do anything analytically.

Is there a reason to not use Symbolics for this?

Again, see above. For all the rest of your questions it’s the same reason.

You’re more than welcome to correct me if I’m wrong. But I did search through all the documentation and even tried starting in Symbolics until I realized it would just be easier using SymbolicUtils.jl

Feel free to point me in the direction where you believe all of what I would like to do is. If Symbolics is capable of doing this, then perhaps the documentation needs to updated to show this.

1 Like

Symbolics.jl doesn’t even have symbolic integration. Again, you’re more than welcome to direct me in the direction where I can contribute to Symbolics.jl . However, like I said, starting from SymbolicUtils.jl was much easier

Adomain and homotopy are symbolic-numeric unless you have a specific case with an analytical solution, which is a small subset of cases. This is why they are in ModelingToolkit :sweat_smile:, and it will just give you the analytical solution if it can derive it.

I would be very surprised if that’s actually true. I pointed to docs that already show tutorials for these things.

Sure. But if you want to derive just the Adomian polynomials and series in analytical form it’s purely analytical for certain nonlinear operators for arbitrary functions it’s a purely analytical method. Same thing with HAM. If you can show me that ModellingToolkit.jl can do this then let’s see the example.

I mean, I just built differentiation and integration from scratch in two day using just SymbolicUtils.jl. It was almost impossible with Symbolics.jl :sweat_smile:

(a) it’s literally the exact same code because Symbolics.jl is built on SymbolicUtils.jl, so Symbolics.jl is just SymbolicUtils.jl with extra functions like differentiation so that’s impossible.

(b) Symbolics.jl already has differentiation implemented. Derivatives and Differentials · Symbolics.jl

(c) Your implementation for integrals is not complete. It only works for very simple atomics. I wouldn’t say you built an integration system in 2 days because it’s not a correct implementation of Riesch and not a complete rule-based system.

lol then why doesn’t my code with Symbolics.jl?

Wow, really? I would have never guessed!

I like how you’re focusing on semantics of the word “complete” rather than the fact that Symbolics.jl doesn’t have integration, or it cannot substitute symbolic functions, and that ModellingToolkit cannot do what I just said.

Like I said, welcome to show me examples of what I want and point me in the right direction. So far, you haven’t provided any.

Just wrap(f(unwrap(x)))) to handle the Num wrapper and it does work with Symbolics.

It’s documented and used extensively and there’s other tutorials that use it too. See the documentation.

SymbolicNumericIntegration.jl is a symbolic integrator that handles almost as much as SymPy. This is detailed pretty extensively:

From looking at your code, it’s just linear combinations of a set of 12 known expressions and powers of those. Almost all integrals do not satisfy that, and very clearly this SymbolicNumericIntegration.jl version handles many more cases than that already.

But I still wouldn’t call SymbolicNumericIntegration.jl complete yet, which is why it’s not in the repo.

Moving Forward

But this is going nowhere, let’s move forward. If you’re not trolling, here’s what I’d recommend. If you wanted to make a solid contribution to this space, I think a good implementation of the Risch algorithm would be the right thing to add.

It’s an algorithm that’s guaranteed to work in some sense, but it’s really slow. The final algorithm we are working towards with Symbolics.jl is we want to mix Risch with SNI and a rule-based approach built on RUBI (https://rulebasedintegration.org/), where it asyncs the use of all 3 together and triggers on first response. That would be a good balance of breadth and performance. We are missing the other two parts right now, which is why there is a funded summer GSoC project for doing Risch that is being advertised.

As for the others, I highly suggest you read the docs a bit. MTK analytically solves many equations and puts the solution in observed and generates 0-equation systems when it can, otherwise it mixes with a tearing algorithm for sub-solutions. But refactoring the analytical solver to be more accessible is easy if people want it, it’s just not that useful to most people.

7 Likes

Wow, finally a legitimate suggestion from you.

I wonder if MIT has a no sarcasm rule.

Whoa! It’s almost like I posted here in order to get help making integration more robust.

Huh, maybe instead of getting your feelings hurt and not addressing my concerns, you could’ve just answered with this.

There’s also no examples of having unevaluated integrals. So basically, this is still behind my code.

Finally, thank you. It’s like pulling teeth with you, isn’t it? Hopefully that MIT “prestige” hasn’t blinded you from being able to talk to another fellow anteater.

I definitely appreciate finally pointing out a direction in which I can help given the fact that your Symbolics.jl clearly isn’t satisfying my needs.

This is criticism for you, I noticed a lot of Julia developers have zero proper documentation of their source code. Additionally, they seem obsessed with abstracting abstractions into more abstractions to the point where their code is too difficult for others to work on, for example Symbolics.jl which has zero documentation and which you’ve just turned into a Frankenstein monster around a simple package like SymbolicUtils.jl.

From this interaction, it’s clear that you’re the one pushing this type of culture. I’m not sure if your intention is to make it so that all Julia code becomes a blackbox and only you and your group can use it, or if it’s just because you think you’re clever.

If I wanted a black box code to do PDEs I would have just gone with COMSOL or Ansys. I have yet to meet anyone that uses ModelingToolkit.jl. I honestly don’t see the point in it. Never once used it in the 6 years of my research. Why are you reinventing the wheel? Why not just focus on making Julia faster with the MIT money you’re getting rather than whatever you think is clever?

Also, if you want users to contribute, document your code better and make sure to show basic abstraction diagrams, function dependencies, minimum functioning multiple dispatch examples, etc. From my point of view, Symbolics.jl is just a Frankenstein monster of SymbolicUtils.jl

Gentle reminder from the moderation that personal attacks lead nowhere. If the discussion doesn’t go back to a respectful tone, I will close it.

18 Likes

Don’t worry, I was getting the feeling that this was a trap with some weird vibes from the start, and it went as downhill as expected.

Look, I tried to be nice and link to all of the stuff. Sounds like you have no interest to collaborate or contribute. Feel free to build whatever you want and I’ll cheer you on. Symbolics.jl is just extensions to SymbolicUtils.jl so if you build nice tools on there we will link to those efforts and sing your praises in the docs. I’d be happy to take PRs get stuff integrated into Symbolics.jl (pun intended) as well so that it can have a system for long term maintenance and keep correctness+performance 10 years down the line, but if you want to build on your own that’s fine as well.

But for now I think it’s best use for both of our time to just bow out of the conversation and say peace for now. Best of luck to you.

7 Likes

That’s the issue. You tried but failed and you’re continuing to use childish language like

I’m wondering why you’re using these words? Can you point to me where I begain this “trap”? From what I recall, it seems like you set me up with a “trap”:

Here’s another example of you belittling:

Let’s get another example:

Here, you made a huge claim which is completely untrue that Adomian and homotopy are symbolic-numeric. Why did you lie?

Can you let me know why you decided to ignore my concerns and questions with valid examples? I mean you still haven’t answered 90% of them.

I’m also wondering why you are allowed to criticize people but it seems that you have strong policing when someone criticizes you. Can you let us all know why that is?

Looking back at the last message, I’m also wondering how my language was any worse than the examples I’ve just shown here.

Can you explain, mod?

On another note, Symbolics.jl separates real and imaginary numbers which I already mentioned which is another obstacle for doing analytical theory. Why is that and why do you believe that Symbolics.jl will be of any use to theorists with that?

For those wondering why my posts are hidden, it’s because I asked why Chris gets to get away with things he says and can avoid criticisms by having mods disappear posts. We’ll see if this one gets disappeared.

They were rightly flagged by the community as going against our site rules.

I’m legitimately confused how this became so confrontational, but this isn’t how we do discussions here. Your contributions are definitely welcome — here, in SciML, or in your own open source packages — but even when disagreeing with others we’ve gotta maintain respect for one another. That seems to have been lost here, so I’m closing this topic.

20 Likes