Expansion of the derivatives of the electric and magnetic fields I'm reading electrodynamics physics notes that describe a cavity of length $L$. The cavity is said to lie along the $z$-axis from $-L$ to $0$. The electric field is polarized in the $x$ direction and the magnetic field is polarized in the $y$ direction.
It then says that the basis functions for expansion of the electric and magnetic fields are
$$u_n(z) = \sin(k_n z) \ \ \ \ \ \ \text{and} \ \ \ \ \ \ v_n(z) = \cos(k_n z),$$
with
$$k_n = n \pi/L$$
These satisfy the relationship
$$\dfrac{\partial{u_n}(z)}{\partial{z}} = k_n v_n(z), \\ \dfrac{\partial{v_n}(z)}{\partial{z}} = -k_n u_n(z),$$
but are said to be "unnormalized" (I'm not totally sure what this means in this case).
It then says that fields in the cavity are expanded as
$$E(z, t) = \sum_n A_n(t) u_n(z), \\ H(z, t) = \sum_n H_n(t) v_n(z),$$
while the expansion of their derivatives follows from the above definitions to become
$$\begin{align*} \dfrac{\partial{E(z, t)}}{\partial{z}} &= \dfrac{2}{L} \sum_n v_n(z) \left( \int_{-L}^0 dz \ v_n(z) \dfrac{\partial{E(z, t)}}{\partial{z}} \right) \\ &= \sum_n v_n(z) \left( \dfrac{2}{L} E(0, t) + k_n A_n(t) \right), \end{align*}$$
$$\begin{align*} -\dfrac{\partial{H(z, t)}}{\partial{z}} &= \dfrac{-2}{L} \sum_n u_n(z) \left( \int_{-L}^0 dz \ u_n(z) \dfrac{\partial{H(z, t)}}{\partial{z}} \right) \\ &= \sum_n u_n(z) k_n H_n(t) \end{align*}$$
I don't understand how these last equations are derived. How does the expansion of the derivatives from the above definitions get us these equations?

EDIT
I found something seemingly relevant during my research. The textbook Complements of Higher Mathematics by Andreas Echsner and Marin Marin says the following:

In the following we will write the Fourier series for the periodical function having the particular period $2\pi$.
Theorem 4.1.3 Consider a periodical function $f : [-\pi, \pi] \to R$ which has the period $T = 2\pi$. Then
(i) if $f$ is an even function, then its Fourier series becomes
$$f(x) = \dfrac{a_0}{2} + \sum_{n = 1}^\infty a_n \cos(nx),$$
where
$$a_0 = \dfrac{2}{\pi} \int_0^\pi f(x) \ dx, \ \ \ \ \ a_n = \dfrac{2}{\pi} \int_0^\pi f(x) \cos(nx) \ dx.$$
(ii) if $f$ is an odd function, then its Fourier series becomes
$$f(x) = \sum_{n = 1}^\infty b_n \sin(nx),$$
where
$$b_n = \dfrac{2}{\pi} \int_0^\pi f(x) \sin(nx) \ dx$$


Remark. It is usual to say that an even function has a Fourier's cosine series and an odd function has a Fourier's sine series.
Now, we consider the case of the functions defined on a non-symmetrical interval of the form $[0, \pi]$.
Theorem 4.1.4 Consider the function $f : [0, \pi] \to R$. Then it admits both a Fourier's cosine series and a Fourier's sine series.
Proof To find the Fourier's cosine series of the function, we construct the following function
$$g(x) = \begin{cases} f(x), & x \in [0, \pi] \\ f(-x), & x \in [-\pi, 0]. \end{cases}$$
It is a simple matter to verify that $g$ is an even function and then, according to the Theorem 4.1.3, it admits a cosine series
$$g(x) = \dfrac{a_0}{2} + \sum_{n = 1}^\infty a_n \cos(nx),$$
where
$$a_0 = \dfrac{2}{\pi} \int_0^\pi g(x) \ dx, \ \ \ \ \ a_n = \dfrac{2}{\pi} \int_0^\pi g(x) \cos(nx) \ dx.$$
But on the interval $[0, \pi]$ the function $g(x)$ is $f(x)$ such that the above series is, in fact, the series of function $f$.
To find the Fourier's sine series of the function, we construct the following function
$$h(x) = \begin{cases} f(x), & x \in [0, \pi] \\ -f(-x), & x \in [-\pi, 0]. \end{cases}$$
It is a simple matter to verify that $h$ is an odd function and then, according to the Theorem 4.1.3, it admits a sine series
$$h(x) = \sum_{n = 1}^\infty b_n \sin(nx),$$
where
$$b_n = \dfrac{2}{\pi} \int_0^\pi g(x) \sin(nx) \ dx.$$
But on the interval $[0, \pi]$ the function $h(x)$ is $f(x)$ such that the above series is, in fact, the series of function $f$. So, the theorem is concluded.

If someone would please help me put this all together in the context of my question, I would greatly appreciate it.
 A: Let's see if the following helps.
First, we don't need to worry about the expansions of $E$ and $H$ themselves; we are told they exist and are of the form
$$
E(z,t)= \sum_{n=0}^\infty A_n(t) \sin(k_nz) \\
H(z,t)= \sum_{n=0}^\infty H_n(t) \cos(k_n z),
$$
whatever the coefficients $A_n(t)$ and $H_n(t)$ are (they have been computed using the formulas you mention).
Now, we want to expand their derivatives. Let's start with the electric field:
$$
\frac{\partial E(t,z)}{\partial z} = \frac{B_0(t)}{2} + \sum_{n=1}^\infty B_n(t)\cos (k_n z),
$$
(the electric field is odd, so its derivative is even, thus the cosines)
where the coefficients $B_n(t)$ are computed as we know (as the theorem you have posted tells us):
$$
B_n(t)=\frac{2}{L} \int_{-L}^0 \frac{\partial E(t,z)}{\partial z}  \cos (k_nz)
 dz.$$
I mean $B_n(t)$ and not $A_n(t)$  because, for the momment, we are expanding $\partial E/\partial z$ as if we knew nothing about $E(t,z)$. Suppose that $\partial E/\partial z$ is a function $f(t,z)$ and we expand it.
For $n\neq 0$, the integral above is computed by parts:
$$ \int_{-L}^0 \frac{\partial E(t,z)}{\partial z}  \cos (k_nz)
 dz= E(t,z)\cos(k_nz)\bigg|_{-L}^0 - \int_{-L}^0 E(t,z)\frac{d}{dz}\cos(k_n z)= E(t,z)\cos(k_nz)\bigg|_{-L}^0 +  \sum_{m=0}^\infty k_n\int_{-L}^0 A_n(t)\sin(k_m z) (z,t)\sin(k_nz)dz =  E(t,z)\cos(k_nz)\bigg|_{-L}^0 - A_n(t)k_n\frac{L}{2}
$$
(you can see the computations here ($m\neq n$) and here ($m=n$), so that it results:
$$B_n(t)= \frac{2}{L}\left(E(t,z)\cos(k_nz)\bigg|_{-L}^0 + k_n\frac{L}{2}\right).
$$
Now let's compute $B_0$:
$$
B_0(t)=\frac{2}{L}\int_{-L}^0 \frac{\partial E(t,z)}{\partial z}dz = \sum_{n=0}^\infty k_n \int_{-L}^0 A_n(t)\cos(n\pi z/L)dz = 0
$$
(answer here.
Hence:
$$
\frac{\partial E(t,z)/\partial z} = \frac{B_0(t)}{2} + \sum_{n=1}^\infty B_n(t)\cos(n\pi z/L) =\sum_{n=1}^\infty \frac{2}{L}\left(E(t,z)\cos(k_nz)\bigg|_{-L}^0 + k_n\frac{L}{2}\right)\cos(n\pi z/L). $$
There is one missing detail, something I do not really understand. For $n>0$, the result for $B_n(t)$ involves  $E(0,t)$ and $E(t,-L)\cos(-n\pi)$.
If we use the series to compute $E(t,-L)$, we get a zero, so that term vanishes, so it would not appear in the final expression, that is OK. But the same should happen to $E(t,0)$.
So check the boundary conditions and see what the values of  $E(t,0)$ and  $E(t,-L)$ are.
The magnetic field seems to follow the same procedure, although you can check that the result is exactly the same as if we computed the derivative $\partial H/\partial z$ directly. Be careful because in doing so we are igonoring the boundary conditions at $z=0,-L$.
Compute $\partial H/\partial z$ using both approaches and check that indeed they agree.
