Question: I have the following differentiation, I need to implement it in C#:

```
W(t)=d/dt(log(A(t)))

```

Where `A(t)` is a array of double data.

How can I obtain the resulting `W(t)` array from the derivative above?

Thanks 

edit:

```
public double[,] derivative()
{
    dvdt = new double[envelope.GetLength(0), envelope.GetLength(1)];
    int h = 1;

    for (int j = 0; j < envelope.GetLength(0); j++)
    {
        for (int i = 0; i < envelope.GetLength(1)-1 ; i++)
        {
            dvdt[j, i] = (envelope[j, i + h] - envelope[j, i]) / (h);
        }
    }
    return dvdt;
}

```

I found this library <http://autodiff.codeplex.com/> but i cant understand how the sample code is working and how i can apply it to my problem eh

Answer: 
To find the derivative of a logarithmic function:

> 
> where y = logb u  
> 
> dy/dx = logb(e) \* u*'*/u  
> 
> where u*'* = du/dx
> 
> 
> 

<http://www.intmath.com/differentiation-transcendental/5-derivative-logarithm.php#derivbases>

So in order to answer your question, we would need to know the derivative of `A(t)`. If you don't know what A(t) is ahead of time, then you'll need to come up with some kind of generic solver, or require that the input includes both the function A and its derivative.

```
public double Log10Derivative(Func<double, double> a, 
                              Func<double, double> aPrime, 
                              double t)
{
    return Math.Log10(Math.E) * (aPrime(t) / a(t));
}

```

As far as performing a `log` on an array, I either never learned that or I forgot how.

### Edit

This should give you an approximation:

```
public double Log10Derivative(Func<double, double> a, 
                              double t)
{
    const double reallySmallNumber = double.Epsilon;
    var aPrimeEst = (a(t) - a(t + reallySmallNumber)) / reallySmallNumber;
    return Math.Log10(Math.E) * (aPrimeEst / a(t));
}

```
I think many of the answers are overthinking this. `d/dt(log(x))` is just `1/x`, so you just need to calculate the reciprocal for each point in the array `A`.

```
double[] W = Array.ConvertAll<double, double>(A, x => 1.0 / x);

```