Indefinite Integral in Programming

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
6 replies · 3K views
TheDemx27
Gold Member
Messages
169
Reaction score
13
I've been contributing to an open source calculator, and I wanted a way to take integrals of functions. I suppose you could implement a definite integral function by using Riemann Sums, but I can't find any way to implement indefinite integrals (or derivatives for that matter).

I've heard that functional programming is more adapt to abstract manipulation of mathematical models, for instance haskell, but I'm really not all too familiar with functionally programming at all. I'd like to stay within OOP.

Does anyone know of any methods one could use to take indefinite integrals?
 
Physics news on Phys.org
TheDemx27 said:
I've been contributing to an open source calculator, and I wanted a way to take integrals of functions. I suppose you could implement a definite integral function by using Riemann Sums, but I can't find any way to implement indefinite integrals (or derivatives for that matter).

I've heard that functional programming is more adapt to abstract manipulation of mathematical models, for instance haskell, but I'm really not all too familiar with functionally programming at all. I'd like to stay within OOP.

Does anyone know of any methods one could use to take indefinite integrals?
See http://www.apmaths.uwo.ca/~arich/, especially http://www.apmaths.uwo.ca/~arich/IntegrationRules/PortableDocumentFiles/PortableDocumentFiles.html.
The guy created a set of rules for integration for many integrands (which apparently outperforms both Maple and Mathematica CAS's by far). So in a way the program doesn't compute the primitive of 1/x, it is just instructed to return "Log(x)" for that particular integral.

Edit: Here's Maxima's source code: https://sourceforge.net/p/maxima/code/ci/master/tree/src/. I am not familiar with it, but try to check out how the symbolic integrations are performed. Maybe search for "antideriv" in this file: https://sourceforge.net/p/maxima/code/ci/master/tree/src/defint.lisp. Also check this file: https://sourceforge.net/p/maxima/code/ci/master/tree/src/expintegral.lisp.
In addition Maxima has a mailing list where the programmers would likely be happy to guide you in your quest.
 
Last edited:
  • Like
Likes   Reactions: TheDemx27 and Fooality
fluidistic said:
See http://www.apmaths.uwo.ca/~arich/, especially http://www.apmaths.uwo.ca/~arich/IntegrationRules/PortableDocumentFiles/PortableDocumentFiles.html.
The guy created a set of rules for integration for many integrands (which apparently outperforms both Maple and Mathematica CAS's by far). So in a way the program doesn't compute the primitive of 1/x, it is just instructed to return "Log(x)" for that particular integral.

Edit: Here's Maxima's source code: https://sourceforge.net/p/maxima/code/ci/master/tree/src/. I am not familiar with it, but try to check out how the symbolic integrations are performed. Maybe search for "antideriv" in this file: https://sourceforge.net/p/maxima/code/ci/master/tree/src/defint.lisp. Also check this file: https://sourceforge.net/p/maxima/code/ci/master/tree/src/expintegral.lisp.
In addition Maxima has a mailing list where the programmers would likely be happy to guide you in your quest.

Just to add on a warning, Maxima is pretty limited at integration, time and time again I end up using Wolfram's integral calculator.

Also, there's some existing GPL projects that work as a client to sage, like this:
https://play.google.com/store/apps/details?id=org.sagemath.droid&hl=en
I remember not being too impressed... If something like that could be merged with a straight up (not cloud based) scientific calculator and GPU based 2D and 3D grapher, I think you could get an incredible product for not too much work.
 
TheDemx27 said:
I've been contributing to an open source calculator, and I wanted a way to take integrals of functions. I suppose you could implement a definite integral function by using Riemann Sums, but I can't find any way to implement indefinite integrals (or derivatives for that matter).

I've heard that functional programming is more adapt to abstract manipulation of mathematical models, for instance haskell, but I'm really not all too familiar with functionally programming at all. I'd like to stay within OOP.

Does anyone know of any methods one could use to take indefinite integrals?

You could study the Risch algorithm:

http://en.wikipedia.org/wiki/Risch_algorithm
 
  • Like
Likes   Reactions: TheDemx27
Simon Bridge said:
sage
Fooality said:
Also, there's some existing GPL projects that work as a client to sage
I kinda wanted to this on my own without dependencies, all in golang. This still looks pretty useful and I may some other time...

SteamKing said:
You could study the Risch algorithm:

http://en.wikipedia.org/wiki/Risch_algorithm
Despite being summarized in "more than 100 pages" this seems easier to implement than the approach Maxima has, which is pretty much the same approach I thought of. Also Maxima is written in some sort of lisp, which isn't very attractive imo.
 
TheDemx27 said:
this [Risch algorithm] seems easier to implement
I take that back.