Skip to content
This repository was archived by the owner on Jul 8, 2026. It is now read-only.
This repository was archived by the owner on Jul 8, 2026. It is now read-only.

Add support of rational number to trigonometric functions #697

Description

@sys27

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 RationalValue store two references to IExpression? Or should we use the Rational class directly and remove RationalValue?
  • 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 The equation solving. #39?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

featureproposalFeatures that are not approved yet

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions