xFunc
xFunc copied to clipboard
Add support of rational number to trigonometric functions
Currently, the rational number is implemented in the following way: it has two NumberValues (numerator and denominator) and can represent only "numerical" rational values, like: 1 // 3. It provides basic abilities to work with rational numbers (+, -, *, /, ^, log) while keeping higher precision compared with irrational numbers, 1 // 3 vs 0.33333....
I think it could be helpful in trigonometric/hyperbolic functions:
sin(2pi // 3) = sqrt(3) // 2
So, the user can use variables and other functions inside rational numbers. For example, instead of using 2.0943951023931953 radians in the sine function, you will be able to write 2pi // 3 and it will be evaluated into the rational number sqrt(3) // 2 instead of 0.8660254037844386.
Questions:
- How to represent the rational number? Should
RationalValuestore two references toIExpression? Or should we use theRationalclass directly and removeRationalValue? - Do we need to add symbolic evaluation, like
3 * (sqrt(2) // 2)->3*sqrt(2) // 2? - If so, when do we need to use symbolic evaluation and when numeric (
2 * (1 // 3)->2 // 3)? - Will it be helpful for #39?