sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.38k stars 469 forks source link

call to integrate with Fricas hangs but works inside Fricas #33344

Open nasser1 opened 2 years ago

nasser1 commented 2 years ago

I think this is a new problem. I asked about it here https://ask.sagemath.org/question/61090/call-to-integrate-with-fricas-hangs-but-works-inside-fricas/ but thought to also enter a ticket on it just in case.

I noticed some calls to integrate using "fricas" algorithm (but possibly others also) hang when run from sagemath but the same integrate command works fast when run directly from Fricas on same computer.

I am running sagemath 9.5 on ArchLinux inside VBox machine. Here is an example

>which sage
/bin/sage
>which fricas
/bin/fricas
>fricas --version
FriCAS 1.3.7
based on sbcl 2.2.1
>sage --version
SageMath version 9.5, Release Date: 2022-01-30
>

Now

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.5, Release Date: 2022-01-30                     │
│ Using Python 3.10.2. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var("a b x d c e")
(a, b, x, d, c, e)
sage: integrand = x*(e *x^3 + d)/(c*x^6 + b*x^3 + a)
sage: fricas.setSimplifyDenomsFlag(fricas.true)
false
sage: anti = integrate(integrand, x, algorithm="fricas")

And the above hangs. I waited for more than 30 minutes. Now I run the same integrate inside Fricas itself, and it completes in less than 10-20 seconds. The output is very large, so I am wondering may be this is why sagemath hangs?

>fricas
Checking for foreign routines
FRICAS="/usr/lib/fricas/target/x86_64-linux-gnu"
spad-lib="/usr/lib/fricas/target/x86_64-linux-gnu/lib/libspad.so"
foreign routines found
openServer result 0
                       FriCAS Computer Algebra System 
                            Version: FriCAS 1.3.7
                 Timestamp: Fri Feb  4 01:39:20 AM CST 2022

(1) -> setSimplifyDenomsFlag(true)
(3) -> integrand := x*(e *x^3 + d)/(c*x^6 + b*x^3 + a);
(4) -> integrate(integrand, x);
                                     Type: Union(Expression(Integer),...)
(5) ->

Is there a limit on the output from integrate command and that is why it hangs?

In sagemath 9.3 this same command worked OK and did not hang. I have few others like this that now hang in 9.5

Any idea what is going on? Is this something I should file a bug report on?

Thanks --Nasser

CC: @sagetrac-tmonteil @EmmanuelCharpentier @mantepse

Component: interfaces

Keywords: symbolic, integrate, fricas

Issue created by migration from https://trac.sagemath.org/ticket/33344

7822f248-ba56-45f1-ab3d-4de7482bdf9f commented 2 years ago
comment:2

FWIW, the problem also exists when running in Sage's fricas_console().

HTH,

mantepse commented 2 years ago
comment:5

actually, I also noticed a (very likely new) communication problem between FriCAS and sage recently: https://mathoverflow.net/questions/415887/generating-function-of-the-square-of-jacobi-polynomial/415912#415912

mantepse commented 2 years ago
comment:7

I don't even know how to start debugging this. It does work without fricas.setSimplifyDenomsFlag(fricas.true).

I cannot confirm comment:2:

┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.7.beta3, Release Date: 2022-06-19               │
│ Using Python 3.10.3. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Warning: this is a prerelease version, and it may be unstable.     ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
sage: fricas.console()
Checking for foreign routines
FRICAS="/usr/local/lib/fricas/target/x86_64-linux-gnu"
spad-lib="/usr/local/lib/fricas/target/x86_64-linux-gnu/lib/libspad.so"
foreign routines found
openServer result 0
                       FriCAS Computer Algebra System 
                         Version: FriCAS 2021-03-06
                   Timestamp: Sa 25 Jun 2022 10:48:45 CEST
-----------------------------------------------------------------------------
   Issue )copyright to view copyright notices.
   Issue )summary for a summary of useful system commands.
   Issue )quit to leave FriCAS and return to shell.
-----------------------------------------------------------------------------

(1) -> setSimplifyDenomsFlag(true)

   (1)  false
                                                                Type: Boolean
(2) -> integrand := x*(e *x^3 + d)/(c*x^6 + b*x^3 + a);

                                          Type: Fraction(Polynomial(Integer))
(3) -> )time on
(3) -> integrate(x, x);

                                          Type: Polynomial(Fraction(Integer))
                           Time: 0.01 (IN) + 0.00 (EV) + 0.03 (OT) = 0.04 sec
(4) -> integrate(integrand, x);

                                         Type: Union(Expression(Integer),...)
                         Time: 0.00 (IN) + 82.89 (EV) + 0.06 (OT) = 82.95 sec
fchapoton commented 1 year ago

Changed keywords from symbolic integrate fricas to symbolic, integrate, fricas

oldk1331 commented 10 months ago

With sage-10.2 and FriCAS-1.3.9, this returns in less than 1 minute.