I am trying to reformulate a first order ODE in a way that I can approximate the solution up to a residuum using a gradient based optimization.
The ODE I am considering is: $$\frac{\text{d}s}{\text{d}t} - \frac{2}{h(t)} \cdot \left(\mu\cdot s(t) - \sigma(t) \cdot \left(\frac{t}{R}+\mu\right)\right) = 0$$
I am assuming that the solution to this ODE can be represented by a polynomial, so I substitute this into my ODE: $$\left(2a\cdot t + b\right) - \frac{2}{h(t)} \cdot \left(\mu\cdot \left(a\cdot t^2 + b\cdot t + c \right) - \sigma(t) \cdot \left(\frac{t}{R}+\mu\right)\right) = \vec e$$
Minimizing the Euclidean norm $\lVert\vec e\rVert_2$ of the residuum $\vec e$ of this ODE is my final goal. To do that efficiently I would like to calculate the analytical gradient of this ODE with respect to the parameters $a$ and $b$.
I assume the Euclidean norm is: $$\int\left(\left(2a\cdot t + b\right) - \frac{2}{h(t)} \cdot \left(\mu\cdot \left(a\cdot t^2 + b\cdot t + c \right) - \sigma(t) \cdot \left(\frac{t}{R}+\mu\right)\right)\right)^2 \text{d}t = \lVert\vec e\rVert_2$$
However I do not know how to calculate the partial derivatives $\frac{\text{d}\lVert\vec e\rVert_2}{\text{d}a}$ and $\frac{\text{d}\lVert\vec e\rVert_2}{\text{d}b}$ with respect to a and b.
Is this even possible and how would I do that?