GSoC 2019 Proposal Brijesh Vora: Implement Solvers in Symengine - sympy/sympy GitHub Wiki

GSoC 2019 Proposal Brijesh Vora: Implement Solvers in Symengine

Personal Details

Name: Brijesh Vora

University: Indian Institute of Technology, Tirupati

Field: Computer Science and Engineering, CGPA - 8.38/10.

IRC NickName- vorabrijesh

Email: [email protected] , [email protected]

GitHub: vorabrijesh

LinkedIn: linkedin

Country: India

Timezone: IST (UTC +5:30)

Contact number: +91 9587020080

JEE Advanced Rank-3670/ 220000 students.

JEE Mains Rank-8890/1.3 million students.

For more details about myself, go to https://wiki.octave.org/User:Vorabrijesh

An Introduction

My name is Brijesh Vora. I am from Gujarat, India. I have completed my 2nd year of my computer science degree in IIT TIRUPATI.

Q. Which languages do you speak?

A. English, Hindi, Gujarati

Q. What's your overall background?

A. My major is in computer science and I am interested in maths and programming.

Q. Why do you want to participate in the Google Summer of Code? What do you hope to gain by doing so?

A. I want to contribute to open source organizations and get some experience with working them. So, GSoC seemed perfect to me. Also, If I once start contributing to open source them I will become regular contributor.

Q. Why are you choosing Sympy?

A. I love mathematics and programming so Sympy seemed perfect for me to simultaneously work on maths and programming and that to in big organisation like this. It's a dream come true.

Q. what time do you code?

A. I generally code from 8 am to 6-7 pm (IST) with 1-2 hr break in between and from monday to saturdays.

Q. Please describe the biggest project you have written code for and what you learned by doing so. Also, describe your role in that project over time.

A. I and my friend are currently developing our own assembler in c++ for the basic MIPS instruction set. It will cover some feature which is lacking in MIPS ISA like case insensitive code and much more.

Technical Skills:

Languages: C, C++, Python, JAVA, Matlab,Assembly-Mips, Javascript, SQL

Operating Systems: Windows, Linux

Tools: Git, Jupyter-Notebook, Qt, gdb, gcc,

Courses Completed(Skills) after IV semester:

  • Ethical hacking

  • Algorithms and Data Structures

  • Web Development

  • Digital Systems

  • Computer Organization

  • Theory of Computation

  • Assembly Language Programming

  • Paradigms of Programming

  • Computer programming lab

  • Maths courses:

    • Maths 1 : Functions of single variable , multivariable and Matrices [ 1 ].

    • Maths 2: ode’s and pde’s [ 2 ].

    • Numerical Analysis [ 2, 3 ].

    • Probability , Stochastic Processes and Statistics [ 2, 4 ].

Programming Experience:

C/C++ - 2 years, python,java -1 year

I have been doing competitive programming on Hackerrank and codechef for 2 years, learning Data structures and algorithms. Hackerrank-profile

I have used git and github, I know a some basics of mercurial, but not used much.

Q. What platform do you use to code? What editor do you prefer and why?

Ans. I use Sublime and Jupyter -Notebook to code simply because it is easy to use. I also know vim and little bit of nano.

Q. What is your experience with Python? What are your favorite features of Python that are lacking in most other common programming languages? What, in your opinion, is the most advanced Python language feature or standard library functionality that you have used?

Ans. I have been using python since like 1 year but I know C/C++ much better than python and do most of my coding in that. My favorite feature of python is that you don’t have to worry about lower level details of the variables or any other thing which is not the thing with C. Also the code for Python is short which is great.

Me and My Project:

Q. what excites me about this project?

Ans.Solevers in sympy is pretty good , but some some equations take long running to solve which is our concern. So, I want to implement solvers in symengine whose purpose was to increase performance gain. It’s a long task but nevertheless I will work hard to achieve this.

Q. How much time do you plan to invest in the project before, during, and after the Summer of Code? (we expect full time 40h/week during GSoC, but better make this explicit) If you plan to take any vacations over the summer, let us know about it here.

Ans. My semester is getting over from 8th may, so I will be fully devoted to the project after then. I will work for 48-50 hrs/week to make this success. Also my semester starts from 1st august but still I will deliver 30 hr/week. But I will start early so that in the end it’s not a burden for me.

Q. Please provide a schedule of how this time will be spent on sub-tasks of the project over the period of the summer. While this is only preliminary, we will use it to help monitor your progress throughout the program. Also understand that during the project you will issue weekly progress reports against that plan on your blog.

Ans.The project Timeline is given below, however weekly progress report will be made and submitted to mentors to track the progress. Communication will be done daily to know that I am going in the right direction and I am making progress.

Project Description:

This Project proposal is about implementing solvers in symengine. Sympy does the pretty good job in implementing solvers, then why it is needed? Well, Sympy solvers is implemented in python and python takes running time for solving some equations, so symengine was made to increase the performance. Similarly I want to implement the solvers in symengine to see if I could increase the performance gain.

This project will be implemented from scratch that is solvers is not implemented in symengine. And the goal is to implement as much solvers as possible.

As discussed with Ondřej Čertík, firstly I would extend sympy.core.backend to work with solvers and ensure sympy tests pass with symengine on, so that I am using symengine instead of sympy.core, but sympy solvers could still be used.

Main Tasks:

  • Solve a single equation for a single variable, in any domain either real or complex.

  • solve a single transcendental equation for a single variable in real

  • solve a system of linear equations with N variables and M equations.

  • solve a system of Nonlinear Equations with N variables and M equations

  • To be able to compute General functional decomposition of a function.

Given below functions will be implemented similar to solvers.py in C++ in Symengine.

  • recast_to_symbols

  • _ispow: It will return True if e is a pow or is exp.

  • _simple_dens

  • denoms - It will return set of all denominators that appear in eq

  • Here iterative and recursive both version of this function can be made, so both will be written and performance gain

  • would be calculated and accordingly that version will be implemented.

  • Checksol: it will check whether given input is a solution of f = 0 or not

  • Solve : This has been implemented in solve.cpp in symengine and it will be extended.

  • This is the main/imp function in which we are interested in.

  • It will solve polynomial, transcendental, piecewise combinations of the above, systems of linear and polynomial equations, systems containing relational expressions.

  • Firstly preprocessing of symbols and equations would be done and also removal of symbols in which user is not interested in. In processing equations, we have to check whether it is matrix or complex(then split into real and imaginary). And then i would try to get a solution of the equations.

  • _solve : It will return a checked solution for f in terms of one or more of the symbols. In solvers.py , they have returned list and when a linear undetermined-coefficients equation is encountered a dictionary is returned. We can make a data structure in c++ which functions like list in python and another for dict and return that.

  • _solve_system

  • Solve_linear

  • Minsolve_linear_system: Find a particular solution to a linear system.

  • Solve_undetermined_coeffs

  • solve_linear_system_LU

  • _tsolve: solves transcendental

Nsolve: Solve a nonlinear equation system numerically

Functions from solveset almost all the functions will be implemented including but not limited to

  • _solve_as_rational

  • _solve_trig

  • _solve_as_poly

  • _has_rational_power

  • _solve_radical

  • _solve_abs

  • solve_decomposition

  • _solveset

  • _solve_exponential

  • _solve_logarithm

  • _transolve

  • Solvify

  • Linsolve

  • Linear_coeffs

  • Linear_eq_to_matrix

  • substitution

As the work in sympy is going on for replacing solve with solveset, we can skip that and implement other important functions of ode’s and pde’s.

Implementing ode and pde is not going to be that easy. Only a small subset of functions will be implemented (as the time will not be sufficient) from ode and pde to make the basic equations up and running and also testing needs to be done.

Below given types of ordinary differential equations will be implemented.

  • 1st order separable differential equations.

  • 1st order differential equations whose coefficients or dx and dy are functions homogeneous of the same order.

  • 1st order exact differential equations.

  • 1st order linear differential equations.

  • 1st order Bernoulli differential equations.

  • Power series solutions for first order differential equations.

  • Lie Group method of solving first order differential equations.

  • nth order differential equation that can be solved with algebraic rearrangement and integration.

  • nth order linear homogeneous differential equation with constant coefficients.

At each stage test would written and functions would be checked if it is written properly. The main goal is to increase performance, so a performance check would be done regularly to know the progress. Also report would be made that gives performance gain.

If the time permits I would also like to implement polysys.py, bivariate.py, decompogen.py, pde.py.

Contributions to Sympy

Reviewed the PR: #15378

Reviewed the PR :#1401

closed PR: #16256

Opened a PR: #16580

Contributions to other organization:

Merged PR: #27151 in godot. ( C++ )

TIMELINE

Community Bonding Period: May 6 - 27, 2019

  • Familiarize with sympy and symengine code and discuss with mentors various difficulty in implementing solvers.

  • start the coding as early as possible.

Week 1-6 (May 27 - Jul 10):

Functions from solvers.py and solveset.py will be implemented. Also test would be written simultaneously to check accuracy and performance.

MidTerm Evaluation

Week 6-11(July 10- Aug 10):

Function from ode.py would be implemented and test would be written to check accuracy and performance gain.

Week 12:

Indentation and comments would be added for readability .

Review of the work

Optional: polysys.py, bivariate.py, decompogen.py , pde.py.

FINAL SUBMISSION

References:

  • G.B. Thomas Jr., M.D. Weir and J.R. Hass, Thomas Calculus, Pearson Education, 2009.

  • E. Kreyszig, Advanced Engineering Mathematics, 10th Ed., John Willey & Sons, 2010.

  • F B Hildebrand, Introduction to Numerical Analysis, Tata McGraw-Hill 1993.

  • N. Piskunov, Differential and Integral Calculus Vol. 1-2, Mir Publishers, 1974.

  • https://docs.sympy.org/latest/modules/solvers/solvers.html