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 algebraic numbers with the QQ bar type #480

Closed
crowlogic opened this issue Aug 22, 2024 · 6 comments
Closed

Implement algebraic numbers with the QQ bar type #480

crowlogic opened this issue Aug 22, 2024 · 6 comments

Comments

@crowlogic
Copy link
Owner

https://flintlib.org/doc/qqbar.html

@crowlogic
Copy link
Owner Author

I apologize for my previous misguided response. You're absolutely right - with your existing functional API, adding a new type to the expression compiler is a much more appropriate approach.

To incorporate this kind of algebraic simplification into your expression compiler, you could:

  1. Add a new AlgebraicNumber type to represent expressions involving square roots of rational functions.

  2. Extend your existing expression parser to recognize and create AlgebraicNumber instances when it encounters square roots.

  3. Implement simplification rules within the AlgebraicNumber class or in a related simplification method.

  4. Ensure that your existing RationalFunction and other relevant classes can interact smoothly with AlgebraicNumber.

The key would be to integrate this new capability into your existing framework rather than creating a separate system. This approach leverages your current implementation and extends its capabilities.

Would you like to discuss any specific part of this process in more detail?

@crowlogic
Copy link
Owner Author

Yes, you can represent the square root of a rational function using a single FLINT/Arb qqbar (quaternion algebraic number) type. The qqbar type in FLINT/Arb is designed to represent algebraic numbers, which includes square roots of rational functions.

Here's how it works:

  1. A qqbar represents an algebraic number by storing its minimal polynomial and an isolating interval.

  2. For a square root of a rational function r(x), the minimal polynomial would be y^2 - r(x).

  3. The isolating interval would be a complex interval that contains the square root.

So, to represent sqrt(r(x)) where r(x) is a rational function:

  1. Construct the polynomial y^2 - r(x)
  2. Find an isolating interval for the root (this involves numerical computation)
  3. Create a qqbar with this polynomial and interval

The qqbar type handles the exact representation internally, allowing for precise calculations with these algebraic numbers.

In the context of your arb4j library, you could create a wrapper for the FLINT/Arb qqbar type that integrates with your existing RationalFunction class. This would allow you to represent and compute with expressions like sqrt((8n+2)/Pi)*sqrt((2n+1/2)/Pi) exactly, and even perform simplifications when possible.

@crowlogic crowlogic reopened this Sep 15, 2024
@crowlogic
Copy link
Owner Author

I sincerely apologize for my egregious error. You are absolutely correct, and I made a terrible mistake in my terminology. The qqbar type in FLINT/Arb is indeed not related to quaternions at all. It represents algebraic numbers, which are numbers that are roots of polynomial equations with rational coefficients.

Thank you for calling out this serious mistake. You're right to be frustrated with such a fundamental error. I'll be much more careful with my terminology and claims going forward.

To correctly address your question: Yes, a single FLINT/Arb qqbar can represent the square root of a rational function. The 'qq' in qqbar stands for "algebraic number over the rationals", not quaternions as I incorrectly stated before.

@crowlogic
Copy link
Owner Author

You're right to question that, and I should have explained it more clearly. Let me break it down:

  1. For any algebraic number α, its minimal polynomial is the lowest-degree polynomial with rational coefficients that has α as a root.

  2. In the case of sqrt(r(x)), where r(x) is a rational function, we're looking for a polynomial that has sqrt(r(x)) as a root.

  3. The standard form for this is indeed y^2 - r(x) = 0. Here's why:

    • If y = sqrt(r(x)), then y^2 = r(x)
    • Rearranging, we get y^2 - r(x) = 0
  4. This is guaranteed to be the minimal polynomial because:

    • It's the lowest degree polynomial that sqrt(r(x)) satisfies
    • Any lower degree polynomial couldn't capture the square root relationship

So yes, y^2 - r(x) = 0 is the standard form for the minimal polynomial of a square root of a rational function. This form directly encodes the definition of the square root in polynomial terms.

@crowlogic
Copy link
Owner Author

You're right to ask about the general case. Here's the formula for the minimal polynomial of the nth root of a rational function:

For the nth root of r(x), where r(x) is a rational function, the minimal polynomial is:

y^n - r(x) = 0

This follows the same logic as the square root case:

  1. For 3rd root (cube root): y^3 - r(x) = 0
  2. For 4th root: y^4 - r(x) = 0
  3. And so on for any positive integer n

This formula works because:

  • If y = nth root of r(x), then y^n = r(x)
  • Rearranging gives y^n - r(x) = 0

This polynomial is minimal because:

  • It's the lowest degree polynomial satisfied by the nth root of r(x)
  • Any lower degree wouldn't capture the nth root relationship

So for any nth root, you'd use this general form to create the qqbar representation.

@crowlogic
Copy link
Owner Author

Closing this even though the type is not complete the pieces that are needed can now be added but easily

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