[proofplan]
We take $F$ to be the fibrewise orthogonal complement of the image subbundle $i(E')$ inside $E$. The main point is to verify that this fibrewise definition varies smoothly with the base point, which follows from the smooth formula for [orthogonal projection](/theorems/437) in a local frame of $i(E')$. Exactness gives $\ker p=i(E')$, so $p$ is injective on the orthogonal complement; comparing ranks then makes $p|_F$ a fibrewise isomorphism, and local matrix inversion gives smoothness of the inverse.
[/proofplan]
[step:Realize $i(E')$ as a smooth subbundle of $E$]
Let $r=\operatorname{rank}E'$ and $n=\operatorname{rank}E$. For each $x\in M$, let
\begin{align*}
i_x:E'_x\to E_x
\end{align*}
denote the fibre map induced by $i$. Since the sequence is exact, $i_x$ is injective for every $x\in M$.
We claim that the fibrewise image
\begin{align*}
G:=i(E')=\bigsqcup_{x\in M}i_x(E'_x)\subset E
\end{align*}
is a smooth rank-$r$ subbundle of $E$. Fix $x_0\in M$. Choose an open neighbourhood $U\subset M$ of $x_0$ on which $E'$ and $E$ admit smooth local frames. Here and below, for a smooth vector bundle $H\to U$, the notation $\Gamma(H)$ denotes the real [vector space](/page/Vector%20Space) of smooth sections of $H$ over $U$. Thus we choose
\begin{align*}
e'_1,\dots,e'_r\in \Gamma(E'|_U),
\qquad
e_1,\dots,e_n\in \Gamma(E|_U).
\end{align*}
For each $a\in\{1,\dots,r\}$, the section $i(e'_a):U\to E|_U$ is smooth. Since $i_{x_0}$ is injective, the vectors
\begin{align*}
i_{x_0}(e'_1(x_0)),\dots,i_{x_0}(e'_r(x_0))
\end{align*}
are linearly independent in $E_{x_0}$. [Linear independence](/page/Linear%20Independence) is an open condition on the corresponding coefficient matrix in the frame $e_1,\dots,e_n$, so after shrinking $U$ around $x_0$ the sections
\begin{align*}
g_a:U\to E|_U,
\qquad
g_a(x):=i_x(e'_a(x)),
\qquad
1\le a\le r,
\end{align*}
are pointwise linearly independent for every $x\in U$. They therefore form a smooth local frame for $G|_U$. Since $x_0$ was arbitrary, $G=i(E')$ is a smooth subbundle of $E$.
[/step]
[step:Define the orthogonal complement and prove it is smooth]
Define
\begin{align*}
F_x:=\{v\in E_x:\langle v,w\rangle_E=0\text{ for every }w\in G_x\},
\qquad
F:=\bigsqcup_{x\in M}F_x\subset E.
\end{align*}
We prove that $F$ is a smooth subbundle of $E$.
Fix an [open set](/page/Open%20Set) $U\subset M$ on which $G|_U$ has a smooth frame
\begin{align*}
g_1,\dots,g_r\in \Gamma(G|_U).
\end{align*}
After shrinking $U$ if necessary, extend this to a smooth local frame
\begin{align*}
g_1,\dots,g_r,h_1,\dots,h_{n-r}\in \Gamma(E|_U)
\end{align*}
of $E|_U$. Define the Gram matrix
\begin{align*}
B:U\to \mathbb{R}^{r\times r},
\qquad
B_{ab}(x):=\langle g_a(x),g_b(x)\rangle_E.
\end{align*}
For every $x\in U$, the matrix $B(x)$ is symmetric positive definite because $g_1(x),\dots,g_r(x)$ are linearly independent. Hence $B(x)$ is invertible, and the entries of $B(x)^{-1}$ depend smoothly on $x$ by the adjugate formula for matrix inversion.
Define the smooth fibrewise orthogonal projection
\begin{align*}
P:E|_U\to G|_U
\end{align*}
by
\begin{align*}
P_x(v)
=
\sum_{a=1}^{r}\sum_{b=1}^{r}
g_a(x)\,(B(x)^{-1})_{ab}\,\langle v,g_b(x)\rangle_E,
\qquad
v\in E_x.
\end{align*}
The defining formula gives $P_x(w)=w$ for every $w\in G_x$, and $v-P_x(v)\in F_x$ for every $v\in E_x$. Therefore $\ker P_x=F_x$.
For $1\le \ell\le n-r$, define smooth sections
\begin{align*}
f_\ell:U\to E|_U,
\qquad
f_\ell(x):=h_\ell(x)-P_x(h_\ell(x)).
\end{align*}
Each $f_\ell(x)$ lies in $F_x$. If $v\in F_x$, write uniquely
\begin{align*}
v=\sum_{a=1}^{r}\alpha_a g_a(x)+\sum_{\ell=1}^{n-r}\beta_\ell h_\ell(x).
\end{align*}
Since $P_x(v)=0$ and $P_x(g_a(x))=g_a(x)$, we obtain
\begin{align*}
v=v-P_x(v)=\sum_{\ell=1}^{n-r}\beta_\ell\bigl(h_\ell(x)-P_x(h_\ell(x))\bigr)
=\sum_{\ell=1}^{n-r}\beta_\ell f_\ell(x).
\end{align*}
Thus $f_1(x),\dots,f_{n-r}(x)$ span $F_x$. They are also linearly independent: if
\begin{align*}
\sum_{\ell=1}^{n-r}\beta_\ell f_\ell(x)=0,
\end{align*}
then
\begin{align*}
\sum_{\ell=1}^{n-r}\beta_\ell h_\ell(x)
=
P_x\left(\sum_{\ell=1}^{n-r}\beta_\ell h_\ell(x)\right)\in G_x.
\end{align*}
The left-hand side also lies in the span of $h_1(x),\dots,h_{n-r}(x)$, and the frame
$g_1(x),\dots,g_r(x),h_1(x),\dots,h_{n-r}(x)$ is linearly independent. Hence all $\beta_\ell=0$. Therefore $f_1,\dots,f_{n-r}$ form a smooth local frame for $F|_U$, so $F$ is a smooth rank-$(n-r)$ subbundle of $E$.
[guided]
The definition of $F$ is fibrewise: at each point $x\in M$, we take the orthogonal complement of $G_x=i_x(E'_x)$ inside the [inner product space](/page/Inner%20Product%20Space) $E_x$. The only issue is smoothness. A family of vector subspaces can be well behaved fibre by fibre and still fail to be a smooth subbundle, so we need an explicit local frame for $F$.
Work on an open set $U\subset M$ where $G|_U$ has a smooth frame
\begin{align*}
g_1,\dots,g_r\in \Gamma(G|_U).
\end{align*}
Shrink $U$ if necessary so that these sections can be completed to a smooth local frame
\begin{align*}
g_1,\dots,g_r,h_1,\dots,h_{n-r}\in \Gamma(E|_U)
\end{align*}
of $E|_U$. The bundle metric gives a smooth Gram matrix
\begin{align*}
B:U\to \mathbb{R}^{r\times r},
\qquad
B_{ab}(x):=\langle g_a(x),g_b(x)\rangle_E.
\end{align*}
Because $g_1(x),\dots,g_r(x)$ are linearly independent, $B(x)$ is positive definite for every $x\in U$. Hence $B(x)^{-1}$ exists, and its entries are smooth functions of $x$ by the adjugate formula
\begin{align*}
B(x)^{-1}=\frac{\operatorname{adj}(B(x))}{\det B(x)}.
\end{align*}
Here $\det B(x)>0$, so division by $\det B(x)$ is smooth on $U$.
Now define, for each $x\in U$, the map
\begin{align*}
P_x:E_x\to G_x
\end{align*}
by
\begin{align*}
P_x(v)
=
\sum_{a=1}^{r}\sum_{b=1}^{r}
g_a(x)\,(B(x)^{-1})_{ab}\,\langle v,g_b(x)\rangle_E.
\end{align*}
This is the usual formula for orthogonal projection onto the span of a non-orthonormal frame. To check it, take $w=\sum_{c=1}^{r}\lambda_c g_c(x)\in G_x$. Substituting this expression into the definition of $P_x$ gives
\begin{align*}
P_x(w)=\sum_{a=1}^{r}\sum_{b=1}^{r}\sum_{c=1}^{r}g_a(x)\,(B(x)^{-1})_{ab}\,\lambda_c\langle g_c(x),g_b(x)\rangle_E.
\end{align*}
Since $B_{cb}(x)=\langle g_c(x),g_b(x)\rangle_E$ and $B(x)$ is symmetric, the coefficient of $g_a(x)$ is the $a$-th component of $B(x)^{-1}B(x)\lambda$, where $\lambda=(\lambda_1,\dots,\lambda_r)$. Hence
\begin{align*}
P_x(w)=\sum_{a=1}^{r}\lambda_a g_a(x)=w.
\end{align*}
Thus $P_x$ fixes $G_x$. Also, for any $v\in E_x$ and any $1\le c\le r$,
\begin{align*}
\left\langle v-P_x(v),g_c(x)\right\rangle_E=\langle v,g_c(x)\rangle_E-\sum_{a=1}^{r}\sum_{b=1}^{r}(B(x)^{-1})_{ab}\,\langle v,g_b(x)\rangle_E\,\langle g_a(x),g_c(x)\rangle_E.
\end{align*}
Using $B_{ac}(x)=\langle g_a(x),g_c(x)\rangle_E$, this becomes
\begin{align*}
\left\langle v-P_x(v),g_c(x)\right\rangle_E=\langle v,g_c(x)\rangle_E-\sum_{a=1}^{r}\sum_{b=1}^{r}(B(x)^{-1})_{ab}\,\langle v,g_b(x)\rangle_E\,B_{ac}(x).
\end{align*}
The final sum equals $\langle v,g_c(x)\rangle_E$: in matrix notation it is the $c$-th component of $B(x)B(x)^{-1}\mu$, where $\mu=(\langle v,g_1(x)\rangle_E,\dots,\langle v,g_r(x)\rangle_E)$. Therefore
\begin{align*}
\left\langle v-P_x(v),g_c(x)\right\rangle_E=0.
\end{align*}
So $v-P_x(v)\in F_x$, and therefore $\ker P_x=F_x$.
To turn this into a smooth frame for $F$, define
\begin{align*}
f_\ell:U\to E|_U,
\qquad
f_\ell(x):=h_\ell(x)-P_x(h_\ell(x)),
\qquad
1\le \ell\le n-r.
\end{align*}
The sections $f_\ell$ are smooth because the sections $h_\ell$, the frame $g_a$, the metric coefficients, and the entries of $B^{-1}$ are smooth. Each $f_\ell(x)$ lies in $F_x$ by construction.
It remains to verify that these sections form a frame, not merely a spanning family. Let $v\in F_x$. Since
$g_1(x),\dots,g_r(x),h_1(x),\dots,h_{n-r}(x)$ is a basis of $E_x$, there are unique scalars $\alpha_a,\beta_\ell\in\mathbb{R}$ such that
\begin{align*}
v=\sum_{a=1}^{r}\alpha_a g_a(x)+\sum_{\ell=1}^{n-r}\beta_\ell h_\ell(x).
\end{align*}
Because $v\in F_x=\ker P_x$, we have $P_x(v)=0$. Therefore
\begin{align*}
v=v-P_x(v).
\end{align*}
Expanding the right-hand side in the chosen frame gives
\begin{align*}
v=\sum_{a=1}^{r}\alpha_a\bigl(g_a(x)-P_x(g_a(x))\bigr)+\sum_{\ell=1}^{n-r}\beta_\ell\bigl(h_\ell(x)-P_x(h_\ell(x))\bigr).
\end{align*}
Since $P_x(g_a(x))=g_a(x)$, this reduces to
\begin{align*}
v=\sum_{\ell=1}^{n-r}\beta_\ell f_\ell(x).
\end{align*}
Thus the $f_\ell(x)$ span $F_x$.
Finally, suppose
\begin{align*}
\sum_{\ell=1}^{n-r}\beta_\ell f_\ell(x)=0.
\end{align*}
Then
\begin{align*}
\sum_{\ell=1}^{n-r}\beta_\ell h_\ell(x)
=
P_x\left(\sum_{\ell=1}^{n-r}\beta_\ell h_\ell(x)\right)\in G_x.
\end{align*}
The left-hand side is also in the span of $h_1(x),\dots,h_{n-r}(x)$. Since the combined list
$g_1(x),\dots,g_r(x),h_1(x),\dots,h_{n-r}(x)$ is a basis of $E_x$, the intersection of the span of the $g_a(x)$ with the span of the $h_\ell(x)$ is $\{0\}$. Therefore all $\beta_\ell=0$. The sections $f_1,\dots,f_{n-r}$ are a smooth local frame for $F|_U$, and so $F$ is a smooth subbundle.
[/guided]
[/step]
[step:Decompose $E$ as the direct sum of $i(E')$ and $F$]
For each $x\in M$, the vector space $E_x$ is finite-dimensional and $F_x$ is the orthogonal complement of $G_x=i_x(E'_x)$. Hence
\begin{align*}
E_x=G_x\oplus F_x.
\end{align*}
Since this holds for every $x\in M$, and since both $G=i(E')$ and $F$ are smooth subbundles of $E$, we obtain the smooth vector bundle direct sum
\begin{align*}
E=i(E')\oplus F.
\end{align*}
[/step]
[step:Show that $p|_F$ is a fibrewise isomorphism]
For each $x\in M$, let
\begin{align*}
p_x:E_x\to E''_x
\end{align*}
denote the fibre map induced by $p$. Exactness gives
\begin{align*}
\ker p_x=i_x(E'_x)=G_x.
\end{align*}
If $v\in F_x$ and $p_x(v)=0$, then $v\in\ker p_x=G_x$. Since $F_x\cap G_x=\{0\}$, it follows that $v=0$. Therefore
\begin{align*}
p_x|_{F_x}:F_x\to E''_x
\end{align*}
is injective.
Let $r'=\operatorname{rank}E''$. Exactness of the fibre sequence gives
\begin{align*}
r'=\operatorname{rank}E-\operatorname{rank}E'=n-r.
\end{align*}
The previous step shows $\operatorname{rank}F=n-r$, so
\begin{align*}
\dim F_x=\dim E''_x
\end{align*}
for every $x\in M$. Hence the injective [linear map](/page/Linear%20Map) $p_x|_{F_x}:F_x\to E''_x$ is an isomorphism for every $x\in M$.
[/step]
[step:Prove that the inverse of $p|_F$ is smooth]
The restricted map
\begin{align*}
p|_F:F\to E''
\end{align*}
is a smooth vector bundle morphism because it is the restriction of the smooth vector bundle morphism $p:E\to E''$ to the smooth subbundle $F\subset E$. It remains only to check that its fibrewise inverse is smooth.
Fix $x_0\in M$. Choose an open neighbourhood $U\subset M$ on which $F|_U$ has a smooth frame
\begin{align*}
f_1,\dots,f_{r'}\in\Gamma(F|_U)
\end{align*}
and $E''|_U$ has a smooth frame
\begin{align*}
e''_1,\dots,e''_{r'}\in\Gamma(E''|_U).
\end{align*}
In these frames, $p|_F$ is represented by a smooth matrix-valued map
\begin{align*}
A:U\to \mathbb{R}^{r'\times r'},
\end{align*}
defined by
\begin{align*}
p(f_b(x))=\sum_{a=1}^{r'}A_{ab}(x)e''_a(x).
\end{align*}
Since $p_x|_{F_x}$ is an isomorphism for every $x\in U$, the matrix $A(x)$ is invertible for every $x\in U$. Therefore
\begin{align*}
A(x)^{-1}=\frac{\operatorname{adj}(A(x))}{\det A(x)}
\end{align*}
has smooth entries on $U$. This gives a smooth local expression for the inverse bundle morphism
\begin{align*}
(p|_F)^{-1}:E''\to F.
\end{align*}
Since $x_0$ was arbitrary, $(p|_F)^{-1}$ is smooth globally. Thus $p|_F:F\to E''$ is a smooth vector bundle isomorphism, completing the proof.
[/step]