2
$\begingroup$

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.

$\endgroup$
3
  • 1
    $\begingroup$ 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] $\endgroup$
    – m_goldberg
    Commented Jul 7, 2016 at 11:12
  • $\begingroup$ @m_goldberg:Oh,I am sorry,I reedit it again.The question still remains unresolved. $\endgroup$
    – Elliot
    Commented Jul 7, 2016 at 11:18
  • $\begingroup$ Your use of Piecewise is still incorrect. Look closely at my previous comment. $\endgroup$
    – m_goldberg
    Commented Jul 7, 2016 at 11:29

2 Answers 2

2
$\begingroup$

Plugging in

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

leads to the output

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])]]
$\endgroup$
0
1
$\begingroup$
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]) *)
$\endgroup$

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