# Integrate over a piecewise function [closed]

I want to calculate the indefinite Integral of

$$f(x)=\begin{cases} 2x\cos(\frac{1}{x})& \text{ if } x\ne 0 \\ 0& \text{ if } x=0 \end{cases}.$$

I use the following code:

F[x_] := Piecewise[{0, x==0}, {2*x*Cos[1/x], x != 0}];
Integrate[Piecewise[{{0, x == 0}, {2*x*Cos[1/x], x != 0}}], x]


It doesn't evaluate. I don't know why it doesn't evaluate the piecewise function.

Maybe this is quite simple question, but it's not easy for me, a greenest amateur.

## closed as off-topic by m_goldberg, Anton Antonov, MarcoB, user9660, J. M. will be back soon♦Jul 7 '16 at 15:58

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, Anton Antonov, MarcoB, Community, J. M. will be back soon
If this question can be reworded to fit the rules in the help center, please edit the question.

• You are missing a pair of curly brackets in your Piecewise expression. Try Integrate[Piecewise[{{0, x == 0}, {2*x*Cos[1/x], x != 0}}], x] – m_goldberg Jul 7 '16 at 11:12
• @m_goldberg:Oh,I am sorry,I reedit it again.The question still remains unresolved. – Elliot Jul 7 '16 at 11:18
• Your use of Piecewise is still incorrect. Look closely at my previous comment. – m_goldberg Jul 7 '16 at 11:29

Plugging in

  F[x_] := Piecewise[{ {0, x == 0}, {2*x*Cos[1/x], x != 0}}];
Integrate[F[x], x]


Piecewise[{{2 (1/2 x^2 Cos[1/x] + 1/2 CosIntegral[1/x] -
1/2 x Sin[1/x]), x <= 0}},
I \[Pi] +
2 (1/2 x^2 Cos[1/x] + 1/2 CosIntegral[1/x] - 1/2 x Sin[1/x])]]

f = Piecewise[{{2 x Cos[1/x], x != 0}}]
Integrate[f, x, Assumptions -> x != 0] // Simplify

(* CosIntegral[1/x] + x (x Cos[1/x] - Sin[1/x]) *)