# Unable to Integrate function

I have a function and am able to integrate it just fine in Mathematica, but get the below error when trying to perform the integral in sagemath.

TypeError: Substitution using function-call syntax and unnamed arguments has been removed. You can use named arguments instead, like EXPR(x=..., y=...)

I will try and comment my Mathematica code and output because I don't have enough karma to post a link.

My sagemath code is below. I tried printing out a few different ways to integrate but never got a way that didn't give a depreciation error.



from sage.symbolic.integration.integral import indefinite_integral

a = var('a')

z = var('z')

q = var('q')

r = var('r')

R = var('R')

s = var('s')

f = (4/(a^3)((zq^2)/r-(zq^2)/rexp(-s(r-R)))r^2exp(-2r/a))

print(indefinite_integral(f,r,R,+Infinity))

print(integrate(f,(r,R,+Infinity)))

print(numerical_integral(f, 0, +Infinity))

print(f.integrate(r))



edit retag close merge delete

Here is the Mathematica code.

( 2022-10-14 02:49:52 +0200 )edit

Could you rewrite your f by putting * where multiplication is needed? (z*q instead of zq, etc.)

( 2022-10-14 12:10:06 +0200 )edit
1

Following @tolga hint, can you confirm that f is $$-\frac{4 \, {\left(\frac{q^{2} z e^{\left({\left(R - r\right)} s\right)}}{r} - \frac{q^{2} z}{r}\right)} r^{2} e^{\left(-\frac{2 \, r}{a}\right)}}{a^{3}}$$ , as suggested by your typing ?

( 2022-10-14 14:49:43 +0200 )edit

Sort by ยป oldest newest most voted

If all parameters are positive, there are no problems with integrate

a, z, q, r, R, s = var("a, z, q, r, R, s")
assume(a>0);assume(R>0);assume(r>0)
assume(s>0);assume(z>0);assume(q>0)
Ex = (4/(a^3)*((z*q^2)/r-(z*q^2)/r*exp(-s*(r-R)))*r^2*exp(-2*r/a))
Im = integrate(Ex,(r,R,oo))
factor(Im)

more

Assuming that your integrand is :

a, z, q, r, R, s = var("a, z, q, r, R, s")
Ex = (4/(a^3)*((z*q^2)/r-(z*q^2)/r*exp(-s*(r-R)))*r^2*exp(-2*r/a))


i.e. : $$\texttt{Ex}=-\frac{4 {\left(\frac{q^{2} z e^{\left({\left(R - r\right)} s\right)}}{r} - \frac{q^{2} z}{r}\right)} r^{2} e^{\left(-\frac{2 \, r}{a}\right)}}{a^{3}}$$

neither giac, fricas nor sympy can give a closed-form expression to this integral ; using maxima leads to a situation where the same asumptions are queried in loop.

However, mathematica (or the gratis (but not free) Wolfram engine) gives an answer :

sage: Im = mathematica.Integrate(Ex, (r, R, oo)) ; Im
ConditionalExpression[(q^2*s*(4*(a + R) + a*(a + 2*R)*s)*z)/
(a*E^((2*R)/a)*(2 + a*s)^2), Re[a] > 0 && Re[2/a + s] > 0]


which can be manually ang roughly (for now) translated as Im[1].sage() if a.real()>0 and (2/a+s).real()>0 else None.

This situation could be quite enhanced if/when logical symbolic functions are added to Sage (work in progress...).

Note : The difficulty does not lies in the computation of an antiderivative (all engines can do that), but in the computation of the limits for r=oo...

HTH,

more