August 28, 2025

16:00, Thursday, 28 August

Final Weeks I’ve been juggling college work and the final stretch of the project, so things have been busy. My mentor and I agreed that the elastic-pendulum-cone example will be the final PR for the GSoC coding period. Everything is basically done only a small change to the example is holding the PR up at the moment, and I will finish that. What’s next I’ll wrap up that small example change t...

August 17, 2025

17:00, Sunday, 17 August

Hello everyone, the GSoC is getting close to the end.

August 07, 2025

16:00, Thursday, 07 August

WrappingCone Status Me and my mentor Hwayeon, had a longer sync-up meeting this week to discuss everything in more detail. She told me to add the complete worked out math of the cable car model and send it publicly on github so that she could view it. I finally learnt some latex in order to get the math to render nicely and not have to rely on any external sources. I worked out all of the math...

July 30, 2025

16:00, Wednesday, 30 July

After a brief slowdown due to the start of college and on-campus internship drives (in which I secured an internship with DE Shaw & Co for Summer of 2026!), progress on SymPy’s WrappingCone is back on track. WrappingCone Status The core of the WrappingCone class is complete except for the geodesic_end_vectors method. All other methods, have been implemented and tested. Symbolic testing fo...

July 26, 2025

12:10, Saturday, 26 July

Hello everyone, a month has passed since the last update.

July 12, 2025

16:00, Saturday, 12 July

Highlights Both PRs finally merged in a single day Setup a new direction to continue Merging the PRs After some internal discussion between my immediate mentor Hwayeon and Jason, the two PRs were finally deemed to be worthy of being in the master branch of SymPy. And they were merged. I was so happy to finally see my examples and code in the dev documentation, informing new users of t...

July 06, 2025

16:00, Sunday, 06 July

Highlights Polished two open pull requests and added new unit tests. Updated point_on_surface to return a symbolic expression instead of a boolean, per Jason Moore’s suggestion. Refactored the WrappingSphere example: improved explanations, reorganized code, and added a hands-on use-case. Pull Request: point_on_surface Enhancement Symbolic Output: Changed the method signature to ...

June 23, 2025

10:30, Monday, 23 June

Hello everyone, PR #28115(Open) is closed to being merged.

June 13, 2025

17:05, Friday, 13 June

Hello everyone, I’m in my second week of GSoC and I’ve almost finished writing the transfer function classes #28115(Open).

June 02, 2025

09:55, Monday, 02 June

Hello everyone, the Community Bonding period has concluded, and I want to share my progress with SymPy.

June 01, 2025

00:00, Sunday, 01 June

This phase I began extensively deep diving into exploring SymPy’s assumptions system, researching and understanding implementations of SAT solvers and SAT handlers.

May 13, 2025

00:00, Tuesday, 13 May

Hello everyone, welcome to my blog. I will be sharing all major updates and progress on my GSoC project through this blog. Stay tuned.

May 08, 2025

14:30, Thursday, 08 May

April 26, 2024

00:00, Friday, 26 April

LLVM Intermediate Representation is an a low-level programming language (more lower than C++, Python etc.).

October 03, 2022

10:00, Monday, 03 October

This will be my last post with a full overview of all my contributions during GSoC 2022.

September 16, 2022

16:00, Friday, 16 September

Here is a short overview of the PRs merged and the ones opened: Merged PR [#24028] implementing a generic coordinate generation helper, which is ready for merging. merged PR [#24037] implementing the CylindricalJoint, which will be ready for review as soon as [#24028] is merged. Opened PR [#24046] implementing the PlanarJoint, which is almost ready for merging. Currently a decision should be made what inputs for defining the rotation_axis and planar_vectors will be supported Opened draft PR [#24053] implementing the SphericalJoint, which will be ready for review as soon as [#24046] is merged.

September 09, 2022

16:00, Friday, 09 September

Decided to make my posts on Friday, so it is more of a reflection of past week (in this case a little more). Besides that I’m also gonna try to keep using the format of my midterm overview. So what has happened: Merged PR [#23981] adding an optional frame argument to RigidBody.parallel_axis and implementing Body.parallel_axis. Merged PR [#23982] changing Body to always have an inertia, also when representing a Particle. This will partially solve issue [#23269]. Merged PR [#23920] changing the definition of a Joint to use intermediate frames. Something that was specifically added last week was the support for supplying an axis with which the interframe should align its X axis. Something which surprisingly gives the exact same results as parent_axis and child_axis did (means that those rotations were actually chosen more logical than I thought). Closed issue [#23913] on the problem that the use of temporary relationships between ReferenceFrames in the Joint class can lead to deleting correct relations. Was also fixed in [#23920]. Raised issue [#1929] in the symengine on the problem of stackability of null Matrices. Raised and closed issue [#24005] on the problem that a CI slow test 2 failed due to a timeout. However due to irreproducibility this issue was also closed. Opened PR [#24028] implementing a generic coordinate generation helper, which is ready for merging. Opened draft PR [#24037] implementing the CylindricalJoint, which will be ready for review as soon as [#24028] is merged.

August 29, 2022

12:35, Monday, 29 August

It seemed good to me to make a midterm overview of what I have done. It would have been better if I would have done this a week earlier, before my midterm, but this will in the end also be helpful for the final evaluation.

06:22, Monday, 29 August

This week I finally set this PR on intermediate frames as ready to review. Besides that I have also created a PR, which adds the optional frame argument to RigidBody.parallel_axis and also implements the parallel_axis method for the Body class. As well as a PR which partially fixes the issue of KanesMethod not being compatible with Body objects, which represents a Particle. This is done by changing the inertia of a Body representing a Particle to zero. Besides that this PR also adds a central inertia setter to RigidBody. As a last thing I have been working on is the implementation of new joint types, mainly the SphericalJoint. However I have not yet published a PR for this, since my implementation is currently dependent on the PR on intermediate frames.

August 22, 2022

13:45, Monday, 22 August

Still working this draft PR, which is now close to ready to really get reviewed. Besides the change to the intermediate frames. This PR now also proposes to replace the parent_joint_pos and child_joint_pos arguments by parent_point and child_point, since that is way more intuitive. Besides that I’ve also opened this issue, which is about a dependency between two tests (an easy fix).

August 15, 2022

09:55, Monday, 15 August

Just before I went on vacation the documentation PRs, i.e. PR about adding a four bar linkage example and the PR explaining the joints framework using figures were merged. Also the PR, which improves the Point.acc method, was merged. However, after my holiday I heard the request of making these figures a bit smaller in filesize. So, this last week I converted them to SVGs in this already merged PR. After this I mainly did some reading up and investigating how we could introduce a Mobilizer joint as described in this paper by Seth, A., Sherman, M., Eastman, P., & Delp, S.

July 14, 2022

18:15, Thursday, 14 July

This is a short post, since I was busy this week with my last exam and preparing for my vacation next few weeks. This also means that I won’t make posts for the next few weeks. As for now I am currently focused partially on making the Body class better integrated within the mechanics, while awaiting reviews on some documentation PRs.

July 08, 2022

18:15, Friday, 08 July

This is finally the first week that I could work full time on GSoC. Started this week with reviewing a PR for the first time. Furthermore I mostly focused this week on documentation. You already saw the draft of the four bar linkage example last week. During which I ran into various other things. First of the amazing dark theme available in the SymPy dev documentation causes some images to be barely readable (raised #23706). Another thing I already new I wanted to do is that there should be a real guide on the Joints Framework. So I made a draft PR about implementing a real guide on the Joints Framework in the physics/mechanics module (checkout the image below for a quick preview). Yesterday, I presented this to my mentors and got positive feedback. We also had a discussion about consistency within the code which raised this issue. Also the planning is to have either next week or after my holiday a discussion about what we actually have within the Mechanics module and what we actually want.

June 29, 2022

18:15, Wednesday, 29 June

Hi again, this is a quick post about my schedule for this GSoC. Made after meeting my mentors for a kickoff meeting, which was great by the way. As I already mentioned a bit in my first post is there a slight change. I will still be working on the documentation these first few weeks ‘till July 14. August 8 I hope to start working on the kinematic loops for which I will have to research some other solutions for as well. At last I hope to implement add some more joints. The part which I will probably skip is adding option to define the orientation of a joint using quaternions. But overall I think it is going to be a nice fun challenge.

April 27, 2022

20:00, Wednesday, 27 April

Thank you to Ondřej Čertík, Oscar Benjamin, Travis Oliphant, and Pamela Chestek for reviewing this blog post. Any errors in the post are my own.

On April 19, 2022, for approximately 11.5 hours, the documentation website for the open source SymPy project and the corresponding GitHub repository were taken down as a result of a DMCA takedown notice submitted by WorthIT Solutions on behalf of HackerRank. In this post, I’d like to explain what the DMCA is and how it works, detail exactly what happened with this incident, and go over my views on the incident and some of the lessons we’ve learned as a result.

What is the DMCA?

The information in this section has been drawn from various sources, including:

The Digital Millennium Copyright Act (DMCA) is a US law that was passed in 1998. It has laid the groundwork for how copyright is enforced in the age of the internet. One of the DMCA provisions that is important to understand is the so-called “safe harbor” provision. The safe harbor provision, roughly speaking, makes it so that websites can avoid liability because they are simply hosting or transmitting copyrighted content on behalf of their end-users.

The safe harbor provision has been absolutely essential to the modern internet. Without it, a website like GitHub could not exist. Imagine if every time someone found their copyrighted content had been uploaded to GitHub without their permission, that they could sue GitHub for damages. If this were the case, GitHub could never operate. The way GitHub works today, it cannot possibly know if every single thing that is uploaded to it is done so legally. The safe harbor provision also makes modern social media websites like Facebook, Twitter, and YouTube possible.

However, in order for a website to have and maintain safe harbor status, it must follow certain practices as outlined by the DMCA. In particular, sites must manage the “notice-and-take-down process”. GitHub’s notice-and-take-down process is described in its DMCA takedown policy.

The notice-and-take-down process works like this: a provider (like GitHub) has a means for a copyright holder to submit a notice. In GitHub’s case, they provide an online form. This notice must include certain information, including the name and address of the submitter, identification of the copyrighted work, the material on the site that is infringing copyright, and a statement of good faith, signed under penalty of perjury, that the person submitting the notice owns the copyright and believes their rights have been infringed upon. GitHub’s form also requires the submitter to assert that they have taken fair use into consideration.

Once the notice is submitted and once the provider confirms that the above things are done, they must “expeditiously” remove public access to the content. The DMCA does not define “expeditiously”.

The owner of the accused content then has the opportunity to file a counter-notice. GitHub’s counter notice procedure is described in its guide to submitting a DMCA counter notice. This gives the person whose content has been removed recourse if they believe the original notice was invalid. A counter notice contains a statement by the user that the content was removed “as a result of mistake or misidentification”, signed under penalty of perjury. When a provider receives a counter notice, they must forward it to the original complainant, and restore the challenged material after 10-14 business days. At this point, if the complainant wishes to keep the material down, they must file a lawsuit against the alleged infringer.

By following these procedures as outlined by the DMCA, GitHub avoids liability to either party.

GitHub goes beyond what the DMCA law requires. All notices and counter notices that have ever been submitted to GitHub are published publicly in the github/dmca repository (with personal information redacted). GitHub has also historically sided with developers in high profile infringement cases, such as the youtube-dl incident in 2020 (this incident involved a takedown relating to copyright circumvention, which is a different part of the DMCA law that I haven’t discussed here because it isn’t relevant to the notice that was sent to SymPy).

It’s important to understand, however, that GitHub’s hands are tied in many ways here. If they do not follow the notice and counter notice procedures exactly as outlined in the DMCA law, they risk losing their safe harbor status with the US Copyright Office. Were this to happen, it would be completely disastrous to GitHub as a business. Without safe harbor protection, GitHub could be liable for any copyrighted content that someone uploaded to its platform.

Finally, a technical note: when someone submits a takedown notice on a single part of a GitHub repository, GitHub’s response is to take down the entire repository. This is because it is technically impossible to remove only part of a repository due to the way git works. Completely scrubbing data from git history is possible, but it’s a destructive process that’s very disruptive to developers. Instead, GitHub requires the repository owners to scrub the data themselves, if they choose to, within one business day. Otherwise, they will take the entire repository down.

What happened

Below I provide a quick timeline of what happened. Times are in Mountain Daylight Time, which is where I live.

First, for background, the SymPy documentation website https://docs.sympy.org/ is hosted on GitHub Pages and mirrors the repository https://github.com/sympy/sympy_doc. It is common for websites to be hosted on GitHub Pages because it’s completely free and easy to set up for someone who is already used to using git and GitHub. This blog itself is hosted on GitHub Pages. The sympy_doc repository only contains the pre-built HTML of SymPy’s documentation. The actual source code lives in the main SymPy repository. However, the DMCA claims were only ever made against the website, so the main SymPy source code repository was unaffected.

  • Friday, Apr 15, 4:26 PM: Admins of the sympy/sympy_doc GitHub repository (myself, Ondřej Čertík, and Oscar Benjamin) received an automated email from support@githubsupport.com informing us that a DMCA takedown notice was filed against the SymPy documentation. Specifically, the claim, which can now be found on the github/dmca repository, claimed that “Someone has illegally copied our client's technical exams questions and answers from their official website https://www.hackerrank.com/ and uploaded them on their platform without permission.” It specifically referenced the page https://docs.sympy.org/latest/modules/solvers/solvers.html. The notice was made on behalf of HackerRank by an individual from “WorthIT Solutions Pvt. Ltd.” The notice also stated “the infringing website is not willing to remove our client's work”, which came as a surprise to us since, at no point in time prior to receiving this notice had we received any communications from HackerRank or WorthIT Solutions.

    The support email stated that if we do not remove the offending content within one business day, the repository, and consequently the docs website, will be taken down.

    While it is not relevant to the legality of the situation, it is worth noting that this was on Good Friday and the upcoming Sunday, April 17, was Easter Sunday, which limited our ability to effectively respond over the weekend.

  • Friday, April 15 - Tuesday, April 19: At first, we were not sure if the support email was legitimate or if it was just convincing spam. One thing that confused us was that the support email came from a domain, githubsupport.com, which did not appear to exist. Another issue is that although GitHub’s policy was to post all DMCA claims to the github/dmca repository, this particular claim had not yet been uploaded there. We reached out to GitHub support to ask if the email was legitimate, and they responded Monday, April 18, 3:18 PM that the email was indeed a legitimate email from GitHub Trust & Safety.

    I had already reached out on Friday to NumFOCUS for assistance. NumFOCUS is a 501(c)(3) non-profit organization that represents many open source scientific projects including SymPy. However, due to the limited time frame of the notice and the fact that it occurred over a holiday weekend, NumFOCUS was not able to connect us with legal counsel until Tuesday.

  • Tuesday, April 19, 12:21 PM: We received notice from GitHub that the sympy/sympy_doc repository has been taken offline. The sympy/sympy_doc repository was replaced with a notice that the documentation was taken down by the DMCA notice with a link to the notice, which had been posted to the public github/dmca repository, and the documentation website itself started to 404. Since this was now public knowledge, we publicly announced this on the SymPy mailing list and Twitter.

    We also worked with NumFOCUS and the legal counsel to send a counter notice to GitHub, since we believed that the notice was mistaken and that the claimed infringement, the code and mathematical examples on the docs page, were likely not even copyrightable.

    Not long after the takedown occurred, someone posted it to Hacker News. The Hacker News posting eventually made its way to the front page and by the end of the day it had made its way to rank 3 on the site, where it received hundreds of upvotes and comments. The story also generated a lot of buzz on Twitter at this time.

  • Tuesday, April 19, 6:40 PM: Vivek Ravisankar, the CEO of HackerRank, posted a public apology on the Hacker News thread:

    Hello, I'm Vivek, founder/CEO of HackerRank. Our intention with this initiative is to takedown plagiarized code snippets or solutions to company assessments. This was definitely an unintended consequence. We are looking into it ASAP and also going to do an RCA to ensure this doesn't happen again.
    
    Sorry, everyone!
    
  • Tuesday, April 19, 8:26 PM: Vivek posted a followup comment on Hacker News:

    Hello again, Vivek, founder/CEO here. In the interest of moving swiftly, here are the actions we are going to take:
    (1) We have withdrawn the DMCA notice for sympy; Sent a note to senior leadership in Github to act on this quickly.
    
    (2) We have stopped the whole DMCA process for now and working on internal guidelines of what constitutes a real violation so that these kind of incidents don't happen. We are going to do this in-house
    
    (3) We are going to donate $25k to the sympy project.
    
    As a company we take a lot of pride in helping developers and it sucks to see this. I'm extremely sorry for what happened here.
    

    HackerRank did follow through with the $25k donation to SymPy.

  • Wednesday, April 20, 12:00 AM (approximately): The SymPy documentation website and the sympy/sympy_doc repository went back online.

  • Wednesday, April 20, 2022, 10:11 AM: We received an email notice from GitHub that the DMCA claim against our repository has been retracted. The retraction is made available online on the github/dmca repository.

My Views

Now that I’ve stated the facts, let me take a moment to give my own thoughts on this whole thing. My belief is that the DMCA claim that was made against the SymPy repository was completely baseless and without merit. Not only is no part of the SymPy documentation, to my knowledge, taken illegally from HackerRank or any other copyrighted source, but the claim itself was completely unspecific about which parts of the documentation were supposedly infringing. This made it impossible for us to comply even if the complaint was legitimate. In addition, it is questionable whether the supposed parts of the documentation that were taken from HackerRank, the mathematical and code examples, are even copyrightable. While this may not have been an actively targeted attack against SymPy, as a community run open source project, it served as one in practice.

We have never learned any more about which parts of the SymPy documentation were supposedly infringing on HackerRank’s copyright, and I expect we never will. Some people online have speculated that HackerRank actually took examples from the SymPy documentation, not the other way around, but I do not know if this is the case or not. It seems likely, given the large number of other takedown notices WorthIT has made to GitHub on HackerRank’s behalf, that they were using some sort of automated or semi-automated detection system, which somehow detected what it thought was infringing content on our website. I have personally never used the HackerRank platform, so I only know what sorts of things are on it from second-hand accounts.

Firstly let me say that if anyone or anything is to be blamed for this, my personal belief is that the blame should primarily lie on the DMCA law itself. While the “safe harbor” provisions of the law have been critical to the development of the modern internet, allowing social websites such as GitHub to exist without the burden of legal liability for user contributed content, other provisions are hostile to those same users, even those who are operating in a completely legal manner. The DMCA works in a “guilty until proven innocent” way, and the very operation of the takedown notice policy implicitly assumes that those making claims are not abusing the system as bad actors. It also incentivizes platforms such as GitHub to step aside and not take sides in claims, even claims such as this one, which refer to likely uncopyrightable material or are too unspecific to reasonably address even if they are legitimate.

The DMCA also has had further chilling effects due to its anti-circumvention provisions. The EFF has written extensively about these. While something as radical as abolishing copyright may be considered to be practically untenable, I believe that laws like the DMCA can be rewritten so that they still serve their intended function of protecting copyright owners and providing “safe harbor” to websites like GitHub, while also protecting the rights of those accused of infringing copyright.

With that being said, I think some blame does need to lie on HackerRank and WorthIT Solutions for abusing the DMCA system and filing claims like this. They also lied in their claim when they said “the infringing website is not willing to remove our client's work.” At no point were we contacted by HackerRank or WorthIT Solutions about any copyright infringement. If we were, we would have been happy to work with them to determine whether any content in SymPy is infringing on copyright and remove it if it was. Even if it were the case that SymPy’s documentation infringed on HackerRank’s copyright, the immediate escalation to a DMCA takedown notice, which legally forced GitHub to completely disable the entire SymPy documentation, was completely inappropriate. Even submitting a counter notice is risky, because by doing so it increases the likelihood that the complaining party will bring an infringement lawsuit. Many DMCA’d repositories do not submit a counter notice for this reason, and we were only able to do so comfortably because we were able to do so via NumFOCUS. Had HackerRank not retracted the notice, we would have had to wait for our counter notice to take effect, meaning our docs website would have remained unavailable for 10-14 days. And had they instead taken down the main SymPy repository instead of the sympy_doc repo where the docs are hosted, this would have been a major disruption for our entire development workflow.

I do want to thank Vivek for quickly retracting the notice once this came to his attention, and I hope that he will be rethinking their DMCA policies at HackerRank, and for their donation to support SymPy and NumFOCUS.

Finally, while many have blamed GitHub, I believe that for the most part, they have acted as they are effectively required to by law. It is important to understand that any similar website based in the US would have likely treated this claim in a similar way. For instance, here is GitLab’s DMCA policy, which you can see is very similar to GitHub’s. By all accounts, GitHub is an industry leader here, by posting all notices and counter notices online, which they are not required to do, and by being very open about their DMCA policies ([1], [2], [3]). With that being said, there are ways that GitHub’s processes could be improved here. The one business day that we were given to respond is actually standard in the industry, and ultimately comes from the “expeditiously” wording of the DMCA. But even so, if we were given more time than this, it would have made things much easier. It may have even been possible for us to reach out to HackerRank and resolve the situation before any actual takedown occurred. It also would be helpful if GitHub, while staying within the DMCA provisions, had a higher standard of legitimacy for takedown notices such as the one we received. As I have noted, the request we received was not nearly specific enough for us to effectively act on it, which should have been apparent to GitHub, since the only information WorthIT provided was a link to the HackerRank home page. Finally, I have two small technical requests from GitHub: first is to make githubsupport.com a real website so that support emails appear more legitimate, and second is to post DMCA notices to the DMCA repository right away rather than only after the repository is taken down, to make it clearer that the notices are in fact legitimate.

Open source communities such as SymPy are under-resourced and typically ill equipped to handle situations like these, which inherently puts them in an inferior position. This is despite the fact that open source software serves a global commons that benefits all. I have estimated that SymPy itself is used by hundreds of thousands of people, and the broader scientific Python ecosystem that it is part of is used by millions of people. Abuses of copyright law against these communities are harmful to society as a whole.

Lessons Learned

I’d like to end with a few lessons that I’ve learned from this whole process.

  1. Take DMCA takedown notices seriously. If you ever receive a DMCA takedown notice from GitHub or any other website, you need to take it seriously. The website is required by law to remove your content after they receive such a notice. You can submit a counter notice, but this increases the likelihood of being sued.
  2. NumFOCUS fiscal sponsorship is invaluable. Our NumFOCUS fiscal sponsorship was invaluable here. Thanks to NumFOCUS, we were able to immediately access high quality legal advice on how to proceed here. Had HackerRank not retracted their notice, or even, heaven forbid, decided to sue, we would have had significant assistance and support from NumFOCUS. If you are part of an open source project that doesn’t have fiscal sponsorship, I would recommend looking into NumFOCUS, or other similar organizations. And if you want to support NumFOCUS, I encourage you to do so.
  3. Make backups of your online data. While the source code of any GitHub repository is effectively backed up onto every computer that has a git clone. Other data such as issues and pull request comments are not. We were lucky that the DMCA notice was sent against our documentation repository instead of our main repository. If our main repository were taken down instead, we would have lost access to all GitHub issue and pull request history. I have been looking into effective ways to backup this data. If anyone has any suggestions here, please let me know in the comments.

I do feel that being on a site like GitHub is still preferable to something like self-hosting. If you self-host, you become responsible for a ton of things which GitHub does for you, like making sure everything stays online, handling servers, and managing spam. Also, self-hosting does not magically shield you from legal threats. If you self-host content that infringes on someone’s copyright, you are still legally liable for hosting that content.

Finally, I want to thank everyone who supported SymPy during this incident. Even if you just talked about this on social media or upvoted the Hacker News story, that helped us get this into the public eye, which led to a much faster resolution than we expected. I especially want to thank Leah Silen and Arliss Collins from NumFOCUS; Ondřej Čertík, Oscar Benjamin, and other SymPy community members; Pamela Chestek, the NumFOCUS legal counsel; and Travis Oliphant for the help they provided to us. Thank you to Thomas Dohmke, GitHub’s CEO, who we have reached out to privately, and who has promised to improve GitHub’s DMCA policies. I also want to thank Vivek Ravisankar from HackerRank for retracting the DMCA claim, and for the generous donation to SymPy.

Now that this incident is over, I’m hopeful we in the SymPy community can all go back to building software.

If you wish to donate to support SymPy, you may do so here.

July 12, 2021

11:45, Monday, 12 July

Hi there! It’s been five weeks into GSoC & I have managed to refactor remaining 3 solvers. With this, I completed all the work which I proposed for my GSoC project. Although I will be working further to make some enhancements in terms of improving speed of dsolve.

The solvers which I managed to refactor are:

  • 2nd_linear_airy: It gives solution of the Airy differential equation

in terms of Airy special functions airyai and airybi.
During refactoring the matching code was also simplified as earlier it used to match the equation and preprocess the coefficients accordingly. But now internal function named get_linear_coeffs is used to extract the coefficients and then try to match with the solver.

>>> from sympy import dsolve, Function
>>> from sympy.abc import x
>>> f = Function("f")
>>> eq = f(x).diff(x, 2) - x*f(x)
>>> dsolve(eq, hint = '2nd_linear_airy')
Eq(f(x), C1*airyai(x) + C2*airybi(x))
  • 2nd_linear_bessel: It gives solution of the Bessel differential equation

if n is integer then the solution is of the form Eq(f(x), C0 besselj(n,x) + C1 bessely(n,x)) as both the solutions are linearly independent else if n is a fraction then the solution is of the form Eq(f(x), C0 besselj(n,x) + C1 besselj(-n,x)) which can also transform into Eq(f(x), C0 besselj(n,x) + C1 bessely(n,x)).

>>> from sympy.abc import x
>>> from sympy import Symbol
>>> v = Symbol('v', positive=True)
>>> from sympy.solvers.ode import dsolve
>>> from sympy import Function
>>> f = Function('f')
>>> y = f(x)
>>> genform = x**2*y.diff(x, 2) + x*y.diff(x) + (x**2 - v**2)*y
>>> dsolve(genform)
Eq(f(x), C1*besselj(v, x) + C2*bessely(v, x))

Here is the Patch for above 2 solvers.(Merged)

  • lie_group: This hint implements the Lie group method of solving first order differential equations. The aim is to convert the given differential equation from the given coordinate system into another coordinate system where it becomes invariant under the one-parameter Lie group of translations. The converted ODE can be easily solved by quadrature.
    In sympy lie_group solver had several heuristics functions implemented which were kept in dsolve.py, So all the helper functions were moved to separate file and a wrapper class was implemented to match and return the solutions.
>>> from sympy import Function, dsolve, exp, pprint
>>> from sympy.abc import x
>>> f = Function('f')
>>> pprint(dsolve(f(x).diff(x) + 2*x*f(x) - x*exp(-x**2), f(x),
... hint='lie_group'))
       /      2\    2
       |     x |  -x
f(x) = |C1 + --|*e
       \     2 /

Here is the Patch for lie_group.

That’s all for now, looking forward for week #6.

July 03, 2021

17:10, Saturday, 03 July

Hi there! It’s been four weeks into GSoC & I have managed to refactor six more solvers. Week 3 included lot of brainstorming around the simplification of the solutions returned by the solvers.

The solvers which I managed to refactor are:

  • nth_linear_constant_coeff_homogeneous: Solves an nth order linear homogeneous differential equation with constant coefficients.This is an equation of the form :

These equations can be solved in a general manner, by taking the roots of the characteristic equation

>>> from sympy import Function, dsolve, pprint
>>> from sympy.abc import x
>>> f = Function('f')
>>> pprint(dsolve(f(x).diff(x, 4) + 2*f(x).diff(x, 3) -
... 2*f(x).diff(x, 2) - 6*f(x).diff(x) + 5*f(x), f(x),
... hint='nth_linear_constant_coeff_homogeneous'))
                    x                            -2*x
f(x) = (C1 + C2*x)*e + (C3*sin(x) + C4*cos(x))*e
  • nth_linear_constant_coeff_variation_of_parameters: Solves an nth order linear differential equation with constant coefficients using the method of variation of parameters.This method works on any differential equations of the form

This method works by assuming that the particular solution takes the form

where y_i is the ith solution to the homogeneous equation. The solution is then solved using Wronskian’s and Cramer’s Rule. The particular solution is given by

where W(x) is the Wronskian of the fundamental system (the system of n linearly independent solutions to the homogeneous equation), and W_i(x) is the Wronskian of the fundamental system with the ith column replaced with [0, 0, …., 0, P(x)].

  • nth_linear_constant_coeff_undetermined_coefficients: Solves an nth order linear differential equation with constant coefficients using the method of undetermined coefficients. This method works on differential equations of the form

where P(x) is a function that has a finite number of linearly independent derivatives.

# Generating trialset for P(x)
>>> from sympy import log, exp, Function
>>> from sympy.solvers.ode.single import NthLinearConstantCoeffUndeterminedCoefficients,SingleODEProblem
>>> from sympy.abc import x
>>> f = Function('f')
>>> eq = 9*x*exp(x) + exp(-x)
>>> obj = NthLinearConstantCoeffUndeterminedCoefficients(SingleODEProblem(eq,f(x),x))
>>> obj._undetermined_coefficients_match(eq,x)
{'test': True, 'trialset': {x*exp(x), exp(-x), exp(x)}}

Note : Both nth_linear_constant_coeff_undetermined_coefficients and nth_linear_constant_coeff_variation_of_parameters require roots of the characterstic equations so instead of inheriting nth_linear_constant_coeff_homogeneous they create an instance of it and reuse the solutions method.

Here is the Patch for above 3 solvers.(Merged)

  • nth_linear_euler_eq_homogeneous: Solves an `n`\th order linear homogeneous variable-coefficient Cauchy-Euler equidimensional ordinary differential equation. This is an equation with form

These equations can be solved in a general manner, by substituting solutions of the form f(x) = x^r , and deriving a characteristic equation for r.

>>> from sympy import Function, dsolve, pprint
>>> from sympy.abc import x
>>> f = Function('f')
>>> eq = f(x).diff(x, 2)*x**2 - 4*f(x).diff(x)*x + 6*f(x)
>>> pprint(dsolve(eq, f(x),
... hint='nth_linear_euler_eq_homogeneous'))
2
f(x) = x *(C1 + C2*x)
  • nth_linear_euler_eq_nonhomogeneous_variation_of_parameters: Solves an `n`\th order linear non homogeneous Cauchy-Euler equidimensional ordinary differential equation using variation of parameters.This is an equation with form

Rest of the procedure is same as nth_linear_constant_coeff_variation_of_parameters.

  • nth_linear_euler_eq_nonhomogenus_undetermined_coefficients: This is an equation with form

These equations can be solved in a general manner, by substituting solutions of the form f(x) = x^r and then deriving a characteristic equation for r and rest of the process is same as nth_linear_constant_coeff_undetermined_coefficients.

Here is the patch for the euler solvers.

That’s all for now, looking forward for week #5.

June 20, 2021

11:05, Sunday, 20 June

Hi there! It’s been two weeks into GSoC & I have managed to refactor two more solvers.Because of my university exams, I started this week’s work from wednesday.

This week the solvers which I managed to refactor are:

  • nth_order_reducible: For example any second order ODE of the form f’’(x) = h(f’(x), x) can be transformed into a pair of 1st order ODEs g’(x) = h(g(x), x) and f’(x) = g(x). Usually the 1st order ODE for g is easier to solve. If that gives an explicit solution for g then f is found simply by integration.
    The patch can be found here.(Merged)
  • 2nd_hypergeometric: It computes special function solutions which can be expressed using the 2F1, 1F1 or 0F1 hypergeometric functions.
    y’’ + A(x) y’ + B(x) y = 0 where `A` and `B` are rational functions.
    These kinds of differential equations have solution of non-Liouvillian form. Given linear ODE can be obtained from 2F1 given by
    (x² — x) y’’ + ((a + b + 1) x — c) y’ + b a y = 0 where {a, b, c} are arbitrary constants.
    Currently only the 2F1 case is implemented in SymPy.
    The patch can be found here. (Documentation was also added for this solver 📝)

That’s all for now, looking forward for week #3.

June 12, 2021

14:33, Saturday, 12 June

Google Summer of Code is a global program focused on bringing more student developers into open source software development. Students work with an open source organization on a 10 week programming project during their break from school.

What is SymPy?

.

SymPy 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.

I have been contributing to Sympy organisation for more than a year now. Last year, I applied for the same but couldn’t get through. But this was not the case this time.On 17th May, results were announced and I got to know that my project was selected.

https://medium.com/media/0928bd7a31ead3ca386cb9beaade863b/href

About my Project

My project is being mentored by Aaron meurer and Oscar benjamin.

The project aims at Refactoring of ODE module. Currently, the dsolve function in the ODE module is a bit messy, as whenever dsolve is called for solving an ODE, it first calls classify_ode() which tries to match each solver and after that, it again calls that particular solver for solving. If a particular solver matches the equation it should directly return the solution instead. So, sometimes the solver which returns the solution is much faster than running all the matches.

My detailed proposal for the project can be found here.

Progress of Week I and Community bonding period

Since I have been contributing to the SymPy for a good amount of time, it was easier for me to get into the community. So, in this period I discussed implementation details of the workflow with my mentors and we concluded that initially each solver should be moved to classes with generalised methods and their associations.

In community bonding period I refactored three solvers:

  • Liouville solver : It solves 2nd order Liouville differential equations.
    General form for which it works : d²y/dx² + g(y)*(dy/dx)² + h(x)*dy/dx.
    Here is my patch for the same. (Merged)
  • Separable solver : It solves 1st order differential equations.
    General form for which it works : P(y)dy/dx=Q(x).
    Here is my patch for the same. (Merged)
  • Separable Reduced solver : It solves 1st order differential equations and
    converts it into separable equation.
    General form for which it works : y′+(y/x) H((x^n) y)=0.
    Here is my patch for the same. (Merged)

During my first week of coding period , I managed to refactor four solvers:

  • 1st_homogeneous_coeff_subs_dep_div_indep : It works on homogenous ODE of the form P(x, y) + Q(x, y) dy/dx = 0 such that P and Q are homogeneous and of the same order. Here the substitution will be <dependent variable>/<independent variable>.
  • 1st_homogeneous_coeff_subs_indep_div_dep : It works on homogenous ODE of the form P(x, y) + Q(x, y) dy/dx = 0 such that P and Q are homogeneous and of the same order. Here the substitution will be <independent variable>/<dependent variable>.
  • 1st_homogeneous_coeff_best : It just calls the solution from above two methods and return the best simplified solution among them.
  • Linear_coefficients : General form of this type:
    y′+F((ax+by+c)/(dx+ey+f))=0. This can be solved by substituting
    x=x′+(e*c−b*f)/(d*b−a*e) and y=y′+(a*f−d*c)/(d*b−a*e). This substitution reduces the equation to a homogeneous differential equation.

As all four solvers were interdependent used to call each other I made a single PR for them. It can be found here. (Merged)

That’s all for now, looking forward for week #2.

June 03, 2021

03:57, Thursday, 03 June

I've ditched Disqus as the comment system on this blog. I am now using Utterances. Utterances is an open source comment system that is backed by GitHub issues. Basically, every post has a corresponding issue opened on GitHub, and the comments on the post are the comments on the issue. Utterances automatically places the comments at the bottom of the post. For example, here is the issue corresponding to this post.

I didn't like Disqus mostly because it serves ads and tracking. Even though I had opted out from as much of it as I could in the Disqus settings, it still loads tracking scripts on every page. I run uBlock Origin always, and it's a bit hypocritical if my own side has things that are blocked by it. In some cases I can't avoid it (as far as I know), like when I embed a YouTube video, but it definitely shouldn't be on every post.

Utterances is a very nice alternative. I has lots of advantages:

  • Comments are not self-hosted. GitHub hosts them. Since you need a GitHub account to comment, this should make comment spam a non-issue.
  • Comments support full Markdown.
  • Users can edit their comments.
  • I can edit and fully moderate all comments.
  • Users log in with a federated system that proves their identity.
  • Email subscription to posts.
  • No ads or tracking.
  • It's completely open source and free to use.

If you use Nikola like I do, it natively supports Utterances (a feature which I added). Otherwise, go to the Utterances and paste the script tag generated at the bottom into your blog template. Then install the Utterances app in your repo, and you are done.

Exporting Disqus Comments

Some of my old posts had Disqus comments, which I wanted to preserve somehow. Here is guide on how I did that, since it wasn't as straightforward as I would have hoped.

The first step is to export your Disqus comments. It's very difficult to actually find the place in the Disqus site where you do this, but I finally found the URL. The export takes some time to complete (for me it took about half an hour). When it finished, Disqus will email you an XML file with all your comments. Note that the file contains all comments for all sites you have ever set up with Disqus. For me, it also included all the comments on my old Wordpress blog, as well as posts for draft blog posts that I never ended up publishing. It also contained all comments that were marked as spam, so you will need to remember to filter those.

I decided that since I only have a handful of posts with Disqus comments, I would just write a script to process them all and manually print them out, which I will then manually enter in to the Utterances comment system for those posts.

I wrote a script to process the comments, which you can find here. Disqus does provides an XML schema for the XML. I used a library called xsData, which lets you take an XML scheme and generate Python dataclasses corresponding to it, which make manipulating the parsed XML much easier than the standard library xml library. The script outputs text like

========== Comments from https://asmeurer.github.io/blog/posts/what-happens-when-you-mess-with-hashing-in-python/ ==========

These are the original comments on this post that were made when this blog used the [Disqus blog system](https://www.asmeurer.com/blog/posts/switching-to-utterances-comments/).

>**Comment from bjd2385 on 2016-08-28 12:33:12+00:00:**

><p>Very interesting post. I was just looking into hash functions (I've never formally learned what the topic entails), and since I'm most familiar with Python this post explained quite a bit, especially your early mathematical points.</p>

>**Comment from Mark Lawrence on 2016-10-03 20:26:54+00:00:**

><p>At what point does Python 3 force the override of __hash__ if you've defined __eq__?  E.g when would your</p><p>AlwaysEqual class fail?</p>

>**Replies:**

>>**Comment from asmeurer on 2016-10-03 20:38:13+00:00:**

>><p>That's a good catch. I originally wrote this post in Python 2. The example does indeed fail in Python 3. More specifically, if you override __eq__, Python 3 automatically sets __hash__ to None. I'll update the post to make this more clear.</p>

>**Comment from Erick Mendonça on 2017-07-30 03:23:55+00:00:**

><p>Great article! We must really pay attention to these details when implementing custom hashes.</p>

>**Comment from Ignacio on 2017-10-07 22:31:56+00:00:**

><p>Thanks a lot for this post! Clarified a lot of concepts.</p>

which I then manually copied to each post's Utterances page on GitHub.

Feel free to adapt my script if you find yourself in a similar situation.

Utterances Comments

Feel free to use the comments on this page to play around with the commenting system.

Note that to comment, there are two options. You can log in on this page, which will let you type your comment in the box below. This requires giving the Utterances bot access to your GitHub account. Alternately, if you don't want to give a bot access, you can just go directly to the GitHub issue page and comment there. I am currently in the process of figuring out how to add some boilerplate to each page that makes this clear (see this Utterances issue). If anyone has any suggestions on how to do this, let me know. For now, I am just going to manually add a statement about this as the first comment on each post.