bug report: integrate(acos(x^2), x) returns incorrect antiderivative (FriCAS 1.3.12)

12 views
Skip to first unread message

Fabian

unread,
Jan 27, 2026, 12:42:53 PM (24 hours ago) Jan 27
to FriCAS - computer algebra system
Hello FriCAS group,

It looks like I found a bug in FriCAS:
F:=integrate(acos(x^2),x)
gives:
      +--------+
     |   4         2      2
- 2 \|- x  + 1  + x acos(x )
----------------------------
              x

D(F,x)-acos(x^2)
gives the following instead of 0:
       2
-------------
   +--------+
 2 |   4
x \|- x  + 1

I use FriCAS via https://sagecell.sagemath.org/ . Here is some Sage-code that produces the above output:

from sage.interfaces.fricas import fricas
fricas.eval(
    "F:=integrate(acos(x^2),x)"
)
print("F=\n",fricas("F"))
fricas.eval("f:=D(F,x)-acos(x^2)")
print("F'-acos(x^2)=\n",fricas("f"))

The FriCAS version is 1.3.12. (print(fricas.eval(")lisp |$build_version|") tells me this.)

The SageMath version is 10.8, Release Date: 2025-12-18. (version() tells me this.)

Fabian

Dima Pasechnik

unread,
Jan 27, 2026, 12:52:13 PM (24 hours ago) Jan 27
to fricas...@googlegroups.com
I can add that I can repeat this at Fricas prompt, it has nothing to
do with Sage per se.
It's for me on Gentoo Linux, with

$ fricas
Checking for foreign routines
FRICAS="/usr/lib64/fricas/target/x86_64-pc-linux-gnu"
spad-lib="/usr/lib64/fricas/target/x86_64-pc-linux-gnu/lib/libspad.so"
foreign routines found
openServer result 0
FriCAS Computer Algebra System
Version: FriCAS 1.3.12 built with sbcl 2.5.11
Timestamp: Thu Dec 11 00:10:42 CST 2025
> --
> You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/fricas-devel/e5fde980-d9d7-4e5d-9fb9-d1cc5c45c021n%40googlegroups.com.

Fabian

unread,
Jan 27, 2026, 1:25:33 PM (23 hours ago) Jan 27
to FriCAS - computer algebra system
Hello Dima,

This was a fast reply!

Fabian
Message has been deleted

Kurt Pagani

unread,
Jan 27, 2026, 5:28:35 PM (19 hours ago) Jan 27
to FriCAS - computer algebra system
The integral cannot be expressed in terms of elementary functions. When you take 'complexIntegrate' it should work, although Google KI says that it requires the Hypergeometric function [2]F[1] to evaluate the second integral "integrate(x^2/sqrt(1-x^4),x)" which is left after partial integration, so *no* guarantees if (1) below is correct 😉 However, I think it is ...

To verify the result below, one has also to use the
fact that

acos(x) = -%i * log(x+sqrt(x^2-1)) holds.


(1) -> complexIntegrate(acos(x^2),x)

   (1)
                      +------+
                      | 4         2             +------+
        2 +---+    - \|x  - 1  - x        +---+ | 4
       x \|- 1 log(----------------) - 4 \|- 1 \|x  - 1
                     +------+
                     | 4         2
                    \|x  - 1  - x
     +
           +---+          1            +---+          1
       4 x\|- 1 ellipticF(-,- 1) - 4 x\|- 1 ellipticE(-,- 1)
                          x                           x
  /
     2 x
                                                    Type: Expression(Integer)

Qian Yun

unread,
Jan 27, 2026, 9:09:02 PM (15 hours ago) Jan 27
to fricas...@googlegroups.com
Thanks for the report.

Git bisect points to
https://github.com/fricas/fricas/commit/1f42999f91ce516a8d027a61be4ecbf32ad2ada4

"Handle some elliptic integrals", June 14, 2022.
(Between 1.3.7 and 1.3.8)

Before this commit, the result is a integral sign
which means fricas proves it does not have elemental
integral, which is correct.

- Best,
- Qian
> --
> You received this message because you are subscribed to the Google
> Groups "FriCAS - computer algebra system" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to fricas-devel...@googlegroups.com <mailto:fricas-
> devel+un...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/fricas-
> devel/e5fde980-d9d7-4e5d-9fb9-d1cc5c45c021n%40googlegroups.com <https://
> groups.google.com/d/msgid/fricas-devel/e5fde980-d9d7-4e5d-9fb9-
> d1cc5c45c021n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Waldek Hebisch

unread,
Jan 27, 2026, 9:33:46 PM (15 hours ago) Jan 27
to fricas...@googlegroups.com
On Wed, Jan 28, 2026 at 10:09:14AM +0800, Qian Yun wrote:
> Thanks for the report.
>
> Git bisect points to
> https://github.com/fricas/fricas/commit/1f42999f91ce516a8d027a61be4ecbf32ad2ada4
>
> "Handle some elliptic integrals", June 14, 2022.
> (Between 1.3.7 and 1.3.8)
>
> Before this commit, the result is a integral sign
> which means fricas proves it does not have elemental
> integral, which is correct.

The reason is that transformations used in postprocessing result
of integration may incorrectly transform elliptic integrals to
0.
> To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/fricas-devel/e34f4198-37cd-463a-9c65-fba93aa7f97f%40gmail.com.

--
Waldek Hebisch

Fabian

unread,
3:11 AM (9 hours ago) 3:11 AM
to FriCAS - computer algebra system
Hello FriCAS group,

Thank you Kurt, Qian, and Waldek for your prompt replies. I have tried out the suggestion by Kurt to use complexIntegrate. The following check indicates that this does not work for acos(x^2):


from sage.interfaces.fricas import fricas
fricas.eval(
    "f:=acos(x^2);"
    "F:=complexIntegrate(f,x);"
)
print(fricas("complexNumeric(eval(D(F,x)-f,x=1/2))"))

This produces the output - 2.63..., which is not close to desired value 0.

Fabian

Kurt Pagani

unread,
6:04 AM (6 hours ago) 6:04 AM
to FriCAS - computer algebra system
This is strange because I get:

I:=complexIntegrate(acos(x^2),x);
J:=complexNormalize(D(I,x)-acos(x^2));
complexNumeric eval(J,x=1/2) --> .. E-20


tst(z) == complexNumericIfCan eval(J,x=z) --> ~0 for most z ;)

There must be another issue (eval doesn't commute wiht complexNormalize):

complexNumeric complexNormalize(eval(D(I,x)-acos(x^2),x=1/2)) -->  - 2.6362321433 - 0.7 E -20 %i

complexNumeric eval(complexNormalize(D(I,x)-acos(x^2)),x=1/2) --> - 0.1866265314 E -20 - 0.7228014483 E -20 %i

By the way, the result of complexIntegrate(acos(x^2),x) seems to be correct, at least in fricas.

Using the log repr of acos,  D(I,x)-acos(x^2) reads:

R:=normalize (D(I,x)+%i*log(x^2+%i*sqrt(1-x^4)));
real R --> 0
imag numer R --> 0 (after a manual subst).

Fabian

unread,
8:10 AM (4 hours ago) 8:10 AM
to FriCAS - computer algebra system
Kurt: complexNumeric eval(J,x=1/2) also gives approximately 0, when I include your code in a Sage code and run it in the SageMathCell. With I:=complexIntegrate(acos(x^2),x) the following line gives almost 0:
complexNumeric eval(D(I,x)+acos(x^2),x=1/2)
This suggests that D(I,x)=-acos(x^2) . This differs from the correct expression acos(x^2) by a sign. I suspect that the mistake comes from choosing wrong branches of the logarithm and square root function.

Fabian

Kurt Pagani

unread,
8:51 AM (4 hours ago) 8:51 AM
to FriCAS - computer algebra system
On Wednesday, 28 January 2026 at 14:10:53 UTC+1 Fabian wrote:
Kurt: complexNumeric eval(J,x=1/2) also gives approximately 0, when I include your code in a Sage code and run it in the SageMathCell. With I:=complexIntegrate(acos(x^2),x) the following line gives almost 0:
complexNumeric eval(D(I,x)+acos(x^2),x=1/2)
This suggests that D(I,x)=-acos(x^2) . This differs from the correct expression acos(x^2) by a sign. I suspect that the mistake comes from choosing wrong branches of the logarithm and square root function.

This might explain it, however the culprit must be 'eval' since the lines below ~prove that D(F,x)=f=acos(x^2)  holds.


                       FriCAS Computer Algebra System
         Version: FriCAS 2025.12.23git built with sbcl 2.2.9.debian
                   Timestamp: Fri  9 Jan 20:25:59 CET 2026
-----------------------------------------------------------------------------
   Issue )copyright to view copyright notices.
   Issue )summary for a summary of useful system commands.
   Issue )quit to leave FriCAS and return to shell.
-----------------------------------------------------------------------------

   Function declaration sixel : TexFormat -> Void has been added to
      workspace.
   Function declaration lisp : String -> SExpression has been added to
      workspace.
f:=acos(x^2);


                                                    Type: Expression(Integer)
F:=complexIntegrate(f,x);


                                                    Type: Expression(Integer)
R:=complexNormalize(D(F,x)-f);


                                                    Type: Expression(Integer)

real R --> 0


   (14)  0
                                                    Type: Expression(Integer)

c:=numer imag R ;


      Type: SparseMultivariatePolynomial(Integer,Kernel(Expression(Integer)))


subst(c, sqrt(x^4-1)=sqrt(x^2+1)*sqrt(x^2-1) ) --> 0


   (16)  0
                                                    Type: Expression(Integer)
(17) ->

 

Fabian


Reply all
Reply to author
Forward
0 new messages