# Algebraicity, dsolve and core SymPy

Hello, the previous week I had learnt a lot, especially the fact that contributing to an open source project is lot more than just coding. Also the fact that Summer of Code is full of ups and downs, just one week into the program and I’ve experienced both. As usual, a short(?) summary about what I’ve accomplished or at-least tried to over the past week.

My work started with trying to implement the second heuristic as given in the Maple paper to solve this PDE $\frac{\partial \eta}{\partial x} + (\frac{\partial \eta}{\partial y} - \frac{\partial \xi}{\partial x}) * h(x, y) - \frac{\partial \xi}{\partial y}*h(x,y)^{2} - \xi*\frac{\partial h}{\partial x} - \eta*\frac{\partial h}{\partial y}$ . The heuristic is as follows, we make the following assumptions for $\xi(x,y)$ and $\eta(x,y)$

1. $\xi(x,y) = 0$, $\eta(x,y) = f(x)*g(y)$
2. $\xi(x,y) = 0$, $\eta(x,y) = f(y)*g(x)$
3. $\eta(x,y) = 0$, $\xi(x,y) = f(x)*g(y)$
4. $\eta(x,y) = 0$, $\xi(x,y) = f(x)*g(y)$

These were the problems that I had faced while trying to implement the heuristic.

1.  Algebraicity: In the above mentioned assumptions, $g$ is a function, that is built by extracting algebraic factors from $h(x, y)$, where $\frac{dy}{dx}=h(x,y)$  . For some strange reason, I chose to ignore, the term algebraic and implemented it by extracting all factors. And then I realized my mistake and had to rewrite some part of the code again. I also found out that there are functions to find out if a function is rational, or a polynomial but not if an expression is algebraic. I had to implement it on my own. (By the way, this was my function in core SymPy or anything outside the differential equation area.) The difference between an algebraic and a rational function is that in a rational function, exponentiation is an integer, however in an algebraic expression, exponentiation can be rational. The source code can be found here. Sample this example SymPy session:

>>> from sympy.abc import x
>>> eq = ((1 - x**2)/(1 + x**2))**(S(1)/2)
>>> eq.is_rational_function()
False
>>> eq.is_algebraic_expr()
True


It can be seen that eq, is algebraic but not a rational function, due to the fact that it is raised to a rational power
The source can be found here. https://github.com/sympy/sympy/pull/2176.

2. To dsolve or not to dsolve: The second ‘problem’ that I was facing was whether or not to use dsolve to simplify the
auxiliary ODE after making the substituting the function $g$ in the PDE. Sample the first assumption, after making
the substitution, it reduces to this ODE, $\frac{df}{dx}*g + f(x)*\frac{dg}{dy}*h - f*g*\frac{\partial h} {\partial y}=0$ . The question was whether to use dsolve again or assume that the heuristic works only if the ODE is
variable separable in $f$ and $x$. After a lot of discussion, and the fact that this ODE might be more
complicated then the initial ODE and a test was hanging, it was agreed to do away with dsolve internally.
By the way, I had written this small script to scrape the ODE’s from this page http://12000.org/my_notes/kamek/KERNEL/index.htm
into a text file. For those interested, however I made a few changes manually even after using the script.
https://gist.github.com/Manoj-Kumar-S/5804909

The source for the second heuristic can be found here. At the time of writing, it hasn’t been merged yet.
https://github.com/sympy/sympy/pull/2156

Well regarding, the downs that I mentioned in the beginning of the post, I tried starting work on the third heuristic. The research paper (Maple )is very vague, and I have no idea how I’m going to implement it as of now after thinking for a day (well almost). I have also asked on sites like math stack and math overflow, but there has no reply till now. However lets see what can be done. Hoping for the best!