Hi, I finally managed to do some amount of work for the past ten days, and I’m happy to day that all that I had wanted to do this GSoC has been pushed in and I’m waiting for comments on my final Pull Request. These were the changes that I had made.
1. Making stuff similar to the series function
While playing around with the code, I found out that, doing series(eq, n=terms), gives the series expansion upto rather than the nth term. This makes the code look a lot neater too. Also the default power is 6, so I changes that too. For instance, take this sample SymPy session
from sympy import dsolve, series from sympy.abc import x, y f = Function("f") pprint(series(exp(x)) 2 3 4 5 x x x x ⎛ 6⎞ 1 + x + ── + ── + ── + ─── + O⎝x ⎠ 2 6 24 120 eq = f(x).diff(x) - x*f(x) pprint(dsolve(eq, hint='1st_power_series')) 2 4 C₀⋅x C₀⋅x ⎛ 6⎞ f(x) = C₀ + ───── + ───── + O⎝x ⎠ 2 8
I also added support for power series solutions of homogeneous differential equations at ordinary points, and regular singular points. A homogeneous second differential equation is of the form . (Any DE mentioned below is homogeneous second order unless otherwise specified, because typing DE is easier than typing a homogeneous second order differential equation).
a] A point is said to be ordinary, if and are analytic at the point.
b] It is said to be regular singular, if and are analytic. For simplicity in the series expansions, assumptions are made such that , and are polynomials. Okay, now for a bit more detail
1. Ordinary points : A DE has a power series solution, at . This can be found by substituting in the DE, and equating the nth coefficient in order to obtain a recurrence relation. However this is not as trivial as it sounds and was one of the more tougher things I had to do.
Take the general case of . Substituting as in the DE. (One has to expand each of the terms , and ), make transformations such that for each term the power of is . The catch here is that the starting point of the summation also changes, so the necessary terms shouls be stripped off such that the starting point is same. This is better explained in one of these tutorials, http://tutorial.math.lamar.edu/Classes/DE/SeriesSolutions.aspx , so you could read that after you’ve read the rest of the blogpost.
A small sample session.
from sympy import * from sympy.abc import x, y eq = (1 + x**2)*(f(x).diff(x, 2)) + 2*x*(f(x).diff(x)) -2*f(x) pprint(eq) 2 d ⎛ 2 ⎞ d 2⋅x⋅──(f(x)) + ⎝x + 1⎠⋅───(f(x)) - 2⋅f(x) dx 2 dx pprint(dsolve(eq)) ⎛ 4 ⎞ ⎜ x 2 ⎟ ⎛ 6⎞ f(x) = C₁⋅x + C₀⋅⎜- ── + x + 1⎟ + O⎝x ⎠ ⎝ 3 ⎠ eq = f(x).diff(x, 2) + x*(f(x).diff(x)) + f(x) pprint(eq) 2 d d x⋅──(f(x)) + f(x) + ───(f(x)) dx 2 dx pprint(dsolve(eq)) ⎛ 2 ⎞ ⎛ 4 2 ⎞ ⎜ x ⎟ ⎜x x ⎟ ⎛ 6⎞ f(x) = C₁⋅x⋅⎜- ── + 1⎟ + C₀⋅⎜── - ── + 1⎟ + O⎝x ⎠ ⎝ 3 ⎠ ⎝8 2 ⎠
2. Regular singular points :
1. Try expressing and as power series
solutions about . Find and which are the constants of the
power series expansions.
2. Solve the indicial equation , to obtain the
roots and of the indicial equation.
3. If is a non integer there exists two series solutions. If
, there exists only one solution. If is an integer,
then the existence of one solution is confirmed. The other solution may
or may not exist.
The power series solution is of the form . The
coefficients are determined by the following recurrence relation.
. For the case
in which is an integer, it can be seen from the recurrence relation
that for the lower root , when equals the difference of both the
roots, the denominator becomes zero. So if the numerator is not equal to zero,
a second series solution exists. (Oh and by the way I just copy – pasted the docstring for the
last part, because I was lazy to write the whole thing again :P)
eq = x**2*(f(x).diff(x, 2)) - 3*x*(f(x).diff(x)) + (4*x + 4)*f(x) # One solution pprint(dsolve(eq)) ⎛ 3 ⎞ 2 ⎜ 16⋅x 2 ⎟ ⎛ 6⎞ f(x) = C₀⋅x ⋅⎜- ───── + 4⋅x - 4⋅x + 1⎟ + O⎝x ⎠ ⎝ 9 ⎠ eq = x**2*(f(x).diff(x, 2)) - x**2*(f(x).diff(x)) + ( x**2 - 2)*f(x) # Two solutions ⎛ 6 5 4 2 ⎞ ⎜ x 3⋅x x x x ⎟ C₁⋅⎜- ─── - ──── - ── + ── + ─ + 1⎟ ⎛ 3 2 ⎞ ⎝ 720 80 8 2 2 ⎠ 2 ⎜ x x x ⎟ ⎛ 6⎞ f(x) = ─────────────────────────────────── + C₀⋅x ⋅⎜- ── + ── + ─ + 1⎟ + O⎝x ⎠ x ⎝ 60 20 2 ⎠
Anyway, that sums up my official GSoC work. Now that I just need to address comments made on my PR which is at, https://github.com/sympy/sympy/pull/2395 . And I just realised that I have my exams coming up the next week, and its been a while since I touched my books (and gone to classes), and thats not a good thing. So have to catch up there. Seems like my whole life is about catching up.