stepthom / math-fun

Just testing out some fun with mathematics.
2 stars 2 forks source link

Add support for fractions #5

Closed stepthom closed 11 years ago

stepthom commented 11 years ago

Right now, the coefficient and exponent of a Term are integers. Change this so that they can be fractions, i.e., a numerator and a denominator. This will most likely involve implementing a Fraction class. Everything else should still work: printing, taking the derivative, etc.

ajslater commented 11 years ago

Two things I'm doing in my output with this one:

Collapsing fractions with numerator = 1 into integers upon printing. Storing both negative and positive numerators and denominators, but normalizing the sign as attached to only the numerator upon printing.

ajslater commented 11 years ago

By default I have fractions turned "off". That is I create fractions with a denominator of 1 and automatically collapse them as indicated in the last comment. To turn automatic generation of fractions on use the '-f' command line switch. (and combine it with the '-d' switch to make sure derivatives work).

stepthom commented 11 years ago

Closed by PR #10.