Outlook Support Number

Outlook Support Number representatives are there to help you, so it’s important to be polite and respectful. Remember, they are people too, and they are doing their best to assist you. While the…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Symbolic Integration By Parts And Substitution With Python

How to prevent SymPy from doing more than it should

My favorite Python package for symbolic computation is SymPy. Like other computer algebra systems, it facilitates tedious computations enormously. But often, for my taste, it does too much at once! For instance, suppose you have a complicated integral to evaluate, and you plug it into SymPy, turn the crank and SymPy spits out the end result. So far so good, but maybe that’s more than you wanted! Maybe you just wanted SymPy to do a little simplification of the integral so that you know better what’s going on. A little simplification like integration by parts and substitution.

Suppose we have the following integral

If we tell SymPy to do it, then it spits out the end result:

Ok, but why square root of 𝜋? The end result is not particularly enlightening. Instead, I would like to make SymPy help me solve the integral by hand! Specifically, with the present integral, I would like to do a substitution first and see where it leads me. The substitution I want is 𝑡=√u. How can we do this with SymPy? Well, that’s easy because there is the transform method of the Integral class:

Ah, this is much better! Why? Because now I see that the integral is (up to a factor) a representation of the Gamma function:

So if we set 𝑝=3/2, the integral is

And if we ask SymPy to do this, we get

Note that I have explicitly defined 𝑝 as positive since I know it is 3/2. This allows SymPy to skip the solution branches for cases where 𝑝 may be negative or complex, which is not of interest in the present case.

So, we now know that

But using the recursion relation of the Gamma function, Γ(𝑥+1)=𝑥Γ(𝑥), we have

Add a comment

Related posts:

Desk Management Trends 2021

2021 will result in a transformation of the way we use and occupy spaces with desk management and hoteling solutions building a malleable foundation for the dynamic workplace of tomorrow. Whether…

It Takes All Kinds

If a team is only as strong as its’ weakest link, is an individual only as strong as their weakest moment? And if so, how could anyone not have empathy for weakness in others? My therapist once told…

298. Bourbon y sobremesa

Del bourbon siempre recuerdo esa exuberancia alcohólica, las notas a miel y los ahumados casi agresivos en algunos casos. De esas bebidas que no permiten la contemplación lejana e indiferente sino la…