Not having coded a computer algebra system myself, I can’t tell you for sure what exactly the implementation is for any given system.
That said, for some simple functions I suspect it’s just a lookup table.
For more complicated general functions, there is a generalized way to determine whether you can compute an antiderivative using only elementary functions, and if so, what it is. It’s called the Risch algorithm. The algorithm itself is so complicated that it isn’t actually fully implemented in any computer algebra system, but the way it works is that it provides a method to turn the procedure of finding the antiderivative of a given function into a giant algebra problem.
It’s really not possible to go into more detail in anything approaching like ELI5, nor would I be competent to do so.
https://en.wikipedia.org/wiki/Risch_algorithm
I believe a good chunk of how Mathematica, for example, works is based on [Meijer functions](https://en.m.wikipedia.org/wiki/Meijer_G-function).
The idea being that they can represent a very large set of “normal functions” and are trivial to integrate themselves.
So the main computational task is not the integration, per se, but the “encoding” and “decoding” of the input and result in a form that can be integrated with simple rules, and then is tolerable for humans, respectively.
As others mentioned there is an algorithm by Risch. It does nothing really new, it combines the standard techniques you may have already seen: linearity, integration by parts, substitution, partial fraction decomposition. The real trick is that it automates integration to become an algorithm, so at each step the computer really knows what is the best step to take next.
However, there are multiple caveats:
1. The algorithm can only deal with _elementary_ functions: what you get from constants, identity (x→x), composition, +, -, ·, /, exponentiation, logarithm, and if so desired certain inverses of polynomial functions (never saw someone actually use those). Those include √, sin, cos, tan, their inverses and much more. The modulus function |x| however is not one of them. If one also allows it, then we have definitive proof that no algorithm as Risch’s can exist at all!
2. The algorithm needs a way to check if two elementary expressions describe the same function within their scope. For example, e^^log(x)/2 is the same as √x for positive x. But we do not yet know if there actually is an algorithm doing this! We can plug in a lot of different values and check numerically, but that is not a definite method, we could just have been unlucky and missed that they are indeed different at x=√7. It is quite possible that such an algorithm does truly not exist, but we don’t know that either.
3. The algorithm will terminate, but not every elementary function has an elementary antiderivative. Famous examples are x^^x and e^^-x² . But the algorithm is quite fine, it will tell you if there is no such elementary antiderivative, and tell you one if it exists.
Integration, in college courses, is normally “here’s a bunch of things that *might* work, eventually you’ll learn to recognise the most promising tool for any given problem”
However, there is actually an algorithm (a step by step procedure) for integration. Unfortunately, it’s far far more complicated than the one for differentiation.
From [Wikipedia](https://en.wikipedia.org/wiki/Risch_algorithm):
>The complete description of the Risch algorithm takes over 100 pages
so it’s not the sort of thing you can expect a human to commit to memory. However, it can be coded into computer algebra software.
Make many small squares and you get pretty good estimate quickly.
0->1.5 sqrt(tan(x))
10 small squares: 1.5154
100 small squares: 1.6706
1000 small squares: 1.6875
10000 small squares: 1.6892
100000 small squares: 1.6894
Error rapidly decreases when number of squares increase and calculators are very good at performing rapid calculations.
Your instinct is correct. You can take a derivative by following a simple procedure, and it is very easy to write a computer algebra system that can take derivatives.
Computing integrals is *not* easy, and there is no procedure that works in all cases. For both humans and computers, computing integrals requires a library of tricks and pattern matching, and speculative trial and error.
Latest Answers