Ask Your Question

Revision history [back]

If you do

sage: f(x)=1/(1-x**2)
sage: g(x)=f.integrate(x)
sage: g(0.5)

why should you expect anything at all? g(x) is only defined up to a constant summand, so g(0.5) could be literally anything. Perhaps you should do

sage: g(0.5) - g(0.0)

Note that since the integrand is undefined when x is 1 or -1, it should not be a surprise that

sage: g(1.5) - g(0.5)

returns something that is not real.

Alternatively, you can do this:

sage: g(x) = f.integrate(x)
sage: h(x) = g(x) - g(0.0)  # h is the integral of f from 0 to x
sage: h(0.5)
0.549306144334055

or

sage: var('t')
sage: h(t) = f.integrate(x, 0, t)

At this point Sage complains, so you can tell it

sage: assume(t>0)

and then (since it still complains if you do f.integrate(x, 0, t)):

sage: assume(t<1)
sage: h(t) = f.integrate(x, 0, t)
sage: h(0.5)