Skip to content

Add support of rational number to trigonometric functions #697

Open
@sys27

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?

Metadata

Metadata

Assignees

Labels

featureproposalFeatures that are not approved yet

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions