integral fail using fricas 1.3.11 using sagemath 10.5 but works with fricas

174 views
Skip to first unread message

Nasser M. Abbasi

unread,
Jan 10, 2025, 2:50:25 PMJan 10
to sage-devel
I have installed sagemath 10.5 and also fricas 1.3.11, all using pacman package manager on EOS/Arch based linux.

i.e. I did not build sagemath 10.5 from sources. 

I was trying this integration, where it works using Fricas directly, but when I use sagemath and give the algorithm as "fricas", it does not return the same result as Fricas does standalone. It returns unevaluated.

Since sagemath is now using the system fricas, then why it does not return the same result for same input?

----------------------------------
>fricas
FRICAS="/usr/lib/fricas/target/x86_64-linux-gnu"
spad-lib="/usr/lib/fricas/target/x86_64-linux-gnu//lib/libspad.so"
                      FriCAS Computer Algebra System  
               Version: FriCAS 1.3.11 built with sbcl 2.4.5

(1) -> integrand:=(dilog(-x + 1)^2 - log(-x + 1)*polylog(3, x))/x

(2) -> integrate( integrand,x)

  (2)  dilog(- x + 1)polylog(3,x)
---------------------------

Now using sagemath

-----------------
>which sage
/usr/bin/sage
>sage --version
SageMath version 10.5, Release Date: 2024-12-04
>which fricas
/usr/bin/fricas
>fricas --version
FriCAS 1.3.11
based on sbcl 2.4.5
>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 10.5, Release Date: 2024-12-04                    │
│ Using Python 3.13.1. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage:  print(fricas.eval(")lisp |$build_version|"))
Value = "FriCAS 1.3.11"


sage: x=var('x')
sage: integrand=(dilog(-x + 1)^2 - log(-x + 1)*polylog(3, x))/x

sage: integrate(integrand,x,algorithm="fricas")

integral((dilog(-x + 1)^2 - log(-x + 1)*polylog(3, x))/x, x)

I checked and Sagemath supports dilog and polylog functions.

So what is the problem? Did I do something wrong? 

Thanks
--Nasser

dmo...@deductivepress.ca

unread,
Jan 10, 2025, 3:45:38 PMJan 10
to sage-devel
The questions "what is the problem? Did I do something wrong?" do not seem to be sage development questions, so they should be asked on a different forum, such as ask.sagemath.org

Martin R

unread,
Jan 10, 2025, 4:36:39 PMJan 10
to sage-devel
fricas dilog and sage dilog are not the same:

sage: fricas(polylog(3, x))
polylog(3,x)
sage: fricas(dilog(x))
dilog(- x + 1)


sage: integrand=(dilog(-x + 1)^2 - log(-x + 1)*polylog(3, x))/x
sage: fricas(integrand)
                                     2
- log(- x + 1)polylog(3,x) + dilog(x)
--------------------------------------
                   x
sage: integrate(integrand, x, algorithm="fricas")

integral((dilog(-x + 1)^2 - log(-x + 1)*polylog(3, x))/x, x)


sage: good_integrand = (dilog(x)^2 - log(-x + 1)*polylog(3, x))/x
sage: fricas(good_integrand)
                                           2
- log(- x + 1)polylog(3,x) + dilog(- x + 1)
--------------------------------------------
                      x
sage: integrate(good_integrand, x, algorithm="fricas")
dilog(x)*polylog(3, x)

Martin

Emmanuel Charpentier

unread,
Jan 12, 2025, 6:55:26 AMJan 12
to sage-devel

Le vendredi 10 janvier 2025 à 22:36:39 UTC+1, axio…@yahoo.de a écrit :

fricas dilog and sage dilog are not the same:

sage: fricas(polylog(3, x))
polylog(3,x)
sage: fricas(dilog(x))
dilog(- x + 1)

This deserves a github issue. Fixing the interface is (probably) not that hard… Would you mind issuing this ?

Note : the problem may be deeper than this :

sage: w0=SR.wild(0) sage: integrand.subs(dilog(w0)==dilog(1-w0)).integrate(x, algorithm="fricas").su ....: bs(dilog(w0)==dilog(1-w0)) integral((dilog(x)^2 - log(-x + 1)*polylog(3, x))/x, x)

sage: integrand=(dilog(-x + 1)^2 - log(-x + 1)*polylog(3, x))/x
sage: fricas(integrand)
                                     2
- log(- x + 1)polylog(3,x) + dilog(x)
--------------------------------------
                   x
sage: integrate(integrand, x, algorithm="fricas")

integral((dilog(-x + 1)^2 - log(-x + 1)*polylog(3, x))/x, x)


sage: good_integrand = (dilog(x)^2 - log(-x + 1)*polylog(3, x))/x
sage: fricas(good_integrand)
                                           2
- log(- x + 1)polylog(3,x) + dilog(- x + 1)
--------------------------------------------
                      x
sage: integrate(good_integrand, x, algorithm="fricas")
dilog(x)*polylog(3, x)

FWIW :

sage: fricas("integrand:=(dilog(-x + 1)^2 - log(-x + 1)*polylog(3, x))/x") 2 - log(- x + 1)polylog(3,x) + dilog(- x + 1) -------------------------------------------- x sage: fricas("integrate( integrand,x)") dilog(- x + 1)polylog(3,x) sage: fricas("integrate( integrand,x)")._sage_() dilog(x)*polylog(3, x)

HTH,

Martin R

unread,
Jan 12, 2025, 8:25:54 AMJan 12
to sage-devel
Sorry, I don't understand.

On Sunday, 12 January 2025 at 12:55:26 UTC+1 emanuel.c...@gmail.com wrote:

Le vendredi 10 janvier 2025 à 22:36:39 UTC+1, axio…@yahoo.de a écrit :

fricas dilog and sage dilog are not the same:

sage: fricas(polylog(3, x))
polylog(3,x)
sage: fricas(dilog(x))
dilog(- x + 1)

This deserves a github issue. Fixing the interface is (probably) not that hard… Would you mind issuing this ?


I don't understand what you mean with "fixing the interface".  The definitions of dilog in FriCAS and SageMath differ:

sage: dilog(1.0)
1.64493406684823
sage: fricas.dilog(0.0)
1.6449340668_4822643647_24152

(this is pi^2/6)

The translation of dilog done by the interface is (hopefully) correct.  So, the only thing that we could do is to change SageMath's definition.

If I understand correctly, the definition of polylog is the same in FriCAS and SageMath.

Martin

Emmanuel Charpentier

unread,
Jan 14, 2025, 1:20:33 AMJan 14
to sage-devel

Dear Martin,

Le dimanche 12 janvier 2025 à 14:25:54 UTC+1, axio…@yahoo.de a écrit :

Sorry, I don't understand.

On Sunday, 12 January 2025 at 12:55:26 UTC+1 emanuel.c...@gmail.com wrote:

Le vendredi 10 janvier 2025 à 22:36:39 UTC+1, axio…@yahoo.de a écrit :

fricas dilog and sage dilog are not the same:

That’s my point. See below.

sage: fricas(polylog(3, x))
polylog(3,x)
sage: fricas(dilog(x))
dilog(- x + 1)

This deserves a github issue. Fixing the interface is (probably) not that hard… Would you mind issuing this ?


I don't understand what you mean with "fixing the interface".  The definitions of dilog in FriCAS and SageMath differ:

sage: dilog(1.0)
1.64493406684823
sage: fricas.dilog(0.0)
1.6449340668_4822643647_24152

(this is pi^2/6)

The translation of dilog done by the interface is (hopefully) correct.  So, the only thing that we could do is to change SageMath's definition.

Nope. From what you say follows that Sage’s dilog(x) and Fricas’ dilog(1-x) are the same mathematical object. Therefore, the Fricas translation of Sage’s dilog(<something>) should be dilog(1-<something>). And vice-versa : the Sage’s translation of Fricas’ dilog(<something>) should be Sage’s dilog(1-<something>).

This can (and should, IMNSHO) be made in the interface.

HTH,

Martin R

unread,
Jan 14, 2025, 1:06:10 PMJan 14
to sage-devel

Nope. From what you say follows that Sage’s dilog(x) and Fricas’ dilog(1-x) are the same mathematical object. Therefore, the Fricas translation of Sage’s dilog(<something>) should be dilog(1-<something>). And vice-versa : the Sage’s translation of Fricas’ dilog(<something>) should be Sage’s dilog(1-<something>).

That's precisely what the FriCAS-SageMath interface currently does.

Martin

dmo...@deductivepress.ca

unread,
Jan 14, 2025, 10:04:14 PMJan 14
to sage-devel
Let's end this thread.  

To sum up, there is no evidence of a problem with sage (or its interface with fricas), because the report was based on the false assumption that typing "dilog(-x + 1)" in fricas means the same thing as typing it in sage.  However, in reality, telling dilog(-x + 1) to fricas is the same as telling dilog(x) to sage. Thus, the integral done in fricas translates to the following in sage:

sage: integrand=(dilog(x)^2 - log(-x + 1)*polylog(3, x))/x
sage: integrate(integrand,x,algorithm="fricas")
dilog(x)*polylog(3, x)

After converting back to fricas, this is the same answer that was obtained by using fricas directly. 
Reply all
Reply to author
Forward
0 new messages