Getting Energy consumed by using the Gradient of the Power My goal is to predict the energy consumption in Wh over a time window by using the current power draw and the current gradient of this power draw. In other words, if my power usage is increasing at this moment, I want to take that into consideration and anticipate for the power to increase further over time.
However, for this application it also makes no sense to view the gradient as constant over the time window. This obviously would mean that over time my power draw would climb indefinetely, which is not realistic.
My idea was to use the following function to describe the curve of the Gradient:
$$
\Delta  P(t) = \Delta P(0)*e^{^{at}}
$$
Given a negative "a" this function starts with the currently observed Gradient but over time goes to zero.
So my power consumption at time T should be:
$$
P(t)=P(0) + \int_{0}^{T} \Delta P(0)*e^{^{at}} dt
$$
If I integrate this again, it should provide me with the energy consumption at time T:
$$
E(t)=E(0)+ \int_{0}^{T}(P(0) + \int_{0}^{T} \Delta P(0)*e^{^{at}} dt) dt
$$
Which I throw in to Wolfram Alpha with the following result for the definite integral:
$$
T(\frac{\Delta P(0)*(e^{aT}-1)}{a}+P(0))
$$
So let's test this with the easiest example I can come up with: E(0) := 0, P(0)= 0, a=0, the Gradient of P is 1[W/s] and my time window is one hour.
This results in 3600 Wh. But that cannot be the correct answer. If the power growing at an (almost) constant rate of one Watt per Second over the time window, I would expect 3600 Watt after one hour (3600 s) but an average over that hour of just 1800 W. So the energy consumed should be 1800 Wh.
I suspect that I make an error somewhere in the way I use these integrals or the defined integral to solve my problem. It's like I first integrate to get the power drawn at point T, which is 3600 W. This I then used for the second integration to get the Energy consumed from the Power. So after the second integration I get the overall result as if these 3600 W were present constantly the whole time.
Can anyone point out the mistake I made?
 A: I initially edited your question to "correct" your notation, but I think your error is actually due to that confusion, so I reverted the changes.
If you actually perform your first integral, you get
$$
P(t)=P(0) + \int_{0}^{t} \Delta P(0)*e^{at'} dt' = P(0) + \Delta P(0) \, \frac{e^{at} - 1}{a} 
$$
Note here that I've used a "dummy" variable $t'$ to perform the integration, to avoid confusion with the upper bound of integration $t$.  If you then integrate this again over the range $t \in [0, T]$, you get
$$
E(T) = E(0) + \int_0^T \left[ P(0) + \Delta P(0) \, \frac{e^{at} - 1}{a}  \right] \, dt = E(0) + P(0) T + \Delta P(0) \frac{e^{aT} - 1 - aT}{a^2}  
$$
The fraction at the end of this expression is indeterminate when $a = 0$ but approaches $T^2/2$ as $a \to 0$;  so in the $a \to 0$ limit we have $E(T) = P(0) T + \frac{1}{2} \Delta P(0) T^2$.  This will, I'm pretty sure, give you a more reasonable result for your test inputs.
Note that the use of dummy variables is very helpful in getting the correct answer.  With the correct dummy variables in place, your original equation for $E$ as a function of time should be
$$
E(\color{red}{T})=E(0)+ \int_{0}^{T}\left[ P(0) + \int_{0}^{\color{red}{t}} \Delta P(0)*e^{a\color{red}{t'}} d\color{red}{t'} \right] dt
$$
(changes marked in red.)  If you try to do this process without carefully distinguishing between $t'$, $t$, and $T$, it's likely that you'll get the wrong answer—particularly if you use a software tool like Wolfram Alpha that takes your original ambiguous input literally.
