Can someone help verify the first part of my solution for this DDE? I'm trying to solve this delayed differential equation that I saw in a paper I'm studying
$$y′(t)=ay(t)−ay(t−\tau)$$
with $a$ as a positive constant, $y(t−\tau)=0$ for $t<\tau$ and the initial condition as $y(0)=y_0$. (I posted about this a couple of days ago and was making a terrible mistake so I deleted that one. I'm doing it again now, but I compare my solution to the one that someone else got and it's slightly different, even though I think my working is correct mostly? I can't see their working so I'm not sure where/if I'm going wrong, so I just wanted to confirm if I'm making a mistake or not.)
I'll outline my working below:
On $[0,\tau]$ we have
$$y′(t)−ay(t)=0$$
which gives us
$$y(t)=y_0e^{at}$$
if we use an integrating factor of $e^{−at}$.
For $[\tau,2\tau]$:
$$y′(t)−ay(t)=−ay_0e^{a(t-\tau)}$$
which gives me $$y(t) = y_0e^{at}[1-ae^{-a\tau}(t-\tau)]$$
Then, for $t \in [2\tau, 3\tau]$, I can just continue using the method of steps, but I get a super long expression that does not,,, particularly seem like it would be very generalizable, so I'm not sure if I can get a closed form solution or not (also why I think I might be making a mistake).
(Edit: Adding it here anyway)
For $t \in [2\tau, 3\tau]$:
$$y(t) = y_0 e^{at}\bigg[1-at+2a\tau +
ae^{-a\tau}\bigg(a\bigg(\frac{t^2}{2} - 2\tau\bigg) + \tau - 2\tau^2\bigg) \bigg]$$
Could someone please confirm if I got the first bits that I've written up there correct though? I'd appreciate it a lot, as I do tend to make many many basic errors sometimes.
EDIT 2:
Got the answer by continuing to use the method of steps and changing how I wrote my solution for $t \in [2\tau, 3\tau]$ to
$$y(t) = y_0\bigg[e^{at}-a(t-\tau)e^{a(t-\tau)} + \frac{a^2}{2}(t-2\tau)^2e^{a(t-2\tau)}\bigg]$$ instead of what it was before, which gave me a much nicer way to look at it.
Then I generalized this to pretty much the exact thing user DinosaurEgg wrote below except I realized it after looking at the answers fully once I was done lol. But yeah, so I get the sum
$$y(t) = y_0 \sum_{k=0}^{n} \frac{(-a)^k}{k!} (t-k\tau)^ke^{a(t-k\tau)}$$ which is again, the exact same as the answer below.
Thanks for all the help though! I do appreciate it! :)
 A: I think what you are trying to get at can be expressed very concisely by applying a Laplace transform to the DDE above to obtain
$$Y(s)=\frac{y_0}{s-a+ae^{-s\tau}}$$
where we denote $Y(s)=\int_0^\infty y(t)e^{-st}dt$. To obtain the expansion you have above just expand the denominator around $\tau=\infty$ which can be achieved by expanding in powers of $e^{-s\tau}$. This yields
$$Y(s)=\frac{y_0}{s-a}\sum_{n=0}^{\infty}\left(-\frac{a}{s-a}\right)^ne^{-ns\tau}$$
Formally inverting the Laplace transform term by term now yields the desired result
$$y(t)=y_0\sum_{n=0}^{\infty}\frac{(-a)^n}{n!}\theta(t-n\tau)(t-n\tau)^ne^{a(t-n\tau)}$$
with $\theta(x)$ the Heaviside step function. Unpacking the formula we derived a little further, we see the solution is different for every interval $(m\tau,(m+1)\tau)~,~ m\in\mathbb{N}$ and is given by
$$y_m(t)=\sum_{n=0}^m\frac{(-a)^n}{n!}(t-n\tau)^ne^{a(t-n\tau)}~~,~~t\in \left(m\tau, (m+1)\tau\right)$$
and this is probably the closest one can get to a closed form expression. Note that continuity is automatically satisfied here, because
$$y_{m+1}(t)-y_m(t)\Big|_{t=(m+1)\tau}=\frac{(-a)^{m+1}}{(m+1)!}(t-(m+1)\tau)^{m+1}e^{a(t-(m+1)\tau)}\Big|_{t=(m+1)\tau}=0$$
With this you can easily verify that your solutions in $(0,2\tau)$ are correct.
A: Your formulas are correct, I think.  But the argument does generalize.
Suppose $p_k(t)$ is a polynomial in $t$ such that $$y(t)=y_0p_k(t-k\tau)e^{a(t-k\tau)}$$ on $t\in[k\tau,(k+1)\tau]$.
Then \begin{align*}
y_0p_k'(t-k\tau)e^{a(t-k\tau)}&=y_0p_k'(t-k\tau)e^{a(t-k\tau)}+y_0ap_k(t-k\tau)e^{a(t-k\tau)}-y_0ap_k(t-k\tau)e^{a(t-k\tau)} \\
&=y'(t)-ay(t) \\
&=-ay(t-\tau) \\
&=-y_0ap_{k-1}((t-\tau)-(k-1)\tau)e^{a(t-\tau-(k-1)\tau)} \\
&=-y_0ap_{k-1}(t-k\tau)e^{a(t-k\tau)}
\end{align*}  Canceling, we find that $p_k'=-ap_{k-1}$.
Moreover, to ensure continuity, we must have $$p_{k-1}(\tau)e^{a\tau}=y(k\tau)=p_k(0)$$  Thus $$p_k(t)=e^{a\tau}p_{k-1}(\tau)-a\int_0^t{p_{k-1}(s)\,ds}$$
Putting it all together, we obtain a simple recurrence for the $\{p_k\}_k$: \begin{align*}
p_k(t)&=e^{a\tau}p_{k-1}(\tau)-a\int_0^t{p_{k-1}(s)\,ds} \\
p_0(t)&=1
\end{align*}
In particular, the recurrence isn't too bad, when expressed in coefficients: if $p_k(t)=\sum_j{c_{k,j}t^j}$, then $$c_{k,j}=\begin{cases}
-\frac{a}{j}c_{k-1,j-1} & j>0 \\
e^{a\tau}\sum_l{c_{k-1,l}\tau^l} & j=0 \\
\end{cases}$$
