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}]

Mathematica graphics

While the following works with Integrate

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

I am using version 11.3 on windows.

  • 7
    $\begingroup$ It's better to use ConditionalExpression, e.g., Integrate[ConditionalExpression[x, x>0], {x, 0, 2Pi}] $\endgroup$ – 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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.