We have f(x)=∣x−1∣cos∣x−2∣sin∣x−1∣+(x−3)∣x2−5x+4∣. We note that x2−5x+4=(x−1)(x−4), so the critical points to examine for differentiability are x=1,2,3, and 4.
At x=2: Near x=2, we have ∣x−1∣=x−1 (smooth) and sin∣x−1∣=sin(x−1) (smooth). Also, cos∣x−2∣=cos(∣x−2∣), and since cosine is an even function, cos∣x−2∣=cos(x−2), which is differentiable. For the second term, x2−5x+4<0 near x=2, so ∣x2−5x+4∣=−(x2−5x+4), a polynomial. Hence f is differentiable at x=2.
At x=3: Near x=3, ∣x−1∣=x−1 and ∣x−2∣=x−2 are both smooth. Also x2−5x+4<0 near x=3 (since 9−15+4=−2), so ∣x2−5x+4∣=−(x2−5x+4), again a polynomial. Hence f is differentiable at x=3.
At x=1: The first term is ∣x−1∣cos∣x−2∣sin∣x−1∣. Near x=1, ∣x−1∣sin∣x−1∣≈(x−1)2 (since sin∣x−1∣/∣x−1∣→1), which is smooth with derivative 0 at x=1. So the first term is differentiable at x=1.
The second term is (x−3)∣(x−1)(x−4)∣=(x−3)(4−x)∣x−1∣ near x=1 (since x−4<0). For x>1: this equals (x−3)(4−x)(x−1), with derivative at x=1: evaluating from the expansion, we get (−2)(3)(1)=−6... more precisely, we compute the derivative of g(x)=(x−3)(4−x)(x−1) at x=1: g′(x) at x=1 equals (4−x)(x−1)+(x−3)(−(x−1))+(x−3)(4−x) evaluated at x=1, giving 0+0+(−2)(3)=−6.
For x<1: this equals (x−3)(4−x)(1−x), and by the same method the derivative at x=1 is 0+0+(−2)(3)(−1)=6.
Since the left derivative (6) differs from the right derivative (−6), f is not differentiable at x=1.
At x=4: The first term is differentiable (∣x−1∣ and ∣x−2∣ are smooth near x=4). The second term is (x−3)(x−1)∣x−4∣.
For x>4: (x−3)(x−1)(x−4). The derivative at x=4 is: expanding as h(x)=(x2−4x+3)(x−4), we get h′(x)=(2x−4)(x−4)+(x2−4x+3), so h′(4)=0+3=3.
For x<4: (x−3)(x−1)(4−x). The derivative at x=4 is: expanding as h(x)=(x2−4x+3)(4−x)=−x3+8x2−19x+12, we get h′(x)=−3x2+16x−19, so h′(4)=−48+64−19=−3.
Since the left derivative (−3) differs from the right derivative (3), f is not differentiable at x=4.
In total, f is not differentiable at exactly 2 points: x=1 and x=4.
Hence, the correct answer is Option B.