<https://github.com/binkley/kotlin-rational>
# mathematics
b
a
Rational fractions are implemented as a part of commons-numbers project: https://commons.apache.org/proper/commons-numbers/. It is quite easy to add them, but I do not know any real applications for them
1
b
@B. K. Oxley (binkley)
a
@breandan those are rational functions, not rational fractions. The difference is fractions are numbers, whereas functions are expressions. We already support polynoms and could add rational functions if needed. For this KMath expression apparatus could be quite useful.
b
I'm not sure I follow. Can you give an example of a rational function that is not a rational fraction?
a
The rational fraction is
2/3
or
176/177
. The idea is that all members of this field are rational and operations produce rational results. The rational function is something like
(x^2 + 2x +1)/(x-3)
. It is a generalization of polynomial function. Whereas polynomial is represented by a vector of numbers, the rational function is represented by two vectors. Again, rational functions form a field, but subjects are expressions, not numbers.
b
According to the Wikipedia article (it could be wrong), your third example is a rational fraction
a
It is a question of terminology, but both Commons-math and the repo you've mentioned are working with rational numbers, not rational functions. Rational numbers probably have their own applications. For example, they do not have some floating point limitations, but I do not know any specifics about that. Implementing rational functions is not complicated and could be an interesting task if there are some concrete applications for that.
b
It is my understanding @B. K. Oxley (binkley)’s implementation supports continued fractions and could be extended to support other quotient fields