• An algebraic integral in FriCAS

    From samuel.thomas.blake@gmail.com@21:1/5 to samuel.t...@gmail.com on Sat Aug 1 01:35:23 2020
    On Thursday, May 7, 2020 at 11:49:37 AM UTC+10, samuel.t...@gmail.com wrote:
    On Thursday, May 7, 2020 at 5:07:58 AM UTC+10, clicl...@freenet.de wrote:
    samuel.thomas.blake@gmail.com schrieb:

    On Wednesday, May 6, 2020 at 3:40:42 PM UTC+10, Nasser M. Abbasi wrote:
    On 5/5/2020 11:14 PM, samuel.thomas.blake@gmail.com wrote:

    int(convert(((-3+x^2)*(1-6*x^2+x^4)^(-1/4))/(-1+x^2),RootOf),x);
    memory used=294.4MB, alloc=112.3MB, time=3.47
    memory used=370.5MB, alloc=112.3MB, time=4.30
    memory used=446.8MB, alloc=112.3MB, time=5.04
    memory used=501.3MB, alloc=112.3MB, time=5.54
    memory used=570.5MB, alloc=112.3MB, time=6.13 1/2*RootOf(_Z^2+1)*ln(-(-RootOf(_Z^4-x^4+6*x^2-1,index = 1)^2*RootOf(_Z^2+1)*x^2+RootOf(_Z^2+1)*x^4+RootOf(_Z^4-x^4+6*x^2
    -1,index = 1)^3*x-RootOf(_Z^4-x^4+6*x^2-1,index = 1)*x^3+RootOf(_Z^4-x^4+6*x^2-1,index = 1)^2*RootOf(_Z^2+1)-5*RootOf(_Z^
    2+1)*x^2+3*RootOf(_Z^4-x^4+6*x^2-1,index = 1)*x)/(x+1)/(x-1))+1/2*ln(-(RootOf(_Z^4-x^4+6*x^2-1,index = 1)^3*x+RootOf(_Z^4
    -x^4+6*x^2-1,index = 1)^2*x^2+RootOf(_Z^4-x^4+6*x^2-1,index = 1)*x^3+x^4-RootOf(_Z^4-x^4+6*x^2-1,index = 1)^2-3*RootOf(_Z
    ^4-x^4+6*x^2-1,index = 1)*x-5*x^2)/(x+1)/(x-1))


    That is a nice trick. I did not know that converting integrand
    to RootOf makes maple do these integrals.

    The antiderivative contains complex numbers, but the result is correct, because
    when it is differentiated it gives back the integrand.

    part1 := 1/(1+6*x^2+x^4)^(3/4);
    part2 := (1-x^2)^2;
    part3 := 1/(1+x^2);
    integrand := part1*part2*part3;
    integrand0 := convert( part1*part2*part3, RootOf);
    anti := int(integrand0,x):

    anti := [allvalues(res)][1]; #pick first solution, same for second solution

    anti := ln(((x^4 + 6*x^2 + 1)^(3/4)*x + sqrt(x^4 + 6*x^2 + 1)*x^2 +
    (x^4 + 6*x^2 + 1)^(1/4)*x^3 + x^4 + sqrt(x^4 + 6*x^2 + 1) +
    3*(x^4 + 6*x^2 + 1)^(1/4)*x + 5*x^2)/(x^2 + 1))/2 +
    ln(-(-sqrt(x^4 + 6*x^2 + 1)*x^4*I + x^6*I + (x^4 + 6*x^2 + 1)^(1/4)*x^5 - 2*I*sqrt(x^4 + 6*x^2 + 1)*x^2 + 6*I*x^4 + 4*(x^4 + 6*x^2 + 1)^(1/4)*x^3
    - (x^4 + 6*x^2 + 1)^(3/4)*x^3 - (x^4 + 6*x^2 + 1)^(3/4)*x
    - sqrt(x^4 + 6*x^2 + 1)*I + 5*I*x^2
    + 3*(x^4 + 6*x^2 + 1)^(1/4)*x)/((x*I + 1)^2*(x*I - 1)^2))*I/2

    back := simplify(diff(anti,x));
    simplify(back-integrand)

    0

    I have to remember this trick ;)


    Its the only way I know of to get Maple to use the Trager-Bronstein algorithm for algebraic functions. Maple gives some nice details of
    the execution of the algorithm using

    infolevel[int] := 5:


    Where did you learn that conversion to RootOf makes Maple apply its
    Risch integrator? This "trick" does not seem to be common knowledge.

    Posting the trace information for this integral could perhaps help to
    raise FriCAS performance towards the level of Maple's algebraic Risch integrator? It's no small step from 70.0% to 91.6%, as measured on
    your testsuite of 190 integrals.

    Martin.

    Hi Martin,

    No, it doesn't seem to be well-known. I saw it used by Bronstein in a post in this group concerning the integral of

    x*(-71-96*x+10*x^2+x^4)^(-1/2)

    Then I subsequently saw it mentioned in passing in a tutorial by Geddes.

    Using this conversion, Maple finds solutions to many integrals where FriCAS reports "implementation incomplete (residue poly has multiple non-linear factors)".

    Cheers,

    Sam


    Greetings, incase anybody is interested, I tried FriCAS 1.3.6 on the same set of 191 integrals. The results are very similar to FriCAS 1.2.6. Interestingly 1.2.6 reports that 4 of the integrals are not elementary

    (1) -> )version
    Value = "FriCAS 1.3.6 compiled at Fri Jul 24 17:12:55 AEST 2020"
    (1) -> )set messages time on
    (1) -> integrate(((4+x^6)*(4+28*x^4-4*x^6+48*x^8-14*x^10+x^12)^(1/2))/x^9,x)

    +--------------------------------------------+
    x 6 | 12 10 8 6 4
    ++ (%A + 4)\|%A - 14 %A + 48 %A - 4 %A + 28 %A + 4
    (1) | -------------------------------------------------------- d%A
    ++ 9
    %A
    Type: Union(Expression(Integer),...)
    Time: 0.03 (IN) + 16.09 (EV) + 0.44 (OT) = 16.56 sec

    (2) -> integrate(((-1+3*x^4)*(1+x+2*x^4+x^5+x^8)^(1/2))/(x^2*(4+x+4*x^4)),x)

    +--------------------------+
    x 4 | 8 5 4
    ++ (3 %A - 1)\|%A + %A + 2 %A + %A + 1
    (2) | ---------------------------------------- d%A
    ++ 6 3 2
    4 %A + %A + 4 %A
    Type: Union(Expression(Integer),...)
    Time: 0.00 (IN) + 16.40 (EV) + 0.09 (OT) = 16.49 sec

    (3) -> integrate(((2+x^3)*(1-2*x^3-x^4+x^6)^(1/2))/(x^3*(-1-x^2+x^3)),x)

    +---------------------+
    x 3 | 6 4 3
    ++ (%A + 2)\|%A - %A - 2 %A + 1
    (3) | --------------------------------- d%A
    ++ 6 5 3
    %A - %A - %A
    Type: Union(Expression(Integer),...)
    Time: 0.00 (IN) + 1.40 (EV) + 0.03 (OT) = 1.44 sec

    (4) -> integrate(((-5+6*x^5)*(20-3*x^2+16*x^5)*(25-x^4+40*x^5+16*x^10)^(1/2))/(x^5*(30-7*x^2+24*x^5)),x)

    (4)
    INTSIGN
    ,
    x
    ,
    +---------------------------+
    10 7 5 2 | 10 5 4
    (96 %A - 18 %A + 40 %A + 15 %A - 100)\|16 %A + 40 %A - %A + 25
    ------------------------------------------------------------------------
    10 7 5
    24 %A - 7 %A + 30 %A
    *
    d%A
    Type: Union(Expression(Integer),...)
    Time: 0.00 (IN) + 15.02 (EV) + 0.03 (OT) = 15.05 sec

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From samuel.thomas.blake@gmail.com@21:1/5 to samuel.t...@gmail.com on Sat Aug 1 01:36:51 2020
    On Saturday, August 1, 2020 at 6:35:24 PM UTC+10, samuel.t...@gmail.com wrote:
    On Thursday, May 7, 2020 at 11:49:37 AM UTC+10, samuel.t...@gmail.com wrote:
    On Thursday, May 7, 2020 at 5:07:58 AM UTC+10, clicl...@freenet.de wrote:
    samuel.thomas.blake@gmail.com schrieb:

    On Wednesday, May 6, 2020 at 3:40:42 PM UTC+10, Nasser M. Abbasi wrote:
    On 5/5/2020 11:14 PM, samuel.thomas.blake@gmail.com wrote:

    int(convert(((-3+x^2)*(1-6*x^2+x^4)^(-1/4))/(-1+x^2),RootOf),x);
    memory used=294.4MB, alloc=112.3MB, time=3.47
    memory used=370.5MB, alloc=112.3MB, time=4.30
    memory used=446.8MB, alloc=112.3MB, time=5.04
    memory used=501.3MB, alloc=112.3MB, time=5.54
    memory used=570.5MB, alloc=112.3MB, time=6.13 1/2*RootOf(_Z^2+1)*ln(-(-RootOf(_Z^4-x^4+6*x^2-1,index = 1)^2*RootOf(_Z^2+1)*x^2+RootOf(_Z^2+1)*x^4+RootOf(_Z^4-x^4+6*x^2
    -1,index = 1)^3*x-RootOf(_Z^4-x^4+6*x^2-1,index = 1)*x^3+RootOf(_Z^4-x^4+6*x^2-1,index = 1)^2*RootOf(_Z^2+1)-5*RootOf(_Z^
    2+1)*x^2+3*RootOf(_Z^4-x^4+6*x^2-1,index = 1)*x)/(x+1)/(x-1))+1/2*ln(-(RootOf(_Z^4-x^4+6*x^2-1,index = 1)^3*x+RootOf(_Z^4
    -x^4+6*x^2-1,index = 1)^2*x^2+RootOf(_Z^4-x^4+6*x^2-1,index = 1)*x^3+x^4-RootOf(_Z^4-x^4+6*x^2-1,index = 1)^2-3*RootOf(_Z
    ^4-x^4+6*x^2-1,index = 1)*x-5*x^2)/(x+1)/(x-1))


    That is a nice trick. I did not know that converting integrand
    to RootOf makes maple do these integrals.

    The antiderivative contains complex numbers, but the result is correct, because
    when it is differentiated it gives back the integrand.

    part1 := 1/(1+6*x^2+x^4)^(3/4);
    part2 := (1-x^2)^2;
    part3 := 1/(1+x^2);
    integrand := part1*part2*part3;
    integrand0 := convert( part1*part2*part3, RootOf);
    anti := int(integrand0,x):

    anti := [allvalues(res)][1]; #pick first solution, same for second solution

    anti := ln(((x^4 + 6*x^2 + 1)^(3/4)*x + sqrt(x^4 + 6*x^2 + 1)*x^2 +
    (x^4 + 6*x^2 + 1)^(1/4)*x^3 + x^4 + sqrt(x^4 + 6*x^2 + 1) +
    3*(x^4 + 6*x^2 + 1)^(1/4)*x + 5*x^2)/(x^2 + 1))/2 +
    ln(-(-sqrt(x^4 + 6*x^2 + 1)*x^4*I + x^6*I + (x^4 + 6*x^2 + 1)^(1/4)*x^5
    - 2*I*sqrt(x^4 + 6*x^2 + 1)*x^2 + 6*I*x^4 + 4*(x^4 + 6*x^2 + 1)^(1/4)*x^3
    - (x^4 + 6*x^2 + 1)^(3/4)*x^3 - (x^4 + 6*x^2 + 1)^(3/4)*x
    - sqrt(x^4 + 6*x^2 + 1)*I + 5*I*x^2
    + 3*(x^4 + 6*x^2 + 1)^(1/4)*x)/((x*I + 1)^2*(x*I - 1)^2))*I/2

    back := simplify(diff(anti,x));
    simplify(back-integrand)

    0

    I have to remember this trick ;)


    Its the only way I know of to get Maple to use the Trager-Bronstein algorithm for algebraic functions. Maple gives some nice details of
    the execution of the algorithm using

    infolevel[int] := 5:


    Where did you learn that conversion to RootOf makes Maple apply its
    Risch integrator? This "trick" does not seem to be common knowledge.

    Posting the trace information for this integral could perhaps help to raise FriCAS performance towards the level of Maple's algebraic Risch integrator? It's no small step from 70.0% to 91.6%, as measured on
    your testsuite of 190 integrals.

    Martin.

    Hi Martin,

    No, it doesn't seem to be well-known. I saw it used by Bronstein in a post in this group concerning the integral of

    x*(-71-96*x+10*x^2+x^4)^(-1/2)

    Then I subsequently saw it mentioned in passing in a tutorial by Geddes.

    Using this conversion, Maple finds solutions to many integrals where FriCAS reports "implementation incomplete (residue poly has multiple non-linear factors)".

    Cheers,

    Sam


    Greetings, incase anybody is interested, I tried FriCAS 1.3.6 on the same set of 191 integrals. The results are very similar to FriCAS 1.2.6. Interestingly 1.2.6 reports that 4 of the integrals are not elementary

    (1) -> )version
    Value = "FriCAS 1.3.6 compiled at Fri Jul 24 17:12:55 AEST 2020"
    (1) -> )set messages time on
    (1) -> integrate(((4+x^6)*(4+28*x^4-4*x^6+48*x^8-14*x^10+x^12)^(1/2))/x^9,x)

    +--------------------------------------------+
    x 6 | 12 10 8 6 4
    ++ (%A + 4)\|%A - 14 %A + 48 %A - 4 %A + 28 %A + 4
    (1) | -------------------------------------------------------- d%A
    ++ 9
    %A
    Type: Union(Expression(Integer),...)
    Time: 0.03 (IN) + 16.09 (EV) + 0.44 (OT) = 16.56 sec

    (2) -> integrate(((-1+3*x^4)*(1+x+2*x^4+x^5+x^8)^(1/2))/(x^2*(4+x+4*x^4)),x)

    +--------------------------+
    x 4 | 8 5 4
    ++ (3 %A - 1)\|%A + %A + 2 %A + %A + 1
    (2) | ---------------------------------------- d%A
    ++ 6 3 2
    4 %A + %A + 4 %A
    Type: Union(Expression(Integer),...)
    Time: 0.00 (IN) + 16.40 (EV) + 0.09 (OT) = 16.49 sec

    (3) -> integrate(((2+x^3)*(1-2*x^3-x^4+x^6)^(1/2))/(x^3*(-1-x^2+x^3)),x)

    +---------------------+
    x 3 | 6 4 3
    ++ (%A + 2)\|%A - %A - 2 %A + 1
    (3) | --------------------------------- d%A
    ++ 6 5 3
    %A - %A - %A
    Type: Union(Expression(Integer),...)
    Time: 0.00 (IN) + 1.40 (EV) + 0.03 (OT) = 1.44 sec

    (4) -> integrate(((-5+6*x^5)*(20-3*x^2+16*x^5)*(25-x^4+40*x^5+16*x^10)^(1/2))/(x^5*(30-7*x^2+24*x^5)),x)

    (4)
    INTSIGN
    ,
    x
    ,
    +---------------------------+
    10 7 5 2 | 10 5 4
    (96 %A - 18 %A + 40 %A + 15 %A - 100)\|16 %A + 40 %A - %A + 25
    ------------------------------------------------------------------------
    10 7 5
    24 %A - 7 %A + 30 %A
    *
    d%A
    Type: Union(Expression(Integer),...)
    Time: 0.00 (IN) + 15.02 (EV) + 0.03 (OT) = 15.05 sec

    * 1.3.6 reports that 4 of the integrals are not elementary

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From nobody@nowhere.invalid@21:1/5 to samuel.thomas.blake@gmail.com on Sun Aug 2 18:30:46 2020
    samuel.thomas.blake@gmail.com schrieb:

    On Saturday, August 1, 2020 at 6:35:24 PM UTC+10, samuel.t...@gmail.com wrote:

    Greetings, incase anybody is interested, I tried FriCAS 1.3.6 on
    the same set of 191 integrals. The results are very similar to
    FriCAS 1.2.6. Interestingly 1.2.6 reports that 4 of the integrals
    are not elementary

    (1) -> )version
    Value = "FriCAS 1.3.6 compiled at Fri Jul 24 17:12:55 AEST 2020"
    (1) -> )set messages time on
    (1) -> integrate(((4+x^6)*(4+28*x^4-4*x^6+48*x^8-14*x^10+x^12)^(1/2))/x^9,x)

    +--------------------------------------------+
    x 6 | 12 10 8 6 4
    ++ (%A + 4)\|%A - 14 %A + 48 %A - 4 %A + 28 %A + 4
    (1) | -------------------------------------------------------- d%A
    ++ 9
    %A
    Type: Union(Expression(Integer),...)
    Time: 0.03 (IN) + 16.09 (EV) + 0.44 (OT) = 16.56 sec

    (2) -> integrate(((-1+3*x^4)*(1+x+2*x^4+x^5+x^8)^(1/2))/(x^2*(4+x+4*x^4)),x)

    +--------------------------+
    x 4 | 8 5 4
    ++ (3 %A - 1)\|%A + %A + 2 %A + %A + 1
    (2) | ---------------------------------------- d%A
    ++ 6 3 2
    4 %A + %A + 4 %A
    Type: Union(Expression(Integer),...)
    Time: 0.00 (IN) + 16.40 (EV) + 0.09 (OT) = 16.49 sec

    (3) -> integrate(((2+x^3)*(1-2*x^3-x^4+x^6)^(1/2))/(x^3*(-1-x^2+x^3)),x)

    +---------------------+
    x 3 | 6 4 3
    ++ (%A + 2)\|%A - %A - 2 %A + 1
    (3) | --------------------------------- d%A
    ++ 6 5 3
    %A - %A - %A
    Type: Union(Expression(Integer),...)
    Time: 0.00 (IN) + 1.40 (EV) + 0.03 (OT) = 1.44 sec

    (4) -> integrate(((-5+6*x^5)*(20-3*x^2+16*x^5)*(25-x^4+40*x^5+16*x^10)^(1/2))/(x^5*(30-7*x^2+24*x^5)),x)

    (4)
    INTSIGN
    ,
    x
    ,
    +---------------------------+
    10 7 5 2 | 10 5 4
    (96 %A - 18 %A + 40 %A + 15 %A - 100)\|16 %A + 40 %A - %A + 25
    ------------------------------------------------------------------------
    10 7 5
    24 %A - 7 %A + 30 %A
    *
    d%A
    Type: Union(Expression(Integer),...)
    Time: 0.00 (IN) + 15.02 (EV) + 0.03 (OT) = 15.05 sec

    * 1.3.6 reports that 4 of the integrals are not elementary

    These four, which both FriCAS 1.2.6 and the most recent (compiled on
    8 Mar 2020) version 1.3.6 return unevaluated, are among the nine
    integrals posted on 6 April 2020 in this thread, and discussed
    subsequently. As announced on 9 April 2020, Waldek has already fixed
    this particular problem in the development version of FriCAS.

    Now I am curious how many from your suite of 191 integrals the next
    version of FriCAS will be able to solve beyond the 70.0% already
    achieved by version 1.2.6. As noted on 6 May 2020 in this thread, it's
    no small step from 70.0% to the 91.6% that Maple's Risch integrator is
    able to solve!

    Martin.

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