We expand the given expression:
sinx(sinx+cosx)=sin2x+sinxcosx=21−cos2x+2sin2x
So the equation becomes sin2x−cos2x=2a−1, which can be written as:
2sin(2x−4π)=2a−1
For real solutions, we need ∣2a−1∣≤2. Since a∈Z, this gives 21−2≤a≤21+2, i.e., −0.207≤a≤1.207. So a=0 or a=1.
Case a=0: We solve sin(2x−4π)=2−1.
This gives 2x−4π=−4π+2kπ or 2x−4π=π+4π+2kπ.
From the first: x=kπ. In [−π,π]: x=−π,0,π.
From the second: x=43π+kπ. In [−π,π]: x=−4π,43π.
So 5 solutions for a=0.
Case a=1: We solve sin(2x−4π)=21.
This gives 2x−4π=4π+2kπ or 2x−4π=43π+2kπ.
From the first: x=4π+kπ. In [−π,π]: x=−43π,4π.
From the second: x=2π+kπ. In [−π,π]: x=−2π,2π.
So 4 solutions for a=1.
The total number of elements in S is 5+4=9.
Hence, the correct answer is Option 4.