Sushant Hiray's Webspace

Sushant Hiray's Webspace

Profile Picture

Sushant Hiray

GSoC Week 10: Complex Complexions Resolved

After a significant amount of work in the past couple of weeks, I’ve finally completed the Complex Module.

Progress

This week I merged PR 248 which covered almost the entire of the complex module.

After merging this PR, Complex Numbers and I could be used in sync with other existing modules in CSymPy. @certik refined the Python wrappers to integrate the Complex Module. Here are the some of the things which could be done using CSymPy python wrappers:

In [1]: from csympy import *

In [2]: I
Out[2]: I

In [3]: I**2
Out[3]: -1

In [4]: I+1
Out[4]: 1 + I

In [5]:  (I+1)**2
Out[5]: 2*I

In [6]: (1+I*2)**(-1)
Out[6]: 1/5 - 2/5*I

In [7]: x = Symbol('x')

In [8]: x+I*x
Out[8]: (1 + I)*x

In [9]: ((2*I + x)*x).expand()
Out[9]: 2*I*x + x^2

In [10]: ((x + I)**2).expand()
Out[10]: -1 + 2*I*x + x^2



The other major work in this week was to work on the expansion of integral powers of complex number. Pull 264 was created to add this functionality. We used a particularly simple yet efficient algorithm to compute the integral power.

def powu(x, n):
    mask = 1
    r = 1
    p = x
    while (mask > 0 and n >= mask):
        if (n & mask):
            r = r*p
        mask <<= 1
        p = p*p
    return r



The current expand is a bit slower than what we were expecting. We will be looking to improve the speed in the coming days.

The Week Ahead

As per the proposal, I will be implementing the Zeta Function.


Thats all for now :) Will get back next week!

Separator line
Separator line
Sushant Hiray - Foodie. Coder. Reader. Binge Watching.
Open Source Evangelist
Contact
 

Menu