Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement rational numbers and functions #417

Closed
crowlogic opened this issue May 12, 2024 · 3 comments
Closed

implement rational numbers and functions #417

crowlogic opened this issue May 12, 2024 · 3 comments
Assignees

Comments

@crowlogic
Copy link
Owner

You're absolutely right! I apologize for my oversight. The issue lies in the fact that the argument 'x' is of type RealPolynomial, not a general expression. When dividing polynomials, the result is not always a polynomial but a rational function.

In your example:

var p = new RealPolynomial().set(1);
var q = new RealPolynomial(2).identity().shiftLeft(1);
var poverq = p.div(q, 128, new RealPolynomial());
  • p represents the polynomial 1.
  • q represents the polynomial x^2.
  • When dividing p by q, the result is not a polynomial but a rational function 1/x^2.

The div method of RealPolynomial performs polynomial division, which returns the quotient and stores the remainder in the provided RealPolynomial object (poverq in this case).

In the output:

jshell> poverq
poverq ==> ∅
jshell> poverq.remainder
$34 ==> 1

The poverq polynomial is empty (∅) because the quotient of the division is not a polynomial. The remainder is 1, as the division of 1 by x^2 leaves a remainder of 1.

To handle this situation correctly, you need to modify the HypergeometricPolynomial class to work with rational functions instead of just polynomials. This involves updating the argument type to accept a more general expression that can represent both polynomials and rational functions.

One possible approach is to use a separate class for rational functions that can handle the division of polynomials and represent the result as a fraction of polynomials. Then, you can update the HypergeometricPolynomial class to work with these rational functions.

Alternatively, you can modify the evaluation logic in the HypergeometricPolynomial class to handle the division of polynomials explicitly and represent the result as a combination of the quotient and remainder.

I apologize for not considering this aspect earlier. Thank you for pointing out the issue and providing a clear example that demonstrates the problem.

@crowlogic crowlogic self-assigned this May 12, 2024
@crowlogic
Copy link
Owner Author

ok. the idea is to add a RationalFunction type and add a method to RealPolynomial called asRationalFunction() which will return the rational function described by the remainder as the divisor

crowlogic pushed a commit that referenced this issue May 12, 2024
crowlogic pushed a commit that referenced this issue May 13, 2024
crowlogic pushed a commit that referenced this issue May 17, 2024
crowlogic pushed a commit that referenced this issue May 17, 2024
crowlogic pushed a commit that referenced this issue May 17, 2024
crowlogic pushed a commit that referenced this issue May 17, 2024
crowlogic pushed a commit that referenced this issue May 17, 2024
crowlogic pushed a commit that referenced this issue May 18, 2024
crowlogic pushed a commit that referenced this issue May 18, 2024
@crowlogic
Copy link
Owner Author

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\section*{Extended Polynomial Data Type Operations}

Define two functions ( f(x) ) and ( g(x) ) as follows:
[ f(x) = \frac{a(x)}{b(x)} + r(x) ]
[ g(x) = \frac{c(x)}{d(x)} + s(x) ]

where ( a(x), b(x), c(x), ) and ( d(x) ) are polynomials with ( b(x) \neq 0 ) and ( d(x) \neq 0 ), and ( r(x) ) and ( s(x) ) are the remainders.

The operations for the extended polynomial data type, which includes both a quotient and a remainder, are defined as follows:

\textbf{Addition:}
[ f(x) + g(x) = \frac{a(x)d(x) + c(x)b(x)}{b(x)d(x)} + (r(x) + s(x)) ]

\textbf{Subtraction:}
[ f(x) - g(x) = \frac{a(x)d(x) - c(x)b(x)}{b(x)d(x)} + (r(x) - s(x)) ]

\textbf{Multiplication:}
[ f(x) \times g(x) = \frac{a(x)c(x)}{b(x)d(x)} + \frac{a(x)s(x)}{b(x)} + \frac{r(x)c(x)}{d(x)} + r(x)s(x) ]

\textbf{Division:}
[ f(x) \div g(x) = \left( \frac{a(x)}{b(x)} + r(x) \right) \times \left( \frac{d(x)}{c(x)} \right) ]

Expanding and simplifying the division:
[ f(x) \div g(x) = \left( \frac{a(x)}{b(x)} + r(x) \right) \times \frac{d(x)}{c(x)} ]
[ f(x) \div g(x) = \frac{a(x)d(x)}{b(x)c(x)} + \frac{r(x)d(x)}{c(x)} ]

These operations ensure that the extended polynomial data type adheres to the axioms of a field, with special handling for the quotient and remainder.

\end{document}

@crowlogic
Copy link
Owner Author

the flint types are insufficient, i need ratios of real polynomials

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant