Indefinite Integral in Programming

In summary: But Maxima's integration routines seem to be 90% lisp!In summary, the conversation revolved around finding a way to implement indefinite integrals and derivatives in an open source calculator. The participants discussed using the Riemann Sums method and functional programming, specifically Haskell. Another suggestion was to study the Risch algorithm for a possible solution. They also mentioned existing GPL projects that could be used as a client to Sage, an open source mathematics software. However, one person expressed interest in implementing the integration on their own without dependencies.
  • #1
TheDemx27
Gold Member
169
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?
 
Technology news on Phys.org
  • #2
sage
 
  • #3
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 TheDemx27 and Fooality
  • #4
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.
 
  • #5
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 TheDemx27
  • #6
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.
 
  • #7
TheDemx27 said:
this [Risch algorithm] seems easier to implement
I take that back.
 

Related to Indefinite Integral in Programming

1. What is an indefinite integral in programming?

An indefinite integral in programming is a mathematical concept that is used to determine the antiderivative of a given function. In simpler terms, it is a way to find the original function when only the derivative is known.

2. How is an indefinite integral represented in programming?

In programming, an indefinite integral is typically represented using the integral symbol (∫) followed by the function to be integrated and the variable of integration. For example, an indefinite integral of the function f(x) would be written as ∫f(x)dx.

3. What is the purpose of using indefinite integrals in programming?

The main purpose of using indefinite integrals in programming is to solve mathematical problems that involve finding the original function, given only its derivative. This is commonly used in fields such as physics, engineering, and economics to model real-world situations.

4. Can indefinite integrals be approximated in programming?

Yes, indefinite integrals can be approximated in programming using numerical methods such as the trapezoidal rule or Simpson's rule. These methods use a series of calculations to approximate the value of the integral, which can be useful when the integral cannot be solved analytically.

5. Are there any limitations to using indefinite integrals in programming?

One limitation of using indefinite integrals in programming is that they can only be used to find the antiderivative of a function, not the definite integral. In addition, some functions may be difficult or impossible to integrate using current programming methods, leading to approximations or errors in the calculated value.

Similar threads

  • Programming and Computer Science
2
Replies
65
Views
3K
Replies
4
Views
7K
Replies
9
Views
2K
  • Programming and Computer Science
Replies
22
Views
976
  • Programming and Computer Science
Replies
15
Views
2K
Replies
4
Views
3K
  • Calculus and Beyond Homework Help
Replies
4
Views
1K
  • General Math
Replies
6
Views
3K
  • Calculus
Replies
5
Views
2K
  • Calculus and Beyond Homework Help
Replies
15
Views
1K
Back
Top