I ran the following code with no problems:
z=t+x;
pr[z_,a_,b_]:= Integrate[z^2,{x,a,b}]
pr[z,a,b]
(OK: a polynomial in a, b, and t *)
However, when I modified the function definition I got in trouble:
z=t+x;
Clear@pr; (* don't forget to do this *)
pr[z_,a_Real,b_Real]:= Integrate[z^2,{x,a,b}]
pr[z,a,b]
(* pr[t+x,a,b] *)
I tried to use Refine together with assumptions that a and b are elements of Reals to solve the problem but that did not work. I guess this was because Refine would affect the Integrate call but not the pr[z,a,b] call.
I managed to deal with this problem by creating a predicate function realQ.
Clear@pr;
realQ[a] = realQ[b] = True;
pr[z_, a_?realQ, b_?realQ] := Integrate[z^2, {x, a, b}]
pr[z, a, b]
(OK: a polynomial in a, b, and t *)
However, I would guess that Mathematica has a better way to do this? Is that the case?
Thanks for the help.
Real
, not its content!!! $\endgroup$