Maksim Surov
Maksim Surov

Reputation: 613

SymPy integration, constant term

I can't understand behavior of sympy.integrate() function. The simplest example, integrate and differentiate:

t = sy.Symbol('t')
t1 = sy.Symbol('t1')
f = sy.Function('f')(t)
I = sy.integrate(f, (t, 0, t1))
f1 = I.diff(t1)
print f1

prints the following:

f(t1) + Integral(0, (t, 0, t1))

But I expect to see just f(t). Calling f1.simplify() does not help.

Why does not sympy symplify the second term? How do I kill it?

Upvotes: 4

Views: 2006

Answers (1)

Bjoern Dahlgren
Bjoern Dahlgren

Reputation: 930

You may invoke the doit method:

>>> f1.doit()
f(t1)

I believe SymPy is reluctant to perform these operations automatically since they may be arbitrarily expensive, and there is no universal system of predicting how expensive they will be. But maybe it would be wise to add some heuristics for integrals of 0 - I don't know. If you are interested in seeing this "fixed" you might want to consider opening an issue for it at http://github.com/sympy/sympy/issues

Upvotes: 2

Related Questions