Shekhar Prasad Rajak2021-07-04T13:22:08+00:00https://shekharrajak.github.ioShekhar Prasad Rajakshekharrajak@live.comPyCon India - Delhi 20172017-11-02T00:00:00+00:00https://shekharrajak.github.io/blog/Talks/SymPy/PyConIndia-Delhi-2017<h4 id="pycon-india-delhi-2017--proposal-for-workshop">PyCon India Delhi 2017 : Proposal for Workshop</h4>
<p>I am very much interested for conferences and talks/workshops and had submitted the workshop
proposal last year(2016) as well for PyCon India. So this year
I started the discussion for the workshop proposal earlier, in the
<a href="https://groups.google.com/forum/#!searchin/sympy/pycon$20india%7Csort:date/sympy/s6IOYvHnHxU/xiiY0vdlAQAJ" target="_blank">SymPy Google mailing thread</a>
to make the workshop proposal
interesting and to improve the tutorial contents.</p>
<p>Since on 2016 proposal, we got the suggestion for adding SymEngine as well into the tutorial content.
So we started discussion for the same. SymEngine project GSoCers, worked for the SymEngine tutorial part.</p>
<p>People who took part for writting the proposal were :</p>
<ul>
<li>Amit Kumar, Core Developer & GSoC-cer at SymPy</li>
<li>Shekhar Prasad Rajak : Core Developer at SymPy GSoC 2016 - Solvers, Sets</li>
<li>Shikhar Jaiswal : Student Developer at SymPy GSoC 2017 - SymPy - SymEngine Integration and Python Wrappers</li>
<li>Ranjith Kumar : Student Developer at SymPy GSoC 2017 - Solvers and Sets in SymEngine</li>
</ul>
<p>Thanks for contributing on the proposal.</p>
<hr />
<h4 id="computer-aided-algebra-system-cas-for-different-programming-languages-using-symengine-and-sympy">Computer aided algebra system (CAS) for different programming languages using SymEngine and SymPy</h4>
<p><strong>Github repo</strong></p>
<p>I extended the previous year PyCon repo : <a href="https://github.com/Shekharrajak/PyCon-SymPy-SymEngine" target="_blank">(Github repo for the tutorial & resources)</a> and modified it. We added some new contents and SymEngine tutorials added as well.</p>
<p>We followed the previous year conferences.Mainly these links:</p>
<ul>
<li>
<p><a href="https://in.pycon.org/cfp/pycon-india-2015/proposals/symbolic-computation-with-python-sympy~bqYrb/">PyCon India 2015</a></p>
</li>
<li>
<p><a href="https://cfp.pydelhi.org/pydelhi-conference-2016/proposals/symbolic-computation-with-python-using-sympy/">PyDelhi Conference 2016</a></p>
</li>
<li>
<p><a href="https://www.youtube.com/watch?v=f4cXX0wa9VM&t=599s">Pycon UK 2016</a></p>
</li>
<li>
<p>Mechanics : <a href="https://www.moorepants.info/blog/npendulum.html">https://www.moorepants.info/blog/npendulum.html</a></p>
</li>
<li>
<p><a href="https://www.youtube.com/watch?v=EG9uOGPBkvQ">plotting example</a></p>
</li>
<li>
<p><a href="http://mattpap.github.io/scipy-2011-tutorial/html/basics.html">http://mattpap.github.io/scipy-2011-tutorial/html/basics.html</a></p>
</li>
<li>
<p><a href="https://github.com/sympy/sympy/wiki/Tutorial">Basic tutorial</a></p>
</li>
</ul>
<hr />
<p><strong>Contents</strong></p>
<p>We divided the tutorial part into SymPy and SymEngine.</p>
<ul>
<li>
<p><a href="https://github.com/Shekharrajak/PyCon-SymPy-SymEngine/tree/master/SymPy_material">SymPy material we used</a></p>
</li>
<li>
<p><a href="https://github.com/Shekharrajak/PyCon-SymPy-SymEngine/tree/master/SymEngine_material">SymEngine material we used</a></p>
</li>
<li>
<p><a href="https://shekharrajak.github.io/PyCon-SymPy-SymEngine/slides-pyconindia2017">Link for the presentation for the workshop day</a>.</p>
</li>
<li>
<p>Interested people can download the IPython noteboook for the tutorial from <a href="https://github.com/Shekharrajak/PyConIndiaSymPyTutorial/archive/master.zip">this link</a>.</p>
</li>
<li>
<p>If people want to see the examples online , it is avaiable <a href="http://nbviewer.jupyter.org/github/Shekharrajak/PyCon-SymPy-SymEngine/tree/master/SymPy_material/tutorial_exercises/">here</a>.</p>
</li>
</ul>
<hr />
<h4 id="2nd-nov-2017-the-workshop-day">2nd Nov 2017: The workshop day</h4>
<p>I reached to the delhi Airport on 2nd Nov around 1AM. Somehow I was able to get room nearby the PyCon center at 5AM :p.</p>
<div class="post_pic"> <img src="/images/pyconIndiaDelhi/cloud2.jpg" /> </div>
<p>I reached to PyCon center at around 9:00AM via cab. Amit and Ranjith were not able to join the PyCon India 2017.
So me and Shikhar were present on time as the Speaker for the workshop.</p>
<div class="post_pic"> <img src="/images/pyconIndiaDelhi/speaker.jpg" /> </div>
<p>We faced some projector issue but fine, we were able to present the slides and tutorial went well. I started the
presentation and slowly went to the tutorial part from beginning to some advance examples.</p>
<div class="post_pic"> <img src="/images/pyconIndiaDelhi/stage.jpg" /> </div>
<p>Shikhar took the mic and covered the SymEngine presentation and basic examples.</p>
<div class="post_pic"> <img src="/images/pyconIndiaDelhi/stage2.jpg" /> </div>
<p>Audience had some good questions and they keep questioning during the workshop. It was a pretty good
experience. It was our first talk/workshop, so we were satisfied with our performance. Hope we will have
better talks/workshops in upcoming conferences, which will transfer the knowledge.</p>
<hr />
<h4 id="after-the-workshop-">After the workshop :</h4>
<p>During the lunch, me and shikhar interacted with fellow speakers and GSoCers. We joined some other
workshops as well. I left earlier, since I was sleepy because of night journey from the Banglore.</p>
<hr />
<h4 id="conclusion">Conclusion</h4>
<p>Overall it was good experience. Since I started preparing the proposal much before the deadline. So we were
able to finish it up on time. I was busy in the month of August, Sept, Oct but we were able to finish the resources and slides on time.
I was expecting some more things to be covered, but it’s fine. I had written few things in the <a href="https://github.com/Shekharrajak/PyCon-SymPy-SymEngine/wiki" target="_blank">Github repo wiki page</a>, it may help for future speakers.
Thanks to PyCon India community for giving us this opportunity.
I hope in future we will have more interesting topics to talk on SymPy and SymEngine and audience
will enjoy to learn SymPy and SymEngine along with us.</p>
<hr />
Coding Period Week 13 - Last week and conclusion2016-08-20T00:00:00+00:00https://shekharrajak.github.io/blog/GSoC-2016/Coding-Period-week-13<hr />
<p><strong>Documentation nonlinsolve:</strong></p>
<p>PR <a href="https://github.com/sympy/sympy/pull/11532">#11532</a></p>
<hr />
<p><strong>Conclusion :</strong></p>
<p>So the GSoC coding period is going to end. Here I am writing what I did, my todo list and suggestions for future work.</p>
<ul>
<li>
<p>One can see the progress report of each week and minutes of meeting here :
<a href="https://github.com/sympy/sympy/wiki/GSoC-2016-Solvers-Progress">GSoC-2016-Solvers-Progress</a></p>
</li>
<li>
<p>My all the PRs link is here : <a href="https://github.com/sympy/sympy/pulls?utf8=%E2%9C%93&q=is%3Aopen%7Cclosed%20is%3Apr%20author%3AShekharrajak%20">sympy/pulls/shekharrajak</a></p>
</li>
<li>
<p>I have created a vertical timeline to show all the work in chrononical order in this link : <a href="http://shekharrajak.github.io/gsoc16_final.html">timeline</a></p>
</li>
</ul>
<hr />
<p><strong>Meanwhile :</strong></p>
<ul>
<li>
<p>I find one issue : <a href="https://github.com/sympy/sympy/issues/11534">#11534</a> in mailing list discussion. This shows that we need better
<code class="language-plaintext highlighter-rouge">invert</code> method for inverting nested roots/powers equtions in <code class="language-plaintext highlighter-rouge">solveset</code> .</p>
</li>
<li>
<p>and this <a href="https://github.com/sympy/sympy/issues/11528">#11528</a>. <code class="language-plaintext highlighter-rouge">factor_list</code> will be helpful in factoring the equation in <code class="language-plaintext highlighter-rouge">solveset</code> and solve for it factors and union the solution(during the PR #11188 discussion with Harsh this idea came out). It will actually replace the <a href="https://github.com/sympy/sympy/blob/master/sympy/solvers/solveset.py#L646">elif f.is_Mul and all(_is_finite_with_finite_vars(m, domain)</a> statement in <code class="language-plaintext highlighter-rouge">_solveset</code> and <code class="language-plaintext highlighter-rouge">factor_list</code> will be used soon.</p>
</li>
</ul>
Coding Period Week 122016-08-15T00:00:00+00:00https://shekharrajak.github.io/blog/GSoC-2016/Coding-Period-week-12<hr />
<p><strong>nonlinsolve continue:</strong></p>
<ul>
<li>
<p>PR : <a href="https://github.com/sympy/sympy/pull/11111">#11111</a></p>
</li>
<li>
<p>few things that should be improved in <code class="language-plaintext highlighter-rouge">nonlinsolve</code> :</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>- If system of equation contains trigonometric functions, `nonlinsolve`
sometime fails because `solve_trig` of `solveset` is not much better and
`nonlinsolve` have to identify what is the Intersection soln when we have
`2*n*pi + pi/2` and `n*pi + pi/2`(means something similar cases).Right now it is returning
one of them.
- `substitution` function which solves the system of equation using substitution method.
There should be better method to handle `imageset` (Complex solution).
- Code quality of `substitution` should be improved.
</code></pre></div> </div>
</li>
</ul>
<hr />
<p><strong>Continue Simplified Trig soln</strong></p>
<ul>
<li>
<p>PR <a href="https://github.com/sympy/sympy/pull/11188">#11188</a></p>
</li>
<li>
<p>Imageset/union is generalized and now it handle basically these three cases:</p>
</li>
</ul>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># img1 = ImageSet(Lambda(n, a*n + b), S.Integers)
# img2 = ImageSet(Lambda(n, c*n + d), S.Integers)
In [1]: img1 = ImageSet(Lambda(n, 4*n + 4), S.Integers)
In [2]: img2 = ImageSet(Lambda(n, 4*n), S.Integers)
# when a == c and (b - d == a) then ans is img2.
In [3]: Union(img1, img2)
Out[3]: {4⋅n | n ∊ ℤ}
# -------------------------------------------------------------
In [4]: img1 = ImageSet(Lambda(n, 4*n + 2), S.Integers)
# when a == c and (b - d) == a/2, means value is a/2 * n
In [5]: Union(img1, img2)
Out[5]: {2⋅n | n ∊ ℤ}
# -------------------------------------------------------------
# 5*n + 5/4 ==> 5*n + 1 + 1/4
# 5*n + 1 + 1/4 is in n + 1/4
# check using img1.superset(img2) == true so img1 in ans
img1 = ImageSet(Lambda(n, n + S(1)/4 ), S.Integers)
img2 = ImageSet(Lambda(n, 5*n + S(5)/4 ), S.Integers)
In [4]: Union(img1, img2)
Out[4]: {n + 1/4 | n ∊ ℤ}
# -------------------------------------------------------------
# img1.issuperset(img2) is false so no change
img1 = ImageSet(Lambda(n, 2*n + S(1)/4 ), S.Integers)
img2 = ImageSet(Lambda(n, 5*n +S(5)/4), S.Integers)
In [5]: Union(img1, img2)
Out[5]: {2⋅n + 1/4 | n ∊ ℤ} ∪ {5⋅n + 5/4 | n ∊ ℤ}
</code></pre></div></div>
<hr />
<p><strong>Meanwhile :</strong></p>
<ul>
<li>I found some more cases where <code class="language-plaintext highlighter-rouge">factor_list</code> fails and opened a PR : https://github.com/sympy/sympy/issues/11528</li>
</ul>
<hr />
<p><strong><em>continue..</em></strong></p>
Coding Period Week 112016-08-07T00:00:00+00:00https://shekharrajak.github.io/blog/GSoC-2016/Coding-Period-week-11<hr />
<p><strong>eliminate() continue:</strong></p>
<ul>
<li>
<p>PR : <a href="https://github.com/sympy/sympy/pull/11485">#11485</a></p>
</li>
<li>
<p>Regarding issue <a href="https://github.com/sympy/sympy/issues/2720">#2720</a>, It is something similar to <code class="language-plaintext highlighter-rouge">eliminate</code> present in
<a href="http://reference.wolfram.com/mathematica/ref/Eliminate.html">wolfram</a>.</p>
</li>
<li>
<p>Right now it is working for real domain and not considering ImageSet, Intersection. Complement. If it find ImageSet, Intersection. Complement
for the symbol to be eliminated, then just raises <code class="language-plaintext highlighter-rouge">NotImaplementedError</code>(in near future it can be implemented).</p>
</li>
<li>
<p>It can take <code class="language-plaintext highlighter-rouge">N</code> nummber of equations and <code class="language-plaintext highlighter-rouge">M</code> number of <code class="language-plaintext highlighter-rouge">symbols</code> to be eliminated. It returns <code class="language-plaintext highlighter-rouge">FiniteSet</code> of equations which doesn’t contains
these <code class="language-plaintext highlighter-rouge">symbols</code>.</p>
</li>
</ul>
<hr />
<p><strong>Continue - Diophantine in Solveset :</strong></p>
<p>PR <a href="https://github.com/sympy/sympy/pull/11234">11234</a></p>
<ul>
<li>In <a href="https://github.com/sympy/sympy/pull/11234/commits/6bd9689d37647d6c28111097c433accc2127262e">commit</a> : returning
<code class="language-plaintext highlighter-rouge">ConditionSet</code> when it <code class="language-plaintext highlighter-rouge">diophantine</code> doesn’t the diophantine equation type and not able to solve.</li>
</ul>
<hr />
<p><strong>Idea for improved _solve_trig in Solveset :</strong></p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
In [1]: solveset(sin(x) + cos(y), x, S.Reals)
Out[1]: {x | x ∊ ℝ ∧ sin(x) + cos(y) = 0}
In [2]: solve(sin(x) + cos(y), x)
Out[2]: [asin(cos(y)) + π, -asin(cos(y))]
</code></pre></div></div>
<ul>
<li>
<p>This above examples is enough to tell that <code class="language-plaintext highlighter-rouge">_solve_trig</code> is not using inverse trigonometric function. We can have something, which can solve trig equations by making free the symbol in lhs and in rhs inverse trig function.</p>
</li>
<li>
<p><code class="language-plaintext highlighter-rouge">solveset(sin(2*x) - sqrt(3)*cos(2*x), x, S.Reals)</code> for this right now <code class="language-plaintext highlighter-rouge">_solve_trig</code> is converting it into <code class="language-plaintext highlighter-rouge">exp</code> form and solving it.
But it is can be simply solved using <code class="language-plaintext highlighter-rouge">sin(x + y) == sin(x)*cos(y) + cos(x)*sin(y)</code> formula.</p>
</li>
<li>
<p>First divide both side with <code class="language-plaintext highlighter-rouge">sqrt(a**2 + b**2)</code> where <code class="language-plaintext highlighter-rouge">a, b</code> is coeff of <code class="language-plaintext highlighter-rouge">sin(2*x)</code> , <code class="language-plaintext highlighter-rouge">cos(2*x)</code>.</p>
</li>
<li>
<p><code class="language-plaintext highlighter-rouge">sin(2*x)/2 - (sqrt(3)/2)*cos(2*x)</code> ==> <code class="language-plaintext highlighter-rouge">sin(2*x)*cos(pi/3) - sin(pi/3)*cos(2*x)</code> ==> <code class="language-plaintext highlighter-rouge">sin(2*x - pi/3)</code>.</p>
</li>
<li>
<p>Now <code class="language-plaintext highlighter-rouge">sin(2*x - pi/3)</code> is solvable using <code class="language-plaintext highlighter-rouge">solve_decomposition</code>.</p>
</li>
</ul>
<hr />
<p><strong>Meanwhile :</strong></p>
<ul>
<li>Some analysis about <code class="language-plaintext highlighter-rouge">Abs</code> solver :</li>
</ul>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
In [1]: solveset(Abs(x) - 1, x)
ValueError:
Absolute values cannot be inverted in the complex domain.
In [2]: solveset(Abs(x) - (1 + I), x)
ValueError:
Absolute values cannot be inverted in the complex domain.
In [3]: solveset(Abs(x) - y , x)
ValueError:
</code></pre></div></div>
<p>Absolute values cannot be inverted in the complex domain.</p>
<ul>
<li>
<p>In 1st case (for complex domain) ans should be <a href="http://www.wolframalpha.com/input/?i=Abs(x)+-+(1+)+%3D0+for+x">http://www.wolframalpha.com/input/?i=Abs(x)+-+(1+)+%3D0+for+x</a></p>
</li>
<li>
<p>In 2nd case EmptySet.
and in 3rd case (general solution when domain=S.Complexes) soln should be <a href="http://www.wolframalpha.com/input/?i=Abs(x)+-+y+%3D0+for+x">http://www.wolframalpha.com/input/?i=Abs(x)+-+y+%3D0+for+x</a></p>
</li>
<li>
<p>In general( 3rd case) it should print
ConditionSet(x, -Abs(re(y)) <= re(x) and re(x) <= Abs(re(y)) and re(y)>0, Eq(im(y), 0) , S.Complexes).</p>
</li>
</ul>
<hr />
<p><strong><em>continue..</em></strong></p>
<hr />
Coding Period Week 102016-07-30T00:00:00+00:00https://shekharrajak.github.io/blog/GSoC-2016/Coding-Period-week-10<hr />
<p><strong>eliminate() continue:</strong></p>
<ul>
<li>
<p>issue <a href="https://github.com/sympy/sympy/issues/2720">#2720</a> : We need some kind of eliminate function, like <a href="http://reference.wolfram.com/mathematica/ref/Eliminate.html">http://reference.wolfram.com/mathematica/ref/Eliminate.html</a>. See also <a href="http://stackoverflow.com/q/20826969/161801">http://stackoverflow.com/q/20826969/161801 </a></p>
</li>
<li>
<p>I am trying to use <code class="language-plaintext highlighter-rouge">subs</code> and <code class="language-plaintext highlighter-rouge">_invert</code> to get answer. May be one can use <code class="language-plaintext highlighter-rouge">replace</code>, <code class="language-plaintext highlighter-rouge">xreplace</code>, <code class="language-plaintext highlighter-rouge">match</code> to eliminate some kind of same sub expression.</p>
</li>
<li>
<p>There can be ans in <code class="language-plaintext highlighter-rouge">Imageset</code>, <code class="language-plaintext highlighter-rouge">Finiteset</code>, <code class="language-plaintext highlighter-rouge">Complement</code>, <code class="language-plaintext highlighter-rouge">Intersection</code> when we use <code class="language-plaintext highlighter-rouge">_invert</code>. So there should be a technique to handle it.</p>
</li>
<li>
<p>Still need some good idea and technique. WIP.</p>
</li>
</ul>
<hr />
<p><strong>Output of solveset should be of one type:</strong></p>
<ul>
<li>
<p>Amit discussed about it. Solution we see in <code class="language-plaintext highlighter-rouge">solveset</code> should be in one type of set. Right now we may have solution in <code class="language-plaintext highlighter-rouge">Imageset</code>, <code class="language-plaintext highlighter-rouge">Finiteset</code>, <code class="language-plaintext highlighter-rouge">Complement</code>, <code class="language-plaintext highlighter-rouge">Intersection</code> or <code class="language-plaintext highlighter-rouge">ConditionSet</code>. So there would be problem for user to handle these many solution type.</p>
</li>
<li>
<p>I think there should be something that separate <code class="language-plaintext highlighter-rouge">Complements</code>, <code class="language-plaintext highlighter-rouge">Intersections</code>,<code class="language-plaintext highlighter-rouge">ConditionSet</code> and main solution in <code class="language-plaintext highlighter-rouge">Finiteset</code>.</p>
</li>
<li>
<p>E.g. if solveset solution is <code class="language-plaintext highlighter-rouge">Intersection(Complement(FiniteSet(x), {y}), {z})</code> then
soln : <code class="language-plaintext highlighter-rouge">FiniteSet(x)</code>, <code class="language-plaintext highlighter-rouge">x != {y}</code>, <code class="language-plaintext highlighter-rouge">{x} intersect {z}</code>.</p>
</li>
</ul>
<hr />
<p><strong>Continue Simplified Trig soln</strong></p>
<p>PR <a href="https://github.com/sympy/sympy/pull/11188">#11188</a></p>
<ul>
<li>
<p>According to the <a href="https://github.com/sympy/sympy/pull/11188#issuecomment-234789616">Harsh comments/review</a> I modified the PR. Now it seems it is
returning more simplified solution( <a href="https://github.com/sympy/sympy/pull/11188/commits/beaac312f03819bd7221887eb2b4cbe5d49bed5e#diff-85baa04bbf4e1dfd9128782738e45424R1141">one case is here</a>) .</p>
</li>
<li>
<p>To understand the changes I did in the <code class="language-plaintext highlighter-rouge">_solve_trig</code> method, one should check <a href="https://gist.github.com/Shekharrajak/17fdcd2320f572fc9fc8674823137e20">this gist</a></p>
</li>
<li>
<p>To see the advantage of imageset union, One good example is in <a href="https://gist.github.com/Shekharrajak/a5efc840d9a7d3062289f2d9c5f20b16">this gist</a></p>
</li>
</ul>
<hr />
<p><strong><em>continue</em></strong></p>
Coding Period Week 92016-07-20T00:00:00+00:00https://shekharrajak.github.io/blog/GSoC-2016/Coding-Period-week-9<p><strong>Some points regarding trigonometric and inverse trigonometric functions in solveset :</strong></p>
<ul>
<li>
<p>There are many issues in solveset <code class="language-plaintext highlighter-rouge">solve_trig</code>.More inverse trigonometric formula and trigonometric identities should be defined/added or improved.
Also <code class="language-plaintext highlighter-rouge">simplify</code>, <code class="language-plaintext highlighter-rouge">trigsimp</code> and in <code class="language-plaintext highlighter-rouge">solveset</code> <code class="language-plaintext highlighter-rouge">_invert</code> methods should be improved accordingly.</p>
</li>
<li>
<p>Some links, that is helpful to improve these functions.</p>
<ul>
<li><a href="https://en.wikipedia.org/wiki/Inverse_trigonometric_functions">https://en.wikipedia.org/wiki/Inverse_trigonometric_functions</a></li>
<li><a href="https://en.wikipedia.org/wiki/Proofs_of_trigonometric_identities">https://en.wikipedia.org/wiki/Proofs_of_trigonometric_identities</a></li>
<li><a href="https://owlcation.com/stem/List-of-Inverse-Trig-Function-Identities-Integrals-and-Derivatives">https://owlcation.com/stem/List-of-Inverse-Trig-Function-Identities-Integrals-and-Derivatives</a></li>
</ul>
</li>
<li>
<p><code class="language-plaintext highlighter-rouge">trigsimp</code> must be more powerful so that <code class="language-plaintext highlighter-rouge">solve_trig</code> get simplified eq. (which solves trig equation by converting them into its <code class="language-plaintext highlighter-rouge">exp</code> form).</p>
</li>
<li>
<p><code class="language-plaintext highlighter-rouge">solve_trig</code> solves the trig eq. using its <code class="language-plaintext highlighter-rouge">exp</code> form. There may be cases when that <code class="language-plaintext highlighter-rouge">exp</code> form is complicated and solveset fail to handle that form.
There should be technique to convert that complicated form to simpler form(if possible) and then call the <code class="language-plaintext highlighter-rouge">solveset_complex</code>. That may help to improve the <code class="language-plaintext highlighter-rouge">solve_trig</code> method.</p>
</li>
<li>
<p>We can use <code class="language-plaintext highlighter-rouge">_osbornei</code>, <code class="language-plaintext highlighter-rouge">hyper_as_trig</code> methods defined in <code class="language-plaintext highlighter-rouge">simplify/fu.py</code> to convert hyperbolic function to trigonometric function, then we can use <code class="language-plaintext highlighter-rouge">trigsimp</code> (we can’t use <code class="language-plaintext highlighter-rouge">trigsimp</code> for hyperbolic functions).</p>
</li>
<li>
<p>First need to improve basic concepts and add more identities. I opened a new PR to improve <code class="language-plaintext highlighter-rouge">rewrite</code> for trigonometric functions , PR is <a href="https://github.com/sympy/sympy/pull/11424/">#11424</a>.</p>
</li>
</ul>
<hr />
<p><strong>eliminate() :</strong></p>
<ul>
<li>
<p>issue <a href="https://github.com/sympy/sympy/issues/2720">#2720</a> : We need some kind of eliminate function, like <a href="http://reference.wolfram.com/mathematica/ref/Eliminate.html">http://reference.wolfram.com/mathematica/ref/Eliminate.html</a>. See also <a href="http://stackoverflow.com/q/20826969/161801">http://stackoverflow.com/q/20826969/161801 </a></p>
</li>
<li>
<p>It looks something related to <a href="https://github.com/sympy/sympy/pull/11111/files#diff-eec0422923e8f100745c015cd8fdd6cfR1135">substitution</a> function.
But they are not same. Using <code class="language-plaintext highlighter-rouge">eliminate()</code> we will try to remove the variable(s) from the each equations(not solving the eq).</p>
</li>
<li>
<p>Plan : First choose eq that have min. variables and get the value of the variable, to be eliminated. Go further and <code class="language-plaintext highlighter-rouge">subs</code> the value to next min. variable eq., and so on.</p>
</li>
<li>
<p>Work in progress.</p>
</li>
</ul>
<hr />
<p><strong>Meanwhile :</strong></p>
<ul>
<li>
<p>I found some basic issues in <code class="language-plaintext highlighter-rouge">ComplexInfinity</code> and trying to solve them in this PR <a href="https://github.com/sympy/sympy/pull/11409">#11409</a>.</p>
</li>
<li>
<p>there may be many things to be added about <code class="language-plaintext highlighter-rouge">ComplexInfinity</code>, one can refer this link to implement them :
<a href="http://reference.wolfram.com/language/ref/ComplexInfinity.html">http://reference.wolfram.com/language/ref/ComplexInfinity.html</a>.</p>
</li>
</ul>
<hr />
<p><strong><em>continue..</em></strong></p>
<hr />
Coding Period Week 82016-07-18T00:00:00+00:00https://shekharrajak.github.io/blog/GSoC-2016/Coding-Period-week-8<hr />
<p><strong>Continue - Diophantine in Solveset :</strong></p>
<p>PR <a href="https://github.com/sympy/sympy/pull/11234">11234</a></p>
<ul>
<li>
<p>For general Pythagorean diop_type (Diophantine eq type), it seems diophantine always returns parameterized solution so I did some changes in the PR. <a href="https://github.com/sympy/sympy/pull/11334/commits/6af46fc35db3a74dfda78b6d8e2a0f7d4ec65afe">commit</a></p>
</li>
<li>
<p>You can refer this <a href="https://github.com/sympy/sympy/pull/11334#issuecomment-230334645">comment</a>.</p>
</li>
</ul>
<hr />
<p><strong>Continue Simplified Trig soln</strong></p>
<p>PR <a href="https://github.com/sympy/sympy/pull/11188">#11188</a></p>
<ul>
<li>After some changes, the PR is ready for review.</li>
</ul>
<hr />
<p><strong>Continue nonlinsolve :</strong></p>
<p>PR <a href="https://github.com/sympy/sympy/pull/11111">#11111</a></p>
<ul>
<li>
<p>Added some XFAIL test-cases of system of Trigonometric equations. <code class="language-plaintext highlighter-rouge">solveset</code> trig solver (<code class="language-plaintext highlighter-rouge">solve_trig</code>) is not smart enough(<code class="language-plaintext highlighter-rouge">solveset</code> returns <code class="language-plaintext highlighter-rouge">ConditionSet</code>, where soln can be simply inverse trig functions using <code class="language-plaintext highlighter-rouge">_invert</code> or inverse Trigonometric functions). So <code class="language-plaintext highlighter-rouge">solveset</code> returns <code class="language-plaintext highlighter-rouge">ConditionSet</code> that means <code class="language-plaintext highlighter-rouge">substitution</code> is not getting soln.</p>
</li>
<li>
<p>It is better to replace trigonometric functions or other <code class="language-plaintext highlighter-rouge">Function</code> with symbols</p>
</li>
</ul>
<p>(e.g. <code class="language-plaintext highlighter-rouge">sin(x)</code> –> <code class="language-plaintext highlighter-rouge">u</code>, <code class="language-plaintext highlighter-rouge">sin(y)</code>–> <code class="language-plaintext highlighter-rouge">v</code>, <code class="language-plaintext highlighter-rouge">f(x)</code>–> <code class="language-plaintext highlighter-rouge">f_x</code>, <code class="language-plaintext highlighter-rouge">g(x)</code> –> <code class="language-plaintext highlighter-rouge">g_x</code>)</p>
<p>and then solve for the symbols. After getting solution from <code class="language-plaintext highlighter-rouge">nonlinsolve</code> user can invert or do <code class="language-plaintext highlighter-rouge">solveset</code></p>
<p>(e.g. solveset(Eq(sin(x), soln_u), x, domain) to get value of <code class="language-plaintext highlighter-rouge">x</code>).</p>
<ul>
<li>Ready for review.</li>
</ul>
<hr />
<p><strong>Meanwhile :</strong></p>
<ul>
<li>
<p>We already know that solveset need improved <code class="language-plaintext highlighter-rouge">invert_real</code> , <code class="language-plaintext highlighter-rouge">invert_complex</code> and <code class="language-plaintext highlighter-rouge">Imageset</code> Intersections.</p>
</li>
<li>
<p>previous work is in this PR <a href="https://github.com/sympy/sympy/pull/10971">10971</a>. Trying to improve them.</p>
</li>
</ul>
<p>Some cases is here :</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># In 2, 4, 5 intersection is not needed.
In [1]: img = ImageSet(Lambda(n, x/n), S.Complexes)
In [2]: Intersection(img, S.Complexes)
Out[2]:
⎧x ⎫
ℂ ∩ ⎨─ | n ∊ ℂ⎬
⎩n ⎭
In [3]: img = ImageSet(Lambda(n, x/n), S.Integers)
In [4]: Intersection(img, S.Complexes)
Out[4]:
⎧x ⎫
⎨─ | n ∊ ℤ⎬ ∩ ℂ
⎩n ⎭
In [5]: Intersection(ImageSet(Lambda(n, 2*n*I*pi), S.Integers), S.Complexes)
Out[5]: {2⋅ⅈ⋅π⋅n | n ∊ ℤ} ∩ ℂ
# ImageSet Intersection is not implemented when inverter returns multiple values.
# here ans should be {0, 1}
In [6]: img1 = ImageSet(Lambda(n, n**2), S.Integers)
In [7]: Intersection(img1, Interval(0,2))
Out[7]:
⎧ 2 ⎫
[0, 2] ∩ ⎨n | n ∊ ℤ⎬
⎩ ⎭
</code></pre></div></div>
<hr />
<p><strong><em>continue..</em></strong></p>
Coding Period Week 72016-07-04T00:00:00+00:00https://shekharrajak.github.io/blog/GSoC-2016/Coding-Period-week-7<p><strong>ImageSet.put_values() :</strong></p>
<p>PR <a href="https://github.com/sympy/sympy/pull/11343">#11343</a></p>
<ul>
<li>
<p>After the discussion Harsh told that it is better to use like <code class="language-plaintext highlighter-rouge">imageset.lamda(values_for_lambda_var)</code> directly, also don’t make lambda variables public , it should be local and before doing <code class="language-plaintext highlighter-rouge">imageset.lamda(values_for_lambda_var)</code> this one need to check whether values are in ` base_set` or not.</p>
</li>
<li>
<p>You can see the previous code here : <a href="https://gist.github.com/Shekharrajak/d70a36c95eefaca5c684497e039c5632">gist</a></p>
</li>
<li>
<p>I updated the docs stating how to put certain values in ImageSet lambda variables.(reverted my changes and edited the ImageSet docs in the PR.)</p>
</li>
</ul>
<p><strong>Continue nonlinsolve :</strong></p>
<p>PR <a href="https://github.com/sympy/sympy/pull/11111">#11111</a></p>
<ul>
<li>How Intersections and Complements are handled :</li>
</ul>
<p>see these examples:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>In [ ]: intr = Intersection(FiniteSet(x), Interval(1,10))
In [ ]: comp = Complement(FiniteSet(x), Interval(1,10))
In [ ]: intr
Out[ ]: [1, 10] ∩ {x}
In [ ]: comp
Out[ ]: {x} \ [1, 10]
In [ ]: type( Intersection(comp, Interval(1,11)))
Out[ ]: sympy.sets.sets.Complement
In [ ]: type(Complement(intr, Interval(1,2)))
Out[ ]: sympy.sets.sets.Complement
</code></pre></div></div>
<p>So first handling the Complements and then intersection will be checked in solveset soln.</p>
<ul>
<li>
<p><code class="language-plaintext highlighter-rouge">nonlinsolve</code> can handle simple trigonometric system of equations but when complex equations
is used then it will return <code class="language-plaintext highlighter-rouge">ConditionSet</code> since <code class="language-plaintext highlighter-rouge">solveset</code> trig solver is not smart enough right now.</p>
</li>
<li>
<p>Trying to break the code into the functions to make the code better.</p>
</li>
</ul>
<hr />
<p><strong>Continue Simplified Trig soln</strong></p>
<p>PR <a href="https://github.com/sympy/sympy/pull/11188">#11188</a></p>
<ul>
<li>I was getting problem in ImageSet union when you run test. Sometimes it pass all the cases but not always.
I found the problem (most probably because order of args in union.reduce is not always same for all the python version
I am using FiniteSet so I hope it is good way to handle this.) Now it passes all the checks all time.</li>
</ul>
<hr />
<p><strong>Meanwhile :</strong></p>
<ul>
<li>I found that <code class="language-plaintext highlighter-rouge">Mod</code> is not defined for complex numbers. e.g.</li>
</ul>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>In [1]: g = Mod(-log(3), 2*I*pi)
In [2]: g
Out[2]: Mod(-log(3), 2⋅ⅈ⋅π)
In [3]: simplify(g)
Out[3]: Mod(-log(3), 2⋅ⅈ⋅π)
In [4]: simplify(g)
Out[4]: Mod(-log(3), 2⋅ⅈ⋅π)
In [5]: g2 = Mod(-log(3), 2*pi)
In [6]: simplify(g2)
Out[6]: -log(3) + 2⋅π
In [7]: simplify(Mod(I,I))
Out[7]: 0
In [8]: simplify(Mod(2*I,I))
Out[8]: 0
In [9]: simplify(Mod(2*I,3*I))
Out[9]: 5⋅ⅈ
In [10]: simplify(Mod(2*I,1+3*I))
Out[10]: Mod(2⋅ⅈ, 1 + 3⋅ⅈ)
</code></pre></div></div>
<p>Need to implement <code class="language-plaintext highlighter-rouge">Mod</code> for complex number as well. There is concept og Gaussian Integers</p>
<p>Some resources I found is this :
<a href="http://math.stackexchange.com/questions/274694/modulo-complex-number">link1</a>,
<a href="http://www.freemathhelp.com/forum/threads/76383-Modulo-of-complex-numbers">link2</a>,
<a href="https://en.wikipedia.org/wiki/Gaussian_integer">link3</a>
<a href="http://fermatslasttheorem.blogspot.in/2005/06/division-algorithm-for-gaussian.html">link4</a></p>
<ul>
<li>
<p>One can see the issue <a href="https://github.com/sympy/sympy/issues/11391">11391</a> for detail discussion.</p>
</li>
<li>
<p>Tried to fix the bug of <code class="language-plaintext highlighter-rouge">is_zero_dimensional</code> in this PR <a href="https://github.com/sympy/sympy/pull/11371">#11371</a>.</p>
</li>
</ul>
<hr />
<p><strong><em>continue..</em></strong></p>
Coding Period Week 62016-06-26T00:00:00+00:00https://shekharrajak.github.io/blog/GSoC-2016/Coding-Period-week-6<p><strong>Continue nonlinsolve :</strong></p>
<p>PR <a href="https://github.com/sympy/sympy/pull/11111">#11111</a></p>
<ul>
<li>Removed the dependency of old solvers <code class="language-plaintext highlighter-rouge">_invert</code>. It was basically helpful for removing <code class="language-plaintext highlighter-rouge">sqrt</code> or Rational power.
Now using <code class="language-plaintext highlighter-rouge">unrad</code> and little changes in <code class="language-plaintext highlighter-rouge">substitution</code> function can handle the system havning <code class="language-plaintext highlighter-rouge">sqrt</code> or <code class="language-plaintext highlighter-rouge">cube root</code>.</li>
</ul>
<hr />
<p><strong>Continue - Diophantine in Solveset :</strong></p>
<p>PR <a href="https://github.com/sympy/sympy/pull/11234">11234</a></p>
<ul>
<li>
<p>Some points we discussed :</p>
<ol>
<li>
<p><code class="language-plaintext highlighter-rouge">Solveset</code> should return all the solution, so we need to check for which kind of eq. <code class="language-plaintext highlighter-rouge">diophantine</code> returns all
the solution. We can get the equation type using <code class="language-plaintext highlighter-rouge">classify_diop</code> defined in <code class="language-plaintext highlighter-rouge">diophantine.py</code>.</p>
</li>
<li>
<p>If there is the case where <code class="language-plaintext highlighter-rouge">diophantine</code> doesn’t return all the solutions then just return <code class="language-plaintext highlighter-rouge">ConditionSet</code> or try to
make all solution (e.g. if just need to permute sign in values then use <code class="language-plaintext highlighter-rouge">permute_signs</code>).</p>
</li>
</ol>
</li>
<li>
<p>After reading the <a href="http://docs.sympy.org/dev/modules/solvers/diophantine.html">diophantine Documentation</a> and <code class="language-plaintext highlighter-rouge">diophantine</code> doctests and examples, I found that :</p>
<ol>
<li>Currently, following five types of Diophantine equations can be solved using <code class="language-plaintext highlighter-rouge">~sympy.solvers.diophantine.diophantine</code> and other helper functions of the Diophantine module.</li>
</ol>
<ul>
<li>Linear Diophantine equations:</li>
</ul>
<p><code class="language-plaintext highlighter-rouge">a1*x1 + a2*x2 + ... + an*xn = b</code>.</p>
<ul>
<li>General binary quadratic equation:</li>
</ul>
<p><code class="language-plaintext highlighter-rouge">ax^2 + bxy + cy^2 + dx + ey + f = 0</code></p>
<ul>
<li>Homogeneous ternary quadratic equation:</li>
</ul>
<p><code class="language-plaintext highlighter-rouge">ax^2 + by^2 + cz^2 + dxy + eyz + fzx = 0</code></p>
<ul>
<li>Extended Pythagorean equation:</li>
</ul>
<p><code class="language-plaintext highlighter-rouge">a_{1} * x_{1}^2 + a_{2} * x_{2}^2 + .... + a_{n} * x_{n}^2 = a_{n+1} * x_{n+1}^2</code></p>
<ul>
<li>General sum of squares:</li>
</ul>
<p><code class="language-plaintext highlighter-rouge">x_{1}^2 + x_{2}^2 + ... + x_{n}^2 = k</code></p>
<ol>
<li>
<p>If I am correct then <code class="language-plaintext highlighter-rouge">Diophantine</code> returns all the soln if eq is Linear Diophantine equations, General binary quadratic equation and Homogeneous ternary quadratic equation. I tried some Linear Diophantine equations and cross checked with online Diophantine solvers(one of the solver is <a href="http://www.numbertheory.org/php/main_pell.html">here</a>).</p>
</li>
<li>
<p>In last 2 (Extended Pythagorean equation and General sum of squares) we need to do <code class="language-plaintext highlighter-rouge">permute_signs</code> to get all the soln.</p>
</li>
</ol>
<p>E.g.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> ```
>>> from sympy.utilities.iterables import permute_signs
>>> list(permute_signs((1, 12)))
[(1, 12), (-1, 12), (1, -12), (-1, -12)]
```
</code></pre></div> </div>
<p>In general if all variables have even powers then we should do <code class="language-plaintext highlighter-rouge">permute_signs</code>. <code class="language-plaintext highlighter-rouge">Diophantine</code> solves the factors of the eq
so if we have eq like this <code class="language-plaintext highlighter-rouge">x**2 - y**2</code>, diophantine solves factors <code class="language-plaintext highlighter-rouge">x + y</code> and <code class="language-plaintext highlighter-rouge">x - y</code>.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> ```
>>> from sympy.solvers.diophantine import diophantine
>>> from sympy.abc import x, y, z
>>> diophantine(x**2 - y**2)
set([(-t_0, -t_0), (t_0, -t_0)])
```
</code></pre></div> </div>
<p>so we should check even powers and permute sign.</p>
<p>other examples :</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
>>> from sympy.solvers.diophantine import diop_general_sum_of_squares
>>> from sympy.abc import a, b, c, d, e, f
>>> diop_general_sum_of_squares(a**2 + b**2 + c**2 + d**2 + e**2 - 2345)
set([(15, 22, 22, 24, 24)])
>>> from sympy.solvers.diophantine import diop_general_pythagorean
>>> diop_general_pythagorean(a**2 + b**2 + c**2 - d**2)
(m1**2 + m2**2 - m3**2, 2*m1*m3, 2*m2*m3, m1**2 + m2**2 + m3**2)
>>> diop_general_pythagorean(9*a**2 - 4*b**2 + 16*c**2 + 25*d**2 + e**2)
(10*m1**2 + 10*m2**2 + 10*m3**2 - 10*m4**2, 15*m1**2 + 15*m2**2
+ 15*m3**2 + 15*m4**2, 15*m1*m4, 12*m2*m4, 60*m3*m4)
>>> from sympy.solvers.diophantine import diop_general_sum_of_even_powers
>>> diop_general_sum_of_even_powers(a**4 + b**4 - (2**4 + 3**4))
set([(2, 3)])
</code></pre></div> </div>
<p>In above these types of cases we need <code class="language-plaintext highlighter-rouge">permute_signs</code>. If we check these solution you can see that <code class="language-plaintext highlighter-rouge">permute_signs</code>
is needed when solutions is not parameterized.</p>
<p>e.g.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
>>> from sympy.solvers.diophantine import diophantine
>>> from sympy.abc import x, y, z
>>> diophantine(x**2 - y**2)
set([(-t_0, -t_0), (t_0, -t_0)])
</code></pre></div> </div>
<p>solution <code class="language-plaintext highlighter-rouge">set([(-t_0, -t_0), (t_0, -t_0)])</code> is same as <code class="language-plaintext highlighter-rouge">set([(-t_0, -t_0), (t_0, t_0), (-t_0, t_0), (t_0, -t_0)])</code>.(because <code class="language-plaintext highlighter-rouge">t_0</code> can take any integer value.)</p>
<p>I discussed these things with <a href="https://github.com/thilinarmtb">@thilinarmtb</a> (He have worked on <code class="language-plaintext highlighter-rouge">diophantine</code>. Blog link : <a href="https://thilinaatsympy.wordpress.com/page/2/">https://thilinaatsympy.wordpress.com/</a>). Main points are :</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Only the linear solver is incomplete, the algorithm in Diophantine module should be fixed (`permute_signs` or something like that won't help). We can use `permute_signs` when we have even powers in all variables. We should update Diophantine module to use permute sign. But we should not returns `ConditionSet` for linear diophantine eq. because for linear diophantine eq `diophantine()`returns parameterized solution which is complete most of the time.
</code></pre></div> </div>
<ol>
<li>
<p><code class="language-plaintext highlighter-rouge">classify_diop</code> can returns these <code class="language-plaintext highlighter-rouge">diop_type</code> :</p>
<ul>
<li>linear</li>
<li>univariate</li>
<li>binary_quadratic</li>
<li>inhomogeneous_ternary_quadratic</li>
<li>homogeneous_ternary_quadratic_normal</li>
<li>homogeneous_ternary_quadratic</li>
<li>inhomogeneous_general_quadratic</li>
<li>inhomogeneous_general_quadratic</li>
<li>homogeneous_general_quadratic</li>
<li>general_sum_of_squares</li>
<li>general_pythagorean</li>
<li>cubic_thue</li>
<li>general_sum_of_even_powers</li>
</ul>
</li>
</ol>
<p>If the equation type is none of these then <code class="language-plaintext highlighter-rouge">solveset_integers</code> should returns <code class="language-plaintext highlighter-rouge">ConditionSet</code>.Because currently <code class="language-plaintext highlighter-rouge">diophantine</code>
can handle these kinds of eq only.</p>
</li>
<li>
<p>PR Update diophantine to get some missing solution: <a href="https://github.com/sympy/sympy/pull/11334">11334</a></p>
</li>
</ul>
<hr />
<p><strong>Continue simplified Trigonometric eq solution :</strong></p>
<p>PR <a href="https://github.com/sympy/sympy/pull/11188">#11188</a></p>
<ul>
<li>
<p>Shifted the <code class="language-plaintext highlighter-rouge">_union_simplify</code> function code to <code class="language-plaintext highlighter-rouge">_union</code> in <code class="language-plaintext highlighter-rouge">fancyset/ImageSet</code> with some changes.</p>
</li>
<li>
<p>Still facing problem (It sometimes pass all cases sometimes fail).</p>
</li>
</ul>
<hr />
<p><strong>Meanwhile :</strong></p>
<ul>
<li>I found a problem in <code class="language-plaintext highlighter-rouge">checksol</code> defined in <code class="language-plaintext highlighter-rouge">sympy/solvers/solvers.py</code> and opened a PR that fixes
the small issue, <a href="https://github.com/sympy/sympy/pull/11339">#11339</a></li>
</ul>
<hr />
<p><strong>continue…</strong></p>
Coding Period Week 52016-06-21T00:00:00+00:00https://shekharrajak.github.io/blog/GSoC-2016/Coding-Period-week-5<p><strong>Continue- nonlinsolve :</strong></p>
<p>PR <a href="https://github.com/sympy/sympy/pull/11111">#11111</a></p>
<ul>
<li>
<p>I found the case where complex solution is missed. When <code class="language-plaintext highlighter-rouge">solve_poly_system</code> is solving polynomial equation and that result is used
in solving non polynomial-equation to get other soln. May be <code class="language-plaintext highlighter-rouge">solve_poly_system</code> return only real solution( so complex solution is not being used for further steps) thats why further step is with this real solution.</p>
</li>
<li>
<p>It seems <code class="language-plaintext highlighter-rouge">solve_poly_system</code> is doing it’s job since it is not designed for all solution. But we have <code class="language-plaintext highlighter-rouge">substitution</code> method using
<code class="language-plaintext highlighter-rouge">solveset_real</code> and <code class="language-plaintext highlighter-rouge">solveset_complex</code> and retuning all solutionn. In new commits I improved the code and now <code class="language-plaintext highlighter-rouge">substitution</code> method can solve all kind of system independently.</p>
</li>
<li>
<p>I come across these kind of situation many times :</p>
</li>
</ul>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>In [68]: x, y, z, r, t = symbols('x, y, z, r, t', real = True)
In [69]: soln = solveset(sqrt(r)*Abs(tan(t))/sqrt(tan(t)**2 + 1) + x*tan(t),x,S.Reals)
In [70]: soln
Out[70]:
⎧ √r⋅│tan(t)│ ⎫
(-∞, ∞) ∩ ⎪───────────────────────⎪
⎨ _____________ ⎬
⎪ ╱ 2 ⎪
⎩╲╱ tan (t) + 1 ⋅tan(t)⎭
In [71]: soln = solveset(sqrt(r)*Abs(tan(t))/sqrt(tan(t)**2 + 1) + x*tan(t),x)
In [72]: soln
Out[72]:
⎧ -√r⋅│tan(t)│ ⎫
⎪───────────────────────⎪
⎨ _____________ ⎬
⎪ ╱ 2 ⎪
⎩╲╱ tan (t) + 1 ⋅tan(t)⎭
</code></pre></div></div>
<p>In other words :</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>In [1]: Intersection(FiniteSet(-x), S.Reals)
Out[1]: (-∞, ∞) ∩ {x}
In [2]: Intersection(FiniteSet(x), S.Reals)
Out[2]: ℝ ∩ {x}
</code></pre></div></div>
<p>So I am not able to extract the <code class="language-plaintext highlighter-rouge">-x</code> here. Because of this <code class="language-plaintext highlighter-rouge">nonlinsolve</code> returning some extra soln.
One case is in test file : <code class="language-plaintext highlighter-rouge">test_issue_5132</code>.</p>
<p>I opened a PR for this <a href="https://github.com/sympy/sympy/pull/11280">#11280</a></p>
<ul>
<li>If someone wants to see the changes I did in <code class="language-plaintext highlighter-rouge">nonlinsolve</code> then check these gist <a href="https://gist.github.com/Shekharrajak/5e77fe344c996c17c177985853884985">nonlinsolve_till_24june_2016</a>,
<a href="https://gist.github.com/Shekharrajak/5d285ce0cf113cfc217c3e33c3ca04c0">nonlinsolve_till_21jun2016.py</a>.</li>
</ul>
<p><strong>previous PRs update :</strong></p>
<ul>
<li>
<p><a href="https://github.com/sympy/sympy/pull/11188">#11188</a> - Simplified Solution for Trigonometric equation :
I did some minor changes.Now I hope it is good to go.</p>
</li>
<li>
<p><a href="https://github.com/sympy/sympy/pull/11234">#11234</a> - Connecting Diophantine and solveset to get Integer solution:
added some testcases. I have defined <code class="language-plaintext highlighter-rouge">solveset_integers</code> for this, it take take list of symbols(to get soln in that order).t
But Currently solveset takes one symbol. I hope this PR is good to go.</p>
</li>
<li>
<p><a href="https://github.com/sympy/sympy/pull/11257">11257</a> - solveset univariate trig inequality solvers : Actually to simplify the
soln I need to use PR <a href="https://github.com/sympy/sympy/pull/11188">#11188</a>, so if it got merged that code will help me in this PR.</p>
</li>
</ul>
<hr />
<p><strong>Meanwhile :</strong></p>
<ul>
<li>I worked on these previous PRs regarding issues I reported <a href="https://github.com/sympy/sympy/pull/11239">#11239</a>, <a href="https://github.com/sympy/sympy/pull/11280">11280</a>.</li>
</ul>
<hr />
<p><strong>continue..</strong></p>
Coding Period Week 42016-06-13T00:00:00+00:00https://shekharrajak.github.io/blog/GSoC-2016/Coding-Period-week-4<h4 id="solveset-when-domain--sintegers"><code class="language-plaintext highlighter-rouge">Solveset</code> when <code class="language-plaintext highlighter-rouge">domain = S.Integers</code></h4>
<p>PR <a href="https://github.com/sympy/sympy/pull/11234">#11234</a></p>
<p>Right now we may not get our solution in Integer domain but we can use concept of diophantine equations in <code class="language-plaintext highlighter-rouge">solveset</code>.
When I messaged about this in giiter channel Aaron told about the <code class="language-plaintext highlighter-rouge">diophantine</code>, already defined in solvers/diophantine.py.
So we can use <code class="language-plaintext highlighter-rouge">diophantine</code> in <code class="language-plaintext highlighter-rouge">solveset</code> to get Integer solution.<code class="language-plaintext highlighter-rouge">diophantine</code> is coded pretty well and works fine.</p>
<h5 id="diophantine-equations">Diophantine Equations</h5>
<p>Let P(x, y, …) is a polynomial with integer coefficients in one or more variables.
A Diophantine equation is an algebraic equation</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>P(x, y, z, ... ) = 0
</code></pre></div></div>
<p>for which integer solutions are sought.</p>
<ul>
<li>More about diophantine equation <a href="http://mathworld.wolfram.com/DiophantineEquation.html">mathworld.wolfram</a></li>
</ul>
<p><strong>Previous work on this :</strong></p>
<p>PR <a href="https://github.com/sympy/sympy/pull/10994">#10994</a></p>
<hr />
<p><strong>solveset_univariate_trig_ineq :</strong>*</p>
<p>PR <a href="https://github.com/sympy/sympy/pull/11257">#11257</a></p>
<ul>
<li>Problem in current branch:</li>
</ul>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>In [ ]: solveset((2*cos(x)+1)/(2*cos(x)-1) > 0, x, S.Reals)
Out[ ]:
(-oo, pi/3) \ ImageSet(Lambda(_n, 2*_n*pi + 5*pi/3), Integers()) U ImageSet(Lambda(_n, 2*_n*pi + pi/3), Integers()) U (2*pi/3, 4*pi/3) \ ImageSet(Lambda(_n, 2*_n*pi + 5*pi/3), Integers()) U ImageSet(Lambda(_n, 2*_n*pi + pi/3), Integers())
</code></pre></div></div>
<p>solution expected is :</p>
<p><code class="language-plaintext highlighter-rouge">(1/3)*(3*pi*n - pi) < x < (1/3)*(3*pi*n +pi), n element in Z</code></p>
<p>I am working on this and have opened PR <a href="https://github.com/sympy/sympy/pull/11257">#11257</a> but it is failing some cases.
I am trying to improve it. It is inspired from previous <code class="language-plaintext highlighter-rouge">solve_univariate_inequality</code> but it seems need changes for trig ineq.</p>
<p>Main intention is to get extended solution for Trigonometric inequality.</p>
<p>eg.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>In [2]: solveset((2*cos(x)+1)/(2*cos(x)-1) > 0, x, S.Reals)
Out[2]:
⎡⎧ π ⎫ ⎧ π ⎫⎤
⎢⎨n⋅π - ─ | n ∊ ℤ⎬, ⎨n⋅π + ─ | n ∊ ℤ⎬⎥
⎣⎩ 3 ⎭ ⎩ 3 ⎭⎦
n [4]: solveset(sin(x) > 1/sqrt(2), x, S.Reals)
Out[4]:
⎛⎧ π ⎫ ⎧ 3⋅π ⎫⎞
⎜⎨2⋅n⋅π + ─ | n ∊ ℤ⎬, ⎨2⋅n⋅π + ─── | n ∊ ℤ⎬⎟
⎝⎩ 4 ⎭ ⎩ 4 ⎭⎠
In [15]: solveset(2*cos(x) + sqrt(3) < 0, x, S.Reals)
Out[15]:
⎛⎧ 5⋅π ⎫ ⎧ 7⋅π ⎫⎞
⎜⎨2⋅n⋅π + ─── | n ∊ ℤ⎬, ⎨2⋅n⋅π + ─── | n ∊ ℤ⎬⎟
⎝⎩ 6 ⎭ ⎩ 6 ⎭⎠
In [16]: solveset_univariate_trig_inequality(tan(x) > 0, x)
Out[16]:
⎛ ⎧ π ⎫⎞
⎜{n⋅π | n ∊ ℤ}, ⎨n⋅π + ─ | n ∊ ℤ⎬⎟
⎝ ⎩ 2 ⎭⎠
</code></pre></div></div>
<ul>
<li>Still need some good idea to improve the PR <a href="https://github.com/sympy/sympy/pull/11257">#11257</a>.
<strong>will continue …</strong></li>
</ul>
<hr />
<p><strong>Continue- nonlinsolve :</strong></p>
<p>PR <a href="https://github.com/sympy/sympy/pull/11111">#11111</a></p>
<ul>
<li>
<p>After Amit’s review and comments, I improved the <code class="language-plaintext highlighter-rouge">docstring</code>, improved the <code class="language-plaintext highlighter-rouge">complements</code> and <code class="language-plaintext highlighter-rouge">intersection</code> <code class="language-plaintext highlighter-rouge">if</code> block
present in <code class="language-plaintext highlighter-rouge">substitution</code> function.</p>
</li>
<li>
<p>The main thing I added is : now <code class="language-plaintext highlighter-rouge">substitution</code> method will return both <code class="language-plaintext highlighter-rouge">Real</code> and <code class="language-plaintext highlighter-rouge">Complex</code> solution. That mean now
it is using <code class="language-plaintext highlighter-rouge">solveset_real</code> and <code class="language-plaintext highlighter-rouge">solveset_complex</code>. Previously it uses <code class="language-plaintext highlighter-rouge">solveset_complex</code> when there is <code class="language-plaintext highlighter-rouge">S.EmpltySet</code>
from <code class="language-plaintext highlighter-rouge">solveset_real</code>.</p>
</li>
<li>
<p>Since both <code class="language-plaintext highlighter-rouge">solveset_real</code> and <code class="language-plaintext highlighter-rouge">solveset_complex</code> solution need similar steps. So I am using <code class="language-plaintext highlighter-rouge">_solve_using_know_values</code> function
a helper for <code class="language-plaintext highlighter-rouge">substitution</code> method, where <code class="language-plaintext highlighter-rouge">solver</code> parameter can be <code class="language-plaintext highlighter-rouge">solveset_real</code> or <code class="language-plaintext highlighter-rouge">solveset_complex</code>. Another parameter is
<code class="language-plaintext highlighter-rouge">result</code> which is list of dict <known_symbol: it’s value> (already solved symbol, mostly from <code class="language-plaintext highlighter-rouge">nonlinsolve/_solve_poly_system</code>).</p>
</li>
</ul>
<p><strong>Meanwhile</strong></p>
<ul>
<li>
<p>Opened an issue <a href="https://github.com/sympy/sympy/issues/11236">#11236</a>.</p>
</li>
<li>
<p>PR <a href="https://github.com/sympy/sympy/pull/11239">#11239</a> for the issue</p>
</li>
<li>
<p>I found that right now <code class="language-plaintext highlighter-rouge">diophantine</code> can’t handle these types of equations :</p>
</li>
</ul>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>In [ ]: diophantine((x+y)**2 - x**3 + y**3)
---------------------------------------------------------------------------
NotImplementedError: No solver has been written for cubic_thue.
</code></pre></div></div>
<p><strong>continue..</strong></p>
Coding Period Week 32016-06-08T00:00:00+00:00https://shekharrajak.github.io/blog/GSoC-2016/Coding-Period-week-3<h3 id="continue-simplified-solution-for-trigonometric-equation">Continue: Simplified solution for Trigonometric Equation:</h3>
<p>PR <a href="https://github.com/sympy/sympy/pull/11188">#11188</a></p>
<p><strong>New Problems :</strong></p>
<ul>
<li>When I tried more testcases having sqrt and other types I found new issues on <code class="language-plaintext highlighter-rouge">reduce_imageset</code> method. Some of the Simplified
solutions contains undesired <code class="language-plaintext highlighter-rouge">n</code> values.</li>
</ul>
<p><strong>Changes in solveset/_solve_radical</strong></p>
<ul>
<li>Sometimes <code class="language-plaintext highlighter-rouge">_solve_radical</code> may get <code class="language-plaintext highlighter-rouge">exp(I*x)</code> terms and solving them we give Imageset, I added the</li>
</ul>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>if isinstance(result, ImageSet) or any(isinstance(r, ImageSet) for r in result.args):
return result
</code></pre></div></div>
<p>in the method.</p>
<p><strong>Using <code class="language-plaintext highlighter-rouge">factor_list</code> in solve_trig :</strong></p>
<ul>
<li>
<p>There are many cases we can do factor of expression and solve each factor may give us more simplified solution.</p>
</li>
<li>
<p>I added the <code class="language-plaintext highlighter-rouge">factor_list</code> and solving each factors and union the solution.</p>
</li>
<li>
<p>When I analyzed how <code class="language-plaintext highlighter-rouge">exp</code> form is solved and found correct order to use <code class="language-plaintext highlighter-rouge">factor</code> or <code class="language-plaintext highlighter-rouge">factor_list</code> ,the summery
is in this <a href="https://gist.github.com/Shekharrajak/17fdcd2320f572fc9fc8674823137e20">gist</a></p>
</li>
</ul>
<script src="https://gist.github.com/Shekharrajak/17fdcd2320f572fc9fc8674823137e20.js"></script>
<ul>
<li>I implemented the above order and shifted the <code class="language-plaintext highlighter-rouge">reduce_imageset</code> method in <code class="language-plaintext highlighter-rouge">_union</code> for <code class="language-plaintext highlighter-rouge">ImageSet</code>.
I created <code class="language-plaintext highlighter-rouge">_union_simiplify</code> a helper method for <code class="language-plaintext highlighter-rouge">_union</code> .</li>
</ul>
<p><strong><code class="language-plaintext highlighter-rouge">_union_simplify</code> better than my previous implementation :</strong></p>
<ul>
<li>
<p>Previous implementation was returning solution in simplified <code class="language-plaintext highlighter-rouge">ImageSet</code>, although it passed the all
test-case except 2-3 cases. But these 2-3 test-cases taught me you are doing over simplification.
So now I understood that we should not simplify the <code class="language-plaintext highlighter-rouge">ImageSet(s)</code> of the one factor solution, it may get simplified
with other factor solution ImageSet(s).</p>
</li>
<li>
<p>Simplify them if there is difference of <code class="language-plaintext highlighter-rouge">pi</code>, that means club [(2<em>n + 1) and (2</em>n) => (n<em>pi)] or [(2</em>n* + 1)
and (2<em>n</em>pi + 2) => (n*pi)].</p>
</li>
</ul>
<p><strong>So now _solve_trig uses factor_list for trig eq and then solve each factor F_i. To solve each factor F_i first do
F_i.rewrite(exp) and get this exp form factors F_ij so now the unnecessary exp will come out that dont contribute in
final solution. That’s why we get simplified <code class="language-plaintext highlighter-rouge">ImageSet</code> that will be Union with previous solution. Inside the
Union => _union => _union_simplify checks for simplification with already present <code class="language-plaintext highlighter-rouge">ImageSet</code>. This is the process
till last factor F_i.</strong></p>
<p><strong>Meanwhile :</strong></p>
<ul>
<li>
<p>After working on blog for 1 week created my own blog template powered by Jekyll. and shifted the old blog into github.
PR for the blog link update in planet: <a href="https://github.com/sympy/planet-sympy/pull/42">pull/42</a></p>
</li>
<li>
<p>I edited my old template(already hosted on <a href="http://s-hacker.info">s-hacker.info</a>) to make it mobile responsive. Now it works perfectly for mobile. <a href="http://shekharrajak.github.io/">shekharrajak.github.io</a></p>
</li>
<li>
<p>Found a issue in <code class="language-plaintext highlighter-rouge">factor_list</code>. <a href="https://github.com/sympy/sympy/issues/11198">issues/11198</a> , When I passed
<code class="language-plaintext highlighter-rouge">f = sqrt(2)*sin(x) -1</code> into <code class="language-plaintext highlighter-rouge">solveset</code> I got this problem.</p>
</li>
<li>
<p>To solve <code class="language-plaintext highlighter-rouge">factor_list</code> issue I opened a PR <a href="https://github.com/sympy/sympy/pull/11201">pull/11201</a>.</p>
</li>
</ul>
Coding Period Week 22016-06-01T00:00:00+00:00https://shekharrajak.github.io/blog/GSoC-2016/Coding-Period-week-2<h3 id="system-of-inequalities">System of Inequalities</h3>
<ul>
<li>
<p>Right now solve uses <code class="language-plaintext highlighter-rouge">reduce_inequalitie</code>s to solve system of equations. But it is not designed for more than one variable.</p>
</li>
<li>
<p>ex: system = <code class="language-plaintext highlighter-rouge">[2*x - 3*y <= 12, x+5*y <=20, x>0] symbols = [x,y]) </code>
you will get :
<code class="language-plaintext highlighter-rouge">NotImplementedError</code>:
inequality has more than one symbol of interest
We know answer is <code class="language-plaintext highlighter-rouge">[0 < x <120/13 and 2(x-6)/3 <= y <= (20-x)/5]</code>
<code class="language-plaintext highlighter-rouge">[x = 120/13 and y = 28/13]</code></p>
</li>
<li>
<p>But <code class="language-plaintext highlighter-rouge">SymPy</code> already have project on this <a href="https://github.com/sympy/sympy/wiki/GSoC-2016-Ideas#cylindrical-algebraic-decomposition">Cylindrical algebraic decomposition</a> to Provide an interface for solving systems of polynomial inequalities.</p>
</li>
<li>
<p>If we want to feature like old <code class="language-plaintext highlighter-rouge">solve</code> then just need to pass system of inequalities having one variable to solve
for one variable. After checking this use <code class="language-plaintext highlighter-rouge">reduce_inequalitie(system, symbol)</code> it will return solution. It is easy to implement.</p>
</li>
</ul>
<h3 id="general-solution-for-trigonometric-equations">General solution for Trigonometric equations</h3>
<ul>
<li>
<p>PR <a href="https://github.com/sympy/sympy/pull/11188">#11188</a></p>
</li>
<li>
<p>Previous work in this problem : <a href="https://github.com/sympy/sympy/pull/10898">#10898</a>,
<a href="https://github.com/sympy/sympy/pull/10713">#10713</a>, <a href="https://github.com/sympy/sympy/pull/10733">#10733</a></p>
</li>
</ul>
<p><strong>Problems in old method :</strong></p>
<ul>
<li>
<p><code class="language-plaintext highlighter-rouge">_solve_trig</code> changes the trig equation in <code class="language-plaintext highlighter-rouge">exp</code> form (it’s fine). But then fraction and solving equation
for it’s parts makes more number of <code class="language-plaintext highlighter-rouge">exp</code>. If we have more number of <code class="language-plaintext highlighter-rouge">exp</code> then we get more number of <code class="language-plaintext highlighter-rouge">imageset</code>,
Since we <code class="language-plaintext highlighter-rouge">_invert</code> for each <code class="language-plaintext highlighter-rouge">exp</code> factors.</p>
</li>
<li>
<p>It retuns <code class="language-plaintext highlighter-rouge">ConditionSet</code> when it can’t solve, but its expression is in ` exp<code class="language-plaintext highlighter-rouge"> form mostly with </code>I` and
in complicated form.</p>
</li>
<li>
<p>some times <code class="language-plaintext highlighter-rouge">_solve_as_poly</code> can solve Trig equations, but it is not using it.</p>
</li>
</ul>
<p><strong>New implemention :</strong></p>
<ul>
<li>
<p>I added <code class="language-plaintext highlighter-rouge">reduce_imageset</code> in <code class="language-plaintext highlighter-rouge">solveset.py</code> to reduce the number of union returned by <code class="language-plaintext highlighter-rouge">_solve_trig</code> method. As Harsh said it is
no specific to <code class="language-plaintext highlighter-rouge">solveset</code>, so I moved the method to <code class="language-plaintext highlighter-rouge">sets/sets.py</code>. I added the doctests and test-cases in <code class="language-plaintext highlighter-rouge">test_sets.py</code>.</p>
</li>
<li>
<p>Now solving the <code class="language-plaintext highlighter-rouge">exp</code> form directly using <code class="language-plaintext highlighter-rouge">solveset</code>. This makes the less number of <code class="language-plaintext highlighter-rouge">ImageSet</code> in many cases.
But to solve equation having <code class="language-plaintext highlighter-rouge">tan</code> in it, will be complicated, for that I changed the <code class="language-plaintext highlighter-rouge">solve_rational</code> method,
so that it can handle <code class="language-plaintext highlighter-rouge">exp</code> with <code class="language-plaintext highlighter-rouge">I</code>. in denominator.</p>
</li>
<li>
<p>Now using <code class="language-plaintext highlighter-rouge">_solve_as_poly</code> when <code class="language-plaintext highlighter-rouge">solveset</code> can’t solve it using <code class="language-plaintext highlighter-rouge">exp</code> form. If this also can’t solve then retuns
the <code class="language-plaintext highlighter-rouge">ConditionSet</code> having simple trig functions, which is understandable.</p>
</li>
</ul>
<p><strong>reduce_imageset :</strong></p>
<ul>
<li>
<p><code class="language-plaintext highlighter-rouge">reduce_imageset</code> take the <code class="language-plaintext highlighter-rouge">ImageSet</code> or Union of <code class="language-plaintext highlighter-rouge">ImageSet</code> and returns the minimum number of <code class="language-plaintext highlighter-rouge">ImageSet</code>.</p>
</li>
<li>
<p>First we extract the <code class="language-plaintext highlighter-rouge">Lambda</code> expression from the each <code class="language-plaintext highlighter-rouge">ImageSet</code> and take principle values. Separate the positive and negative principle values and sort them.</p>
</li>
<li>
<p>+ve and -ve values are passed into <code class="language-plaintext highlighter-rouge">interpolate</code> method defined in <code class="language-plaintext highlighter-rouge">polys/polyfuncs.py</code> to get the general function in terms
of Dummy <code class="language-plaintext highlighter-rouge">n</code>.</p>
</li>
<li>
<p>If only one <code class="language-plaintext highlighter-rouge">Imageset</code> or value in +ve or -ve value list then return that as it is. Here we need to note that Dummy <code class="language-plaintext highlighter-rouge">n</code> defined here
is different then original lambda expression, so need to return original <code class="language-plaintext highlighter-rouge">imageset</code>. So I am storing original <code class="language-plaintext highlighter-rouge">ImageSet</code> in dict with
its principle vales.</p>
</li>
<li>
<p>If more than one +ve/-ve values are there then interpolate expression will be <code class="language-plaintext highlighter-rouge">ImageSet</code> expression and return.</p>
</li>
<li>
<p>Here I separe the -ve and +ve values because interpolate returns complicated expressions if we both types of values.</p>
</li>
<li>
<p>Also I sorted the +ve and -ve list, to get simplified expression from interpolate.</p>
</li>
</ul>
<p><strong>Problems :</strong></p>
<ul>
<li>In this PR <code class="language-plaintext highlighter-rouge">solveset_real(tan(x), x)</code> returns <code class="language-plaintext highlighter-rouge">imageset(Lambda(n, pi*(n - 1)), S.Integers)</code>
but I want <code class="language-plaintext highlighter-rouge">imageset(Lambda(n, n*pi), S.Integers)</code>.</li>
</ul>
<p><strong>Issues :</strong></p>
<ul>
<li>Meanwhile I found a issue in <code class="language-plaintext highlighter-rouge">solveset</code>. <a href="https://github.com/sympy/sympy/issues/11194">issues/11194</a>.
<code class="language-plaintext highlighter-rouge">2*sin(x) - 2*sqrt(3)*cos(x) - sqrt(3)*tan(x) +3 = 0</code> can be easily solved if we factorize it correctly. But I haven’t found
a good way to get its factor. I tried <code class="language-plaintext highlighter-rouge">factor</code>, <code class="language-plaintext highlighter-rouge">expand(Trig + True)</code> , <code class="language-plaintext highlighter-rouge">expand_trig</code>, <code class="language-plaintext highlighter-rouge">rewrite(sin)</code>.</li>
</ul>
Community Bonding Period2016-05-22T00:00:00+00:00https://shekharrajak.github.io/blog/GSoC-2016/Community-Bonding-Period<p><br /><br /></p>
<h2 id="week-1--23-april-2016---30-april-2016">Week 1 ( 23 April 2016 - 30 April 2016)</h2>
<h3 id="excited-about-my-gsoc-blog">Excited about my GSoC Blog</h3>
<p>I created my blog on around Nov-Dec 2015, mostly for GSoC ( confident :p ). But the template was still on github with random contents. <a href="http://github.com/shekharrajak/MyBlog">Blog repo</a></p>
<p>So it was the time to replace these contents and edit the template and host on my personal site</p>
<p>On 23 April 2016 00:30 (IST) GSoC projects are announced, next day in the evening I edited the blog template and made it for GSoC. I added two posts ( contribution before GSoC and project) and hosted late night.</p>
<p>In this week I had Lab exams and Minor tests also. I had some chat/Email with the mentors about the project as well.</p>
<h2 id="week-2-3--1-may-2016---14-may-2016">Week 2, 3 ( 1 May 2016 - 14 May 2016)</h2>
<p>It was End Examination time ( 5 - 12 May). In this period I tried to be active in gitter chat and Mailing list. I worked on my previously opened PRs and new issues.</p>
<p>Some of them are : <a href="https://github.com/sympy/sympy/pull/10733">pull/10733</a>, <a href="https://github.com/sympy/sympy/pull/10550">pull/10550</a>. I related some new issues with old PRs and tried to fix them.</p>
<p>I tried to add new feature in <code class="language-plaintext highlighter-rouge">decompogen</code> method in this PR <a href="https://github.com/sympy/sympy/pull/11085">pull/11085</a></p>
<p>We had first hangout on 2 May 2016 , in which <a href="https://github.com/kshitij10496">Kshitij</a> and me choose our work for next week. I choose to work on Non Linear System of Equations and Multivariate Equation solver for <code class="language-plaintext highlighter-rouge">Solveset</code>.</p>
<p>Minutes of meeting is in Wiki page <a href="https://github.com/sympy/sympy/wiki/GSoC-2016-Solvers-Progress#meeting-01">GSoC-2016-Solvers-Progress#meeting-01</a></p>
<h2 id="week-4-5--15-may-2016---23-may-2016">Week 4, 5 ( 15 May 2016 - 23 May 2016)</h2>
<p>After the End semester examination, we had 2nd meeting on <a href="https://github.com/sympy/sympy/wiki/GSoC-2016-Solvers-Progress#meeting-02">15 May 2016</a>. We ( <a href="https://github.com/hargup">Harsh</a>, <a href="https://github.com/aktech">Amit</a>, <a href="https://github.com/kshitij10496">kshitij</a> and <a href="https://github.com/shekharrajak">me</a>) discussed about what should be done before coming on meeting and documenting ideas/mplementation on blog or somewhere.</p>
<p>I started working on <code class="language-plaintext highlighter-rouge">nlinsolve</code> to solve Non Linear System of Equations.</p>
<h2 id="auditing-sympys-non-linear-system-of-equation-solver">Auditing SymPy’s non linear system of equation solver</h2>
<p>A non-linear system of equations is a system in which at least one of the variables has an exponent other than 1 and/or there is a product of variables in one of the equations.</p>
<h3 id="how-old-solver-handle-this-">How old Solver handle this :</h3>
<ul>
<li>
<p>SymPy uses <code class="language-plaintext highlighter-rouge">_solve_system</code> function to solve all kind of systems( linear, non linear, Multivariate Equations).</p>
</li>
<li>
<p><code class="language-plaintext highlighter-rouge">_solve_system</code>, try to converts all the equations into Poly and checks for linear system.
If all the Poly equations are linear then solve this using minsolve_linear_system or solve_linear_system.</p>
</li>
<li>
<p>If all the equations are not linear then<code class="language-plaintext highlighter-rouge"> _solve_poly_system</code> try to solve them.
If system is not zero dimensional then returns <code class="language-plaintext highlighter-rouge">NotImplementedError</code>. <code class="language-plaintext highlighter-rouge">_solve_poly_system</code> uses Groebner basis of the system, when any one equation in the basis contains only symbol, then this reduced system is solvable.</p>
</li>
<li>
<p>When solve_poly_system returns solutions for some variables, then one by one solve the equation using <code class="language-plaintext highlighter-rouge">solve</code> for
all the remain unsolved variables.</p>
</li>
</ul>
<h3 id="problems-in-old-solver-method-">Problems in old Solver method :</h3>
<ul>
<li>
<p><code class="language-plaintext highlighter-rouge">solve_poly_system</code> can return solution for zero-dimensional only. So when polynomial Equation system is positive dimensional system (infinite solution) then <code class="language-plaintext highlighter-rouge">NotImplementedError</code> is returned by <code class="language-plaintext highlighter-rouge">_solve_poly_system</code>.</p>
</li>
<li>
<p>Elimination, substitution and solve_poly_system is in one function <code class="language-plaintext highlighter-rouge">_solve_system</code>. So it is messy.</p>
</li>
<li>
<p>When it solves for unsolved symbol, after substituting known values in the equation using <code class="language-plaintext highlighter-rouge">solve</code> then we don’t get solution in general form. eg. if equation is sin(x) + y = 0 and known solution is y = -1 then solve returns pi/2.</p>
</li>
<li>
<p>When it solves for unsolved symbol, after substituting known values in the equation using <code class="language-plaintext highlighter-rouge">solve</code> then we don’t get solution in general form. eg. if equation is sin(x) + y = 0 and known solution is y = -1 then solve returns pi/2.</p>
</li>
</ul>
<h3 id="my-idea-and-implementation-">My idea and implementation :</h3>
<h4 id="nlinsolve">nlinsolve</h4>
<p>I opened a PR <a href="https://github.com/sympy/sympy/pull/11111">pull/11111</a> with initial code.</p>
<h5 id="idea-">Idea :</h5>
<ul>
<li>
<p>The main idea was to use <code class="language-plaintext highlighter-rouge">solve_poly_system</code> method ( sympy/solvers/polysys.py ) which works pretty well in old solvers, to solve zero-dimensional system.</p>
</li>
<li>
<p><code class="language-plaintext highlighter-rouge">solve_poly_system</code> is used to solve equations which are polynomial.</p>
</li>
<li>
<p>If all the equations are polynomail and have finite solution (zero-dimensional) then <code class="language-plaintext highlighter-rouge">solve_poly_system</code> solve them.</p>
</li>
<li>
<p>When system has all the equatons polynomial but not zero-dimensional then it has infinite number of solutions, To handle these system I thought about method used in this <a href="http://people.math.gatech.edu/~aleykin3/math4803spr13/BOOK/chapter1.pdf">PDF</a> page: 9 , examples : 2.2</p>
</li>
</ul>
<p>I implemented <code class="language-plaintext highlighter-rouge">nlinsolve_matrix</code> using these steps for 2 equations and 2 variables. The code can be found in this <a href="https://gist.github.com/Shekharrajak/a4ff089582f41b163f494a369cf51294"> gist </a></p>
<script src="https://gist.github.com/Shekharrajak/a4ff089582f41b163f494a369cf51294.js"></script>
<p>This method give equation on <code class="language-plaintext highlighter-rouge">y</code> ( if 2 variables are <code class="language-plaintext highlighter-rouge">x</code> and <code class="language-plaintext highlighter-rouge">y</code>. Matrix created using coefficients of <code class="language-plaintext highlighter-rouge">x</code> power). But Matrix returns <code class="language-plaintext highlighter-rouge">0</code> for positive dimensional system ( I only checked for 2 equations 2 variables poisitive dimentional system). So we can’t get an equation of <code class="language-plaintext highlighter-rouge">y</code>. After seeing this issue I didn’t generalize this method for more equations and variables.</p></p>
<ul>
<li>
<p>I read more about positive dimensional systems from Kshitij’s proposal and internet. I found another way of solving them using RUR (Rational Univariate Representation), some good examples/PDFs are :</p>
<ul>
<li>http://www.maplesoft.com/support/help/Maple/view.aspx?path=Groebner/RationalUnivariateRepresentation</li>
<li>http://www.m-hikari.com/imf-2010/5-8-2010/ayadIMF5-8-2010.pdf</li>
<li>href=”http://research.cs.tamu.edu/keyser/Papers/AMSDimacs2005.pdf</li>
<li>http://homepages.math.uic.edu/~jan/mcs563/lec12.pdf</li>
</ul>
</li>
</ul>
<p>These links contains examples but not the clearly the methods for positive dimensional system.</p>
<ul>
<li>
<p>I am still finding a good way to get the RUR.</p>
</li>
<li>
<p>If we have system in which some of the equations are polynomial and some are not then substitution method is best (I didn’t find other symbolic way).</p>
</li>
<li>
<p>First solve the polynomial equations if present for all the combinations of <code class="language-plaintext highlighter-rouge">symbols</code> according to the number of polynomial equations. Store the solutions with <code class="language-plaintext highlighter-rouge">symbols</code> in <code class="language-plaintext highlighter-rouge">dict</code>. Each solution may contains symbols that can be solved using substitution method.</p>
</li>
<li>
<p>Now solve the non polynomial equations using knows solutions( one by one substitution of known solution ) and solve. After solving substitute in the previous solution if that symbol was in there.</p>
</li>
<li>
<p>If number of equations and number of variables are equal then we get solution for each variable independently otherwise solutions may depend on each other.</p>
</li>
<li>
<p>Work is still in progress for RUR and substitution method.</p>
</li>
</ul>
<h4 id="problems-i-am-facing-">Problems I am facing :</h4>
<p><strong>1.</strong> How can we get RUR for the system of equation to get solution for +ve Dimensional.</p>
<p><strong>What I think :</strong> After reading the articles and discussion with <a href="https://github.com/jksuom">@jksoum </a>, I found that Groebner basis and concepts of Gauss-Jordan method for linear systems is helpful to eliminate the variabels.<br /> Now I am trying Groebner Basis of the system( which is reduced form and can be solved using proper substitution method). The main thing is elimination systematically and ordering of monomials.<br />After solving the groebner basis expressions we may get the answer.</p>
<p><strong>2.</strong> Solveset may return Imageset/FiniteSet/Intersection/complement during substitution method.</p>
<p><strong>What I think :</strong> Sometimes <code class="language-plaintext highlighter-rouge">solveset</code> returns real solution with intersection with <code class="language-plaintext highlighter-rouge">R</code> (-oo to oo) or in ImageSet. If solution is in ImageSet then need to check the expression ( if there is unsolved symbol in substitution steps).</p>
<p>If we get ConditionSet then <code class="language-plaintext highlighter-rouge">NotImplementedError</code>.</p>
<p>If we are solving <code class="language-plaintext highlighter-rouge">a + 1/d</code> for <code class="language-plaintext highlighter-rouge">d</code> then <code class="language-plaintext highlighter-rouge">solveset</code> will return<code class="language-plaintext highlighter-rouge"> FiniteSet(-1/a)</code> complement <code class="language-plaintext highlighter-rouge">FiniteSet(0)</code>. so need to consider first args and store the complement in dict.</p>
<p><strong>3.</strong> There may be Complex solution but no real solution so need to consider both complex and real solutions (inside substitution step) ?</p>
<p><strong>What I think :</strong> For complex/real solution we will get next solution( after substituting that solution). Need to check complex solution if no real solution from <code class="language-plaintext highlighter-rouge">solveset</code> (inside substitution method)</p>
<p><strong>I continued the work and next week I tried to fix these problems and almost succeed.My further work on <code class="language-plaintext highlighter-rouge">nlinsolve</code> is <a href="http://shekharrajak.github.io/Coding-Period-Week-1/">here</a></strong></p>
<h2 id="solveset-for-non-symbol">Solveset for non symbol</h2>
<p>I opened a PR <a href="https://github.com/sympy/sympy/pull/11128">pull/11128</a> to add this feature.</p>
<h3 id="idea--1">Idea :</h3>
<ul>
<li>
<p>First detect the <code class="language-plaintext highlighter-rouge">symbol</code> ( for which we are solving equation ) is not a symbol and replace it with some temporary symbol in both <code class="language-plaintext highlighter-rouge">symbol</code> and <code class="language-plaintext highlighter-rouge">f</code> ( expression )</p>
</li>
<li>
<p>We need to use Symbol only to replace, because all the other methods/functions are made for symbols .I realized this after failing many times :) .</p>
</li>
<li>
<p>After this there may be non invertable terms like <code class="language-plaintext highlighter-rouge">Derivative</code>, <code class="language-plaintext highlighter-rouge">Integrals</code> ( <code class="language-plaintext highlighter-rouge">function</code> is not needed here). If want to solve for <code class="language-plaintext highlighter-rouge">f(x)</code> then <code class="language-plaintext highlighter-rouge">f(x)</code> is replaced from <code class="language-plaintext highlighter-rouge">symbol</code> and <code class="language-plaintext highlighter-rouge">f</code> as well.</p>
</li>
</ul>
<p>I defined a method <code class="language-plaintext highlighter-rouge">check_noninverts(f, symbol)</code> for this.</p>
<ul>
<li>
<p>Now <code class="language-plaintext highlighter-rouge">solveset</code> treat them as Symbol and solves. At the end we need to replace back these temporary variables. For this I defined <code class="language-plaintext highlighter-rouge">swap_back(result, swapped_symbol, non_inverts)</code>.This works for ConditionSet also. Most of the time in Trigonometric Equations doesn’t contains Non invertable terms so ImageSet was not needed.</p>
</li>
<li>
<p>All checks have passed after little modifications.</p>
</li>
</ul>
Coding Period Week 12016-05-22T00:00:00+00:00https://shekharrajak.github.io/blog/GSoC-2016/Coding-Period-Week-1<h3 id="nlinsolve-continue">nlinsolve continue</h3>
<ul>
<li>You can read the problems in old solver <code class="language-plaintext highlighter-rouge">_solve_system</code> in <a href="http://shekharrajak.github.io/Community-Bonding-Period/">previous blog</a> , if you haven’t.</li>
</ul>
<p><strong>PR <a href="https://github.com/sympy/sympy/pull/11111">nlinsolve</a></strong></p>
<p><strong>How it is better than old solver _solve_system :</strong></p>
<ul>
<li><strong>Positive dimensional system solver :</strong> <code class="language-plaintext highlighter-rouge">nlinsolve</code> can return solution for positive dimensional system.</li>
</ul>
<p><strong>How :</strong> After reading articles on positive dimensional system and analyzing elimination method. I found that if we know Groebner Basis of the positive dimensional system (calling it as basis) then we can start solving equation(having least number of variable first in the basis) using <code class="language-plaintext highlighter-rouge">solveset</code> and substituting that solved solutions into other equation (of basis)to get solution in terms of minimum variables.
Here the important thing is how we are substituting the known values and in which equations.</p>
<ul>
<li><strong>Complex solution in general form :</strong> <code class="language-plaintext highlighter-rouge">nlinsolve</code> can return solution in general form .</li>
</ul>
<p><strong>How :</strong> If all the equations are not <a href="http://www.mathwarehouse.com/algebra/polynomial/polynomial-equation.php">polynomial equations</a> means after solving Polynomial equations using <code class="language-plaintext highlighter-rouge">solve_poly_system</code> go to substitution method (defined in solveset) with this solution and solve for unsolved variables. In between to solve for particular variable <code class="language-plaintext highlighter-rouge">solveset</code> is used. When it find real solution then further steps will be using this real solution. If no real solution then it go for complex solution if it is found then extract the expression from the <code class="language-plaintext highlighter-rouge">imageset</code> and use it for further substitution. When solution is valid then add this general solution (solution in imageset) in the final result.</p>
<ul>
<li><strong>Complements will be added if any :</strong> <code class="language-plaintext highlighter-rouge">nlinsolve</code> maintains <code class="language-plaintext highlighter-rouge">dict</code> to add complements for variables if any.</li>
</ul>
<p><strong>How :</strong> When there is infinite solution and <code class="language-plaintext highlighter-rouge">solveset</code> found complements during substitution method.
For example : solution = <code class="language-plaintext highlighter-rouge">{a : 1/d, b : -d, c : -1/d, d : d}</code> then in complements <code class="language-plaintext highlighter-rouge">dict {d : 0}</code> will be maintained and the final solution <code class="language-plaintext highlighter-rouge">{a : 1/d, b : -d, c : -1/d, d : {d} \ {0}}</code> is returned.</p>
<ul>
<li><strong>Unknowingly added features :</strong> <code class="language-plaintext highlighter-rouge">nlinsolve</code> can return solution for positive dimensional linear system and simple linear system. But I recommend to use it for linear systems, since <code class="language-plaintext highlighter-rouge">linsolve</code> can do far better than <code class="language-plaintext highlighter-rouge">nlinsolve</code> for linear system.</li>
</ul>
<p><strong>How :</strong> Since it is using Groebner basis (inside <code class="language-plaintext highlighter-rouge">solve_poly_system</code>) of the system for polynomial equations. If it fails for some equation then basis is used in substitution method. So it can solve positive dimensional linear system.</p>
<hr />
<h3 id="trigonometric-inequality-solution-in-general-form">Trigonometric inequality solution in General form</h3>
<p>Currently <code class="language-plaintext highlighter-rouge">solveset</code> returns solution for trigonometric inequalities in the range of 2*pi. Solveset is designed to return all the solution. So need improvement in inequality solver.</p>
<p>From current master branch <code class="language-plaintext highlighter-rouge">of SymPy</code>:
Extended answer should be :<code class="language-plaintext highlighter-rouge"> 1/6 *(12*π*n - 7*π) < x < 1/6 (12*π*n + π), n ∈ Z</code></p>
<p><strong>Idea:</strong>
Solveset uses <code class="language-plaintext highlighter-rouge">solve_univariate_inequality</code> to solve univariate inequalities.</p>
<ul>
<li>
<p>It uses <code class="language-plaintext highlighter-rouge">solve</code> to get the singularities and solution for the expression = 0. So if we want to get solution in general form then need to replace this old solver with <code class="language-plaintext highlighter-rouge">Solveset</code>.</p>
</li>
<li>
<p>To solve a trig inequality, transform it into one or many trig inequalities. Solving trig inequalities finally results in solving basic trig inequalities.</p>
</li>
<li>
<p>Step 1. Transform the given trig inequality into standard form <code class="language-plaintext highlighter-rouge">R(x) > 0 (or < 0)</code>.
Example. The inequality <code class="language-plaintext highlighter-rouge">(cos 2x < 2 + 3sin x)</code> will be transformed into standard form:
<code class="language-plaintext highlighter-rouge">R(x) = cos 2x – 3sin x - 2 < 0</code></p>
</li>
</ul>
<p>Step 2. Find the common period . The common period must be the least multiple of the periods of all trig functions presented in the inequality. The complete solution set must, at least, cover one whole common period.
Example. The trig inequality <code class="language-plaintext highlighter-rouge">R(x) = cos 2x – 3sin x - 2 < 0</code> has <code class="language-plaintext highlighter-rouge">2π</code> as common period
Example. The trig inequality <code class="language-plaintext highlighter-rouge">R(x) = sin x – cos x/2 - 0.5 > 0</code> has <code class="language-plaintext highlighter-rouge">4π</code> as common period.</p>
<p>Step 3. Solve the trig equation <code class="language-plaintext highlighter-rouge">R(x) = 0</code> If R(x) contains only one trig function, solve it as a basic trig equation.
If<code class="language-plaintext highlighter-rouge"> R(x)</code> contains 2 or more trig functions, there are 2 methods, described below, to solve it.</p>
<p>a. METHOD 1. Transform <code class="language-plaintext highlighter-rouge">R(x)</code> into a product of many basic trig equations. Next, solve these basic trig equations separately to get all values of x that will be used in Step 4.
Example 8. Solve: <code class="language-plaintext highlighter-rouge">cos x + cos 2x > - cos 3x (0 < x < 2π)</code>
Solution. Step 1. Standard form: <code class="language-plaintext highlighter-rouge">R(x) = cos x + cos 2x + cos 3x > 0</code>
Step 2. Common period: <code class="language-plaintext highlighter-rouge">2π</code>
Step 3. Solve<code class="language-plaintext highlighter-rouge"> R(x) = 0</code>. Transform it into a product using Sum to Product Identity:
<code class="language-plaintext highlighter-rouge">R(x) = cos x + cos 2x + cos 3x = cos 2x (1 + 2cos x) = 0.</code></p>
<p>b. METHOD 2. This method transforms a trig inequality with 2 or more trig functions into a trig inequality having only one trig function (called t) as variable. Next, solve for t from this trig equation, as a basic trig equation. Then, solve for x from these values of t.
chosen as function variable are: <code class="language-plaintext highlighter-rouge">sin x = t; cos x = t; cos 2x = t; tan x = t; and tan x/2 = t</code>.
Example 10. Solve: <code class="language-plaintext highlighter-rouge">3sin² x = sin 2x + cos² x</code>
Solution. Divide both sides by <code class="language-plaintext highlighter-rouge">cos² x (cos x ≠ 0; x ≠ π/2)</code>. Let <code class="language-plaintext highlighter-rouge">tan x = t</code>.
<code class="language-plaintext highlighter-rouge">3 t² – 2t - 1 = 0</code>. This is a quadratic equation having 2 real roots: 1 and -1/3
Next, solve the 2 basic trig equations: <code class="language-plaintext highlighter-rouge">tan x = t = 1</code>, and <code class="language-plaintext highlighter-rouge">tan x = t = -1/3</code>
Use <code class="language-plaintext highlighter-rouge">decompogen</code> defined in <code class="language-plaintext highlighter-rouge">sympy/solvers</code></p>
<p>Step 4. Solve the trig inequality <code class="language-plaintext highlighter-rouge">R(x) < 0 (or > 0)</code>. Then express the solution set in the form of intervals. Based on the found values of <code class="language-plaintext highlighter-rouge">x</code> from Step 3, solve, algebraically, the trig inequality<code class="language-plaintext highlighter-rouge"> R(x) < 0 (or > 0)</code> by separately solving each basic trig inequality <code class="language-plaintext highlighter-rouge">f(x), g(x) .</code>., and then by setting up a sign table (sign chart). In final solution extend this with n*(common period).</p>
<h3 id="domain-and-range">Domain and Range</h3>
<p><strong>Function’domain :</strong></p>
<p>If a function does not model data or verbal conditions, its domain is the largest set of real numbers for which the value of is a real number. Exclude from a function’s domain real numbers that cause division by zero and real numbers that result in an even root of a negative number.</p>
<p><strong>Range:</strong></p>
<p>Values, the function can give.</p>
<ul>
<li>. The domain of is the set of all real numbers that are common to the domain of and the domain of Thus, we must find the domains of and before finding their intersection.</li>
</ul>
<p><strong>The Composition of Functions</strong></p>
<p>The composition of the function with is denoted by and is defined by the equation
<code class="language-plaintext highlighter-rouge">(f*g)(x) = f(g(x))</code><code class="language-plaintext highlighter-rouge">
The domain of the composite function is the set of all such that
1\. </code>x<code class="language-plaintext highlighter-rouge"> is in the domain of </code>g<code class="language-plaintext highlighter-rouge"> and
2\. </code>g(x)<code class="language-plaintext highlighter-rouge"> is in the domain of </code>f`.</p>
<p>The following values must be excluded from the input
• If <code class="language-plaintext highlighter-rouge">x</code> is not in the domain of g, it must not be in the domain of <code class="language-plaintext highlighter-rouge">f*g</code>
• Any <code class="language-plaintext highlighter-rouge">x</code> for which <code class="language-plaintext highlighter-rouge">g(x)</code> is not in the domain of <code class="language-plaintext highlighter-rouge">f</code>, must not be in the domain of <code class="language-plaintext highlighter-rouge">f*g</code>.</p>
<p><strong>Problems :</strong></p>
<ul>
<li>
<p>Finding common period of the complicated expressions. We can use LCM of</p>
</li>
<li>
<p>finding domain/range.</p>
</li>
</ul>
<p><strong>Reference</strong></p>
<ul>
<li><a href="http://miamibeachhigh.schoolwires.com/cms/lib07/FL01000126/Centricity/Domain/261/Ch1_Section7.pdf">Domain and range , function decomposition</a></li>
<li><a href="http://web.fscj.edu/Lyn.Noble/mac1105/Wrksht/DomainRange.pdf">Squre root domain and range</a></li>
<li><a href="http://web.fscj.edu/Lyn.Noble/mac1105/Wrksht/DomainRange.pdf">Domain range</a></li>
<li><a href="http://api.ning.com/files/n7ZUxQJY0YvfdRhhyH9DefMJ7cW08TWE8*egZvne-ZkVLkiWu1DzglvTH-7oM7zryLg7OSdRWmrEpVOlUHVHLLWtWkPhF11w/SOLVINGTRIGONOMETRICINEQUALITIESMETHODSANDSTEPS.pdf">Inequality Trig Function</a></li>
<li><a href="http://www.shsu.edu/kws006/Precalculus/4.9_Pythagorean_Identities_files/S%26Z%2010.7.pdf">Trig Function , domain extended intervals</a></li>
</ul>
<h3 id="nlinsolve-xfail-try">nlinsolve XFAIL try</h3>
<ul>
<li>solveset_real have some issues with expression having sqrt. It is returning some answer instead of <code class="language-plaintext highlighter-rouge">S.EmptySet</code>.</li>
</ul>
<p><code class="language-plaintext highlighter-rouge">solveset(20*sqrt(y**2 + (sqrt(-(y - 10)*(y + 10)) + 10)**2) - 60, y, S.Reals)</code>
this is returning</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>⎧-3⋅√391 3⋅√391⎫
⎨────────, ──────⎬
⎩ 20 20 ⎭
</code></pre></div></div>
<p>But original answer is <code class="language-plaintext highlighter-rouge">emptyset</code>.</p>
<ul>
<li>Another thing is we are converting expressions into polynomial using <code class="language-plaintext highlighter-rouge">.as_poly(*symbols, extension=True)</code> so need to remove extra solution. code is added for this and works fine.</li>
</ul>
<p><strong>Issues :</strong></p>
<p>Meanwhile I found some issues.</p>
<ul>
<li>
<p><a href="https://github.com/sympy/sympy/issues/11184">issues/11184</a> - Expressions having nested <code class="language-plaintext highlighter-rouge">sqrt</code> returns some solution
, but original solution is EmptySet.</p>
</li>
<li>
<p><a href="https://github.com/sympy/sympy/issues/11175">issues/11175</a> - bug in <code class="language-plaintext highlighter-rouge">is_zero_dimensional</code>.</p>
</li>
</ul>
GSoC Application2016-04-24T00:00:00+00:00https://shekharrajak.github.io/blog/GSoC-2016/GSoC-Project<h3 id="getting-up-for-project">Getting up for Project</h3>
<p>So it was around last week of Jan 2016. I had 2 personal chat with <a href="https://github.com/aktech">Amit</a> (GSoC 2015) first one before starting the contribution and second was this time. I followed his advice, when I didn’t know how to contribute to <code class="language-plaintext highlighter-rouge">SymPy</code> .</p>
<p>Now after the good contribution I asked some questions about Application process and Project for <code class="language-plaintext highlighter-rouge">SymPy</code>. According to his advice I started working on choosing the project as early as possible and discussing the ideas with senior developers.
As I was interested and found some bugs on <code class="language-plaintext highlighter-rouge">Solveset</code>, Solvers module. So I decided to work on <code class="language-plaintext highlighter-rouge">Solveset</code> module and improve this.</p>
<h3 id="sympysolvers">sympy/solvers</h3>
<p><strong>Abstract of my application</strong>
“ Solvers module is mostly used module, so it is very important that Solver works perfectly and give all solution. Harsh Gupta( GSoC 2014) and Amit Kumar (GSoC 2015) have worked on Solveset submodule. Solveset returns a set object and a set object takes care of all types of output. But to make Solveset fully functional, need to implement Non-linear multivariate Equation and System of multivariate Equation solver, System of Inequality solvers, Transcendental Equation solver and have to improve solve_trig, <code class="language-plaintext highlighter-rouge">_invert methods</code> . So in this summer I want to implement these remaining things, to complete Solveset.”</p>
<h3 id="discussions">Discussions</h3>
<p>I started discussion on <code class="language-plaintext highlighter-rouge">Solveset</code> and Solver module in <code class="language-plaintext highlighter-rouge">SymPy</code>. Thanks to all the active members in gitter chat room and mailing list, they helped me a lot to improve my ideas. Special thanks to <a href="https://github.com/asmeurer">Aaron Meurer</a> , <a href="https://github.com/hargup">Harsh Gupta</a> , <a href="https://github.com/aktech">Amit Kumar</a> , <a href="https://github.com/jksuom">Kalevi Suominen</a> ,<a href="https://github.com/smichr">Christopher Smith</a> and all others who helped me in gitter chat.</p>
<p>Threads:</p>
<ul>
<li><a href="https://groups.google.com/forum/#!topic/sympy/XhgBx2bVFaA">mailing list</a></li>
<li><a href="https://github.com/sympy/sympy/wiki/Solveset-and-Solver-Discussion">wiki/Solveset-and-Solver-Discussion</a></li>
</ul>
<p>You can find my application here :
<a href="https://github.com/sympy/sympy/wiki/GSoC-2016-Shekhar-Prasad-Rajak-Application:-Solvers:-Completing-Solveset">Wiki page</a></p>
<h3 id="and-this-is-the-happiest-moment-of-this-journey">And this is the happiest moment of this journey</h3>
<div class="result"> <img src="/images/img/result.png" /> </div>
<hr />
Contribution before GSoC2016-04-24T00:00:00+00:00https://shekharrajak.github.io/blog/GSoC-2016/Contribution-before-GSoC<h3 id="sympy-">SymPy :</h3>
<p><a href="http://www.sympy.org/en/index.html">SymPy</a> is a Python library for symbolic mathematics. It aims to become a full-featured Computer Algebra System (CAS) while keeping the code as simple as possible in order to be comprehensible and easily extensible.</p>
<p>It was month of August 2015, when I was learning new libraries in python and somehow reached at Amit’s blog about <code class="language-plaintext highlighter-rouge">SymPy</code> and his contribution to <code class="language-plaintext highlighter-rouge">SymPy</code>. I am very much interested in Mathematics so it was pretty amazing to see how <code class="language-plaintext highlighter-rouge">SymPy</code> is solving equations and doing mathematics using python.</p>
<h3 id="joined-gitter-chat-room-">Joined gitter chat room :</h3>
<p>The time I joined <code class="language-plaintext highlighter-rouge">SymPy</code> gitter chat room, I found many active contributors/developers replying the questions and discussing ideas. I didn’t know how <code class="language-plaintext highlighter-rouge">SymPy</code> works and didn’t work in Python previously. I started reading Documentations and Wiki Pages present in <code class="language-plaintext highlighter-rouge">SymPy</code> repository in github. I watched the videos and tried some problems myself, but doing only these things would not help.
I started participating in gitter chat discussion, give answer whatever I knew and questioned whenever I had doubts. These became my everyday work.
Slowly I understood the modules and code organization of <code class="language-plaintext highlighter-rouge">SymPy</code>.But there were still something I didn’t know, that’s why I was not able to send any patches/Pull Request in github <code class="language-plaintext highlighter-rouge">SymPy</code> repo till Nov-Dec 2015.</p>
<h3 id="started-sending-pull-request">Started sending Pull Request</h3>
<p>I had been active in <code class="language-plaintext highlighter-rouge">SymPy</code> gitter chat room for around 3 month but still struggling to fix a bug. I tried most of the easy bugs but didn’t understand where is the problem in the code.</p>
<p>So I started fixing Documentation bugs and formating. But I wanted to fix bugs related to code.</p>
<p>One day someone was discussing about debugger tool. He was also getting difficulty in understanding the code. I read some articles and started using PuDB.</p>
<p>PuDB works very well and easy to work with it. I restarted exploring the easy bugs and using debugger it was pretty easy to detect the line where the problem was.</p>
<h3 id="contribution-started-now">Contribution started now</h3>
<p>Okay, so after learning these many thing I was very much interested about <code class="language-plaintext highlighter-rouge">SymPy</code>, because I almost understood how the Open Source Developers work. I enjoyed my days fixing/trying to fix bugs in SymPy. All the day I think about the bug and try to solve them. I enjoyed a lot in this period. It was around Dec 2015 ,Jan 2016.</p>
<h3 id="mergedopenclosed-contributions-in-chronological-order-before-gsoc-2016">Merged/Open/Closed contributions in chronological order before GSoC 2016</h3>
<p><a href="https://github.com/sympy/sympy/pull/10215">#10215</a> : some Usage/examples for <code class="language-plaintext highlighter-rouge">srepr</code> and added some lines to show how <code class="language-plaintext highlighter-rouge">repr</code> different from <code class="language-plaintext highlighter-rouge">srepr</code> printing.</p>
<p><a href="https://github.com/sympy/sympy/pull/10311">#10311</a> : Projects using <code class="language-plaintext highlighter-rouge">SymPy</code> in docs.</p>
<p><a href="https://github.com/sympy/sympy/pull/10312">#10312</a> : <a href="https://github.com/sympy/sympy/pull/10215">#10215</a> extended and added more usage/examples for <code class="language-plaintext highlighter-rouge">srepr</code>.</p>
<p><a href="https://github.com/sympy/sympy/pull/10314/">#10314</a> : Dot printing examples and usage.</p>
<p><a href="https://github.com/sympy/sympy/pull/10319/">#10319</a> : Addition of namespaces, namespaces_default, translation for <code class="language-plaintext highlighter-rouge">SciPy</code> in <code class="language-plaintext highlighter-rouge">lambdify.py</code>.</p>
<p><a href="https://github.com/sympy/sympy/pull/10330">#10330</a> : removal of <code class="language-plaintext highlighter-rouge">guide.rst</code>.</p>
<p><a href="https://github.com/sympy/sympy/pull/10333">#10333</a> : better comment at <code class="language-plaintext highlighter-rouge">SymPy/interactive/tests/test_print_builtin_option</code>.</p>
<p><a href="https://github.com/sympy/sympy/pull/10370">#10370</a> : <code class="language-plaintext highlighter-rouge">math.fabs()</code> converts its argument to float if it can (if it can’t, it throws an exception). It then takes the absolute value, and returns the result as a float. Fixes <a href="https://github.com/sympy/sympy/issues/9474">#9474</a></p>
<p><a href="https://github.com/sympy/sympy/pull/10385">#10385</a> :<code class="language-plaintext highlighter-rouge">SymPy</code> treated symbols having <code class="language-plaintext highlighter-rouge">zero = True</code> assumption as non-negative & non-positive & real. But <code class="language-plaintext highlighter-rouge">SymPy</code> don’t know; that is 0.It was not defined anywhere in <code class="language-plaintext highlighter-rouge">SymPy</code>. Previously line <code class="language-plaintext highlighter-rouge">x = Symbol('x' ,zero=True)</code>, <code class="language-plaintext highlighter-rouge">x</code> was treated as symbol only, during execution and didn’t took its value.
Fixes <a href="https://github.com/sympy/sympy/issues/8167">#8167</a></p>
<p><a href="https://github.com/sympy/sympy/pull/10407">#10407</a> : In <code class="language-plaintext highlighter-rouge">NumPy</code><code class="language-plaintext highlighter-rouge">amin</code> is defined as <code class="language-plaintext highlighter-rouge">numpy.amin(a, axis=None, out=None, keepdims=False)</code> So if we use <code class="language-plaintext highlighter-rouge">Min</code> and <code class="language-plaintext highlighter-rouge">Numpy</code> is installed in the system. Then <code class="language-plaintext highlighter-rouge">SymPy</code> use <code class="language-plaintext highlighter-rouge">NumPy</code> for<code class="language-plaintext highlighter-rouge"> lambdify</code> method. So when we pass <code class="language-plaintext highlighter-rouge">l(1, 2, 3)</code> Then it takes ` a =1 ,axis=2,out=3<code class="language-plaintext highlighter-rouge"> where a is list of numbers for which we want minimum. </code>SymPy<code class="language-plaintext highlighter-rouge"> mapping with </code>NumPy<code class="language-plaintext highlighter-rouge"> </code>amin` is not correct.</p>
<p><a href="https://github.com/sympy/sympy/pull/10444">#10444</a> : Integration of summation type expressions.
Fixes <a href="https://github.com/sympy/sympy/issues/7827">#7827</a></p>
<p><a href="https://github.com/sympy/sympy/pull/10460">#10460</a> : <code class="language-plaintext highlighter-rouge">Solveset</code> is now able to solve <code class="language-plaintext highlighter-rouge">XFAIL</code> <code class="language-plaintext highlighter-rouge">test_issue_failing_pow</code>. <code class="language-plaintext highlighter-rouge">assert solveset(x**(S(3)/2) + 4, x, S.Reals) == S.EmptySet</code>.</p>
<p><a href="https://github.com/sympy/sympy/pull/10482">#10482</a> : This is able to give solutions in reduced/simplified and known easy form in many cases. Fixes <a href="https://github.com/sympy/sympy/issues/9834">#9824</a> , <a href="https://github.com/sympy/sympy/issues/10426">#10426</a></p>
<p><a href="https://github.com/sympy/sympy/pull/10494">#10494</a> : Few lines added in docs for <code class="language-plaintext highlighter-rouge">Singleton</code> <code class="language-plaintext highlighter-rouge">S</code>.</p>
<p><a href="https://github.com/sympy/sympy/pull/10502">#10502</a> : Needed a list which stores about if particular <code class="language-plaintext highlighter-rouge">cond</code> solution is added or not. Otherwise it may not add result , like previously if <code class="language-plaintext highlighter-rouge">cond</code> solution is not added but still [if condition] true (for this particular issue’s testcase) and then it will mark <code class="language-plaintext highlighter-rouge">matches_other_piece = True</code> so this solution couldn’t be added into result.
Fixes <a href="https://github.com/sympy/sympy/issues/10122">#10122</a></p>
<p><a href="https://github.com/sympy/sympy/pull/10542">#10542</a> : Need to pass if integral have symbolic upper and lower bound. Fixes : <a href="https://github.com/sympy/sympy/issues/10434">#10434</a></p>
<p><a href="https://github.com/sympy/sympy/pull/10547">#10547</a> : Problem was <code class="language-plaintext highlighter-rouge">Solveset</code> assuming that condition symbol is same as symbol for which it is finding solution. so there was problem when condition doesn’t contains the solution symbol. Now is storing the symbols of condition and defining the interval accordingly for all the symbols.
Fixes : <a href="https://github.com/sympy/sympy/issues/10534">#10534</a></p>
<p><a href="https://github.com/sympy/sympy/pull/10550">#10550</a> : solveset_real need to check symbol in piecewise-condition.Expression with multiple abs ,having Piecewise solution as 0.
Fixes : <a href="https://github.com/sympy/sympy/issues/10122">#10122</a> and <a href="https://github.com/sympy/sympy/issues/10534">#10534</a></p>
<p><a href="https://github.com/sympy/sympy/pull/10552">#10552</a> :<code class="language-plaintext highlighter-rouge">Solveset</code> hyperbolic Functions.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># complex solution
>>>> solveset(sinh(x))
{n⋅ⅈ⋅π | n∊ ℤ}
# Real solution
>>>> solveset(sinh(x), x, S.Reals)
{0}
</code></pre></div></div>
<p>Fixes <a href="https://github.com/sympy/sympy/issues/9531">#9531</a> , <a href="https://github.com/sympy/sympy/issues/9824">#9824</a> , <a href="https://github.com/sympy/sympy/issues/10426">#10426</a>, <a href="https://github.com/sympy/sympy/issues/7914">#7914</a> and <a href="https://github.com/sympy/sympy/issues/9606">#9606</a></p>
<p><a href="https://github.com/sympy/sympy/pull/10575">#10575</a> : <code class="language-plaintext highlighter-rouge">linsolve</code> now able to solve unsimplified equations having constant variable. Fixes : <a href="https://github.com/sympy/sympy/issues/10568">#10568</a></p>
<p><a href="https://github.com/sympy/sympy/pull/10579">#10579</a>: modified domain range if denominator is zero. Fixes <a href="https://github.com/sympy/sympy/issues/8715">#8715</a></p>
<p><a href="https://github.com/sympy/sympy/pull/10622">#10622</a> : Decompogen checking whether function contains <code class="language-plaintext highlighter-rouge">symbol</code> or not.</p>
<p><a href="https://github.com/sympy/sympy/pull/10649">#10649</a>: replacing solver in some module.</p>
<p><a href="https://github.com/sympy/sympy/pull/10689">#10689</a>: Real solution for some <code class="language-plaintext highlighter-rouge">const**(symbol)</code> type equation.
Fixes Real solution for <a href="https://github.com/sympy/sympy/issues/10688">#10688</a></p>
<p><a href="https://github.com/sympy/sympy/pull/10713">#10713</a>: Proposing a method to get general form for list of args.</p>
<p><a href="https://github.com/sympy/sympy/pull/10733">#10733</a>: Rewriting <a href="https://github.com/sympy/sympy/pull/10552">#10552</a> and <a href="https://github.com/sympy/sympy/pull/10482">#10482</a> with extensions. Fixes <a href="https://github.com/sympy/sympy/issues/10671">#10671</a> , <a href="https://github.com/sympy/sympy/issues/7914">#7914</a> , <a href="https://github.com/sympy/sympy/issues/9531">#9531</a> , <a href="https://github.com/sympy/sympy/issues/9606">#9606</a> , <a href="https://github.com/sympy/sympy/issues/9824">#9824</a> , <a href="https://github.com/sympy/sympy/issues/10426">#10426</a> , <a href="https://github.com/sympy/sympy/issues/10217">#10217</a> and most of the XFAIL present in test_solveset.</p>
<p><a href="https://github.com/sympy/sympy/pull/10764">#10764</a>: TODO part of <a href="https://github.com/sympy/sympy/pull/10733">#10733</a> Fixes XFAIL test-cases and <a href="https://github.com/sympy/sympy/issues/7914">#7914</a></p>
<p><a href="https://github.com/sympy/sympy/pull/10898">#10898</a>: Implementing the logic of <a href="https://github.com/sympy/sympy/pull/10713">#10713</a> in solve_trigmethod insolveset. This PR is able to give simplified solution for trigonometric equation.
Example :</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>>>>print solveset(cos(x) +cos(3*x) + cos(5*x), x, S.Reals)
ImageSet(Lambda(_n, _n*pi/6),Integers())
</code></pre></div></div>
<p><a href="https://github.com/sympy/sympy/pull/10971">#10971</a> Fixes [#10864]((https://github.com/sympy/sympy/issues/10864) Old solver have ` _tsolve<code class="language-plaintext highlighter-rouge"> to solve transcendental equation, but in solveset </code>_invert<code class="language-plaintext highlighter-rouge"> method can handle some works of the </code>_tsolve` method. One of them could be:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>x =symbols('x' , positive = True)</span>
solveset(x**(y*z) - x,x,S.Reals)</span>
</code></pre></div></div>
<p><a href="https://github.com/sympy/sympy/pull/10994">#10994</a> Now solveset returns Integers solution for an equation using <code class="language-plaintext highlighter-rouge">diophantine.py</code> .</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>>>> solveset(2*x + 3*y - 5, x, S.Integers)
{(3⋅t₀ - 5, -2⋅t₀ + 5) | t₀ ∊ ℤ}
>> solveset(2*x + 3*y - 5, domain=S.Integers)
{(3⋅t₀="" -="" 5,="" -2⋅t₀="" +="" 5)="" |="" t₀="" ∊="" ℤ}
</code></pre></div></div>
<p><a href="https://github.com/sympy/sympy/pull/11008">#11008</a> Fixes <a href="https://github.com/sympy/sympy/issues/10876">#10876</a></p>
<h3 id="bugsissues-reported">Bugs/issues reported</h3>
<ul>
<li><a href="https://github.com/sympy/sympy/issues/10033">#10033</a> : Wrong answer by Inequality solver.</li>
<li><a href="https://github.com/sympy/sympy/issues/10313">#10313</a> : Need good description about Dot printing.</li>
<li><a href="https://github.com/sympy/sympy/issues/10453">#10453</a> : Integrate return wrong answer (inverse trigonometric functions).</li>
<li><a href="https://github.com/sympy/sympy/issues/10568">#10568</a> : <code class="language-plaintext highlighter-rouge">linsolve</code> Returns <code class="language-plaintext highlighter-rouge">EmptySet</code> if equation is not simplified.</li>
<li><a href="https://github.com/sympy/sympy/issues/10688">#10688</a> : Not able to solve some <code class="language-plaintext highlighter-rouge">const**(symbol)</code> type equation.</li>
<li><a href="https://github.com/sympy/sympy/issues/10864">#10864</a> : <code class="language-plaintext highlighter-rouge">solveset(x**(y*z) - x, x, S.Reals)</code><code class="language-plaintext highlighter-rouge"> returns </code>ConditionSet`.</li>
</ul>
<h3 id="getting-ready-to-choose-a-project">Getting ready to choose a Project</h3>
<p>As I am too much excited to work for <code class="language-plaintext highlighter-rouge">SymPy</code> all the time. Jan 2016 I started preparing the GSoC proposal. After these contribution the another major part was choosing a project and getting idea to improve certain module in <code class="language-plaintext highlighter-rouge">SymPy</code>.Then I started working on Project for the GSoC proposal.</p>
<p>You can read about my Project in this blog :
<a href="https://shekharrajak.github.io">GSoC 2016 Project</a></p>