-
Notifications
You must be signed in to change notification settings - Fork 111
Add Rational Expressions #95
base: master
Are you sure you want to change the base?
Conversation
Expressions shouldn't be broken anymore, and the parser should do its thing just fine.
TODO: Add tests for rational logic
Just removed some unnecessary commits and squashed some smaller ones together |
Expressions are no longer closed under division.
yay...
Status update: The responsibilities and role of the Rational class has changed. Instead of being implemented at the term level (inside of expressions), Rationals now sit above Expressions in the library's hierarchy. They are still used to represent division of two expressions, its just that now Rationals contain expressions v.s expressions contain terms/rationals. I made this change to avoid having expressions inside of expressions, as it not only makes a mess of object types to deal with but it also makes expressions recursive and therefore more difficult to solve when put inside equations. Expressions now function exactly the same as they did before I made any changes to the base library, so long as they do not undergo any operations with Rationals (with the exception of division*). Any time a Rational gets involved in adding, subtracting, multiplying, or dividing Expressions, the Expression mutates into a Rational. Also, Rationals can now be initialized in any way that an expression can. Variable names, Terms, Variable objects, constants, and all. A rational can be initialized with one or two expression/expression-compatible objects. If only one object is given, the rational's numerator is initialized to that object, and the denominator is initialized to one. Otherwise, the first argument is assigned to the numerator and the second is assigned to the denominator. Didn't expect to be writing a book, but I guess I've made a lot of changes 😆. Thats all for now. |
For a long time many people have reported the lack of functionality regarding the division of expressions.
See these issues:
#92
#90
#82
#76
At first I tried to make rational expressions more recursive in nature, (i.e rational expression inside of rational expression), but decided against it as those types of expressions can be easily simplified. The new feature does break some tests regarding dividing expressions, and new tests have yet to be created as well. I apologize if there are any formatting issues, I tried to clean up the diff to make it as consistient as possible. In fact, this is my first time contributing to a project. I'm open to any suggestions or comments (so long that they are constructive in nature 😁).