Jacobi polynomials and recursive functions in arb4j's expression compiler

50 views
Skip to first unread message

Stephen Crowley

unread,
Jan 19, 2024, 5:42:11 PMJan 19
to flint...@googlegroups.com
I know no one cares, but Im close to finished with the Jacobi polynomial implementation in arb4j . There is a little more work to be done on the expression compiler, but it's quite functional now.

I currently have the code referring to the decompiled versions of the class files generated by https://github.com/crowlogic/arb4j/blob/master/src/main/java/arb/expressions/Expression.java as
a debugging step.... the decompiled versions have very little modification and are currently there to facilitate debugging

P(1)=0.5*x

P(2)=0.75*x^2 - 0.375

P(3)=1.25*x^3 - 0.9375*x

P(4)=2.1875*x^4 - 2.1875*x^2 + 0.2734375

P(5)=3.9375*x^5 - 4.921875*x^3 + 1.23046875*x

P(6)=7.21875*x^6 - 10.828125*x^4 + 4.060546875*x^2 - 0.2255859375

P(7)=13.40625*x^7 - 23.4609375*x^5 + 11.73046875*x^3 - 1.46630859375*x

P(8)=25.13671875*x^8 - 50.2734375*x^6 + 31.4208984375*x^4 - 6.2841796875*x^2 + 0.196380615234375

The code to print the RealPolynomial such that it looks like a polynomial rather than just an array is at

https://github.com/crowlogic/arb4j/blob/master/src/main/java/arb/RealPolynomial.java

I will modify it soon to support writing the exponent in UTF chars so as to avoid the ascii representation of x^p

@Override

public String toString()

{

if (getLength() == 0)

{

return "∅";

}

if (getLength() == 1)

{

return get(0).toString();

}

StringBuilder builder = new StringBuilder();

for (int i = getLength() - 1; i >= 0; --i)

{

Real xi = get(i);

if (!xi.isZero())

{

if (i < getLength() - 1)

{

builder.append(xi.sign() >= 0 ? " + " : " ");

}

if (!xi.isOne())

{

builder.append(xi);

}

if (i > 0)

{

builder.append("*x");

if (i > 1)

{

builder.append("^" + i);

}

}

}

}

return (builder.toString() + (remainder != null ? " with remainder " + remainder : "")).replaceAll("-", "- ");

}

the recursions are a different form than how they are usually presented, this way avoids repeated calculations

j
The equivalent code that would have to be manually written if it were not for the expression compiler , just to evaluate the P function , is shown here


quite long, verbose, tedious and error-prone

usable




Stephen Crowley

unread,
Jan 19, 2024, 5:44:28 PMJan 19
to flint-devel
The JacobiPolynomialPrototype link should have been

Stephen Crowley

unread,
Jan 30, 2024, 11:31:12 PMJan 30
to flint...@googlegroups.com

I think this syntax for the RealPolynomial java interface for arb_t is pretty good but it would be even better to have a way of reliably converting exact fractions.. or maybe I should just focus on on making a RealRationalPolynomial interface for fmpq_poly_t and implement the recursions directly with the real rational polynomial type.

Anyone have any opionions?

https://github.com/crowlogic/arb4j/blob/master/src/main/java/arb/functions/polynomials/orthogonal/JacobiPolynomialSequence.java

https://github.com/crowlogic/arb4j/blob/master/src/main/java/arb/RealPolynomial.java

Here's the first 20 Jacobi polynomials with α=β=-½

P(0,x)=1

P(1,x)=0.5x

P(2,x)=0.75x² - 0.375

P(3,x)=1.25x³ - 0.9375x

P(4,x)=2.1875x⁴ - 2.1875x² + 0.2734375

P(5,x)=3.9375x⁵ - 4.921875x³ + 1.23046875x

P(6,x)=7.21875x⁶ - 10.828125x⁴ + 4.060546875x² - 0.2255859375

P(7,x)=13.40625x⁷ - 23.4609375x⁵ + 11.73046875x³ - 1.46630859375x

P(8,x)=25.13671875x⁸ - 50.2734375x⁶ + 31.4208984375x⁴ - 6.2841796875x² + 0.196380615234375

P(9,x)=47.48046875x⁹ - 106.8310546875x⁷ + 80.123291015625x⁵ - 22.2564697265625x³ + 1.6692352294921875x

P(10,x)=90.212890625x¹⁰ - 225.5322265625x⁸ + 197.3406982421875x⁶ - 70.47882080078125x⁴ + 8.80985260009765625x² - 0.176197052001953125

P(11,x)=172.224609375x¹¹ - 473.61767578125x⁹ + 473.61767578125x⁷ - 207.207733154296875x⁵ + 37.00138092041015625x³ - 1.8500690460205078125x

P(12,x)=330.09716796875x¹² - 990.29150390625x¹⁰ + 1114.07794189453125x⁸ - 577.6700439453125x⁶ + 135.3914165496826171875x⁴ - 11.6049785614013671875x² + 0.1611802577972412109375

P(13,x)=634.80224609375x¹³ - 2063.1072998046875x¹¹ + 2578.884124755859375x⁹ - 1547.330474853515625x⁷ + 451.304721832275390625x⁵ - 56.413090229034423828125x³ + 2.01475322246551513671875x

P(14,x)=1224.261474609375x¹⁴ - 4284.9151611328125x¹² + 5891.7583465576171875x¹⁰ - 4017.10796356201171875x⁸ + 1405.9877872467041015625x⁶ - 234.33129787445068359375x⁴ + 14.645706117153167724609375x² - 0.1494459807872772216796875

P(15,x)=2366.905517578125x¹⁵ - 8875.89569091796875x¹³ + 13313.843536376953125x¹¹ - 10170.297145843505859375x⁹ + 4160.5761051177978515625x⁷ - 873.720982074737548828125x⁵ + 80.9000909328460693359375x³ - 2.16696672141551971435546875x

P(16,x)=4585.8794403076171875x¹⁶ - 18343.51776123046875x¹⁴ + 29808.21636199951171875x¹² - 25222.33692169189453125x¹⁰ + 11822.9704320430755615234375x⁸ - 3009.483382701873779296875x⁶ + 376.185422837734222412109375x⁴ - 17.913591563701629638671875x² + 0.1399499340914189815521240234375

P(17,x)=8902.0012664794921875x¹⁷ - 37833.505382537841796875x¹⁵ + 66208.63441944122314453125x¹³ - 61479.446246623992919921875x¹¹ + 32513.168688118457794189453125x⁹ - 9753.9506064355373382568359375x⁷ + 1551.764869205653667449951171875x⁵ - 110.8403478004038333892822265625x³ + 2.30917391250841319561004638671875x

P(18,x)=17309.44690704345703125x¹⁸ - 77892.511081695556640625x¹⁶ + 146048.458278179168701171875x¹⁴ - 147671.2189257144927978515625x¹² + 87020.5397240817546844482421875x¹⁰ - 30122.49451987445354461669921875x⁸ + 5857.1517121978104114532470703125x⁶ - 570.50179014913737773895263671875x⁴ + 21.393817130592651665210723876953125x² - 0.1320605995715595781803131103515625

P(19,x)=33707.87029266357421875x¹⁹ - 160112.3838901519775390625x¹⁷ + 320224.767780303955078125x¹⁵ - 350245.83975970745086669921875x¹³ + 227659.7958438098430633544921875x¹¹ - 89437.776938639581203460693359375x⁹ + 20639.486985839903354644775390625x⁷ - 2579.935873229987919330596923828125x⁵ + 146.587265524431131780147552490234375x³ - 2.44312109207385219633579254150390625x

Jeffrey Sarnoff

unread,
Jan 30, 2024, 11:53:21 PMJan 30
to flint...@googlegroups.com
A distinct RationalPolynomial type would be cleaner and more easily optimized.

--

---
You received this message because you are subscribed to the Google Groups "flint-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flint-devel...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/flint-devel/9c1a01d7-c164-45dd-b9cd-0af4067e7265%40gmail.com.
Reply all
Reply to author
Forward
0 new messages