# symbolic integration

This post is a wiki. Anyone with karma >750 is welcome to improve it.

Hi, I am a sage-noob. To calculate the vortex sheet of a flat plate in potential flow, I have to solve some integrales of such a king:

Mathematica syntax: Integrate[Exp[-I * t * 2 * m * k]*((1/t+1)^0.5-1),t,0, Infinity]

And this is the reult:

If[Im[k m] < 0,
((0. + 0.5 I) - (0. + 0.886227 I) HypergeometricU[-0.5, 0, (2 I) k m])/km


My approach in Sagemath is:

f(x) = exp(-I*x*2*m*k)*((1/x+1)^0.5-1)
integral(f, x, 0, infinity)


But Sagemath is asking for assumptions regarding m and k. Im[k m] < 0 would be the appropriate assumption. What would be the right syntax? Thank you very much for your answers.

Best wishes, Chris

edit retag close merge delete

Sort by ยป oldest newest most voted

I would have done:

sage: var('m k')
(m, k)
sage: assume(m, 'complex')
sage: assume(k, 'complex')
sage: assume(imag_part(k*m) < 0)
sage: assumptions()
[m is complex,
k is complex,
imag_part(m)*real_part(k) + imag_part(k)*real_part(m) < 0]


but this seems not to work in your case. With decomposing a little more:

sage: var('mi mr ki kr')
(mi, mr, ki, kr)
sage: assume(mr, 'real')
sage: assume(mi, 'real')
sage: assume(kr, 'real')
sage: assume(ki, 'real')
sage: m = mr + I*mi
sage: k = kr + I*ki
sage: assume((k*m).imag_part() < 0)
sage: assumptions()
[mr is real,
mi is real,
kr is real,
ki is real,
-imag_part(kr)*imag_part(mi) - imag_part(ki)*imag_part(mr) - imag_part(mi)*real_part(ki) + imag_part(mr)*real_part(kr) - imag_part(ki)*real_part(mi) + real_part(kr)*real_part(mi) + imag_part(kr)*real_part(mr) + real_part(ki)*real_part(mr) < 0]


seems not to work either. If we replace the last assumption by:

sage: assume(ki*mr+kr*mi < 0)


it complains that some assumptions are missing, then:

sage: assume(kr>0)
sage: assume(ki>0)
sage: assume(mr>0)
sage: assume(mi<0)


at his point Maxima accepts to work with your integral but provides nothing interesting:

sage: assumptions()
[mr is real,
mi is real,
kr is real,
ki is real,
kr*mi + ki*mr < 0,
kr > 0,
mr > 0,
ki > 0,
mi < 0]
sage: integral(f, x, 0, infinity)
integrate(((1/x + 1)^0.5 - 1)*e^((2*ki - 2*I*kr)*(I*mi + mr)*x), x, 0, +Infinity)
sage: assume(kr>0)


Sorry for not helping more, it seems that Maxima is not able to solve this integral.

You can try with sympy as folows, but i do not think the result is more useful:

sage: sage: assume(m, 'complex')
sage: sage: assume(k, 'complex')
sage: sage: assume(imag_part(k*m) < 0)
sage: sympy.integrate(f, (x, 0, infinity))
Piecewise((-0.282094791773878*meijerg(((0.5,), ()), ((-1, 0), ()), 2*exp_polar(I*pi/2)*polar_lift(k)*polar_lift(m)) + I/(2*k*m), Abs(periodic_argument(exp_polar(I*pi/2)*polar_lift(k)*polar_lift(m), oo)) < pi/2), (Integral(((1 + 1/x)**0.5 - 1)*exp(-2*I*k*m*x), (x, 0, oo)), True))

more