Amit Kumar2024-01-01T16:23:27+05:30https://iamit.inAmit Kumardtu.amit@gmail.comPorting SymPy Gamma to Google App Engine Python 32020-10-31T00:00:00+05:30https://iamit.in/blog/upgrading-sympy-gamma<p>This summer I had plenty of time during COVID-19 lockdown and I was looking at
<a href="https://sympygamma.com/">SymPy Gamma</a>.</p>
<center><img src="/assets/sympy-gamma-port/sympy_gamma_demo.gif" width="700" /></center>
<h2 id="sympy-gamma">Sympy Gamma</h2>
<p>SymPy Gamma is a web application that executes mathematical expressions
via natural language input from the user, after parsing them as SymPy
expressions it displays the result with additional related computations.
It is inspired from the idea of <a href="http://www.wolframalpha.com/">WolframAlpha</a> which is based on the
commercial Computer Algebra System named <a href="https://en.wikipedia.org/wiki/Mathematica">“Mathematica”</a>.</p>
<center><img src="/assets/misc/wolfram-alpha-logo.svg" width="300" /></center>
<p>I have always been impressed by it ever since I first found about it.
While playing with it during this summer, I realised that it runs on Google
App Engine’s Python 2.7 runtime. It is powered by SymPy, an open source
computer algebra system.</p>
<center><img align="center" src="/assets/misc/Sympy_logo.svg" width="150" /></center>
<h2 id="the-problem">The Problem</h2>
<p>Despite being widely used around the world (about ~14K users everyday,
as seen from Google Analytics), there hasn’t been a lot of development
in the past 5 years. Due to this the current infrastructure
was stuck on <a href="https://en.wikipedia.org/wiki/Google_App_Engine">Google App Engine</a>’s Python 2 runtime which obviously does
not support Python 3.</p>
<p>This also prevented it to use the latest version of SymPy. The SymPy
version (~0.7.6) it was using was last updated 6 years ago. This made
SymPy Gamma in urgent need for upgradation. At the time of writing this blog,
SymPy Gamma is running on Google App Engine’s latest runtime and latest
version of SymPy.</p>
<h2 id="solution-and-process">Solution and Process</h2>
<p>It was a fun project and was interesting to see how Google cloud offering has evolved
from Google App Engine to Google Cloud Platform. The old App engine did
seem like a minimal cloud offering launched by Google in an attempt to
ship something early and quickly. It reminded me of my first cloud project
in college (<a href="https://github.com/aktech/dturmscrap">dturmscrap</a>), which I
deployed to Google App Engine, back in 2015.</p>
<p>I used Github projects to track the whole project, all the work done for this
can be seen <a href="https://github.com/sympy/sympy_gamma/projects/1">here</a>.</p>
<h2 id="-git-log">$ Git Log</h2>
<p>Here is a summary of what was achieved:</p>
<ul>
<li>
<p><a href="https://github.com/sympy/sympy_gamma/pull/135">PR 135</a>: Migrating Django to a slightly higher version,
this was the first blood just to make sure everything was working. I upgraded it to the latest version of
Django that was supported on Python 2 runtime. This also exposed the broken CI, which was fixed in this.</p>
</li>
<li>
<p><a href="https://github.com/sympy/sympy_gamma/pull/137">PR 137</a>: This upgraded the CI infrastructure to use Google Cloud SDK
for deployment, the previous method was discontinued.</p>
</li>
<li>
<p><a href="https://github.com/sympy/sympy_gamma/pull/140">PR 140</a>: Upgrading the Database backend to use Cloud NDB instead
of the legacy App Engine NDB.</p>
</li>
<li>
<p><a href="https://github.com/sympy/sympy_gamma/pull/148">PR 148</a>: Since we change the database backend, we needed something for
testing locally, this was done by using Google Cloud Datastore emulator locally.</p>
</li>
<li>
<p><a href="https://github.com/sympy/sympy_gamma/pull/149">PR 149</a>: The installation and setup of the project was quite a challenge.
Installing and keeping track of the versions of a number of application was non-trivial. This Pull request dockerized
the project and made the development setup trivial and it all boiled down to just one command.</p>
</li>
<li>
<p><a href="https://github.com/sympy/sympy_gamma/pull/152">PR 152</a>: The login feature was previously implemented using the user API
of the Google App Engine’s Python2 runtime, which was not available in Python 3 runtime. We removed the login feature as it
was not used by many and was too much effort to setup OAuth for login.</p>
</li>
<li>
<p><a href="https://github.com/sympy/sympy_gamma/pull/153">PR 153</a>: Now was the time to slowly move towards Python 3 by making the
code compatible with both 2 and 3. It was achieved via <a href="https://python-modernize.readthedocs.io/en/latest/">python-modernize</a>.</p>
</li>
<li>
<p><a href="https://github.com/sympy/sympy_gamma/pull/154">PR 154</a>: We then made the migration to Python 3.7 runtime and removed submodules
and introduced a <code class="language-plaintext highlighter-rouge">requirements.txt</code> for installing dependencies.</p>
</li>
<li>
<p><a href="https://github.com/sympy/sympy_gamma/pull/154">PR 159</a>: The above change made it possible to upgrade SymPy to latest version,
which was 1.6 at that time.</p>
</li>
<li>
<p><a href="https://github.com/sympy/sympy_gamma/pull/154">PR 165</a>: The last piece of the puzzle was upgrading Django itself, so we upgraded
it to the latest version, which was Django 3.0.8.</p>
</li>
</ul>
<h4 id="next-steps">Next Steps</h4>
<ul>
<li>At the time of writing this Google has released the Python 3.8 runtime, it would nice to further upgrade it now.</li>
<li>The test coverage can be increased.</li>
<li>The code can be refactored to be more readable and approachable for new contributors.</li>
</ul>
<p>Thanks to Google for properly <a href="https://cloud.google.com/appengine/docs/standard/python/migrate-to-python3">documenting the process</a>,
which made the transition much easier.</p>
<p>Thanks to <a href="https://numfocus.org/">NumFocus</a>, without them this project would not have been possible. Also thanks to
<a href="https://github.com/certik">Ondrej Certik</a> and <a href="http://github.com/asmeurer">Aaron Meurer</a> for their advice and support
throughout the project.</p>
SymPy Workshop at FOSSASIA 2016, Singapore 🎙️2016-03-26T00:00:00+05:30https://iamit.in/blog/SymPy Workshop at FOSSASIA 2016, Singapore<p>Hi there! Last week I went to <a href="https://en.wikipedia.org/wiki/Singapore">Singapore</a> for <a href="http://2016.fossasia.org/">FOSSASIA</a> Open Tech Summit 2016. I conducted a Worskhop on <a href="http://sympy.org">SymPy</a> and assisted the <a href="http://pydy.org">PyDy</a> Workshop in Python track hosted by <a href="https://kushaldas.in/">Kushal Das</a>. This blog post accounts to my experience as a speaker, as a attendee at FOSSASIA and as a traveler to Singapore.</p>
<h2 id="about-fossasia"><strong>About FOSSASIA</strong></h2>
<p><img align="center" src="/assets/misc/fossasia.png" width="200" /></p>
<blockquote>
<p>FOSSASIA is the premier Free and Open Source technology event in Asia for developers, start-ups, and contributors. Projects at FOSSASIA range from open hardware, to design, graphics and software. FOSSASIA was established in 2009. Previous events took place in Cambodia and Vietnam.</p>
</blockquote>
<p>As the name suggests its one of the largest tech conferences in Asia and my expectations were pretty high from this conference and moreover It was my first international conference. I witnessed lots of amazing people in the conference and interacted with a few as well. This is how it started:</p>
<p><img align="center" src="/assets/misc/harish-fossasia.jpg" width="400" /></p>
<h2 id="the-sympypydy-workshop">The SymPy/PyDy Workshop</h2>
<p>Community is more important than Code @ Singapore Science Center Level 3, Pauling Lab
<img align="center" src="/assets/sympy-zen.jpg" width="400" /></p>
<p>The SymPy and PyDy workshop was scheduled on 20th March at 1:00 - 2:00 PM (PyDy) and 2:00 - 4:00 PM (SymPy). <a href="http://www.moorepants.info/">Jason</a> suggested to conduct the SymPy workshop first since PyDy uses SymPy and it would be easier for people to learn SymPy first and then PyDy, but since the <a href="http://2016.fossasia.org/schedule/">schedule</a> was already published, It was not possible to reschedule the workshops, so we had to continue with PyDy first.
<a href="https://github.com/sahilshekhawat">Sahil</a> started the PyDy workshop at 1:00 PM, though we had to spend a lot of time installing Anaconda to everyone’s systems by creating a local server and distributing flash drives as most of the people didn’t had Anaconda or Canopy installed. This has been the problem for almost all the workshops I have conducted in the past. It seems I need to invent an efficient way to do this faster in future as we spent 30-40 odd minutes in installation.</p>
<p><img align="center" src="/assets/misc/sympy-fossasia.jpg" width="400" /></p>
<p>Fortunately <a href="https://github.com/sahilshekhawat">Sahil</a> finished his presentation at around 2:15 PM. Then I took over for SymPy workshop, I started with the basic introduction to SymPy, the slides can be found <a href="http://slides.com/aktech/sympy">here</a>. Then I jumped to IPython notebook exercises to demonstrate more of SymPy. People were amazed by the capabilities of this amazing piece of software. The most beautiful feature they liked was printing and integration. The workshop went pretty well except for the glitches in the HDMI port of my laptop (probably, its the right time to get a new laptop). Here are some SymPy stickers for you, if you missed there.</p>
<p><img align="center" src="/assets/misc/sympy-sticker-fossasia.jpg" width="400" /></p>
<h2 id="singapore-was-fun-">Singapore was Fun ;)</h2>
<p>Visiting Singapore has been a great experience, the culture is a mix of <a href="https://en.wikipedia.org/wiki/Malaysian">Malaysian</a>, Indian and native Singaporean. The City is well connected with <a href="https://en.wikipedia.org/wiki/Mass_Rapid_Transit_(Singapore)">MRT/SMRT</a> (Metro and Buses). It’s quite easy get anywhere around the city. People here are very helpful and nice. I didn’t faced any problems throughout my stay there. I spent most of my time near <a href="https://en.wikipedia.org/wiki/Science_Centre_Singapore">Science Center</a>, China Town and Little India. There were lot of people from India and particularly from Delhi and three from my University. It was awesome time spent with geeks all around. Tagging some of them <a href="http://devmaany.co/">Mayank</a>, <a href="http://www.ishankhanna.in/">Ishaan</a>, <a href="http://omerjerk.in/">Umair</a>, <a href="https://github.com/jig08">Jigyasa</a>, <a href="http://iyask.me/">Yask</a>, <a href="http://garvitdelhi.blogspot.in/">Garvit</a>, <a href="http://home.iiitd.edu.in/~manan13056/">Manan</a>, sorry If I missed someone. Here is a pic of the last day of the conference.</p>
<p><img align="center" src="/assets/misc/fossasia-all.jpg" width="400" /></p>
<h2 id="thank-you">Thank you!</h2>
<p>Thank you FOSSASIA Organizing Team, Hong Phuc Dang for inviting me to be part of this awesome FOSS community.
I would not have been able to attend the conference without the generous financial support from SymPy, Thank you <a href="http://www.ondrejcertik.com/">Ondrej Certik</a>, <a href="http://asmeurer.github.io/blog/">Aaron Meurer</a> & SymPy contributors.</p>
<h3 id="good-bye">Good Bye!</h3>
<p>Good bye! everyone, see you on my next blog post, meanwhile you can have a look at a Picture of me doing back flip at Sentosa ;)
<img align="center" src="/assets/amit-backflip.gif" /></p>
SymPy Workshop at PyDelhi Meetup 🎙️2016-02-07T00:00:00+05:30https://iamit.in/blog/SymPy Workshop at PyDelhi Meetup<p>Hi there! It’s been sometime now since my last blog post, It’s probably the right time to write one now. Yesterday, I gave a talk on SymPy at Python Delhi User group Meetup at <a href="https://maps.google.com/maps?f=q&hl=en&q=29%2C+Rajpur+Road%2C+Delhi%2C+in">CSDS</a>, New Delhi. Things never go the way you want, an hour was wasted in just setting up Anaconda on everyone’s system, eventually I had to cut on the material I could demonstrate, though It was nice to see that people were very enthusiatic about SymPy, they actively solved excercises. It was fun interacting with everyone.</p>
<p>Here is a Pic of the Seminar room at CSDS:
<img align="center" src="/assets/sympy-workshop.jpg" /></p>
<p>I should also admit that, I have increased my appetite for attending conferences and meetups, these days. In the last 4 months I have attended 3 Meetups (PyDelhi Meetup) and 1 Conference (PyCon India 2015). I think this is one of the best things I have done in last few years & I would recommend anyone with a slight interest in Python either Beginner or Expert should attend <a href="http://www.pydelhi.org">PyDelhi</a> <a href="http://www.meetup.com/pydelhi/events/">Meetups</a>. Looking forward to more such meetups and conferences.</p>
<p><img src="/assets/misc/sympy-sticker.jpg" /></p>
<p>I gave SymPy stickers to everyone who solved atleast one excercise (Since, I didn’t had enough stickers).</p>
GSoC : Throughout in SymPy # Wrap Up2015-08-28T00:00:00+05:30https://iamit.in/blog/GSoC : Throughout in SymPy # Wrap Up<p>Hi! I am Amit Kumar (<a href="http://www.github.com/aktech"><strong>@aktech</strong></a>), a final year undergraduate student of Mathematics & Computing at Delhi Technological University. This post summarizes my experience working on GSoC Project on Improving Solvers in SymPy.</p>
<h2 id="introduction">Introduction</h2>
<p>I first stumbled upon SymPy last year, while looking for some Open Source Computer Algebra Systems to contribute. I didn’t had any Open Source experience by then, So SymPy was an Ideal Choice for getting into the beautiful world of Open Source. I wasn’t even Proficient in Python so at first it was little difficult for me, but Thanks! to the beauty of the language itself, which makes anyone comfortable with it in no time. Soon, I decided to participate into Google Summer of Code under SymPy. Though at this point of time, I didn’t had decided about the project, I would like to work in Summers.</p>
<h5 id="first-contribution">First Contribution</h5>
<p>I started learning the codebase & made my first contribution by Fixing an EasyToFix bug in <code class="language-plaintext highlighter-rouge">solvers.py</code> through the PR <a href="https://github.com/sympy/sympy/pull/8647">#8647</a>, Thanks to <a href="">@smichr</a> for helping me making my first ever open source contribution. After my first PR, I started looking for more things to work and improve upon and I started commiting quite often. During this period I learnt the basics of Git, which is one of the most important tools for contributing to Open Source.</p>
<h2 id="project-ideas">Project Ideas</h2>
<p>When I got a bit comfortable with the basics of SymPy & contributing to open source in general, I decided to chose an area (module) to concentrate on. The modules I was interested in, were Solvers and Integrals, I was literally amazed by the capability of a CAS to integrate and solve equations. I decided to work on one of these in the summers. There was already some work done on the Integrals module in 2013, which was yet to be Merged. I wasn’t well versed about the Manuel Bronsteins works on Methods of Integration in a Computer Algebra System, so I was little skeptical about working on Integrals. The Solvers module attracted me due it’s awesome capabilities, I found it one of the most useful features of any Computer Algebra Systems, So I finally decided to work on Solvers Module.</p>
<h2 id="coding">Coding</h2>
<p>I was finally accepted to work on Solvers this summer. I had my exams during the community bonding period, So I started almost in the first week of Coding Period. I made a detailed timeline of my work in summers, but through my experience I can say that’s seldom useful. Since, you never know what may come out in between you and your schedule. As an instance PR <a href="https://github.com/sympy/sympy/pull/9540">#9540</a>, was a stumbling block in lot of my work, which was necessary to fix for proceeding ahead.</p>
<h4 id="phase-i-before-mid-terms">Phase I (Before Mid Terms)</h4>
<p>When coding period commenced, I started implementing the <code class="language-plaintext highlighter-rouge">linsolve</code>, the linear system solver which is tolerant to different input forms & can solve almost all forms of linear systems. At the start I got lot of reviews from Jason and Harsh, regarding improvement of the function. One of the most important thing I learnt which they focused on was Test Driven Development, they suggested me to write extensive tests before implementing the logic, which helps in reducing the problems in visualizing the final implementaion of the function and avoids API changes.</p>
<p>After <code class="language-plaintext highlighter-rouge">linsolve</code> I implemented <code class="language-plaintext highlighter-rouge">ComplexPlane</code>, which is basically Complex Sets. It is useful for representing infinite solutions in argand plane. While implementing this I learnt that chosing the right API is one of the most important factors while designing aa important functionality. To know more about it, see my blog post <a href="http://iamit.in/blog/GSoC-week-3/">here</a>. During this period I also worked on fixing Intersection’s of FiniteSet with symbolic elements, which was a stumbling block.</p>
<h4 id="phase-ii-after-mid-terms">Phase II (After Mid Terms)</h4>
<p>After successfully passing the Mid Terms, I started working more on robustness of <code class="language-plaintext highlighter-rouge">solveset</code>, Thanks to @hargup for pointing out the motivation for this work. The idea is to tell the user about the domain of solution returned. Simplest motivation was the solution of the equation <code class="language-plaintext highlighter-rouge">|x| - n</code>, for more info see my blog post <a href="http://iamit.in/blog/GSoC-week-7/">here</a>. I also worked on various trivial and non trivial bugs which were more or less blocking my work.</p>
<p>Then I started replacing <code class="language-plaintext highlighter-rouge">solve</code> with <code class="language-plaintext highlighter-rouge">solveset</code> in the codebase, the idea was to make a smooth transition between <code class="language-plaintext highlighter-rouge">solve</code> and <code class="language-plaintext highlighter-rouge">solveset</code>, while doing this Jason pointed out that I should not remove <code class="language-plaintext highlighter-rouge">solve</code> tests, which can make <code class="language-plaintext highlighter-rouge">solve</code> vunerable to break, So I reverted removing of solve tests. Later we decided to add <code class="language-plaintext highlighter-rouge">domain</code> argument to <code class="language-plaintext highlighter-rouge">solveset</code>, which would help the user in easily dictating to solveset about what solutions they are interested in, thanks to @shivamvats for doing this in a PR.
After the decision of adding <code class="language-plaintext highlighter-rouge">domain</code> argument, Harsh figured out that, as of now <code class="language-plaintext highlighter-rouge">solveset</code> is vunerable to API changes, so it’s not the right time to replace solve with solveset, so we decided to halt this work, as a result I closed my several PR’s unmerged.</p>
<p>I also worked on Implementing Differential Calculus Method such as <code class="language-plaintext highlighter-rouge">is_increasing</code> etc, which is also Merged now. Meanwhile I have been working on documenting <code class="language-plaintext highlighter-rouge">solveset</code>, because a lot of people don’t know what we are doing & why we are doing, so It’s very important to answer all those subtle questions which may come up in there mind, So we decided to create a FAQ style documentation of <code class="language-plaintext highlighter-rouge">solveset</code> see PR <a href="https://github.com/sympy/sympy/pull/9500">#9500</a>. This is almost done, some polishing is needed. It would be Merged soon.</p>
<p>During this period apart from my work, there are some other works as well which is worth mentioning, one of them is <code class="language-plaintext highlighter-rouge">ConditionSet</code> by Harsh which serves the purpose of unevaluated solve object and even much more than that for our future endeavours with <code class="language-plaintext highlighter-rouge">solveset</code>. Others being <code class="language-plaintext highlighter-rouge">codomain</code> & <code class="language-plaintext highlighter-rouge">not_empty</code> by Gaurav <a href="http://github.com/gxyd">@gxyd</a> which are also important additions to SymPy.</p>
<h2 id="advice">Advice</h2>
<p>TODO: Probably, this will need a comprehensive post, I would write soon.</p>
<h2 id="future-plans">Future Plans</h2>
<p>Recently Harsh came up with an idea of tree based solver. Since now <code class="language-plaintext highlighter-rouge">ConditionSet</code> has been introduced, the solving of equations can be seen as set transformation, We can do the following things to solve equations (abstract View):</p>
<ul>
<li>Apply Various Set Transformations on the given Set.</li>
<li>Define a Metric of the usability or define a notion of better solution over others.</li>
<li>Different Transformation would be the nodes of the tree.</li>
<li>Suitable searching techniques could be applied to get the best solution.</li>
</ul>
<p>For more info see mailing list thread <a href="https://groups.google.com/forum/#!topic/sympy/-SIbX0AFL3Q">here</a>.</p>
<p>As a part of this I worked on implementing a general decomposition function <code class="language-plaintext highlighter-rouge">decompogen</code> in PR <a href="https://github.com/sympy/sympy/pull/9831">#9831</a>, It’s almost done, will be merged soon.</p>
<p>I plan for a long term association with SymPy, I take the full responsibilty of my code. I will try to contribute as much as I can particularly in sets and solvers module.</p>
<h2 id="conclusion">Conclusion</h2>
<p>On a concluding note, I must say that getting the opportunity to work on SymPy this summer has been one of the best things that could happen to me. Thanks to Harsh for helping me all my endeavour, also for being one of the best mentors I could get. I would like to thank Sean as well who from his busy schedule took up the time to attend meetings, hangouts and for doing code reviews. Also thanks to Chris Smith who is the most gentle and helpful person I have ever seen, he is one of the reasons I started contributing to SymPy.
Thanks to Aaron, Ondrej, and last but not the least my fellow GSoCer’s at SymPy <a href="http://github.com/leosartaj">leosartaj</a>, <a href="http://github.com/debugger22">debugger22</a>, <a href="http://github.com/sumith1896">sumith1896</a>, <a href="http://github.com/shivamvats">shivamvats</a>, <a href="https://github.com/abinashmeher999">abinashmeher999</a>. Special Thanks to whole SymPy team and Community for a wonderful collaboration experience. Kudos!</p>
GSoC : This week in SymPy #10 & #112015-08-11T00:00:00+05:30https://iamit.in/blog/GSoC : This week in SymPy #10 &11<p>Hi there! It’s been 11 weeks into <a href="https://en.wikipedia.org/wiki/Google_Summer_of_Code">GSoC</a>
and we have reached into the last week before the soft deadline. Here is the Progress so far.</p>
<h3 id="-progress-of-week-10--11-"> <strong>Progress of Week 10 & 11</strong> <img style="float: left" src="/assets/gsoc/pr.png" /></h3>
<p>Last couple of weeks, I worked mainly on the Documentation of the solveset module. It’s very important to let others know what we are doing and why we are doing, so this <a href="http://github.com/sympy/sympy/pull/9500">PR #9500</a> is an effort to accomplish that.
Here are some of the important questions, I have tried to answer in the <a href="http://github.com/sympy/sympy/pull/9500">PR #9500</a></p>
<ul>
<li>What was the need of a new solvers module?</li>
<li>Why do we use sets as an output type?</li>
<li>What is this domain argument about?</li>
<li>What will you do with the old solve?</li>
<li>What are the general design principles behind the development of solveset?</li>
<li>What are the general methods employed by solveset to solve an equation?</li>
<li>How do we manipulate and return an infinite solutions?</li>
<li>How does solveset ensures that it is not returning any wrong solution?</li>
</ul>
<p>There is still some polishing required in this as suggested by <a href="http://github.com/hargup">@hargup</a></p>
<h4 id="linsolve-docs"><strong>Linsolve Docs</strong></h4>
<p>I completed the documentation PR for <code class="language-plaintext highlighter-rouge">linsolve</code>. See <a href="https://github.com/sympy/sympy/pull/9587">PR #9587</a></p>
<h4 id="differential-calculus-methods"><strong>Differential Calculus Methods</strong></h4>
<p>I have also started working on the differential calculus methods as mentioned in my proposal <a href="https://github.com/sympy/sympy/wiki/GSoC-2015-Application-AMiT-Kumar--Solvers-:-Extending-Solveset#week-12">here</a>.
See <a href="https://github.com/aktech/sympy/tree/diff-cal">diff-cal</a> branch.</p>
<h3 id="from-__future__-import-plan--week-12"><strong>from __future__ import plan</strong> Week #12:</h3>
<p>This week I plan to finish up all the pending work and wrap up the project and get <a href="http://github.com/sympy/sympy/pull/9500">PR #9500</a> Merged.</p>
<h3 id="-git-log"><strong>$ git log</strong></h3>
<ul>
<li><a href="https://github.com/sympy/sympy/pull/9500">PR #9500</a> : Documenting <code class="language-plaintext highlighter-rouge">solveset</code></li>
<li><a href="https://github.com/sympy/sympy/pull/9587">PR #9587</a> : Add Linsolve Docs</li>
</ul>
<p>That’s all for now, looking forward for week #12. :grinning:</p>
GSoC : This week in SymPy #92015-07-28T00:00:00+05:30https://iamit.in/blog/GSoC : This week in SymPy #9<p>Hi there! It’s been nine weeks into <a href="https://en.wikipedia.org/wiki/Google_Summer_of_Code">GSoC</a>
. Here is the Progress for this week.</p>
<h3 id="-progress-of-week-9-"> <strong>Progress of Week 9</strong> <img style="float: left" src="/assets/gsoc/pr.png" /></h3>
<p>This week I worked on Replacing <code class="language-plaintext highlighter-rouge">solve</code> with <code class="language-plaintext highlighter-rouge">solveset</code> or <code class="language-plaintext highlighter-rouge">linsolve</code> in the codebase:
Here are the modules, I covered, as of now:</p>
<ul>
<li><a href="https://github.com/sympy/sympy/pull/9740">diffgeom</a></li>
<li><a href="https://github.com/sympy/sympy/pull/9718">calculus</a></li>
<li><a href="https://github.com/sympy/sympy/pull/9724">core</a></li>
<li><a href="https://github.com/sympy/sympy/pull/9743">functions</a></li>
<li><a href="https://github.com/sympy/sympy/pull/9744">galgebra</a></li>
<li><a href="https://github.com/sympy/sympy/pull/9708">geometry</a></li>
<li><a href="https://github.com/sympy/sympy/pull/9745">ntheory</a></li>
<li><a href="https://github.com/sympy/sympy/pull/9738">simplify</a></li>
<li><a href="https://github.com/sympy/sympy/pull/9717">series</a></li>
<li><a href="https://github.com/sympy/sympy/pull/9716">sets</a></li>
<li><a href="https://github.com/sympy/sympy/pull/9710">stats</a></li>
</ul>
<p><a href="github.com/moorepants">@moorepants</a> pointed out that I should not change old <code class="language-plaintext highlighter-rouge">solve</code>tests, since people may break an untested code, this argument is valid, so I have added equivalent tests for <code class="language-plaintext highlighter-rouge">solveset</code>, where it is competent with <code class="language-plaintext highlighter-rouge">solve</code>.</p>
<p>There are some untested code in codebase as well, where <code class="language-plaintext highlighter-rouge">solve</code> is used, for those cases replacing has not been done, as the tests would pass anyway, since those lines are not tested. So I have added a TODO for those instances, to replace with <code class="language-plaintext highlighter-rouge">solveset</code>, when those lines are tested.</p>
<h4 id="other-work">Other Work</h4>
<p>I also changed the output of <code class="language-plaintext highlighter-rouge">linsolve</code> when no solution are returned, earlier it throwed <code class="language-plaintext highlighter-rouge">ValueError</code> & now it returns an <code class="language-plaintext highlighter-rouge">EmptySet()</code>, which is consistent with rest of the <code class="language-plaintext highlighter-rouge">solveset</code>. See <a href="https://github.com/sympy/sympy/pull/9726">PR #9726</a></p>
<h3 id="from-__future__-import-plan--week-10"><strong>from __future__ import plan</strong> Week #10:</h3>
<p>This week I plan to Merge my pending PR’s on replacing old <code class="language-plaintext highlighter-rouge">solve</code> in the code base with <code class="language-plaintext highlighter-rouge">solveset</code>, and work on Documentation & <code class="language-plaintext highlighter-rouge">lambertw</code> solver.</p>
<h3 id="-git-log"><strong>$ git log</strong></h3>
<ul>
<li><a href="https://github.com/sympy/sympy/pull/9726">PR #9726</a> : Return EmptySet() if there are no solution to linear system</li>
<li><a href="https://github.com/sympy/sympy/pull/9724">PR #9724</a> : Replace solve with solveset in core</li>
<li><a href="https://github.com/sympy/sympy/pull/9717">PR #9717</a> : Replace solve with solveset in sympy.calculus</li>
<li><a href="https://github.com/sympy/sympy/pull/9716">PR #9716</a> : Use solveset instead of solve in sympy.sets</li>
<li><a href="https://github.com/sympy/sympy/pull/9717">PR #9717</a> : Replace solve with solveset in <code class="language-plaintext highlighter-rouge">sympy.series</code></li>
<li><a href="https://github.com/sympy/sympy/pull/9710">PR #9710</a> : Replace solve with solveset in <code class="language-plaintext highlighter-rouge">sympy.stats</code></li>
<li><a href="https://github.com/sympy/sympy/pull/9708">PR #9708</a> : Use solveset instead of solve in <code class="language-plaintext highlighter-rouge">sympy.geometry</code></li>
<li><a href="https://github.com/sympy/sympy/pull/9587">PR #9587</a> : Add Linsolve Docs</li>
<li><a href="https://github.com/sympy/sympy/pull/9500">PR #9500</a> : Documenting <code class="language-plaintext highlighter-rouge">solveset</code></li>
</ul>
<p>That’s all for now, looking forward for week #10. :grinning:</p>
GSoC : This week in SymPy #82015-07-21T00:00:00+05:30https://iamit.in/blog/GSoC : This week in SymPy #8<p>Hi there! It’s been eight weeks into <a href="https://en.wikipedia.org/wiki/Google_Summer_of_Code">GSoC</a>
. Here is the Progress for this week.</p>
<h3 id="-progress-of-week-8-"> <strong>Progress of Week 8</strong> <img style="float: left" src="/assets/gsoc/pr.png" /></h3>
<p>This week, my PR for making <code class="language-plaintext highlighter-rouge">invert_real</code> more robust was Merged, along with these:</p>
<ul>
<li>
<p><a href="https://github.com/sympy/sympy/pull/9628">PR #9628</a> : Make <code class="language-plaintext highlighter-rouge">invert_real</code> more robust</p>
</li>
<li>
<p><a href="https://github.com/sympy/sympy/pull/9668">PR #9668</a> : Support solving for Dummy symbols in <code class="language-plaintext highlighter-rouge">linsolve</code></p>
</li>
<li>
<p><a href="https://github.com/sympy/sympy/pull/9666">PR #9666</a> : Equate <code class="language-plaintext highlighter-rouge">S.Complexes</code> with <code class="language-plaintext highlighter-rouge">ComplexPlane(S.Reals*S.Reals)</code></p>
</li>
</ul>
<p><strong>Note</strong>: We renamed <code class="language-plaintext highlighter-rouge">S.Complex</code> to <code class="language-plaintext highlighter-rouge">S.Complexes</code>, which is analogous with <code class="language-plaintext highlighter-rouge">S.Reals</code> as suggested by <a href="https://github.com/jksuom">@jksuom</a>.</p>
<p>I also opened <a href="https://github.com/sympy/sympy/pull/9671">PR #9671</a> for Simplifying ComplexPlane output when ProductSet of FiniteSets are given as input: <code class="language-plaintext highlighter-rouge">ComplexPlane(FiniteSet(x)*FiniteSet(y))</code>, It was earlier simplified to:</p>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">ComplexPlane</span><span class="p">(</span><span class="n">Lambda</span><span class="p">((</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">),</span> <span class="n">x</span> <span class="o">+</span> <span class="n">I</span><span class="o">*</span><span class="n">y</span><span class="p">),</span> <span class="p">{</span><span class="n">x</span><span class="p">}</span> <span class="n">x</span> <span class="p">{</span><span class="n">y</span><span class="p">})</span>
</code></pre></div></div>
<p>It isn’t very useful to represent a point or discrete set of points in <code class="language-plaintext highlighter-rouge">ComplexPlane</code> with an expression like above. So in the above PR it is now simplified as <code class="language-plaintext highlighter-rouge">FiniteSet</code> of discrete points in <code class="language-plaintext highlighter-rouge">ComplexPlane</code>:</p>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">In</span> <span class="p">[</span><span class="mi">3</span><span class="p">]:</span> <span class="n">ComplexPlane</span><span class="p">(</span><span class="n">FiniteSet</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">c</span><span class="p">)</span><span class="o">*</span><span class="n">FiniteSet</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">))</span>
<span class="n">Out</span><span class="p">[</span><span class="mi">3</span><span class="p">]:</span> <span class="p">{</span><span class="n">a</span> <span class="o">+</span> <span class="n">I</span><span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="n">a</span> <span class="o">+</span> <span class="n">I</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="n">a</span> <span class="o">+</span> <span class="n">I</span><span class="o">*</span><span class="n">z</span><span class="p">,</span> <span class="n">b</span> <span class="o">+</span> <span class="n">I</span><span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="n">b</span> <span class="o">+</span> <span class="n">I</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="n">b</span> <span class="o">+</span> <span class="n">I</span><span class="o">*</span><span class="n">z</span><span class="p">,</span> <span class="n">c</span> <span class="o">+</span> <span class="n">I</span><span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="n">c</span> <span class="o">+</span> <span class="n">I</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="n">c</span> <span class="o">+</span> <span class="n">I</span><span class="o">*</span><span class="n">z</span><span class="p">}</span>
</code></pre></div></div>
<p>It’s awaiting Merge, as of now.</p>
<p>Now, I have started replacing <code class="language-plaintext highlighter-rouge">solve</code> with <code class="language-plaintext highlighter-rouge">solveset</code> and <code class="language-plaintext highlighter-rouge">linsolve</code>.</p>
<h3 id="from-__future__-import-plan--week-9"><strong>from __future__ import plan</strong> Week #9:</h3>
<p>This week I plan to Merge my pending PR’s & work on replacing old <code class="language-plaintext highlighter-rouge">solve</code> in the code base with <code class="language-plaintext highlighter-rouge">solveset</code>.</p>
<h3 id="-git-log"><strong>$ git log</strong></h3>
<ul>
<li><a href="https://github.com/sympy/sympy/pull/9710">PR #9710</a> : Replace solve with solveset in <code class="language-plaintext highlighter-rouge">sympy.stats</code></li>
<li><a href="https://github.com/sympy/sympy/pull/9708">PR #9708</a> : Use solveset instead of solve in <code class="language-plaintext highlighter-rouge">sympy.geometry</code></li>
<li><a href="https://github.com/sympy/sympy/pull/9671">PR #9671</a> : Simplify <code class="language-plaintext highlighter-rouge">ComplexPlane({x}*{y})</code> to <code class="language-plaintext highlighter-rouge">FiniteSet(x + I*y)</code></li>
<li><a href="https://github.com/sympy/sympy/pull/9668">PR #9668</a> : Support solving for Dummy symbols in linsolve</li>
<li><a href="https://github.com/sympy/sympy/pull/9666">PR #9666</a> : Equate S.Complexes with <code class="language-plaintext highlighter-rouge">ComplexPlane(S.Reals*S.Reals)</code></li>
<li><a href="https://github.com/sympy/sympy/pull/9628">PR #9628</a> : Make invert_real more robust</li>
<li><a href="https://github.com/sympy/sympy/pull/9587">PR #9587</a> : Add Linsolve Docs</li>
<li><a href="https://github.com/sympy/sympy/pull/9500">PR #9500</a> : Documenting <code class="language-plaintext highlighter-rouge">solveset</code></li>
</ul>
<p>That’s all for now, looking forward for week #9. :grinning:</p>
GSoC : This week in SymPy #72015-07-15T00:00:00+05:30https://iamit.in/blog/GSoC : This week in SymPy #7<p>Hi there! It’s been seven weeks into <a href="https://en.wikipedia.org/wiki/Google_Summer_of_Code">GSoC</a>
and second half has started now. Here is the Progress so far.</p>
<h3 id="-progress-of-week-7-"> <strong>Progress of Week 7</strong> <img style="float: left" src="/assets/gsoc/pr.png" /></h3>
<p>This week I Opened <a href="https://github.com/sympy/sympy/pull/9628">#9628</a>, which is basically an attempt to make <code class="language-plaintext highlighter-rouge">solveset</code> more robust, as I mentioned in my <a href="http://iamit.in/blog/GSoC-week-6/">last post</a>.
The idea is to tell the user about the domain of solution returned.</p>
<p>Now, It makes sure that n is positive, in the following example:</p>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
<span class="n">In</span> <span class="p">[</span><span class="mi">3</span><span class="p">]:</span> <span class="n">x</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s">'x'</span><span class="p">,</span> <span class="n">real</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">In</span> <span class="p">[</span><span class="mi">4</span><span class="p">]:</span> <span class="n">n</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s">'n'</span><span class="p">,</span> <span class="n">real</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">In</span> <span class="p">[</span><span class="mi">7</span><span class="p">]:</span> <span class="n">solveset</span><span class="p">(</span><span class="n">Abs</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">-</span> <span class="n">n</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="n">Out</span><span class="p">[</span><span class="mi">7</span><span class="p">]:</span> <span class="n">Intersection</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="n">oo</span><span class="p">),</span> <span class="p">{</span><span class="n">n</span><span class="p">})</span> <span class="n">U</span> <span class="n">Intersection</span><span class="p">((</span><span class="o">-</span><span class="n">oo</span><span class="p">,</span> <span class="mi">0</span><span class="p">],</span> <span class="p">{</span><span class="o">-</span><span class="n">n</span><span class="p">})</span>
</code></pre></div></div>
<p>Otherwise it will return an <code class="language-plaintext highlighter-rouge">EmptySet()</code></p>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">In</span> <span class="p">[</span><span class="mi">6</span><span class="p">]:</span> <span class="n">solveset</span><span class="p">(</span><span class="n">Abs</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">-</span> <span class="n">n</span><span class="p">,</span> <span class="n">x</span><span class="p">).</span><span class="n">subs</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span>
<span class="n">Out</span><span class="p">[</span><span class="mi">6</span><span class="p">]:</span> <span class="n">EmptySet</span><span class="p">()</span>
</code></pre></div></div>
<p>Earlier:</p>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">In</span> <span class="p">[</span><span class="mi">12</span><span class="p">]:</span> <span class="n">solveset</span><span class="p">(</span><span class="n">Abs</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">-</span> <span class="n">n</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="n">Out</span><span class="p">[</span><span class="mi">12</span><span class="p">]:</span> <span class="p">{</span><span class="o">-</span><span class="n">n</span><span class="p">,</span> <span class="n">n</span><span class="p">}</span>
</code></pre></div></div>
<p>So, for this to happen, we needed to make changes in the <code class="language-plaintext highlighter-rouge">invert_real</code>:</p>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">Abs</span><span class="p">):</span>
<span class="n">g_ys</span> <span class="o">=</span> <span class="n">g_ys</span> <span class="o">-</span> <span class="n">FiniteSet</span><span class="p">(</span><span class="o">*</span><span class="p">[</span><span class="n">g_y</span> <span class="k">for</span> <span class="n">g_y</span> <span class="ow">in</span> <span class="n">g_ys</span> <span class="k">if</span> <span class="n">g_y</span><span class="p">.</span><span class="n">is_negative</span><span class="p">])</span>
<span class="k">return</span> <span class="n">_invert_real</span><span class="p">(</span><span class="n">f</span><span class="p">.</span><span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span>
<span class="n">Union</span><span class="p">(</span><span class="n">g_ys</span><span class="p">,</span> <span class="n">imageset</span><span class="p">(</span><span class="n">Lambda</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="o">-</span><span class="n">n</span><span class="p">),</span> <span class="n">g_ys</span><span class="p">)),</span> <span class="n">symbol</span><span class="p">)</span>
<span class="n">Union</span><span class="p">(</span><span class="n">imageset</span><span class="p">(</span><span class="n">Lambda</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">n</span><span class="p">),</span> <span class="n">g_ys</span><span class="p">).</span><span class="n">intersect</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">oo</span><span class="p">)),</span>
<span class="n">imageset</span><span class="p">(</span><span class="n">Lambda</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="o">-</span><span class="n">n</span><span class="p">),</span> <span class="n">g_ys</span><span class="p">).</span><span class="n">intersect</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="o">-</span><span class="n">oo</span><span class="p">,</span> <span class="mi">0</span><span class="p">))),</span>
<span class="n">symbol</span><span class="p">)</span>
</code></pre></div></div>
<p>So, we applied set operations on the invert to make it return non-EmptySet only when there is a solution.</p>
<h3 id="now-for-more-complex-cases">Now For more Complex Cases:</h3>
<p>For the following case:</p>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">In</span> <span class="p">[</span><span class="mi">14</span><span class="p">]:</span> <span class="n">invert_real</span><span class="p">(</span><span class="mi">2</span><span class="o">**</span><span class="n">x</span><span class="p">,</span> <span class="mi">2</span> <span class="o">-</span> <span class="n">a</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="n">Out</span><span class="p">[</span><span class="mi">14</span><span class="p">]:</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="p">{</span><span class="n">log</span><span class="p">(</span><span class="o">-</span><span class="n">a</span> <span class="o">+</span> <span class="mi">2</span><span class="p">)</span><span class="o">/</span><span class="n">log</span><span class="p">(</span><span class="mi">2</span><span class="p">)})</span>
</code></pre></div></div>
<p>For the invert to be real, we must state that <code class="language-plaintext highlighter-rouge">a</code> belongs to the Interval <code class="language-plaintext highlighter-rouge">(-oo, 2]</code> otherwise it would be complex, but no set operation on <code class="language-plaintext highlighter-rouge">{log(-a + 2)/log(2)}</code> can make the interval of <code class="language-plaintext highlighter-rouge">a</code> to be in <code class="language-plaintext highlighter-rouge">(-oo, 2]</code>.</p>
<p>Although, it does returns an <code class="language-plaintext highlighter-rouge">EmptySet()</code> on substituting absurd values:</p>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">In</span> <span class="p">[</span><span class="mi">23</span><span class="p">]:</span> <span class="n">solveset</span><span class="p">(</span><span class="mi">2</span><span class="o">**</span><span class="n">x</span> <span class="o">+</span> <span class="n">a</span> <span class="o">-</span> <span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="p">).</span><span class="n">subs</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
<span class="n">Out</span><span class="p">[</span><span class="mi">23</span><span class="p">]:</span> <span class="n">EmptySet</span><span class="p">()</span>
</code></pre></div></div>
<p>So, we need not make any changes to the <code class="language-plaintext highlighter-rouge">Pow</code> handling in <code class="language-plaintext highlighter-rouge">invert_real</code> & It’s almost done now, except for a couple of TODO’s:</p>
<ul>
<li>Document new changes</li>
<li>Add More tests</li>
</ul>
<p>Though, I will wait for final thumbs up from <a href="http://www.github.com/hargup">@hargup</a>, regarding this.</p>
<h3 id="from-__future__-import-plan--week-7"><strong>from __future__ import plan</strong> Week #7:</h3>
<p>This week I plan to complete <a href="https://github.com/sympy/sympy/pull/9618">PR #9628</a> & get it Merged & start working on replacing old <code class="language-plaintext highlighter-rouge">solve</code> in the code base with <code class="language-plaintext highlighter-rouge">solveset</code>.</p>
<h3 id="-git-log"><strong>$ git log</strong></h3>
<p>Below is the list of other PR’s I worked on:</p>
<ul>
<li><a href="https://github.com/sympy/sympy/pull/9671">PR #9671</a> : Simplify <code class="language-plaintext highlighter-rouge">ComplexPlane({x}*{y})</code> to <code class="language-plaintext highlighter-rouge">FiniteSet(x + I*y)</code></li>
<li><a href="https://github.com/sympy/sympy/pull/9668">PR #9668</a> : Support solving for Dummy symbols in linsolve</li>
<li><a href="https://github.com/sympy/sympy/pull/9666">PR #9666</a> : Equate S.Complexes with <code class="language-plaintext highlighter-rouge">ComplexPlane(S.Reals*S.Reals)</code></li>
<li><a href="https://github.com/sympy/sympy/pull/9628">PR #9628</a> : [WIP] Make invert_real more robust</li>
<li><a href="https://github.com/sympy/sympy/pull/9587">PR #9587</a> : Add Linsolve Docs</li>
<li><a href="https://github.com/sympy/sympy/pull/9500">PR #9500</a> : Documenting <code class="language-plaintext highlighter-rouge">solveset</code></li>
</ul>
<p>That’s all for now, looking forward for week #8. :grinning:</p>
GSoC : This week in SymPy #62015-07-06T00:00:00+05:30https://iamit.in/blog/GSoC : This week in SymPy #6<p>Hi there! It’s been six weeks into <a href="https://en.wikipedia.org/wiki/Google_Summer_of_Code">GSoC</a>,
and it marks the half of GSoC. The Mid term evaluations have been done now, Google has been preety quick doing this, I recieved the passing mail within 15 minutes after the deadline to fill up evaluations, so basically GSoC Admin did the following, (I guess):</p>
<div class="language-sql highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">SELECT</span> <span class="o">*</span> <span class="k">FROM</span> <span class="n">GSoCStudents</span>
<span class="k">WHERE</span> <span class="n">EvaluationResult</span><span class="o">=</span><span class="s1">'PASS'</span><span class="p">;</span>
</code></pre></div></div>
<div class="language-sql highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">and</span> <span class="n">SendThemMail</span>
</code></pre></div></div>
<p>(Don’t Judge my SQL, I am not good at it!)</p>
<h3 id="-progress-of-week-6-"> <strong>Progress of Week 6</strong> <img style="float: left" src="/assets/gsoc/pr.png" /></h3>
<p>Last week my <code class="language-plaintext highlighter-rouge">Linsolve</code> <a href="https://github.com/sympy/sympy/pull/9438">PR #9438</a>
finally got Merged Thanks! to <a href="http://github.com/hargup">@hargup</a> <a href="http://github.com/moorepants">@moorepants</a> <a href="http://github.com/flacjacket">@flacjacket</a> <a href="http://github.com/debugger22">@debugger22</a> for reviewing it and suggesting constructive changes.</p>
<p>This week I worked on Intersection’s of <code class="language-plaintext highlighter-rouge">FiniteSet</code> with symbolic elements, which was a blocking issue for lot of things, I managed to Fix the failing test which I mentioned in my last post. Eventually this PR got Merged as well, which has opened doors for lot of improvements.</p>
<p>Thanks to <a href="https://github.com/jksuom">@jksuom</a> & <a href="https://github.com/hargup">@hargup</a> for iterating over this PR, and making some very useful comments for improving it to make it Mergeable.</p>
<p>I had a couple of hangout meeting with <a href="https://github.com/hargup">@hargup</a> this week, (though now he has left for SciPy for a couple of weeks), we discussed about the further plan, for making <code class="language-plaintext highlighter-rouge">solveset</code> more robust, such as like returning the domain of invert while calling the <code class="language-plaintext highlighter-rouge">invert_real</code> , See <a href="https://github.com/sympy/sympy/issues/9617">#9617</a>.</p>
<p>Motivation for this:</p>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">In</span> <span class="p">[</span><span class="mi">8</span><span class="p">]:</span> <span class="n">x</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s">'x'</span><span class="p">,</span> <span class="n">real</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">In</span> <span class="p">[</span><span class="mi">9</span><span class="p">]:</span> <span class="n">n</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s">'n'</span><span class="p">,</span> <span class="n">real</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">In</span> <span class="p">[</span><span class="mi">12</span><span class="p">]:</span> <span class="n">solveset</span><span class="p">(</span><span class="n">Abs</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">-</span> <span class="n">n</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="n">Out</span><span class="p">[</span><span class="mi">12</span><span class="p">]:</span> <span class="p">{</span><span class="o">-</span><span class="n">n</span><span class="p">,</span> <span class="n">n</span><span class="p">}</span>
</code></pre></div></div>
<p>The solution returned above is not actually complete, unless, somehow we state <code class="language-plaintext highlighter-rouge">n</code> should be positive for the output set to be non-Empty. See <a href="https://github.com/sympy/sympy/issues/9588">#9588</a></p>
<h3 id="from-__future__-import-plan--week-7"><strong>from __future__ import plan</strong> Week #7:</h3>
<p>This week I plan to work on making <code class="language-plaintext highlighter-rouge">invert_real</code> more robust.</p>
<p>Relavant Issue:</p>
<ul>
<li><a href="https://github.com/sympy/sympy/issues/9617">#9617</a></li>
<li><a href="https://github.com/sympy/sympy/issues/9588">#9588</a></li>
</ul>
<h3 id="-git-log"><strong>$ git log</strong></h3>
<ul>
<li><a href="https://github.com/sympy/sympy/pull/9618">PR #9618</a> : Add test for <code class="language-plaintext highlighter-rouge">solveset(x**2 + a, x)</code> issue 9557</li>
<li><a href="https://github.com/sympy/sympy/pull/9587">PR #9587</a> : Add Linsolve Docs</li>
<li><a href="https://github.com/sympy/sympy/pull/9500">PR #9500</a> : Documenting <code class="language-plaintext highlighter-rouge">solveset</code></li>
<li><a href="https://github.com/sympy/sympy/pull/9612">PR #9612</a> : solveset return solution for <code class="language-plaintext highlighter-rouge">solveset(True, ..)</code></li>
<li><a href="https://github.com/sympy/sympy/pull/9540">PR #9540</a> : Intersection’s of FiniteSet with symbolic elements</li>
<li><a href="https://github.com/sympy/sympy/pull/9438">PR #9438</a> : Linsolve</li>
<li><a href="https://github.com/sympy/sympy/pull/9463">PR #9463</a> : ComplexPlane</li>
<li><a href="https://github.com/sympy/sympy/pull/9527">PR #9527</a> : Printing of ProductSets</li>
<li><a href="https://github.com/sympy/sympy/pull/9524">PR # 9524</a> : Fix solveset returned solution making denom zero</li>
</ul>
<p>That’s all for now, looking forward for week #7. :grinning:</p>
GSoC : This week in SymPy #4 & #52015-06-23T00:00:00+05:30https://iamit.in/blog/GSoC : This week in SymPy #4 & 5<p>Hi there! It’s been five weeks into <a href="https://en.wikipedia.org/wiki/Google_Summer_of_Code">GSoC</a>,
This week, I worked on polishing my previous PR’s to improve coverage and
fixing some bugs.</p>
<h3 id="-progress-of-week-4--5-"> <strong>Progress of Week 4 & 5</strong> <img style="float: left" src="/assets/gsoc/pr.png" /></h3>
<p>During the last couple of weeks my <code class="language-plaintext highlighter-rouge">ComplexPlane</code> Class <a href="https://github.com/sympy/sympy/pull/9463">PR #9438</a>
finally got <strong><em>Merged</em></strong> thanks to <a href="http://github.com/hargup">Harsh</a> for thoroughly reviewing it and suggesting constructive changes.</p>
<p>For this I Managed to improve it’s coverage to perfect 100%, which is indeed satisfying, as it depicts all the new code being pushed is completely tested.</p>
<p>This week I also improved the Exception handling and coverage in my <code class="language-plaintext highlighter-rouge">linsolve</code> <a href="https://github.com/sympy/sympy/pull/">PR</a>, It also have a 100% coverage.</p>
<h3 id="coverage-report">Coverage Report</h3>
<ul>
<li>[1] <code class="language-plaintext highlighter-rouge">gauss_jordan_solve</code> <strong>100 %</strong></li>
<li>[2] <code class="language-plaintext highlighter-rouge">linsolve</code> : <strong>100: %</strong></li>
</ul>
<h4 id="ref">Ref:</h4>
<ul>
<li>[1] <a href="http://iamit.in/sympy/coverage-report/matrices/">http://iamit.in/sympy/coverage-report/matrices/</a></li>
<li>[2] <a href="http://iamit.in/sympy/coverage-report/solveset/">http://iamit.in/sympy/coverage-report/solveset/</a></li>
</ul>
<p>It’s good to be Merged now.</p>
<h3 id="blocking-issue-intersections-of-finiteset-with-symbolic-elements"><strong>Blocking Issue</strong>: Intersection’s of FiniteSet with symbolic elements</h3>
<p>During Week 5, While working on transcendental equation solver in <code class="language-plaintext highlighter-rouge">solveset.py</code>, I discovered a blocking issue in <code class="language-plaintext highlighter-rouge">FiniteSets</code>, which is with the Intersection of <code class="language-plaintext highlighter-rouge">FiniteSet</code> containing symbolic elements, for example:</p>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">In</span> <span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="n">a</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s">'a'</span><span class="p">,</span> <span class="n">real</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">In</span> <span class="p">[</span><span class="mi">3</span><span class="p">]:</span> <span class="n">FiniteSet</span><span class="p">(</span><span class="n">log</span><span class="p">(</span><span class="n">a</span><span class="p">)).</span><span class="n">intersect</span><span class="p">(</span><span class="n">S</span><span class="p">.</span><span class="n">Reals</span><span class="p">)</span>
<span class="n">Out</span><span class="p">[</span><span class="mi">3</span><span class="p">]:</span> <span class="n">EmptySet</span><span class="p">()</span>
</code></pre></div></div>
<p>Currently, either <code class="language-plaintext highlighter-rouge">FiniteSet</code> is able to evaluate intersection otherwise it, returns an <code class="language-plaintext highlighter-rouge">EmptySet()</code>.
(See <a href="https://github.com/sympy/sympy/issues/9536">9536</a> & <a href="https://github.com/sympy/sympy/issues/8217">8217</a>).</p>
<p>To fix this, I have opened the PR <a href="https://github.com/sympy/sympy/pull/9540">#9540</a>.
Currently It fixes both the issues (<a href="https://github.com/sympy/sympy/issues/9536">9536</a> & <a href="https://github.com/sympy/sympy/issues/8217">8217</a>), but there are some failing tests using the current behaviour of <code class="language-plaintext highlighter-rouge">FiniteSet</code>.</p>
<p>####For example:</p>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">In</span> <span class="p">[</span><span class="mi">16</span><span class="p">]:</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s">'x y z'</span><span class="p">,</span> <span class="n">integer</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">In</span> <span class="p">[</span><span class="mi">19</span><span class="p">]:</span> <span class="n">f1</span> <span class="o">=</span> <span class="n">FiniteSet</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
<span class="n">In</span> <span class="p">[</span><span class="mi">20</span><span class="p">]:</span> <span class="n">f2</span> <span class="o">=</span> <span class="n">FiniteSet</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">z</span><span class="p">)</span>
</code></pre></div></div>
<ul>
<li>In Master:</li>
</ul>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">In</span> <span class="p">[</span><span class="mi">23</span><span class="p">]:</span> <span class="n">f1</span><span class="p">.</span><span class="n">intersect</span><span class="p">(</span><span class="n">f2</span><span class="p">)</span>
<span class="n">Out</span><span class="p">[</span><span class="mi">23</span><span class="p">]:</span> <span class="p">{</span><span class="n">x</span><span class="p">}</span>
</code></pre></div></div>
<ul>
<li>It should rather be:</li>
</ul>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">In</span> <span class="p">[</span><span class="mi">5</span><span class="p">]:</span> <span class="n">f1</span><span class="p">.</span><span class="n">intersect</span><span class="p">(</span><span class="n">f2</span><span class="p">)</span>
<span class="n">Out</span><span class="p">[</span><span class="mi">5</span><span class="p">]:</span> <span class="p">{</span><span class="n">x</span><span class="p">}</span> <span class="n">U</span> <span class="n">Intersection</span><span class="p">({</span><span class="n">y</span><span class="p">},</span> <span class="p">{</span><span class="n">x</span><span class="p">,</span> <span class="n">z</span><span class="p">})</span>
</code></pre></div></div>
<p>The current behavior of FiniteSet in Master is non-acceptable, since in the above example <code class="language-plaintext highlighter-rouge">x, y, z</code> are integer symbols, so they can be any integer, but in the <em>Master</em> , they are assumed to be distinct, which is wrong.
There are such failing tests in <code class="language-plaintext highlighter-rouge">test_wester.py</code> <a href="https://github.com/sympy/sympy/blob/master/sympy/core/tests/test_wester.py#L74">here</a>, which is updated here: <a href="https://github.com/aktech/sympy/commit/e8e6a0bb9285c315e9bade2bcd10b954760d4965">aktech@e8e6a0b</a> to incorporate with the right behaviour.</p>
<p>As of now there are a couple of failing tests, which needs to passed, before we can <strong>Merge</strong> <a href="https://github.com/sympy/sympy/pull/9540">#9540</a></p>
<p>####TODO Failing Tests:</p>
<ul>
<li><a href="https://travis-ci.org/sympy/sympy/jobs/67831123">sympy/stats/tests/test_rv.py</a></li>
<li><a href="https://travis-ci.org/sympy/sympy/jobs/67831130">sympy/combinatorics/tests/test_partitions.py</a></li>
</ul>
<h3 id="from-__future__-import-plan--week-6"><strong>from __future__ import plan</strong> Week #6:</h3>
<p>This week I plan to <a href="https://github.com/sympy/sympy/pull/9540">Fix Intersection’s of FiniteSet with symbolic elements</a> & start working on <code class="language-plaintext highlighter-rouge">LambertW</code> solver in <code class="language-plaintext highlighter-rouge">solveset</code>.</p>
<h3 id="-git-log"><strong>$ git log</strong></h3>
<p><img align="left" src="/assets/gsoc/opr.png" /> <a href="https://github.com/sympy/sympy/pull/9540">PR #9540</a> : Intersection’s of FiniteSet with symbolic elements</p>
<ul>
<li><a href="https://github.com/sympy/sympy/pull/9438">PR #9438</a> : Linsolve</li>
<li><a href="https://github.com/sympy/sympy/pull/9463">PR #9463</a> : ComplexPlane</li>
<li><a href="https://github.com/sympy/sympy/pull/9527">PR #9527</a> : Printing of ProductSets</li>
<li><a href="https://github.com/sympy/sympy/pull/9524">PR # 9524</a> : Fix solveset returned solution making denom zero</li>
</ul>
<p>That’s all for now, looking forward for week #6. :grinning:</p>
GSoC : This week in SymPy #32015-06-17T00:00:00+05:30https://iamit.in/blog/GSoC : This week in SymPy #3<p>Hi there! It’s been three weeks into <a href="https://en.wikipedia.org/wiki/Google_Summer_of_Code">GSoC</a>, & I have managed to get some pace.
This week, I worked on creating <code class="language-plaintext highlighter-rouge">ComplexPlane</code> Class.</p>
<h3 id="-progress-of-week-3-"> <strong>Progress of Week 3</strong> <img style="float: left" src="/assets/gsoc/pr.png" /></h3>
<p>The major portion of this week went onto creating <code class="language-plaintext highlighter-rouge">ComplexPlane</code> Class.
<a href="https://github.com/sympy/sympy/pull/9463">PR #9438</a></p>
<h3 id="design"><strong>Design</strong></h3>
<p>The design for the ComplexPlane class supports both forms of representation of Complex regions in <a href="https://en.wikipedia.org/wiki/Complex_plane">Complex Plane.</a></p>
<ul>
<li><strong><em>Polar form</em></strong></li>
</ul>
<blockquote>
<p>Polar form is where a complex number is denoted by the <em>length</em> (<strong><em>r</em></strong>) (otherwise known as the magnitude, absolute value, or modulus) and the <em>angle</em> (<strong><em>θ</em></strong>) of its vector.</p>
</blockquote>
<ul>
<li><strong><em>Rectangular form</em></strong></li>
</ul>
<blockquote>
<p>Rectangular form, on the other hand, is where a complex number is denoted by its respective <em>horizontal</em> (<strong><em>x</em></strong>) and <em>vertical</em> (<strong><em>y</em></strong>) components.</p>
</blockquote>
<p><img src="/assets/gsoc/complex_repr.png" /></p>
<h3 id="initial-approach">Initial Approach</h3>
<p>While writing code for <code class="language-plaintext highlighter-rouge">ComplexPlane</code> class, we started with the following design:
Input <a href="https://en.wikipedia.org/wiki/Interval_(mathematics)">Interval</a> of a and b interval, as following:</p>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">ComplexPlane</span><span class="p">(</span><span class="n">a_interval</span><span class="p">,</span> <span class="n">b_interval</span><span class="p">,</span> <span class="n">polar</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
</code></pre></div></div>
<p>Where <code class="language-plaintext highlighter-rouge">a_interval</code> & <code class="language-plaintext highlighter-rouge">b_interval</code> are the respective intervals of <code class="language-plaintext highlighter-rouge">x</code> and <code class="language-plaintext highlighter-rouge">y</code> for complex number in rectangular form or the respective intervals of <code class="language-plaintext highlighter-rouge">r</code> and <code class="language-plaintext highlighter-rouge">θ</code> for complex number in polar form when polar flag is True.</p>
<p>But the <strong><em>problem</em></strong> with this approach is that <strong><em>we can’t represent two different regions in a single</em></strong> <strong><code class="language-plaintext highlighter-rouge">ComplexPlane</code></strong> <strong><em>call</em></strong>, i.e. , for example let say we have two rectangular regions be represented as follows:</p>
<p><img src="/assets/gsoc/complex_rect.png" /></p>
<p><strong><em>We have to represent this with two</em></strong> <strong><code class="language-plaintext highlighter-rouge">ComplexPlane</code></strong> <strong><em>calls:</em></strong></p>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">rect1</span> <span class="o">=</span> <span class="n">ComplexPlane</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">),</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">))</span>
<span class="n">rect2</span> <span class="o">=</span> <span class="n">ComplexPlane</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">),</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">8</span><span class="p">))</span>
<span class="n">shaded_region</span> <span class="o">=</span> <span class="n">Union</span><span class="p">(</span><span class="n">rect1</span><span class="p">,</span> <span class="n">rect2</span><span class="p">)</span>
</code></pre></div></div>
<p><strong><em>Similiary for, the following polar region:</em></strong></p>
<p><img src="/assets/gsoc/complex_polar.png" /></p>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">halfdisk1</span> <span class="o">=</span> <span class="n">ComplexPlane</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">pi</span><span class="p">),</span> <span class="n">polar</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">halfdisk2</span> <span class="o">=</span> <span class="n">ComplexPlane</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">pi</span><span class="p">),</span>
<span class="n">polar</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">shaded_region</span> <span class="o">=</span> <span class="n">Union</span><span class="p">(</span><span class="n">halfdisk1</span><span class="p">,</span> <span class="n">halfdisk2</span><span class="p">)</span>
</code></pre></div></div>
<h3 id="better-approach">Better Approach</h3>
<p>The <strong><em>solution</em></strong> to the above problem is to <strong><em>wrap up two calls of</em></strong> <strong><code class="language-plaintext highlighter-rouge">ComplexPlane</code></strong> <strong><em>into one</em></strong>. To do this, a better input API was needed, and the problem was solved with the help of <strong><code class="language-plaintext highlighter-rouge">ProductSet</code></strong>.</p>
<p>Now we take input in the form of <a href="http://mathworld.wolfram.com/ProductSet.html"><code class="language-plaintext highlighter-rouge">ProductSet</code></a> or Union of ProductSets:</p>
<p>The region above is represented as follows:</p>
<ul>
<li>For Rectangular Form</li>
</ul>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">psets</span> <span class="o">=</span> <span class="n">Union</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">)</span><span class="o">*</span><span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span>
<span class="n">Interval</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">)</span><span class="o">*</span><span class="n">Interval</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">8</span><span class="p">))</span>
<span class="n">shaded_region</span> <span class="o">=</span> <span class="n">ComplexPlane</span><span class="p">(</span><span class="n">psets</span><span class="p">)</span>
</code></pre></div></div>
<ul>
<li>For Polar Form</li>
</ul>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">psets</span> <span class="o">=</span> <span class="n">Union</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span><span class="o">*</span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">pi</span><span class="p">),</span>
<span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">*</span><span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">pi</span><span class="p">))</span>
<span class="n">shaded_region</span> <span class="o">=</span> <span class="n">ComplexPlane</span><span class="p">(</span><span class="n">psets</span><span class="p">,</span> <span class="n">polar</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
</code></pre></div></div>
<p><strong><em>Note:</em></strong>
The input <code class="language-plaintext highlighter-rouge">θ</code> interval for polar form tolerates any interval in terms of <code class="language-plaintext highlighter-rouge">π</code> , it is handled by the function <code class="language-plaintext highlighter-rouge">normalize_theta_set</code> (wrote using <code class="language-plaintext highlighter-rouge">_pi_coeff</code> function), It normalizes <code class="language-plaintext highlighter-rouge">θ</code> set to an equivalent interval in <code class="language-plaintext highlighter-rouge">[0, 2π)</code>, which simplifies various other methods such as <code class="language-plaintext highlighter-rouge">_union</code>, <code class="language-plaintext highlighter-rouge">_intersect</code>.</p>
<h3 id="from-__future__-import-plan--week-4"><strong>from __future__ import plan</strong> Week #4:</h3>
<p>This week I plan to polish my pending PR’s to get them Merged & start working on <code class="language-plaintext highlighter-rouge">LambertW</code> solver in <code class="language-plaintext highlighter-rouge">solveset</code>.</p>
<h3 id="-git-log"><strong>$ git log</strong></h3>
<ul>
<li><a href="https://github.com/sympy/sympy/pull/9438">PR #9438</a> : Linsolve</li>
<li><a href="https://github.com/sympy/sympy/pull/9463">PR #9463</a> : ComplexPlane</li>
<li><a href="https://github.com/sympy/sympy/pull/9527">PR #9527</a> : Printing of ProductSets</li>
<li><a href="https://github.com/sympy/sympy/pull/9524">PR # 9524</a> : Fix solveset returned solution making denom zero</li>
</ul>
<p>That’s all for now, looking forward for week #4. :grinning:</p>
GSoC : This week in SymPy #22015-06-07T00:00:00+05:30https://iamit.in/blog/GSoC : This week in SymPy #2 <p>Hi there! It’s been two weeks into GSoC, & I have managed to flip some bits.</p>
<p>This week, I started working on <code class="language-plaintext highlighter-rouge">ComplexPlane</code> Class, & also worked on improving <code class="language-plaintext highlighter-rouge">linsolve</code>.</p>
<h3 id="progress-of-week-2"><strong>Progress of Week 2</strong></h3>
<p><img src="/assets/gsoc/pr.png" /></p>
<p>The major portion of this week went into improving <code class="language-plaintext highlighter-rouge">linsolve</code> function, which I wrote last week,
PR : <strong><a href="https://github.com/sympy/sympy/pull/9438">#9438</a></strong>.</p>
<p><a href="http://www.github.com/moorepants">Jason</a> suggested to let the Matrix code be the core source for all linear solve operations (i.e. remove all algorithmic solve code from everywhere else in sympy). Then for any linear solve stuff that can’t be handled by the Matrix code base, implement that here in <code class="language-plaintext highlighter-rouge">linsolve</code>.</p>
<p>It was indeed a good idea, since solving linear system is more of Matrix stuff than that of solvers in CAS, So we introduced a new solver in <code class="language-plaintext highlighter-rouge">matrices.py</code> named as:</p>
<ul>
<li><code class="language-plaintext highlighter-rouge">gauss_jordan_solve()</code> : It solves <code class="language-plaintext highlighter-rouge">Ax = b</code> using Gauss Jordan elimination.</li>
</ul>
<p>There may be zero, one, or infinite solutions. If one solution
exists, it will be returned. If infinite solutions exist, it will
be returned parametrically in terms of Dummy parameters. If no solutions exist, It will throw
ValueError.</p>
<p>Now <code class="language-plaintext highlighter-rouge">linsolve</code> is a light wrapper around <code class="language-plaintext highlighter-rouge">gauss_jordan_solve()</code> method, it basically converts all the input types into the standard A & b form & calls A.gauss_jordan_solve() and replaces the dummy parameters with the symbols input by the user.</p>
<h3 id="plan-for-week-3">Plan for Week 3:</h3>
<p>This week I plan to complete ComplexPlane class & get the following PR’s Merged:</p>
<ul>
<li><a href="https://github.com/sympy/sympy/pull/9438">PR #9438</a></li>
<li><a href="https://github.com/sympy/sympy/pull/9463">PR #9463</a></li>
</ul>
<p>That’s all for now, looking forward for week #3.</p>
GSoC : This week in SymPy #12015-06-01T00:00:00+05:30https://iamit.in/blog/GSoC : This week in SymPy #1<p>Hi there! The First week of the coding period has came to an end, this week has been very hectic for me due to my practicals and Minor project submission at college, though I mananged to reach the goal for this week.</p>
<p>This week, I worked on Linear system solver <code class="language-plaintext highlighter-rouge">linsolve</code> in the <code class="language-plaintext highlighter-rouge">solveset</code> Module, as I mentioned in my last <a href="http://iamit.in/blog/GSoC-Getting-Up-For-the-Coding-Period/">post</a>, about my goals for Week 1.</p>
<h3 id="progress-of-week-1"><strong>Progress of Week 1</strong></h3>
<p><img src="/assets/gsoc/pr.png" /> I implemented the following two functions:</p>
<p>PR : <strong><a href="https://github.com/sympy/sympy/pull/9438">#9438</a></strong>.
It’s almost good to merge after a final review by <a href="http://www.github.com/flacjacket">flacjacket</a> & <a href="http://www.github.com/hargup">hargup</a>.</p>
<ul>
<li>
<p><strong><code class="language-plaintext highlighter-rouge">linear_eq_to_matrix</code></strong> : <em>method to convert system of linear Equations to Matrix Form.</em></p>
</li>
<li>
<p><strong><code class="language-plaintext highlighter-rouge">linsolve</code></strong>: <em>It’s the General Linear System solver.</em></p>
</li>
</ul>
<p>Thanks to <a href="http://www.github.com/moorepants">Jason</a> for reviewing my initial implementation & suggesting useful changes.</p>
<h3 id="algorithm-used">Algorithm Used</h3>
<p>The algorithm used in <code class="language-plaintext highlighter-rouge">linsolve</code> is Gauss-Jordan elimination, which results, after elimination, in an reduced row echelon form matrix. (used <code class="language-plaintext highlighter-rouge">rref()</code> method of matrices)</p>
<h3 id="capabilities-of-linsolve">Capabilities of Linsolve</h3>
<p><code class="language-plaintext highlighter-rouge">linsolve</code> is a powerful linear system solver, It can solve all types of linear systems, accepted in all input forms, hence providing a user friendly Public API.</p>
<ul>
<li><strong><em>under-determined</em></strong>:</li>
</ul>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">In</span> <span class="p">[]:</span> <span class="n">A</span> <span class="o">=</span> <span class="n">Matrix</span><span class="p">([[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span> <span class="p">[</span><span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">],</span> <span class="p">[</span><span class="mi">7</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">9</span><span class="p">]])</span>
<span class="n">In</span> <span class="p">[]:</span> <span class="n">b</span> <span class="o">=</span> <span class="n">Matrix</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">9</span><span class="p">])</span>
<span class="n">In</span> <span class="p">[]:</span> <span class="n">linsolve</span><span class="p">((</span><span class="n">A</span><span class="p">,</span> <span class="n">b</span><span class="p">),</span> <span class="p">[</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">])</span>
<span class="n">Out</span><span class="p">[]:{(</span><span class="n">z</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="o">-</span><span class="mi">2</span><span class="o">*</span><span class="n">z</span> <span class="o">+</span> <span class="mi">2</span><span class="p">,</span> <span class="n">z</span><span class="p">)}</span>
</code></pre></div></div>
<ul>
<li><strong><em>well-behaved</em></strong>:</li>
</ul>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">In</span> <span class="p">[]:</span> <span class="n">Eqns</span> <span class="o">=</span> <span class="p">[</span><span class="mi">3</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">-</span> <span class="n">z</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">z</span> <span class="o">+</span> <span class="mi">2</span><span class="p">,</span> <span class="o">-</span> <span class="n">x</span> <span class="o">+</span> <span class="n">S</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="o">*</span><span class="n">y</span> <span class="o">-</span> <span class="n">z</span><span class="p">]</span>
<span class="n">In</span> <span class="p">[]:</span> <span class="n">linsolve</span><span class="p">(</span><span class="n">Eqns</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">)</span>
<span class="n">Out</span><span class="p">[]:{(</span><span class="mi">1</span><span class="p">,</span> <span class="o">-</span><span class="mi">2</span><span class="p">,</span> <span class="o">-</span><span class="mi">2</span><span class="p">)}</span>
</code></pre></div></div>
<ul>
<li><strong><em>over-determined</em></strong>:</li>
</ul>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1"># Parametrized solution
</span><span class="n">In</span> <span class="p">[]:</span> <span class="n">A</span> <span class="o">=</span> <span class="n">Matrix</span><span class="p">([[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">6</span><span class="p">],</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">15</span><span class="p">,</span> <span class="mi">9</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">3</span><span class="p">]])</span>
<span class="n">In</span> <span class="p">[]:</span> <span class="n">b</span> <span class="o">=</span> <span class="n">Matrix</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">])</span>
<span class="n">In</span> <span class="p">[]:</span> <span class="n">linsolve</span><span class="p">((</span><span class="n">A</span><span class="p">,</span> <span class="n">b</span><span class="p">),</span> <span class="p">[</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">])</span>
<span class="n">Out</span><span class="p">[]:{(</span><span class="o">-</span><span class="mi">3</span><span class="o">*</span><span class="n">z</span> <span class="o">+</span> <span class="mi">5</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">z</span><span class="p">)}</span>
<span class="c1"># No solution
</span><span class="n">In</span> <span class="p">[]:</span> <span class="n">A</span> <span class="o">=</span> <span class="n">Matrix</span><span class="p">([[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">6</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">9</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">3</span><span class="p">]])</span>
<span class="n">In</span> <span class="p">[]:</span> <span class="n">b</span> <span class="o">=</span> <span class="n">Matrix</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">])</span>
<span class="n">In</span> <span class="p">[]:</span> <span class="n">linsolve</span><span class="p">((</span><span class="n">A</span><span class="p">,</span> <span class="n">b</span><span class="p">),</span> <span class="p">[</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">])</span>
<span class="n">Out</span><span class="p">[]:</span> <span class="p">....</span>
<span class="nb">ValueError</span><span class="p">:</span> <span class="n">Linear</span> <span class="n">system</span> <span class="n">has</span> <span class="n">no</span> <span class="n">solution</span>
</code></pre></div></div>
<h3 id="the-input-formats-supported">The input formats supported:</h3>
<p>(as mentioned in my last <a href="http://iamit.in/blog/GSoC-Getting-Up-For-the-Coding-Period/">post</a>)</p>
<ul>
<li>Augmented Matrix Form</li>
<li>List Of Equations Form</li>
<li>Input A & b Matrix Form (from <code class="language-plaintext highlighter-rouge">Ax = b</code>)</li>
</ul>
<h3 id="plan-for-week-2">Plan for Week 2:</h3>
<p>This week I plan to work on Complex Sets.</p>
<p>That’s all for now, looking forward for week #2.</p>
GSoC : Getting Up For the Coding Period2015-05-24T00:00:00+05:30https://iamit.in/blog/GSoC : Getting-Up-For-the-Coding-Period <h3 id="the-start-of-coding-period"><strong>The Start of Coding Period!</strong></h3>
<p>The Community bonding Period is close to end now & my Exams as well. Tomorrow starts the Coding Period & I have been waiting for it for some time now.</p>
<p>Recently I gave a quick look to my Proposed Timeline in my <a href="https://github.com/sympy/sympy/wiki/GSoC-2015-Application-AMiT-Kumar--Solvers-:-Extending-Solveset#timeline">Proposal</a>, & decided to swap the 2nd Week’s work with Ist, this will help me securing few credits in my College’s Minor Project Submission (Which has the deadline of 30th May).</p>
<h3 id="plan-for-week-1"><strong>Plan for Week 1</strong></h3>
<p>This week, I am planning to work on Solving Linear systems in <code class="language-plaintext highlighter-rouge">solveset</code>. (Currently solveset support univariate solvers only).</p>
<p>The main functions, I would be implementing are:</p>
<ul>
<li>
<p><code class="language-plaintext highlighter-rouge">eq_to_matrix</code> :
<em>method to convert system of Equations to Matrix Form.</em></p>
</li>
<li>
<p><code class="language-plaintext highlighter-rouge">linsolve</code>: <em>It’s the General Linear System solver.</em></p>
</li>
</ul>
<p>As mentioned in the proposal, Solving system of linear equations is an important feature of solvers in a CAS. Most of the CAS have a convenient single function to solve linear systems, for example <code class="language-plaintext highlighter-rouge">LinearSolve</code> in Mathematica.</p>
<p>The <strong><code class="language-plaintext highlighter-rouge">linsolve</code></strong> which I would be implementing is inspired from Matlab & Maxima.</p>
<h5 id="features-overview"><strong>Features Overview</strong></h5>
<p>We have a lot of reusable code in <code class="language-plaintext highlighter-rouge">sympy.matrices</code> & <code class="language-plaintext highlighter-rouge">sympy.solvers.solvers</code>, which would be quite useful.
One of the most important thing I would like to have in <code class="language-plaintext highlighter-rouge">linsolve</code> is supporting a lot of input formats.
Though, most of the CAS suport only one input format. This feature would be quite useful for sympy’s <code class="language-plaintext highlighter-rouge">linsolve</code>.</p>
<h6 id="the-three-most-common-input-formats-i-can-recall-as-of-now-are">The three most common input formats, I can recall as of now are:</h6>
<ul>
<li>Augmented Matrix Form</li>
<li>List Of Equations Form</li>
<li>Input A & b Matrix Form (from <code class="language-plaintext highlighter-rouge">Ax = b</code>)</li>
</ul>
<p>It would be great to have all three input formats supported in the Public API <code class="language-plaintext highlighter-rouge">linsolve</code> Method.</p>
<p>Looking forward for Coding Period, that’s all for now.</p>
Google Summer Of Code with SymPy2015-04-28T00:00:00+05:30https://iamit.in/blog/Google-Summer-Of-Code-with-SymPy<p><img src="/assets/gsoc/GSOC2015.png" alt="GSoC 2015" /></p>
<p>Yay! the much awaited results of <a href="http://www.google-melange.com/gsoc/projects/list/google/gsoc2015">Google Summer Of Code</a> is out now, and I have been selected to work with <a href="http://www.sympy.org/">SymPy</a> under <a href="https://www.python.org/psf/">Python Software Foundation.</a></p>
<h3 id="for-those-who-dont-know-about-gsoc">For those who don’t know about GSoC</h3>
<blockquote>
<p><strong><a href="http://en.wikipedia.org/wiki/Google_Summer_of_Code">Google Summer of Code</a></strong> is a global program that offers students stipends to write code for open source projects.</p>
</blockquote>
<h3 id="a-bit-about-sympy">A bit about SymPy</h3>
<p><img style="float: right" src="/assets/gsoc/sympy.png" /></p>
<blockquote>
<p>SymPy is a Python library for symbolic mathematics. It aims to become a full-featured <strong><a href="http://en.wikipedia.org/wiki/Computer_algebra_system">Computer Algebra System</a></strong> (CAS) while keeping the code as simple as possible in order to be comprehensible and easily extensible.</p>
</blockquote>
<h3 id="about-my-project">About My Project</h3>
<p>My Project is being mentored by some really awesome guys <a href="https://github.com/certik">Ondřej Čertík</a>, <a href="https://github.com/flacjacket">Sean Vig</a> and <a href="https://github.com/hargup">Harsh Gupta</a>.</p>
<p>The Project aims at improving the current Equation solvers in SymPy. The Current solve is a huge mess, It needs to be broken into various sub-hints, to make the code more robust, modular, and approachable for developers, moving in lines of the new API, as developed in solveset. Currently the new API is implemented for univariate Equations only, we need to incorporate it for linear systems, multivariate equations & transcendental by rewriting the solvers for these in the new solveset Module.</p>
<p><a href="https://github.com/sympy/sympy/wiki/GSoC-2015-Application-AMiT-Kumar--Solvers-:-Extending-Solveset">Here is my Proposal</a>.</p>
<p>Looking forward for a great summer with SymPy!</p>