>>12845167sin(x) goes from -1 to 1, and has a period of 2pi; to go from a simple sine to the pic in OP you have to shift it upwards, as y(0)=1 hence the +1, and rescale it to the proper amplitude hence the multiplication by 3. Last but not least you have to divide the x by pi because the period in OP is 2 instead of 2pi.