strange result from integrate when changing setSimplifyDenomsFlag(true)

5 views
Skip to first unread message

Nasser M. Abbasi

unread,
Aug 8, 2023, 7:06:20 PM8/8/23
to FriCAS - computer algebra system
I can't understand this behavior of 1.3.9. Starting with fresh session, it seems the result one time works, and another time fails, using same exact command. Sometimes trying twice it works.

>fricas --version
FriCAS 1.3.9
based on sbcl 2.3.0

--------------------------------------------------------
1) -> unparse(integrate((2+3*x)/(2^(2/3)-x)/(x^3-1)^(1/2),x)::InputForm)
 
   >> Error detected within library code:
   catdef: division by zero

(1) -> unparse(integrate((2+3*x)/(2^(2/3)-x)/(x^3-1)^(1/2),x)::InputForm)
"...57042834961904521699968)*3^(1/2))""

(2) -> unparse(integrate((2+3*x)/(2^(2/3)-x)/(x^3-1)^(1/2),x)::InputForm)
 
   >> Error detected within library code:
   catdef: division by zero

------------------------------------------------------------------------------

Here is another fresh session, but now I set setSimplifyDenomsFlag(true)
before anything

1) -> setSimplifyDenomsFlag(true)

   (1)  false
                                                                Type: Boolean
(2) ->  unparse(integrate((2+3*x)/(2^(2/3)-x)/(x^3-1)^(1/2),x)::InputForm)

   (2)
  "(3^(1/2)*(12*(2^(1/3))^2+18*2^(1/3)+4)^(1/2)*log((((18*x^16+(-102)*x^15+252*
  x^14+5580*x^13+(-6348)*x^12+5328*x^11+41976*x^10+(-15168)*x^9+(-47808)*x^7+32
  448*x^6+(-9216)*x^5+(-4608)*x^4+(-15360)*x^3+4608*x^2+9216*x+3072)*(2^(1/3))^
  2+(4*x^16+306*x^15+(-756)*x^14+1240*x^13+19044*x^12+(-15984)*x^11+9328*x^10+4
  5504*x^9+(-10624)*x^7+(-97344)*x^6+27648*x^5+(-1024)*x^4+46080*x^3+(-13824)*x
  ^2+2048*x+(-9216))*2^(1/3)+((-12)*x^16+68*x^15+2268*x^14+(-3720)*x^13+4232*x^
  12+47952*x^11+(-27984)*x^10+10112*x^9+31872*x^7+(-21632)*x^6+(-82944)*x^5+307
  2*x^4+10240*x^3+41472*x^2+(-6144)*x+(-2048)))*3^(1/2)*(x^3+(-1))^(1/2)*(12*(2
  ^(1/3))^2+18*2^(1/3)+4)^(1/2)+((696*x^17+84216*x^14+332688*x^11+(-796224)*x^8
  +423168*x^5+(-44544)*x^2)*(2^(1/3))^2+(6960*x^16+244992*x^13+115536*x^10+(-94
  6560)*x^7+757248*x^4+(-178176)*x)*2^(1/3)+(29*x^18+41760*x^15+504600*x^12+(-6
  10624)*x^9+(-300672)*x^6+445440*x^3+(-59392))))/(x^18+(-24)*x^15+240*x^12+(-1
  280)*x^9+3840*x^6+(-6144)*x^3+4096))+(24*2^(1/3)+(-36))*weierstrassPInverse(0
  ,4,x))/18"

(3) ->  unparse(integrate((2+3*x)/(2^(2/3)-x)/(x^3-1)^(1/2),x)::InputForm)

   (3)
  "(3^(1/2)*(12*(2^(1/3))^2+18*2^(1/3)+4)^(1/2)*log((((18*x^16+(-102)*x^15+252*
  x^14+5580*x^13+(-6348)*x^12+5328*x^11+41976*x^10+(-15168)*x^9+(-47808)*x^7+32
  448*x^6+(-9216)*x^5+(-4608)*x^4+(-15360)*x^3+4608*x^2+9216*x+3072)*(2^(1/3))^
  2+(4*x^16+306*x^15+(-756)*x^14+1240*x^13+19044*x^12+(-15984)*x^11+9328*x^10+4
  5504*x^9+(-10624)*x^7+(-97344)*x^6+27648*x^5+(-1024)*x^4+46080*x^3+(-13824)*x
  ^2+2048*x+(-9216))*2^(1/3)+((-12)*x^16+68*x^15+2268*x^14+(-3720)*x^13+4232*x^
  12+47952*x^11+(-27984)*x^10+10112*x^9+31872*x^7+(-21632)*x^6+(-82944)*x^5+307
  2*x^4+10240*x^3+41472*x^2+(-6144)*x+(-2048)))*3^(1/2)*(x^3+(-1))^(1/2)*(12*(2
  ^(1/3))^2+18*2^(1/3)+4)^(1/2)+((696*x^17+84216*x^14+332688*x^11+(-796224)*x^8
  +423168*x^5+(-44544)*x^2)*(2^(1/3))^2+(6960*x^16+244992*x^13+115536*x^10+(-94
  6560)*x^7+757248*x^4+(-178176)*x)*2^(1/3)+(29*x^18+41760*x^15+504600*x^12+(-6
  10624)*x^9+(-300672)*x^6+445440*x^3+(-59392))))/(x^18+(-24)*x^15+240*x^12+(-1
  280)*x^9+3840*x^6+(-6144)*x^3+4096))+(24*2^(1/3)+(-36))*weierstrassPInverse(0
  ,4,x))/18"
                                                                 Type: String
(4) ->  unparse(integrate((2+3*x)/(2^(2/3)-x)/(x^3-1)^(1/2),x)::InputForm)
 
   >> Error detected within library code:
   catdef: division by zero

(4) ->

----------------------------------------------------

So you see, it seems Fricas does not always generate same result. It seems random to me. There many such integrals that generate division by zero, but it seems if one tries again it can work. Here is current list of integrals that show this problem. So I am not sure if trying again in the test program will solve this or not.

----------------------------------------------------------------
sqlite> select command_in_fricas from main where fricas_anti LIKE '%catdef: division by zero%';

integrate((1-2^(1/3)*x)/(2^(2/3)+x)/(x^3+1)^(1/2),x, algorithm="fricas")
integrate(1/(2^(2/3)-x)/(x^3-1)^(1/2),x, algorithm="fricas")
integrate(1/(2^(2/3)+x)/(-x^3-1)^(1/2),x, algorithm="fricas")
integrate((2+3*x)/(2^(2/3)-x)/(x^3-1)^(1/2),x, algorithm="fricas")
integrate((1+x+3^(1/2))/(d*x+c)/(-x^3-1)^(1/2),x, algorithm="fricas")
integrate((1+x-3^(1/2))/(d*x+c)/(-x^3-1)^(1/2),x, algorithm="fricas")
integrate(1/(e*cos(d*x+c))^(5/2)/(a+b*sin(d*x+c))^2,x, algorithm="fricas")
integrate((e*cos(d*x+c))^(11/2)/(a+b*sin(d*x+c))^4,x, algorithm="fricas")
integrate(1/(a+b*sin(d*x+c))^4/(e*cos(d*x+c))^(1/2),x, algorithm="fricas")
integrate(1/(-1+cos(x)^2)^(1/2),x, algorithm="fricas")
integrate(1/(-1+cos(x)^2)^(3/2),x, algorithm="fricas")
integrate((d*sec(f*x+e))^(3/2)/(a+b*tan(f*x+e)),x, algorithm="fricas")
integrate((d*sec(f*x+e))^(5/2)/(a+b*tan(f*x+e))^2,x, algorithm="fricas")
integrate(tan(d*x+c)^(2/3)*(a+I*a*tan(d*x+c))^(1/2),x, algorithm="fricas")
integrate(tan(d*x+c)^(1/3)*(a+I*a*tan(d*x+c))^(1/2),x, algorithm="fricas")
integrate((a+I*a*tan(d*x+c))^(1/2)/tan(d*x+c)^(4/3),x, algorithm="fricas")
---------------------------------------------------

Question is: Whey Fricas gives different result for same command? 

--Nasser


  
           








Nasser M. Abbasi

unread,
Aug 8, 2023, 11:04:26 PM8/8/23
to FriCAS - computer algebra system
FYI,

I did not know Fricas now has a github issues page. So I entered the above there

Waldek Hebisch

unread,
Aug 9, 2023, 5:39:35 AM8/9/23
to 'Nasser M. Abbasi' via FriCAS - computer algebra system
On Tue, Aug 08, 2023 at 04:06:20PM -0700, 'Nasser M. Abbasi' via FriCAS - computer algebra system wrote:
> I can't understand this behavior of 1.3.9. Starting with fresh session, it
> seems the result one time works, and another time fails, using same exact
> command. Sometimes trying twice it works.
>
> >fricas --version
> FriCAS 1.3.9
> based on sbcl 2.3.0
>
> --------------------------------------------------------
> 1) -> unparse(integrate((2+3*x)/(2^(2/3)-x)/(x^3-1)^(1/2),x)::InputForm)
>
> >> Error detected within library code:
> catdef: division by zero
<snip>
>
> So you see, it seems Fricas does not always generate same result. It seems
> random to me. There many such integrals that generate division by zero, but
> it seems if one tries again it can work.

This is an old problem. FriCAS uses (pseudo)random numbers. In case
above FriCAS evaluates several rational functions at a random point.
If any of denominators evaluates to 0, then we get error as above.

This part probably should be rewritten, but correct code is going
to be much more complicated than current code.

--
Waldek Hebisch
Reply all
Reply to author
Forward
0 new messages