Since I am still revising for exams and so not working full time, I decided to start gsoc early. For this reason I have quite a lot to cover in this post. The next updates will obviously be shorter.

## Randomised Testing

A large part of my project consists of putting various complicated formulae into well-organised tables, so that many more can be derived from them. I figured the only way to be sure these entries are all corect would be to evaluate them numerically, at random points. I thus extended the bin/test utility to store and print the used seed, and also to allow to set the seed manually. This way randomised testing becomes reproducible. I have also implemented a file utility/randtest.py that has some helpers for doing the actual testing (e.g. comparison at a point, or numerical evaluation of derivatives).

This code has proved very helpful to me, in particular with the complicated formulae it often takes annoyingly many attempts to copy them correctly from the books.

## Special Function Updates

Since this project is all about integrating special functions, my first duty was to add some of them, and improve others. I have added Bessel functions and modified Bessel functions of the first and second kind (J, K, I, Y) as well as Hankel functions (H1, H2). All of these functions have docstrings, can be differentiated, and have latex printing. I have also incorporated the spherical bessel functions into this new framework, and polished the polynomial generation code for them. You can now do this [1] in a breeze, which used to take ages. In fact you can also do e.g. 300 but that would have been a mess to put even on pastebin :D. So ole for the new polys module.

I have also fixed a few minor bugs in the incomplete gamma code, added numerical evaluation and pretty printing:

In [3]: lowergamma(a, z) Out[3]: Î³(a, z) In [9]: uppergamma(0.3, 0.5) Out[9]: 0.556994831009607

Finally I added Hypergeometric Meijer G function classes. These are not in itself all too interesting, but I did take care of pretty printing, e.g. [2] (it looks a bit nicer in the font sympy uses, without the gaps between lines).

## Hypergeometric Function Expansion

The more interesting question is of course what to do with the hypergeometric and Meijer G functions, in particular how to express them using better-known named special functions. This is really a large part of my entire gsoc project, so no perfect results can be expected yet, but I believe I have made quite some good progress. I implemented the basic parts of Kelly Roach’s algorithm for expanding hypergeometric functions. I also sifted through hundreds (literally!) of pages of tables of a russian (!) handbook on special function identities and as of now added 23 key formulae, from which most others can be derived. The results are fairly cool: [3].

As Fredrik Johansson pointed out to me, one obvious application of hypergeometric function expansion is symbolic summation of series. Using the existing infrastructure of sympy implementing this was essentially trivial, and the results are also not too bad: [4].

On the other hand, I believe it is bad practice not to mention problems, so here is a partial list of what is currently not working:

- For some of the most complicated formulae, I have not yet computed nices bases, which yields answers that are … well, unhelpful. [The answer here is completely ridiculous because it uses an automatically computed basis, which is far from optimal. With a hand-picked basis, the result will come out as a sum of three products of two bessel functions, with some prefactors.]
- The code is sometimes incredibly slow. Most of the time is spent simplifying rational functions, which is really not part of the new algorithm at all, but waiting ages for an answer is obviously not satisfactory, so I will have to investigate this.
- The algorithm will sometimes not recognise that a formula applies.
- I have not yet implemented so called “PFD duplication”, which is a fairly general formula, but only applies to cases which seem fairly obscure to me. I have decided not to implement it (it’s fairly complicated) until I meet an example “in the wild”.
- There are about 60 pages left that I have not yet sifted through.
- There are many more formulae involving special functions that are not yet in sympy.
- Various other bits and pieces are missing or unfinished.

At least in Safari, http://pastebin.com/raw.php?i=ezfpcgyS uses a monospaced font, and has no gaps.

In http://pastebin.com/kirwfcLg, what is the random piecewise at the top? I’m assuming it’s just the summation, but I think you forgot an In/Out.

By the way, there are several issues open for unimplemented summations. You should comment on the ones that your code can do (and add tests for them in your branch, so they can be closed once it gets in).

Let me know what you discover about what is slowing things down with regard to simplifying rational functions. One thing I do know is that the gcd algorithm for multivariate polynomials can sometimes be slow, so if your rational functions are in more than one variable, then that might be it.

By the way, sorry for commenting multiple times. I really need to write one comment and not click “post” until I have finished reading the entire blog post.

I don’t mind about several comments, so don’t bother to stack them if it interrupts your flow of reading.

As to the slowdown, I will of course keep you posted.