Hi developers,
I am Aditya Saxena, a 2nd year ECE student at IIT BHU. I wish to contribute to the SymPy community but I am new to SymPy and so to get a better understanding of it, I was going through the tutorial as suggested in the documentation. While going through it I noticed that the Integration function is not giving out the 'constant term' in the output expression.
For example in the following code:
>>> from sympy import *>>> x = symbols('x')>>> a = Integral(cos(x)*exp(x), x)>>> Eq(a, a.doit())
we get the output as:
Eq(Integral(exp(x)*cos(x), x), exp(x)*sin(x)/2 + exp(x)*cos(x)/2)
I am certainly not a developer here - though I would love to reach the level of understanding of SymPy that would make that possible!
I looked in the online documentation (just using GOOGLE) and found this:
Note that SymPy does not include the constant of integration. If
you want it,
you can add one yourself, or rephrase your problem as a
differential equation
and use dsolve to solve it, which does add
the constant (see Solving Differential Equations).
I think the real problem is that to add a constant of integration, SymPy would have to choose a symbol to represent it, and that might already be in use. I guess if you write an indefinite integral, you are supposed to know how to use it. You can also get round the problem using a dummy limit, for example:
Integral(cos(x)*exp(x), (x,0,c))
I wondered why you wrote your example in a convoluted way - using Integral (which needs subsequent activation with doit) as opposed to integrate, which doesn't, and why you needed to use Eq. To obtain an integral simply write:
integrate(cos(x)*exp(x), x)
David