what is exponential integral function in Fricas?

45 views
Skip to first unread message

Nasser M. Abbasi

unread,
Apr 9, 2024, 11:24:35 PM4/9/24
to FriCAS - computer algebra system
I found problem integrating many problems using sagemath calling Fricas to do the integration when using exponential integral function. These are problems from Rubi test files.

It works OK with other CAS systems supported by sagemath (Maxima and GIAC) but sagemath 10.3 does not seem to correctly translate the call to Fricas.

I am having hard time finding what the exponential integral function is called before I ask at sagemath forum. I looked at the Fricas book and do not see anything,. I tried Ei but this does not work. (i.e. does not give same answer as other cas systems).

First here is a link to the special function I am taking about



Here is a test to what values it should give for some random input. In Mathematica it gives 

ExpIntegralE[3, 5.0]
.000877801

In Maple

Ei(3,5.0)
0.0008778008928

IN sagemath 10.3

sage: exp_integral_e(3,5.0)
0.000877800892770638

But I tried Ei(3,5.0)   in Fricas and it gives error.

Here is an example, using sagemath trying to integrate. It works OK with maxima and giac but gives error with Fricas. I am using 

>fricas --version
FriCAS 1.3.10
based on sbcl 2.3.11

with sagemath 
>sage --version
SageMath version 10.3, Release Date: 2024-03-19

Starting sagemath and typing:

sage: var('x a b')
(x, a, b)

sage: integrate(exp_integral_e(1,b*x),x,algorithm="giac")
integrate(exp_integral_e(1, b*x), x)

sage: integrate(exp_integral_e(1,b*x),x,algorithm="maxima")
-exp_integral_e(2, b*x)/b

sage: integrate(exp_integral_e(1,b*x),x,algorithm="fricas")
RuntimeError                              Traceback (most recent call last)
TypeError: An error occurred when FriCAS evaluated 'exp_integral_e(((1)::EXPR INT),(b)*(x))':
   There are no library operations named exp_integral_e

So clearly sagemath did not translate the exp_integral_e to Fricas correctly.

What should the translation look like?  

Thanks
--Nasser 



Waldek Hebisch

unread,
Apr 10, 2024, 12:30:13 AM4/10/24
to 'Nasser M. Abbasi' via FriCAS - computer algebra system
On Tue, Apr 09, 2024 at 08:24:35PM -0700, 'Nasser M. Abbasi' via FriCAS - computer algebra system wrote:
> I found problem integrating many problems using sagemath calling Fricas to
> do the integration when using exponential integral function. These are
> problems from Rubi test files.
>
> It works OK with other CAS systems supported by sagemath (Maxima and GIAC)
> but sagemath 10.3 does not seem to correctly translate the call to Fricas.
>
> I am having hard time finding what the exponential integral function is
> called before I ask at sagemath forum. I looked at the Fricas book and do
> not see anything,. I tried Ei but this does not work. (i.e. does not give
> same answer as other cas systems).

Well, 'Ei' is "true exponential integral". Other systems ofer you
variants, in FriCAS it is just 'Ei'. Some variants are equivalent
to incomplete gamma function, in such case FriCAS gives you
incomplete gamma.

> First here is a link to the special function I am taking about
>
> https://reference.wolfram.com/language/ref/ExpIntegralE.html
>
> https://www.maplesoft.com/support/help/maple/view.aspx?path=Ei
>
> Here is a test to what values it should give for some random input. In
> Mathematica it gives
>
> ExpIntegralE[3, 5.0]
> .000877801
>
> In Maple
>
> Ei(3,5.0)
> 0.0008778008928
>
> IN sagemath 10.3
>
> sage: exp_integral_e(3,5.0)
> 0.000877800892770638
>
> But I tried Ei(3,5.0) in Fricas and it gives error.

'Ei' takes a single argument. If you need relations between various
functions look into Abramowitz and Stegun, FriCAS Ei is exactly as
defined in Abramowitz and Stegun.

>
> Here is an example, using sagemath trying to integrate. It works OK with
> maxima and giac but gives error with Fricas. I am using
>
> >fricas --version
> FriCAS 1.3.10
> based on sbcl 2.3.11
>
> with sagemath
> >sage --version
> SageMath version 10.3, Release Date: 2024-03-19
>
> Starting sagemath and typing:
>
> sage: var('x a b')
> (x, a, b)
>
> sage: integrate(exp_integral_e(1,b*x),x,algorithm="giac")
> integrate(exp_integral_e(1, b*x), x)
>
> sage: integrate(exp_integral_e(1,b*x),x,algorithm="maxima")
> -exp_integral_e(2, b*x)/b
>
> sage: integrate(exp_integral_e(1,b*x),x,algorithm="fricas")
> RuntimeError Traceback (most recent call last)
> TypeError: An error occurred when FriCAS evaluated
> 'exp_integral_e(((1)::EXPR INT),(b)*(x))':
> There are no library operations named exp_integral_e
>
> So clearly sagemath did not translate the exp_integral_e to Fricas
> correctly.
>
> What should the translation look like?

Maple page says:

Ei(a, z) = z^(a-1)*GAMMA(1-a, z)

In FriCAS that would be

Ei(a, z) == z^(a-1)*Gamma(1 - a, z)

I am not sure if Maple is right, example above leads to Gamma(0, x)
which is undefined.

--
Waldek Hebisch

Nasser M. Abbasi

unread,
Apr 10, 2024, 3:16:15 AM4/10/24
to FriCAS - computer algebra system

" Maple page says:

Ei(a, z) = z^(a-1)*GAMMA(1-a, z)

In FriCAS that would be

Ei(a, z) == z^(a-1)*Gamma(1 - a, z)

I am not sure if Maple is right, example above leads to Gamma(0, x)
which is undefined."


"with the exception of the point 0 in the case of 
Ei1(z)."

Ok, so the bottom line is that Fricas does not have a builtin function for the two argument version
for exponential integral function that sagemath can translate the call to.

In this case, for now, I will remove these problems (135 in total from this particular Rubi test file), because now
Fricas fails all of them since sagemath is assuming Fricas has the two argument version.

--Nasser

Martin R

unread,
Apr 10, 2024, 3:32:15 AM4/10/24
to FriCAS - computer algebra system
Given an authorative answer, it should not be hard to add that translation to the sagemath-fricas interface.  Just let me know.

Martin

Nasser M. Abbasi

unread,
Apr 10, 2024, 4:18:52 AM4/10/24
to FriCAS - computer algebra system
I am not an  authorative answer, but it seems the Maple definition for the two argument version works. I just tried it on few values and now Fricas returns same answer as Mathematica and also as Maxima called from sagemath


---sagemath---------------
var('x')
a=3
anti=integrate(exp_integral_e(a,x),x,algorithm="maxima")
anti.subs(x=3.0)
-----------------

gives

-0.00766504289993192


------- MMA ------------
anti = Integrate[ExpIntegralE[a, x], x]
anti /. {x -> 3.0, a -> 3}
-------------------

gives

-0.00766504

----- sagemath/fricas---------
sage: anti=integrate(x^(a-1)*gamma(1-a,x),x,algorithm="fricas")
sage: anti.subs(x=3.0)
--------------------

gives same

-0.00766504289993192

So the 2 argument function

            exp_integral_e(a,x)  

in sagemath can be converted to

           x^(a-1)*gamma(1-a,x)

internally when calling only fricas since fricas does not know about exp_integral_e(a,x)

It is up to the caller to insure that correct `a` value is used. But at least now Fricas will now be able to integrate all these problems using this conversion by sagemath.

Sagemath 10.3 on Linux

--Nasser

James Cloos

unread,
Apr 10, 2024, 2:10:52 PM4/10/24
to 'Nasser M. Abbasi' via FriCAS - computer algebra system
You got me curious. So I searched thru the hyperdoc and found:

ellipticE(x,y)

The doc says:

elliptibE(z,m) = integrate(sqrt(1-m*t^2)/sqrt(1-t^2),t=0..z)

so that looks right.

-JimC
--
James Cloos <cl...@jhcloos.com>
OpenPGP: https://jhcloos.com/0x997A9F17ED7DAEA6.asc
Reply all
Reply to author
Forward
0 new messages