Like I said in my last post, this was my first week in college after summer vacation. I had to reschedule my daily work according to my class timings (which are pretty arbitrary). Anyway, since I do not have a test anytime soon, things were manageable.
This week I worked on
rs_series in PR 9614.
As Donald Knuth succinctly said, 'Premature optimisation is the root of all
evil', my first goal was to write a function that used
ring_series to expand
Basic expressions and worked in all cases. That has been achieved. The new
function is considerably faster than SymPy's
series in most cases. eg.
In : %timeit rs_series(sin(a)*cos(a) - exp(a**2*b),a,10) 10 loops, best of 3: 46.7 ms per loop In : %timeit (sin(a)*cos(a) - exp(a**2*b)).series(a,0,10) 1 loops, best of 3: 1.08 s per loop
However, in many cases the speed advantage is not enough, especially considering
that all elementary
ring_series functions are faster than SymPy's series
functions by factors of 20-100. Consider:
In : q Out: (exp(a*b) + sin(a))*(exp(a**2 + a) + sin(a))*(sin(a) + cos(a)) In : %timeit q.series(a,0,10) 1 loops, best of 3: 2.81 s per loop In : %timeit rs_series(q,a,10) 1 loops, best of 3: 3.99 s per loop
In this case,
rs_series is in fact slower than the current
This means that
rs_series needs to be optimised, as expanding the same
expression directly with
rs_* functions is much faster.
In : %timeit (rs_exp(x*y,x,10) + rs_sin(x,x,10))*(rs_exp(x**2+ x,x,10) + rs_sin(x,x,10))*(rs_sin(x,x,10) + rs_cos(x,x,10)) 1 loops, best of 3: 217 ms per loop
I spent Friday playing with
rs_series. Since the function is recursive, I even
tried using a functional approach (with map, reduce, partial, etc). It was fun
exploring SymPy's functional capabilities (which are quite decent, though
Haskell's syntax is of course more natural). This didn't make much difference in
speed. Code profiling revealed that
rs_series is making too many function
calls (which is expected). So, I plan to try a non-recursive approach to see if
that makes much of a difference. Other than that, I will also try to make it
smarter so that it does not go through needless iterations (which it currently
does in many cases).
I had a discussion with Sumith about Polynomial wrappers. I am helping him
with constructors and multiplication. We both want the basic
done as soon as possible, so that I can start with writing series expansion of
functions using it.
I also sent a PR 562 that adds C
Complex class. This will be especially helpful for Ruby wrappers
that Abinash is working on. FQA
is a nice place to read about writing C++/C wrappers and for some side
Other than that, I also happened to have a discussion with
Harsh on the new solve-set he and
Amit are working on. Their basic idea is that you
always work with sets (input and output) and that the user can choose what
domain he wants to work on. The latter idea is quite similar to what SymPy's
does. Needless to say, their approach is much more powerful that
will be working with them.
Targets for the next week are as modest as they are crucial:
rs_seriesto make it faster.
Finish Polynomial wrappers and start working on series expansion.