is there an algebraic function type? multiplying rational function by algebraic numbers

48 views
Skip to first unread message

Stephen Crowley

unread,
Dec 27, 2024, 6:51:27 AM12/27/24
to flint-devel

Does Flint/Arb have a type for representing algebraic functions? I'm adding support for more types to the arb4j expression compiler and need to handle multiplication between RationalFunction and AlgebraicNumber types.

I just added AlgebraicNumber support, and changed the default result type to that whenever an Integer is raised to the power of another Integer and it doesnt know that its restricted to positive numbers, it has to handle the possibility of it being negative at runtime. If at compile-time. and by compile-time, I mean dynamically compiled expression within the JVM (not C code or Java code compile-time).  Long way of saying, yes this error will go away when I add support for adding a flag to Integer enforces strict nonnegative ensuring the result of an Integer raised to the power of it would never result in a value that could not also be represented as an Integer but it seems like it is still useful and often necessary to multiply an algebraic number by a rational function and hence the question

arb.exceptions.CompilerException: Could not determine resultant type for
this=F(n)*x+G(null)*C(n)-1 where left.type=class arb.RationalFunction
and right.type=class arb.AlgebraicNumber

p.s. the RationalFunction version of the Jacobi polynomials in arb4j are working pretty well now since I've taken someones advice here who suggested taking the time to do that rather than rely on some algorithm to convert from Real numbers back to Fractions
progress.png


Stephen Crowley

unread,
Feb 1, 2025, 2:00:50 PMFeb 1
to flint-devel


Subject: Re: Type handling in algebraic operations  

My previous question about type classification was unclear. The answer lies in **arb4j**, which dynamically compiles expressions into Java bytecode, handling *any* function type (algebraic, transcendental, etc.) through runtime code generation.  

The confusion arose because I had already implemented this generality—arb4j’s compiler resolves arbitrary expressions (e.g., `sin(x)^n`, `log(z)/2`) by generating optimized evaluation code. The system abstracts type concerns entirely, whether the result is a rational function, polynomial, or transcendental expression.  

While the solution is Java-centric, it demonstrates a unified approach to exact arithmetic that avoids static type constraints. Apologies for the vague phrasing earlier—this was a case of overcomplicating an already-solved problem.  

I had just failed to realize at the time that the feature I had been remaining to implement, which is full functional support, which is generating code that implements functions that returns functions, which returns.... I haven't tried any deeper than that, but I'm sure it works fine.

—  
*arb4j*: [GitHub](https://github.com/crowlogic/arb4j) | [FLINT integration example](https://groups.google.com/g/flint-devel/c/VAEdGlAoFHM)

Citations:
[1] crowlogic/arb4j - GitHub https://github.com/crowlogic/arb4j
[2] Fast evaluation of multiple functions on multiple arguments https://discourse.julialang.org/t/fast-evaluation-of-multiple-functions-on-multiple-arguments/25040
[3] Java Expressions Library - GNU.org https://www.gnu.org/software/jel/manual.html
[4] exprtk/readme.txt at master - GitHub https://github.com/ArashPartow/exprtk/blob/master/readme.txt
[5] flintlib/arb: Arb has been merged into FLINT -- use https ... - GitHub https://github.com/flintlib/arb
[6] google/cel-java: Fast, portable, non-Turing complete ... - GitHub https://github.com/google/cel-java
[7] Java Expressions Library (JEL) home - GNU.org https://www.gnu.org/software/jel/
[8] Jacobi polynomials and recursive functions in arb4j's expression ... https://groups.google.com/g/flint-devel/c/VAEdGlAoFHM
[9] Arb - a C library for arbitrary-precision ball arithmetic — Arb 2.23.0 ... https://arblib.org
[10] divide by zero - Is 1/0 a legal Java expression? - Stack Overflow https://stackoverflow.com/questions/2934063/is-1-0-a-legal-java-expression/34673724
[11] flint-devel - Google Groups https://groups.google.com/g/flint-devel
[12] [PDF] Arb Documentation https://arblib.org/arb.pdf
[13] PSA: New arrow-switch statement doesn't check exhaustiveness (yet) https://www.reddit.com/r/java/comments/dp9eud/psa_new_arrowswitch_statement_doesnt_check/
[14] Wind River Diab Compiler: Optimize Your Code https://www.windriver.com/products/diab-compiler
[15] Debian Math Team / flint-arb · GitLab https://salsa.debian.org/math-team/flint-arb
[16] Jep - Java Expression Parser - SingSurf.org https://singsurf.org/djep/jep.php
[17] Can/do compilers simplify logical expressions involving functions? https://stackoverflow.com/questions/7274692/can-do-compilers-simplify-logical-expressions-involving-functions
[18] arb_calc.h – calculus with real-valued functions - Fredrik Johansson https://fredrikj.net/arb/arb_calc.html
[19] [PDF] Expression Isolation of Compiler-Induced Numerical Inconsistencies ... https://web.cs.ucdavis.edu/~rubio/includes/isc23.pdf
[20] Welcome to Arb's documentation! - Fredrik Johansson https://fredrikj.net/arb/
Reply all
Reply to author
Forward
0 new messages