Taken from elsewhere on the web : -
"The derivative of a sine function is
d SIN(ω*t) / dt = ω * COS(ω t) where ω = angular frequency = 2 π *frequency
and this derivative leads the original function by 90 degrees (a quarter period) because a cosine wave leads a sine wave by 90 degrees. This derivative is also different in amplitude from the original sine wave because the cosine wave is multiplied by the angular frequency. If we take the simple difference of equally spaced successive points of the sine wave (i.e. 20 points in a 20 period sine wave, 21 points in a 21 period sine wave etc.) we can cause that difference to have the same amplitude as the sine wave if we “normalize” the difference. Normalization is done by multiplying the difference by (1/ω). In the case the sine wave the angular frequency is 2*Pi divided by the period of the sine wave therefore the amplitude normalization factor is
Normalizer = Period / (2*π)
Using the normalizer, this difference function of sine wave now has the same amplitude as the sine wave and leads it by 90 degrees in phase (a quarter cycle). The amount of phase lead can be reduced with a little vector arithmetic. Vector addition of the sine wave and difference function results in a vector that leads the sine wave by only 45 degrees. Since this vector forms the hypotenuse of a right angled triangle, it is also larger than the sine wave by a factor of 1.414. We simply divide the sum by 1.414 to achieve the correct amplitude for our leading signal.
In summary, we create a leading signal by taking the difference of equally spaced successive samples of a sine wave; multiply that difference by Period/(2*π); add that product to the sine wave; and divide the sum by 1.414."
I would like to use this approach to create a leading signal for a sine wave which always has a set constant lead e.g. the above approach gives a 2.5 point lead for a 20 period sine wave but will give a 5 point lead for a 40 period sine wave. Since I will always know the period and the difference between successive points of the sine wave, how can I adjust the vector arithmetic so that the lead will always be a constant 2.5 points (or constant 3.5 points, whatever?) irrespective of the sine wave period?