How do integral calculators work?

569 views

A derivative calculator seems a lot easier to build as it much more “rule” based and solutions are usually what you would expect them to be. But how on earth can integral calculators figure out absolutely brutal integrals like sqrt(tanx) is in less than 5 seconds?

In: 102

9 Answers

Anonymous 0 Comments

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

Anonymous 0 Comments

There are rule based solutions for integration, too.

However, failing that, a computer can brute force a Riemann sum accurate to 0.01% in milliseconds. That’s what computers are good at – lots and lots of simple operations. It just splits the curve into rectangles and adds their areas together.

Anonymous 0 Comments

There’s no ELI5 answer but an introduction to this would be reading about the [Risch Algorithm](https://en.wikipedia.org/wiki/Risch_algorithm).

Anonymous 0 Comments

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.

Anonymous 0 Comments

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.

Anonymous 0 Comments

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.

Anonymous 0 Comments

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.

Anonymous 0 Comments

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.

Anonymous 0 Comments

In terms of pen to paper calculus, integration is just as straighforward and “rule based” as integration is, albeit a bit more involved. Programming a calculator to do it is exactly the same but in “reverse” with more steps