how a step function has frequency content in it?
There is a mathematical 'reason': Any signal / waveform / function that varies in time (time domain) can be transformed to a function in the 'frequency domain', which shows its frequency spectrum.
If you do a Fourier transform on the (time domain) function which is zero for all time before t=0 and 1 for all time after t=0, the result is an infinite, continuous spectrum of frequency components. The power of each component is, of course, infinitessimally low so you can't measure anything.
In a practical situation, if you do a FT of a repeating square wave with finite rise time and a period of T, the resulting frequency domain function will consist of a DC component and a series of frequency components, starting at 1/T, then 3/T, 5/T, 7/T with gradually decreasing amplitudes. A series of narrow pulses will have a spectrum which includes all hamonics (1/T,2/T, 3/T, 4/T etc).
IS it true that a function varies from +2 to +4 also has frequency component in it.
It's more an identity than a 'truth'. It's down to the definitions of time and frequency domain. Any time varying function can be described in the frequency domain and vice versa.
Time and frequency domain descriptions are merely two different ways of characterising the SAME thing.
A good intuitive exercise could be to grab a few of the first harmonics mentioned in post #2 and try to build the step function from scratch and see how the 'squareness' develops.
Being picky, I would point out that a "unit step signal" is not a "square wave". A unit step function is zero for all time before until it changes value. Thereafter, it is 1, for the rest of all time. There are no 'harmonics' because there is no 'repeat' and the 'fundamental' has zero frequency.
It is a very idealised function and, as its (infinite) energy is spread over an infinite number of frequency components of infinitessimally small value.
You're right of course. I actually replaced 'square wave' with 'step function' before submitting when I discovered I wasn't answering his question. That was never going to work very well I guess. Thanks for keeping the place tidy.
Glad you didn't take offence.
These things can be confusing enough and it's so easy for people to rush off with a message that just adds to the confusion. All these basic relationships with signals are much more difficult that many people want to think!
Separate names with a comma.