• Re: A rational integral and Rioboo's algorithm

    From nobody@nowhere.invalid@21:1/5 to Sam Blake on Tue Jan 2 21:32:27 2024
    Sam Blake schrieb:

    For fun I have been implementing the rational integral routines from Bronstein's Symbolic Integration I in Mathematica. As part of my
    testing I stumbled across the following example integral

    \int x/(2 + 4 x + 5 x^2 + 2 x^3 + x^4) dx

    Rubi does well on this example

    In[66]:= Int[x/(2 + 4 x + 5 x^2 + 2 x^3 + x^4), x]

    Out[66]= -(ArcTan[(1 + 2 x)/Sqrt[7 - 4 Sqrt[2]]]/(
    2 Sqrt[2 (7 - 4 Sqrt[2])])) +
    ArcTan[(1 + 2 x)/Sqrt[7 + 4 Sqrt[2]]]/(2 Sqrt[2 (7 + 4 Sqrt[2])]) -
    ArcTanh[(7 + 4 (1/2 + x)^2)/(4 Sqrt[2])]/(2 Sqrt[2])

    While my rational function integrator returns

    In[67]:= IntegrateRational[x/(2 + 4 x + 5 x^2 + 2 x^3 + x^4), x]

    Out[67]= 1/2 (((-1 + I Sqrt[7 - 4 Sqrt[2]]) Log[
    1/2 (1 - I Sqrt[7 - 4 Sqrt[2]]) + x])/(
    2 (2 + 5/2 (-1 + I Sqrt[7 - 4 Sqrt[2]]) +
    3/4 (-1 + I Sqrt[7 - 4 Sqrt[2]])^2 +
    1/4 (-1 + I Sqrt[7 - 4 Sqrt[2]])^3)) + ((-1 -
    I Sqrt[7 - 4 Sqrt[2]]) Log[
    1/2 (1 + I Sqrt[7 - 4 Sqrt[2]]) + x])/(
    2 (2 + 5/2 (-1 - I Sqrt[7 - 4 Sqrt[2]]) +
    3/4 (-1 - I Sqrt[7 - 4 Sqrt[2]])^2 +
    1/4 (-1 - I Sqrt[7 - 4 Sqrt[2]])^3)) + ((-1 +
    I Sqrt[7 + 4 Sqrt[2]]) Log[
    1/2 (1 - I Sqrt[7 + 4 Sqrt[2]]) + x])/(
    2 (2 + 5/2 (-1 + I Sqrt[7 + 4 Sqrt[2]]) +
    3/4 (-1 + I Sqrt[7 + 4 Sqrt[2]])^2 +
    1/4 (-1 + I Sqrt[7 + 4 Sqrt[2]])^3)) + ((-1 -
    I Sqrt[7 + 4 Sqrt[2]]) Log[
    1/2 (1 + I Sqrt[7 + 4 Sqrt[2]]) + x])/(
    2 (2 + 5/2 (-1 - I Sqrt[7 + 4 Sqrt[2]]) +
    3/4 (-1 - I Sqrt[7 + 4 Sqrt[2]])^2 +
    1/4 (-1 - I Sqrt[7 + 4 Sqrt[2]])^3)))

    I find similar results from AXIOM and FriCAS. Is this a limitation of Rioboo's algorithm?


    This is an interesting example. Derive 6.10 also solves the integral in
    real terms:

    INT(x/(2 + 4*x + 5*x^2 + 2*x^3 + x^4), x)

    SQRT(238 - 136*SQRT(2))*ATAN(SQRT(119 - 68*SQRT(2))*(2*x + 1)/17)/68
    - SQRT(136*SQRT(2) + 238)*ATAN(SQRT(68*SQRT(2) + 119)*(2*x + 1)/17)/68
    + SQRT(2)*LN((x^2 + x - SQRT(2) + 2)/(x^2 + x + SQRT(2) + 2))/8

    as it starts by factoring the denominator:

    2 + 4*x + 5*x^2 + 2*x^3 + x^4 =
    (x^2 + x + SQRT(2) + 2)*(x^2 + x - SQRT(2) + 2)

    and then expands the integrand into partial fractions. Indeed, the
    cubic resolvent of the denominator factors as (y - 4)*(y^2 - y - 4).

    By contrast, FriCAS 1.3.9 returns a whopping:

    ((34^(1/2)*((-102)*rootOf((136*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^3+136*%%E1*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^2+(136*%%E1^2+(-5))*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)+(136*%%E1^3+(-5)*%%E1+1))/136,%%E1)^
    2+(-68)*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)*rootOf((136*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^3+136*%%E1*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^2+(136*%%E1^2+(-5))*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%
    E0)+(136*%%E1^3+(-5)*%%E1+1))/136,%%E1)+((-102)*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^2+5))^(1/2)+((-34)*rootOf((136*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^3+136*%%E1*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^2+(136*%%
    E1^2+(-5))*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)+(136*%%E1^3+(-5)*%%E1+1))/136,%%E1)+(-34)*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)))*log(((164*34^(1/2)*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)+38*34^(1/2))*rootOf((136*
    rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^3+136*%%E1*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^2+(136*%%E1^2+(-5))*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)+(136*%%E1^3+(-5)*%%E1+1))/136,%%E1)+(38*34^(1/2)*rootOf((544*%%E0^4+
    (-20)*%%E0^2+4*%%E0+1)/544,%%E0)+5*34^(1/2)))*((-102)*rootOf((136*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^3+136*%%E1*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^2+(136*%%E1^2+(-5))*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)+(
    136*%%E1^3+(-5)*%%E1+1))/136,%%E1)^2+(-68)*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)*rootOf((136*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^3+136*%%E1*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^2+(136*%%E1^2+(-5))*rootOf((544*%
    %E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)+(136*%%E1^3+(-5)*%%E1+1))/136,%%E1)+((-102)*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^2+5))^(1/2)+((5576*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)+1292)*rootOf((136*rootOf((544*%%E0^4+(-20)*%%E0^
    2+4*%%E0+1)/544,%%E0)^3+136*%%E1*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^2+(136*%%E1^2+(-5))*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)+(136*%%E1^3+(-5)*%%E1+1))/136,%%E1)^2+(5576*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^2+
    (-170))*rootOf((136*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^3+136*%%E1*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^2+(136*%%E1^2+(-5))*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)+(136*%%E1^3+(-5)*%%E1+1))/136,%%E1)+(1292*
    rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^2+(-170)*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)+(52*x+(-42)))))+(((-1)*34^(1/2)*((-102)*rootOf((136*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^3+136*%%E1*rootOf((544*%%E0^4+(-20)*%%
    E0^2+4*%%E0+1)/544,%%E0)^2+(136*%%E1^2+(-5))*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)+(136*%%E1^3+(-5)*%%E1+1))/136,%%E1)^2+(-68)*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)*rootOf((136*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%
    E0)^3+136*%%E1*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^2+(136*%%E1^2+(-5))*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)+(136*%%E1^3+(-5)*%%E1+1))/136,%%E1)+((-102)*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^2+5))^(1/2)+((-34)*
    rootOf((136*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^3+136*%%E1*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^2+(136*%%E1^2+(-5))*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)+(136*%%E1^3+(-5)*%%E1+1))/136,%%E1)+(-34)*rootOf((544*%%
    E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)))*log((((-164)*34^(1/2)*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)+(-38)*34^(1/2))*rootOf((136*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^3+136*%%E1*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%
    E0)^2+(136*%%E1^2+(-5))*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)+(136*%%E1^3+(-5)*%%E1+1))/136,%%E1)+((-38)*34^(1/2)*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)+(-5)*34^(1/2)))*((-102)*rootOf((136*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+
    1)/544,%%E0)^3+136*%%E1*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^2+(136*%%E1^2+(-5))*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)+(136*%%E1^3+(-5)*%%E1+1))/136,%%E1)^2+(-68)*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)*rootOf((
    136*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^3+136*%%E1*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^2+(136*%%E1^2+(-5))*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)+(136*%%E1^3+(-5)*%%E1+1))/136,%%E1)+((-102)*rootOf((544*%%E0^4+(
    -20)*%%E0^2+4*%%E0+1)/544,%%E0)^2+5))^(1/2)+((5576*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)+1292)*rootOf((136*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^3+136*%%E1*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^2+(136*%%E1^2+(-5))
    *rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)+(136*%%E1^3+(-5)*%%E1+1))/136,%%E1)^2+(5576*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^2+(-170))*rootOf((136*rootOf((544*%%E0^4+(-20)*%%E0^2+4*%%E0+1)/544,%%E0)^3+136*%%E1*rootOf((544*%%E0^4+(-
    20)*%%E0^2+4*%%E0+1)/544,%%E0)^2+(1

    which is the sum of three logarithms involving many nested rootOf()s
    where the %%En denote local variables. The quartic of the inner
    rootOf() factors as:

    544*z^4 - 20*z^2 + 4*z + 1 =
    1/17*(68*SQRT(2)*z^2 + 34*z + 3*SQRT(2) - 1)
    *(68*SQRT(2)*z^2 - 34*z + 3*SQRT(2) + 1)

    and its cubic resolvent is (34*y - 3)*(272*y^2 + 34*y + 1).

    Let's see if FriCAS version 1.3.10 will do better.

    Martin.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From nobody@nowhere.invalid@21:1/5 to Richard Fateman on Wed Jan 3 19:07:56 2024
    Richard Fateman schrieb:

    On Tuesday, January 2, 2024 at 12:32:26 PM UTC-8, nob...@nowhere.invalid wrote:

    Sam Blake schrieb:

    For fun I have been implementing the rational integral routines from Bronstein's Symbolic Integration I in Mathematica. As part of my
    testing I stumbled across the following example integral

    \int x/(2 + 4 x + 5 x^2 + 2 x^3 + x^4) dx

    Rubi does well on this example

    In[66]:= Int[x/(2 + 4 x + 5 x^2 + 2 x^3 + x^4), x]

    Out[66]= -(ArcTan[(1 + 2 x)/Sqrt[7 - 4 Sqrt[2]]]/(
    2 Sqrt[2 (7 - 4 Sqrt[2])])) +
    ArcTan[(1 + 2 x)/Sqrt[7 + 4 Sqrt[2]]]/(2 Sqrt[2 (7 + 4 Sqrt[2])]) - ArcTanh[(7 + 4 (1/2 + x)^2)/(4 Sqrt[2])]/(2 Sqrt[2])

    While my rational function integrator returns

    In[67]:= IntegrateRational[x/(2 + 4 x + 5 x^2 + 2 x^3 + x^4), x]

    Out[67]= 1/2 (((-1 + I Sqrt[7 - 4 Sqrt[2]]) Log[
    1/2 (1 - I Sqrt[7 - 4 Sqrt[2]]) + x])/(
    2 (2 + 5/2 (-1 + I Sqrt[7 - 4 Sqrt[2]]) +
    3/4 (-1 + I Sqrt[7 - 4 Sqrt[2]])^2 +
    1/4 (-1 + I Sqrt[7 - 4 Sqrt[2]])^3)) + ((-1 -
    I Sqrt[7 - 4 Sqrt[2]]) Log[
    1/2 (1 + I Sqrt[7 - 4 Sqrt[2]]) + x])/(
    2 (2 + 5/2 (-1 - I Sqrt[7 - 4 Sqrt[2]]) +
    3/4 (-1 - I Sqrt[7 - 4 Sqrt[2]])^2 +
    1/4 (-1 - I Sqrt[7 - 4 Sqrt[2]])^3)) + ((-1 +
    I Sqrt[7 + 4 Sqrt[2]]) Log[
    1/2 (1 - I Sqrt[7 + 4 Sqrt[2]]) + x])/(
    2 (2 + 5/2 (-1 + I Sqrt[7 + 4 Sqrt[2]]) +
    3/4 (-1 + I Sqrt[7 + 4 Sqrt[2]])^2 +
    1/4 (-1 + I Sqrt[7 + 4 Sqrt[2]])^3)) + ((-1 -
    I Sqrt[7 + 4 Sqrt[2]]) Log[
    1/2 (1 + I Sqrt[7 + 4 Sqrt[2]]) + x])/(
    2 (2 + 5/2 (-1 - I Sqrt[7 + 4 Sqrt[2]]) +
    3/4 (-1 - I Sqrt[7 + 4 Sqrt[2]])^2 +
    1/4 (-1 - I Sqrt[7 + 4 Sqrt[2]])^3)))

    I find similar results from AXIOM and FriCAS. Is this a limitation of Rioboo's algorithm?


    This is an interesting example. Derive 6.10 also solves the integral in real terms:

    INT(x/(2 + 4*x + 5*x^2 + 2*x^3 + x^4), x)

    SQRT(238 - 136*SQRT(2))*ATAN(SQRT(119 - 68*SQRT(2))*(2*x + 1)/17)/68
    - SQRT(136*SQRT(2) + 238)*ATAN(SQRT(68*SQRT(2) + 119)*(2*x + 1)/17)/68
    + SQRT(2)*LN((x^2 + x - SQRT(2) + 2)/(x^2 + x + SQRT(2) + 2))/8

    as it starts by factoring the denominator:

    2 + 4*x + 5*x^2 + 2*x^3 + x^4 =
    (x^2 + x + SQRT(2) + 2)*(x^2 + x - SQRT(2) + 2)

    and then expands the integrand into partial fractions. Indeed, the
    cubic resolvent of the denominator factors as (y - 4)*(y^2 - y - 4).

    By contrast, FriCAS 1.3.9 returns a whopping:

    [...]

    which is the sum of three logarithms involving many nested rootOf()s
    where the %%En denote local variables. The quartic of the inner
    rootOf() factors as:

    544*z^4 - 20*z^2 + 4*z + 1 =
    1/17*(68*SQRT(2)*z^2 + 34*z + 3*SQRT(2) - 1)
    *(68*SQRT(2)*z^2 - 34*z + 3*SQRT(2) + 1)

    and its cubic resolvent is (34*y - 3)*(272*y^2 + 34*y + 1).

    Let's see if FriCAS version 1.3.10 will do better.


    In Maxima ... factor the denominator in an algebraic field...

    (%o4) x^4+2*x^3+5*x^2+4*x+2
    (%i5) factor(%, subst(a,x,%));

    (%o5) (x-a)*(x+a+1)*(x^2+x+a^2+a+4)

    from which integration produces a relatively compact form.

    This expresses the factors of the denominator in terms of any one still
    unknown root. Even though all of the roots are complex:

    SOLUTIONS(a^4 + 2*a^3 + 5*a^2 + 4*a + 2 = 0, a)

    [- 1/2 + #i*SQRT(4*SQRT(2) + 7)/2, - 1/2 - #i*SQRT(4*SQRT(2) + 7)/2,
    - 1/2 + #i*SQRT(7 - 4*SQRT(2))/2, - 1/2 - #i*SQRT(7 - 4*SQRT(2))/2]

    the constant a^2 + a in the quadratic factor is real for any of them,
    and so will then be an antiderivative based on the decomposition:

    x^4 + 2*x^3 + 5*x^2 + 4*x + 2 =
    (x^2 + x - a^2 - a)*(x^2 + x + a^2 + a + 4)

    in which the pair of linear factors is treated as a another quadratic.

    If the code in Bronstein's book is indeed claimed to produce a real antiderivative for

    IntegrateRational[x/(2 + 4 x + 5 x^2 + 2 x^3 + x^4), x]

    and nothing has been overlooked in the code itself, there should be a
    bug in the Mathematica implementation. Breaking four complex logarithms
    up into real and imaginary parts should be within the capabilities of programming on Mathematica - the imaginary parts would finally cancel.
    If the code can identify complex conjugate pairs, the imaginary parts
    could be ignored right away.

    Martin.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From nobody@nowhere.invalid@21:1/5 to Sam Blake on Thu Jan 4 22:33:06 2024
    Sam Blake schrieb:

    In this example AXIOM and FriCAS both have polynomials in the
    denominator of arctan terms:

    integrate((5 - 6*x^2 - 12*x^5 - 15*x^6 + 10*x^9)/(1 + 5*x^2 - 4*x^3 - 3*x^4 - 10*x^5 + 6*x^6 + 5*x^8 - 4*x^9 + x^12),x)

    The FriCAS solution is especially strange as it introduces a square
    root of a polynomial in the denominator of an arctan.

    Here's a better form:

    In[315]:= IntegrateRational[(5 - 6 x^2 - 12 x^5 - 15 x^6 + 10 x^9)/(1 + 5 x^2 - 4 x^3 - 3 x^4 - 10 x^5 + 6 x^6 + 5 x^8 - 4 x^9 + x^12), x]

    Out[315]=
    Sqrt[1/2 (5 + Sqrt[37])] ArcTan[Sqrt[1/6 (-5 + Sqrt[37])] x^2] +
    Sqrt[1/2 (5 + Sqrt[37])]
    ArcTan[1/6 (3 Sqrt[2 (5 + Sqrt[37])] x - Sqrt[6 (-5 + Sqrt[37])] x^2 +
    Sqrt[6 (-5 + Sqrt[37])] x^5)] -
    1/2 Sqrt[1/2 (-5 + Sqrt[37])]
    Log[-2 - Sqrt[2 (-5 + Sqrt[37])] x + 2 x^3] +
    1/2 Sqrt[1/2 (-5 + Sqrt[37])]
    Log[-2 + Sqrt[2 (-5 + Sqrt[37])] x + 2 x^3]


    Derive 6.10 fails on this one as it cannot factor the denominator:

    x^12 - 4*x^9 + 5*x^8 + 6*x^6 - 10*x^5 - 3*x^4 - 4*x^3 + 5*x^2 + 1

    = 1/4*(2*x^6 - 4*x^3 + x^2*(5 - SQRT(37)) + 2)
    *(2*x^6 - 4*x^3 + x^2*(SQRT(37) + 5) + 2)

    = 1/4*(SQRT(2)*x^3 + x*SQRT(SQRT(37) - 5) - SQRT(2))
    *(SQRT(2)*x^3 - x*SQRT(SQRT(37) - 5) - SQRT(2))
    *(SQRT(2)*x^3 - SQRT(2) + #i*x*SQRT(SQRT(37) + 5))
    *(SQRT(2)*x^3 - SQRT(2) - #i*x*SQRT(SQRT(37) + 5))

    I suspect that the square root of a polynomial in the denominator of
    the arc tangent returned by FriCAS is introduced by halving the
    argument range in order to prevent unnecessary discontinuitities:

    ATAN(w) = 2*ATAN(w/(1 + SQRT(1 + w^2)))

    Unfortunately, this step would usually frustrate a subsequent Rioboo
    splitting of the arc tangent, which could have served the same purpose
    better if applied instead.

    Martin.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From nobody@nowhere.invalid@21:1/5 to clicliclic@freenet.de on Thu Jan 11 13:12:13 2024
    "clicliclic@freenet.de" schrieb:

    Sam Blake schrieb:

    In this example AXIOM and FriCAS both have polynomials in the
    denominator of arctan terms:

    integrate((5 - 6*x^2 - 12*x^5 - 15*x^6 + 10*x^9)/(1 + 5*x^2 - 4*x^3 - 3*x^4 - 10*x^5 + 6*x^6 + 5*x^8 - 4*x^9 + x^12),x)

    The FriCAS solution is especially strange as it introduces a square
    root of a polynomial in the denominator of an arctan.

    Here's a better form:

    In[315]:= IntegrateRational[(5 - 6 x^2 - 12 x^5 - 15 x^6 + 10 x^9)/(1 + 5 x^2 - 4 x^3 - 3 x^4 - 10 x^5 + 6 x^6 + 5 x^8 - 4 x^9 + x^12), x]

    Out[315]=
    Sqrt[1/2 (5 + Sqrt[37])] ArcTan[Sqrt[1/6 (-5 + Sqrt[37])] x^2] +
    Sqrt[1/2 (5 + Sqrt[37])]
    ArcTan[1/6 (3 Sqrt[2 (5 + Sqrt[37])] x - Sqrt[6 (-5 + Sqrt[37])] x^2 +
    Sqrt[6 (-5 + Sqrt[37])] x^5)] -
    1/2 Sqrt[1/2 (-5 + Sqrt[37])]
    Log[-2 - Sqrt[2 (-5 + Sqrt[37])] x + 2 x^3] +
    1/2 Sqrt[1/2 (-5 + Sqrt[37])]
    Log[-2 + Sqrt[2 (-5 + Sqrt[37])] x + 2 x^3]


    Derive 6.10 fails on this one as it cannot factor the denominator:

    x^12 - 4*x^9 + 5*x^8 + 6*x^6 - 10*x^5 - 3*x^4 - 4*x^3 + 5*x^2 + 1

    = 1/4*(2*x^6 - 4*x^3 + x^2*(5 - SQRT(37)) + 2)
    *(2*x^6 - 4*x^3 + x^2*(SQRT(37) + 5) + 2)

    = 1/4*(SQRT(2)*x^3 + x*SQRT(SQRT(37) - 5) - SQRT(2))
    *(SQRT(2)*x^3 - x*SQRT(SQRT(37) - 5) - SQRT(2))
    *(SQRT(2)*x^3 - SQRT(2) + #i*x*SQRT(SQRT(37) + 5))
    *(SQRT(2)*x^3 - SQRT(2) - #i*x*SQRT(SQRT(37) + 5))

    I suspect that the square root of a polynomial in the denominator of
    the arc tangent returned by FriCAS is introduced by halving the
    argument range in order to prevent unnecessary discontinuitities:

    ATAN(w) = 2*ATAN(w/(1 + SQRT(1 + w^2)))

    Unfortunately, this step would usually frustrate a subsequent Rioboo splitting of the arc tangent, which could have served the same purpose
    better if applied instead.


    Here too, FriCAS 3.1.10 gives a nice answer:

    integrate((5 - 6*x^2 - 12*x^5 - 15*x^6 + 10*x^9)/
    (1 + 5*x^2 - 4*x^3 - 3*x^4 - 10*x^5 + 6*x^6 + 5*x^8 - 4*x^9 + x^12),x)

    (((37^(1/2)+(-5))/2)^(1/2)*log(x*((37^(1/2)+(-5))/2)^(1/2)+(x^3+(-1)))+((-1)*((37^(1/2)+(-5))/2)^(1/2)*log((-1)*x*((37^(1/2)+(-5))/2)^(1/2)+(x^3+(-1)))+(2*((37^(1/2)+5)/2)^(1/2)*atan((((x^5+(-1)*x^2)*37^(1/2)+((-5)*x^5+5*x^2+6*x))*((37^(1/2)+5)/2)^(1/2))/
    6)+2*((37^(1/2)+5)/2)^(1/2)*atan(((x^2*37^(1/2)+(-5)*x^2)*((37^(1/2)+5)/2)^(1/2))/6))))/2

    Martin.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From nobody@nowhere.invalid@21:1/5 to clicliclic@freenet.de on Thu Jan 11 13:11:19 2024
    "clicliclic@freenet.de" schrieb:

    Sam Blake schrieb:

    For fun I have been implementing the rational integral routines from Bronstein's Symbolic Integration I in Mathematica. As part of my
    testing I stumbled across the following example integral

    \int x/(2 + 4 x + 5 x^2 + 2 x^3 + x^4) dx

    Rubi does well on this example

    In[66]:= Int[x/(2 + 4 x + 5 x^2 + 2 x^3 + x^4), x]

    Out[66]= -(ArcTan[(1 + 2 x)/Sqrt[7 - 4 Sqrt[2]]]/(
    2 Sqrt[2 (7 - 4 Sqrt[2])])) +
    ArcTan[(1 + 2 x)/Sqrt[7 + 4 Sqrt[2]]]/(2 Sqrt[2 (7 + 4 Sqrt[2])]) -
    ArcTanh[(7 + 4 (1/2 + x)^2)/(4 Sqrt[2])]/(2 Sqrt[2])

    While my rational function integrator returns

    In[67]:= IntegrateRational[x/(2 + 4 x + 5 x^2 + 2 x^3 + x^4), x]

    Out[67]= 1/2 (((-1 + I Sqrt[7 - 4 Sqrt[2]]) Log[
    1/2 (1 - I Sqrt[7 - 4 Sqrt[2]]) + x])/(
    2 (2 + 5/2 (-1 + I Sqrt[7 - 4 Sqrt[2]]) +
    3/4 (-1 + I Sqrt[7 - 4 Sqrt[2]])^2 +
    1/4 (-1 + I Sqrt[7 - 4 Sqrt[2]])^3)) + ((-1 -
    I Sqrt[7 - 4 Sqrt[2]]) Log[
    1/2 (1 + I Sqrt[7 - 4 Sqrt[2]]) + x])/(
    2 (2 + 5/2 (-1 - I Sqrt[7 - 4 Sqrt[2]]) +
    3/4 (-1 - I Sqrt[7 - 4 Sqrt[2]])^2 +
    1/4 (-1 - I Sqrt[7 - 4 Sqrt[2]])^3)) + ((-1 +
    I Sqrt[7 + 4 Sqrt[2]]) Log[
    1/2 (1 - I Sqrt[7 + 4 Sqrt[2]]) + x])/(
    2 (2 + 5/2 (-1 + I Sqrt[7 + 4 Sqrt[2]]) +
    3/4 (-1 + I Sqrt[7 + 4 Sqrt[2]])^2 +
    1/4 (-1 + I Sqrt[7 + 4 Sqrt[2]])^3)) + ((-1 -
    I Sqrt[7 + 4 Sqrt[2]]) Log[
    1/2 (1 + I Sqrt[7 + 4 Sqrt[2]]) + x])/(
    2 (2 + 5/2 (-1 - I Sqrt[7 + 4 Sqrt[2]]) +
    3/4 (-1 - I Sqrt[7 + 4 Sqrt[2]])^2 +
    1/4 (-1 - I Sqrt[7 + 4 Sqrt[2]])^3)))

    I find similar results from AXIOM and FriCAS. Is this a limitation
    of Rioboo's algorithm?


    This is an interesting example. Derive 6.10 also solves the integral
    in real terms:

    INT(x/(2 + 4*x + 5*x^2 + 2*x^3 + x^4), x)

    SQRT(238 - 136*SQRT(2))*ATAN(SQRT(119 - 68*SQRT(2))*(2*x + 1)/17)/68
    - SQRT(136*SQRT(2) + 238)*ATAN(SQRT(68*SQRT(2) + 119)*(2*x + 1)/17)/68
    + SQRT(2)*LN((x^2 + x - SQRT(2) + 2)/(x^2 + x + SQRT(2) + 2))/8

    as it starts by factoring the denominator:

    2 + 4*x + 5*x^2 + 2*x^3 + x^4 =
    (x^2 + x + SQRT(2) + 2)*(x^2 + x - SQRT(2) + 2)

    and then expands the integrand into partial fractions. Indeed, the
    cubic resolvent of the denominator factors as (y - 4)*(y^2 - y - 4).

    By contrast, FriCAS 1.3.9 returns a whopping:

    [...]

    which is the sum of three logarithms involving many nested rootOf()s
    where the %%En denote local variables. The quartic of the inner
    rootOf() factors as:

    544*z^4 - 20*z^2 + 4*z + 1 =
    1/17*(68*SQRT(2)*z^2 + 34*z + 3*SQRT(2) - 1)
    *(68*SQRT(2)*z^2 - 34*z + 3*SQRT(2) + 1)

    and its cubic resolvent is (34*y - 3)*(272*y^2 + 34*y + 1).

    Let's see if FriCAS version 1.3.10 will do better.


    FriCAS Version 1.3.10 is out and returns:

    integrate(x/(2 + 4*x + 5*x^2 + 2*x^3 + x^4), x)

    ((-4)*((4*2^(1/2)+7)/34)^(1/2)*atan((2*x+1)*2^(1/2)*((4*2^(1/2)+7)/34)^(1/2))+(4*(((-4)*2^(1/2)+7)/34)^(1/2)*atan((2*x+1)*2^(1/2)*(((-4)*2^(1/2)+7)/34)^(1/2))+((-1)*2^(1/2)*log(2^(1/2)+(x^2+x+2))+2^(1/2)*log((-1)*2^(1/2)+(x^2+x+2)))))/8

    which represents a massive improvement.

    Martin.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)