Look at the deduction in the picture. This derives the first order approximation of derivation in the z-domain (digital), ie. It cuts of at the first term.
Integration is simply the inverse To understand this, you must now that integration in the laplace domain (analog) is performed by multiplying by 1/s. The digital equivalent is then calculated with tustin's method as below in the first two lines. Depending on the accuracy you want, you can cut of at the first, second, third, etc.Term.
The highest order of z in the formula will determine the number of values you need to store. Next, you need to reorganize the formula in terms of z^(-d) as is shown in the next two lines. Thus, for a first order approximation, you will get in the z-domain: X(z) = 2/T (1-z^(-1))/(1+z^(-1)) I(z) or X(z) (1+z^(-1)) = 2/T (1-z^(-1)) I(z) Where I(z) en X(z) are the z-domain representations of the integral and signal resp.
We can transform this back to the time domain by using z^(-d) X(z) => x(n-d) x(n) + x(n-1) = 2/T (i(n)-i(n-1)) So we get: T*(x(n) + x(n-1))/2 + i(n-1) = i(n) This is more or less the same as the formula you used intuitively. If you want a more accurate result, you need to cut off the series further down, and calculate in the same way (though it will be longer calculations).
My guess is your trying to integrate an analog signal by digitizing it...perhaps a sensor for controlling something. It's going to be difficult to give you a usable example of the method without more detail mainly because the method was developed to convert analog transform functions (things like filters) into the digital realm (and back to analog again). This is hackaday, and I suspect something simpler such as reading the value with the ADC of a micro-controller and then doing simple control based on the value will work.
If this isn't the case, and you're making some crazy inverted pendulum or helicopter controller or something then I recommend trying to find a book on discrete time control theory. Of course if you have the ADC part working and need to filter noise digitally (or something similar) I suggest asking a pointed question like: I need to filter 30kHz and greater frequencies from a signal digitally sampled at 500 samples per second. Then someone might be able to give you an implementable formula to drop into your code.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.