Graph of function #y=f(x)#, by definition, is a set of all points #(A,B)# on the coordinate plane that satisfy the equation

#B=f(A)#.

Given a graph of a function #y=f(x)#, the graph of #y=f(Kx)#, where #K!=0#, can be obtained by "squeezing" the original graph horizontally towards the Y-axis in #K# times.

Here is why.

Consider a point #(A,B)# belongs to original graph. It means that #B=f(A)#.

Consider now a point #(A/K,B)#. Obviously, it belongs to a graph of function #y=f(Kx)# since

#f(KA/K)=f(A)=B#

So, for each point #(A,B)# that belongs to a graph of function #y=f(x)#, point #(A/K,B)# belongs to a graph of function #y=f(Kx)#.

The point #(A/K,B)# can be obtained from the point #(A,B)# by horizontal "squeezing" towards Y-axis.

Of course, if #K<0#, the whole graph is symmetrically reflected relative to Y-axis. If #|K|<1#, our "squeezing" is, actually, stretching.

To construct a graph of function #y=cos(pi x)#, we have to start from #y=cos(x)# and "squeeze" is horizontally towards Y-axis by a factor #pi#.

That means, the shape is preserved, but the periodicity will be in #pi# times smaller, that is #(2pi)/pi=2#.