Sachin Agarwal Open Source Enthusiast

GSoC 2020 - Week 2

Key highlights of this week’s work are:

  • Fixed _eval_nseries() of Mul

    • This was a long pending issue. Previously, in the codebase the series expansion of a product was computed as the product of expansions of the factors. This approach was correct only when the leading term of each series is a constant but not in general.

      For example, to compute the expansion of f(x)/x**10 at x = 0 to order O(x**10) it is necessary to compute the series expansion of the function f(x) to order O(x**20) and thus, computing till order O(x**10) would not suffice.

      The strategy we implemented to resolve this issue was:

      • Compute the order n0 of the leading term of the product as the sum of the orders of the leading terms of the factors.
      • For each factor, compute n - n0 terms of its series expansion (starting from its leading term of order n1 and ending at order n - n0 + n1).
      • Multiply the expansions (truncating at terms of order n).

      I enjoyed implementing all this because at every step we had to ensure that we are not compromising with the efficiency of the code. Finally, this issue was resolved and we ended up adding an extremely optimised implementation of the function to the codebase.

  • Used is_meromorphic() function to speed up limit evaluations

    • In this PR, we made use of the is_meromorphic() function of SymPy to speed up limit evaluations for certain type of cases.

      A function is said to be meromorphic at a point, if at that point the limit of the function exists but is infinite. In these cases, the value of the limit can usually be determined with the help of the series expansion of that function and thus, there is no need to invoke the Gruntz algorithm.

      While working on the implementation of this functionality, we required the leading term of the series expansion of the function in the limit expression at the point at which the limit needs to be evaluated.

      But we came across a weird situation, where for some functions, we got Complex Infinity as the leading term. Thus, we had to rectify the _eval_as_leading_term() methods of these functions (done in a separate PR).

      After resolving this issue, we succeeded in adding the required functionality and hence, increased the efficiency of the limit evaluation algorithm of SymPy.

Follow @sachin-4099