Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[request] support for symbolic integration #58

Open
anandijain opened this issue Feb 27, 2021 · 14 comments
Open

[request] support for symbolic integration #58

anandijain opened this issue Feb 27, 2021 · 14 comments

Comments

@anandijain
Copy link
Contributor

anandijain commented Feb 27, 2021

something like:

@variables t
D = Differential(t)
z = t
julia> expand_integral((z))
0.5(t^2) or 1//2(t^2)

also a question is handling the new constant, should you define a new parameter?

┆Issue is synchronized with this Trello card by Unito

@ChrisRackauckas
Copy link
Member

As a note, it's never good to have unicode in the public facing API. So it would be good to encode that as integral, and if the user is so inclined they should they can do const ∫ = integral. I think doing it like this and defining it similar to Differential is a good idea.

The best way to get this started is to setup an import https://rulebasedintegration.org/ into the SymbolicUtils rules system. We can then augment it with a deep learning approach SciML/NeuralPDE.jl#44 which generates a ton of test cases and trains on them.

@eprovst
Copy link

eprovst commented Mar 5, 2021

Alternatively, there is of course the Risch algorithm, which—to my knowledge—is the gold standard for symbolic integration, however it's limited to elementary functions.

As another drawback: it's famous for having a description of over 100 pages...

@ufechner7
Copy link

ufechner7 commented Mar 7, 2021

RUBI looks very promising. But which data set to use as starting point? What about: https://github.com/sympy/sympy/tree/master/sympy/integrals/rubi/rules

The official test suits are only available in:

  • Axiom syntax
  • Maple syntax
  • Mathematica syntax
  • Maxima syntax

But Python looks easier to me ...

@ufechner7
Copy link

Just started to look at the first rule, second form for integrands of the form (a + b x) m.

Program code:

Int[x_^m_.,x_Symbol] :=
x^(m+1)/(m+1) /;
FreeQ[m,x] && NeQ[m,-1]

So perhaps the first thing we need is an implementation of FreeQ in Julia?
Documentation: https://reference.wolfram.com/language/ref/FreeQ.html

Any idea how to do that?

@ufechner7
Copy link

I created the (nearly empty) package https://github.com/ufechner7/Rubi.jl

The input I need from the Symbolics.jl developers is how to define the integrator interface.

@ChrisRackauckas
Copy link
Member

I think if we setup Rubi rulesets it would make sense for them to live in Symbolics.jl or JuliaSymbolics? I don't quite see the maintenance structure of having it separate: that looks a little odd but if you want to setup the rules parsing like that, that's cool.

Alternatively, there is of course the Risch algorithm, which—to my knowledge—is the gold standard for symbolic integration, however it's limited to elementary functions.

Setting up the ability to call into https://github.com/nsmith5/Maxima.jl for risch could be interesting.

@eprovst
Copy link

eprovst commented Mar 10, 2021

Using Maxima is definitely possible, but I think that somewhat goes against "[...] that is directly extendable in the same language as the users."

I'm not familiar with the structure of the Maxima project, but it seems to 'only' be about 1100 lines of terse, mostly undocumented lisp code (https://sourceforge.net/p/maxima/code/ci/master/tree/src/risch.lisp), which might for instance be doable as a Summer of Code project? There's also a couple of subsets of the Risch algorithm which cover most of the more basic cases.

Either way, integration—however fundamental it is to a CAS system—is a though problem. Overall a CAS is a massive undertaking, but also one of the first things I was looking for when I started using Julia, so I'm very hopeful this project gets the attention and contributions it deserves and needs. 🙂

@ChrisRackauckas
Copy link
Member

I wouldn't require it as a dependency. It's like https://github.com/JuliaSymbolics/SymbolicSAT.jl . We can make the integral syntax for specifying an integral equation exist generically, but allow other packages to add a function that performs the integration with a different backend. That is one way to quickly boost the functionality, and will let us benchmark how accurate our stuff is too when we get to implementing it.

@jakubMitura14
Copy link

Of course it is massive amount of work required to complete this but what is the state of the integration functionality at the moment, is there any roadmap for it ?

@anandijain
Copy link
Contributor Author

@jakubMitura14 none in the repo yet but
@ufechner7 made https://github.com/ufechner7/Rubi.jl and @miguelraz made https://github.com/miguelraz/Rubin.jl

I'm not sure how far along these are yet though, may be good starting places if you'd like to help though

@ChrisRackauckas
Copy link
Member

Both of those are empty code repos:

https://github.com/miguelraz/Rubin.jl/blob/master/src/Rubin.jl

https://github.com/ufechner7/Rubi.jl/blob/main/src/Rubi.jl

It's a bad case of cookie licking.

https://communitymgt.fandom.com/wiki/Cookie_Licking

Nobody has worked on this, so this is wide open for anyone to work on.

@agucova
Copy link

agucova commented Aug 19, 2021

@ChrisRackauckas I believe @miguelraz's repo is pretty much active and ongoing, it's just that a lot of the preliminary work is just parsing the rules.

@mhmodzoka
Copy link

mhmodzoka commented Oct 17, 2021

I see a function "Integral", will we see it working soon?

  help?> Symbolics.Integral
  No documentation found.

  Symbolics.Integral is of type UnionAll.

  Summary
  ≡≡≡≡≡≡≡≡≡

  struct UnionAll <: Type{T}

  Fields
  ≡≡≡≡≡≡≡≡

  var  :: TypeVar
  body :: Any

  Supertype Hierarchy
  ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

  UnionAll <: Type{T} <: Any

@fgerick
Copy link

fgerick commented Apr 10, 2022

I had a little weekend project to see what is possible with MathLink.jl. I have managed to parse most of the rules to @rule integrate(...). The project is available here: https://github.com/fgerick/SymbolicRubi.jl with the parsing in the gen folder.

There's a tiny example that the rules do work in theory, but most of the functions defined by Rubi (or Mathematica) are not translated. This is obviously needed and probably the most tedious part. Also, for the steps afterwards, I do not have the expertise to continue without guidance. I'm happy to keep working on this, but maybe someone can already say if this is useful or if there is a better approach to this?

Cheers

EDIT: for some reason the x86 tests fail for the simple comparison. not sure why...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants