# Integrating function with /; in its definition

why

f[x_ /; x>=0]:=x;
Integrate[f[x] ,{x,0,2 Pi}]


return unevaluated? Notice that the above definition of f[x] works OK with other Mathematica functions, such as Plot

Plot[f[x], {x, 0, 2 Pi}]


While the following works with Integrate

f[x_]:=x;
Integrate[f[x] ,{x,0,2 Pi}]


I am using version 11.3 on windows.

• It's better to use ConditionalExpression, e.g., Integrate[ConditionalExpression[x, x>0], {x, 0, 2Pi}] – Carl Woll Mar 7 at 22:54

f[x_ /; x>=0]:=x means "if whatever>=0 rewrite f[whatever] as whatever. But that doesn't apply to f[x] when x is a symbol without a numerical value. Thus, f[x] simply remains f[x]. For abstracting the notion of a function with a break like this, use Piecewise or HeavisideTheta: Integrate understands what those mean.