code that decides whether a given integral is elementary in the wikipedia sense

17 views
Skip to first unread message

Fabian

unread,
Jan 21, 2026, 1:47:04 PM (6 days ago) Jan 21
to FriCAS - computer algebra system
Hello FriCAS group members,

I am looking for some FriCAS-code that decides whether a given integral is elementary in the sense of wikipedia (https://en.wikipedia.org/wiki/Elementary_function). For example, the error function is NOT elementary in this sense.

I have tried the following Sage-code in the SageMathCell:

from sage.interfaces.fricas import fricas
print(fricas.eval("elem?(internalIntegrate(exp(-x^2), x))"))

This produces the output ``true''. From this I conclude that elem? tests elementarity in a broader sense than that from wikipedia.

I would appreciate any help.

Fabian

PS: I am new to FriCAS.

Waldek Hebisch

unread,
Jan 21, 2026, 2:35:05 PM (6 days ago) Jan 21
to fricas...@googlegroups.com
Yes, 'elem?' really means that FriCAS can find the integral,
either elementary or not.

FriCAS may use nonelementary function in integral, but should
do so only when there is no elementary expression. So to
check that the integral is elementary you need to check if
FriCAS result is an elementary function. The following
should do this

elem_ker(k) ==
symbolIfCan(k) case Symbol or (
op := operator(k); has?(op, 'elem) or has?(op, '%alg))

elem_expr(ex) == reduce(_and, [elem_ker(k) for k in tower(ex)])

A little explanation: FriCAS expression is a rational function
of kernels. Kernels may be variables, constants, algebraic
expressions or application of functions to arguments. To
check that expression is elementary you need to check that
each kernel contained in it (directly or indirectly) is elementary.
'tower' gives you appropriate list of kerenls. 'elem_ker'
above checks if kernel is elementary looking at 3 possible cases:
'symbolIfCan' checks for variables and constants, 'has?(op, 'elem)'
checks for elementary transcendental functions, 'has?(op, '%alg)'
checks for algebraic expressions.

Note: there are cases which FriCAS currently can not decide,
in such cases intead of returning a result FriCAS throws an
error.

--
Waldek Hebisch

Fabian

unread,
Jan 23, 2026, 11:35:18 AM (4 days ago) Jan 23
to FriCAS - computer algebra system

Hello Waldek,

Thank you very much for your prompt answer! I have tried out your code. It appears to work.

Fabian
Reply all
Reply to author
Forward
0 new messages