Using Integrate to define a function

I'd like to define a function by way of the output of a definite integral with symbolic bounds. For instance, F[m_,k_] := Integrate[x,{x,m,k}] would define F[m_,k_] := (1/2)(k^2 - m^2) This seems to work fine for simple examples, but I've run into the cases where the evaluation takes much longer than the indefinite integral. For instance running

Integrate[r/((p - z)^2 + r^2)^(3/2), {z, 0, L}]

takes several minutes to compute and seems to give different output sometimes. However running the indefinite integral

Integrate[r/((p - z)^2 + r^2)^(3/2), z]

returns almost immediately. How can I use an indefinite integral to generate a function for me? I've tried syntax along the form

F[r_, z_] := Integrate[r/((p - z)^2 + r^2)^(3/2), z]
F[r, L] - F[r, 0]`

but that just takes the indefinite integral of a variable called L and runs in to trouble with the number (it outputs some integral with respect to 0).

This works much faster:

f[r_, z_, from_, to_] := (int = Integrate[r/((l - z)^2 + r^2)^(3/2), z];
Limit[int, z -> to] - Limit[int, z -> from])

sol = f[r, z, 0, L0] The reason is takes much longer when doing definite integration directly is due to assumptions. If you gives assumptions, then it will be fast also. Try this:

Assuming[Element[{l, r, L0}, Reals] && l > 0 && r > 0 && L0 > 0,
Integrate[r/((l - z)^2 + r^2)^(3/2), {z, 0, L0}]] Now it gives same result, but much faster

Simplify[% - sol]
(* 0 *)
• Thank you, I began to suspect it was because of the assumptions, but didn't know the proper syntax for including them into the integration. The limit solution is more along the lines of what I was trying to do to work around it. – Bobak Hashemi Nov 4 '14 at 3:18