Differentiation Implementation in C #

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

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

Where A(t) is an array of double data.

How to get the resulting array W(t) 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 can’t understand how the sample code works and how I can apply it to my eh problem

+6
math c #
source share
4 answers

None of this applies to your question, but can help you move again. Getting stuck on trivial items in your thesis can be a royal pain.

Do you have access to Mathematica? The last thing I checked, they had a .NET shell around their main engine called .NET / Link.

Mathematica's stellar performance. In addition, it now supports resources such as GPUs and clusters that can provide a huge performance boost if any of your applications are parallelizable.

This will allow you to focus on the rest of your application, instead of reinventing the wheel. In addition, since you can enter your formulas directly in the Mathematica Notebook Editor, you can use a more general data-based approach from C #.

Here is some typically Tungsten impervious documentation .

See also this topic on Mathematica parsing in C #.

(I recommend Mathematica because you mentioned that you may need a solver for more than one formula / equation / etc. If the implementation of the solver is not the main part of your thesis, I would recommend using a non-standard formula like this component and focus on your original research.)

+3
source share

To find the derivative of a logarithmic function:

where y = log b u
dy / dx = log b (e) * u ' / u
where u ' = du / dx

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

So, to answer your question, we need to know the derivative of A(t) . If you do not know that A (t) is ahead of time, then you need to come up with some kind of common solver or require that the input include 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)); } 

Regarding the execution of log in the array, I either did not find out about it or forgot how to do it.

Edit

This should give you an approximate value:

 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)); } 
+1
source share

Usually you yourself develop a formula for the derivative, and if the memory serves d/dx[log_b x] = [1/(x ln b)] dx . If A(t) is a simple array:

 double log_b = Math.Log(10); // Assumes Math.Log = ln and b = 10 double dt = 1.0; // dt is 1 in this case, change if otherwise double[] W = new double[A.GetLength(0)]; for (int t = 0; t < A.GetLength(0); ++t) { W[t] = dt / (A[t] * log_b); } 
+1
source share

I think many of the answers are overdoing it. d/dt(log(x)) is just 1/x , so you just need to calculate the inverse for each point of array A

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

All Articles