Q:

Refactoring blocks of code that differ only by one function call

I've got similar formulas for counting Hartley transformation. The only difference is input function - sin, cos, exp in the following lines of code:
Math.Exp((double)tau)
Math.Sin((double)tau)
Math.Cos((double)tau)

How can I escape almost identical code fragments and shorten my code in following fragment?
 private void CountHartley(ref double [] arr, string function)
        {
            int N = arr.Length;
            if (function == "exp")
            {
                for (int nu = 0, tau = 0; ((nu < N) && (tau < N)); nu++, tau++)
                {
                    arr[nu] = 1 / (double)N *
                                 Math.Exp((double)tau) *
                                 (Math.Sin(2 * Math.PI * nu * tau / (double) N) +
                                 Math.Cos(2 * Math.PI * nu * tau / (double) N));
                }
            }
            else if (function == "sin")
            {
                for (int nu = 0, tau = 0; ((nu < N) && (tau < N)); nu++, tau++)
                {
                    arr[nu] = 1 / (double)N *
                                 Math.Sin((double)tau) *
                                 (Math.Sin(2 * Math.PI * nu * tau / (double)N) +
                                 Math.Cos(2 * Math.PI * nu * tau / (double)N));
                }
            }
            else
            {
                for (int nu = 0, tau = 0; ((nu < N) && (tau < N)); nu++, tau++)
                {
                    arr[nu] = 1 / (double)N *
                                 Math.Cos((double)tau) *
                                 (Math.Sin(2 * Math.PI * nu * tau / (double)N) +
                                 Math.Cos(2 * Math.PI * nu * tau / (double)N));
                }
            }
}

A:

Instead of passing in a string with the function to use, you can pass in the function directly.
You can use the Func<T, TResult> Delegate for this as follows:
private void CountHartley(ref double [] arr, Func<double, double> function)
{
    int N = arr.Length;
    for (int nu = 0, tau = 0; ((nu < N) && (tau < N)); nu++, tau++)
    {
        arr[nu] = 1 / (double)N *
                     function((double)tau) *
                     (Math.Sin(2 * Math.PI * nu * tau / (double) N) +
                     Math.Cos(2 * Math.PI * nu * tau / (double) N));
    }
}

Usage:
var result = CountHartley(arr, Math.Cos);

