What would be the most efficient method to programatically implement symbolic integration?

492 Views Asked by At

At the moment, I'm a CS student who's main research focus is graphics. For a current project of mine, I need to write an indefinite integral calculator, in the vein of those available of wolfram alpha and symbolab; I'm aware that some already exist in higher-level languages like Python, but, due to the nature of graphics processing, I can only code in high-speed, low-level languages like C and C++.

With this in mind, what algorithms are available to calculate (rather than approximate) the indefinite integrals of elementary functions? I'm aware of Risch's method, but this seems very difficult to implement; do simpler alternatives exist?

If all the available methods would take too much processing power, technical expertise, or time to implement, I would be willing to sacrifice some small degree of accuracy, if that's even possible; I've had situations in the past where allowing a 99% success rate opens up a variety of much simpler methods.

Thanks for any help you can offer.

1

There are 1 best solutions below

0
On

There are a vast number of different algorithms if you allow numerically integrating it. However, since your field of expertise is computer graphics I think you may be more familiar with those numerical analysis than me.

Hence I will assume that you need symbolic integration even though I think at last you will end up with computing with real numbers in your integration result, which will not be better than using good numerical analysis at first point. As you are in CS, I am fairly sure that you understand this (using symbolic integration + giving input will result in some error due to floating point precision and etc) and somehow decided that considering all this, you want symbolic integration.

Risch's method is very powerful. As I understand, there is some conjecture that if a function $f$ has elementary antiderivative, Risch's algorithm will always return correct antiderivative, and if there isn't, it will return that information too. (I don't accurately remember, but I think I've read that it is proven under assumption of some mathematical conjecture)

In practice, you may use Risch-Norman Algorithm, which is simpler version of Risch, but it does not guarantee such property (100% success). As far as I know, Sympy and other symbolic integration programs use this algorithm mainly. Risch-Norman is also difficult to implement and I haven't found a open-source, reasonably good implementation in C++. Here are some article I've found about this algorithm.
Article about implementing it to Mathematica
Article about implementing it to Maple

Overall, I do not recommend to try implementing such algorithm. Symbolic integration itself is very, very difficult and big project, which might end up with your last paragraph - taking too much time for implementation. If numerical methods work for whatever you want, I am almost certain that it is better to stick with it.