Feeds:
Posts

## SAGE tip: Differentiation of an Integral

This morning I read a post at sage-devel group titled “Integral Functions”, and was really interesting.

For example, say you want to define a function as the primitive integral of another function,
$F(x) = \int_0^x\;f(x')\;dx'$,

sage: var('x') sage: f = function('f',x) sage: F = integral(f, x, 0, x) sage: F.derivative(x)

gives an error… Why? derivative expect all parameters of $F$ to be symbols, and zero is an integer.

## Bypass

A sort of solution to this problem is giving a whole set of parameters to the limits, say, $F(x, a, b) = \int_a^b\;dx\; f(x)$

sage: var('x,a,b') (x, a, b) sage: f = function('f',x) sage: F = integral(f, x, a, b) sage: F.derivative(x) 0 sage: F.derivative(a) -f(a) sage: F.derivative(b) f(b)

Thus, it’s well defined for any case.

If you don’t give integration limits,

sage: var('x') sage: f = function('f',x) sage: F = integral(f, x) sage: F.derivative(x) f(x)

it work as expected.

The discussion page is HERE

Enjoy!

DOX