Is there an easier/ more elegant way to solve this ODE? $$y' = y^2 + g(x)$$ where
$$g(x) = \frac{x^4 - 6x^3 + 12x^2 - 14x+9}{(1+x)^2}$$
I have found the homogeneous solution to be
$$y_h(x) = \frac{1}{\frac{1}{2}-x}$$
to obtain the particular solution I try
$$y_p(x) = \frac{\sum_{i=0}^4 a_ix^i}{1+x}$$, which on substitution becomes
$$-\sum_{i,j=0}^{i+j = 4}a_ia_jx^{i+j} + (1+x)\sum_{i=0}^3(i+1)a_{i+1}x^i - \sum_{i = 0}^4a_ix^i = p(x)$$
This seems a little crazy, none the less I put this into the form
$$\textbf{Fx}= \textbf{p}$$
where $\textbf{p}$ are the coefficients of the polynomial and $\textbf{F}$ is given by

In the above matrix the coefficients run from 1 to 5 instead of 0 to 4.
I stopped here, I do not know how to go on. I have a matrix of unknowns and I am embarrassed to say, I do not know how to deal with this.
$$y(x) = \frac{(1-x)(2-x)}{1+x}$$
there must be a nicer way of obtaining this solution.
 A: Let's define the following function
$$y(x)=\sum _{k=0}^{\infty} a_k x^k$$
Differentiating we get
$$y'(x)=\sum _{k=0}^{\infty} k a_k x^{k-1}$$
Consider the differential equation
$$y'(x)= y^2 - \frac{x^4 - 6x^3 + 12x^2 - 14x+9}{(1+x)^2};\;y(0)=2$$
which can be written as follows
$$(1+x)^2 y'(x)-(1+x)^2y(x)+(x^4 - 6x^3 + 12x^2 - 14x+9)=0$$
Plugging the function and its derivative we get
$$(1+x)^2\sum _{k=0}^{\infty} k a_k x^{k-1}-(1+x)^2\sum _{k=0}^{\infty} a_k x^k+x^4 - 6x^3 + 12x^2 - 14x+9=0$$
All coefficient must be zero, like in the right side.
Remember the initial condition $y(0)=a_0=2$ so we get the first coefficient
then expanding and collecting the previous polynomial the term of first degree has coefficient $a_1+5=0$ so we have $a_1=-5$
Then the second degree term has coefficient $-2 a_1+2 a_2-22=0$ plugging the value of $a_1=-5$ we get $a_2=6$
The third degree coefficient is $8-a_1^2-7 a_1+3 a_3+8=0$ gives $a_3=-6$
Going on this way we see that for $k\geq 1$ coefficients are $a_{2k}=6;\;a_{2k+1}=-6$
Therefore the function can be written as
$$y(x)=2-5x+6\sum _{k=2}^{\infty }  (-1)^k x^k$$
The sum is a geometric one with ratio $-x$ whose sum is $\dfrac{1}{1+x}-1+x$
The solution is then 
$$y(x)=2-5x+6\left(\frac{1}{1+x}-1+x\right)=\frac{x^2-3 x+2}{x+1}$$
It's not that easy
A: This is a special case of a Riccati equation.  The general Riccati equation is $y^\prime = a(x) y^2 + b(x) y + c(x)$.  The trick to solving it is the substitution
$$y(x) = -\frac{w^\prime(x)}{a(x) w(x)}.$$
This reduces it to the second-order linear ODE
$$w^{\prime \prime} - \left(\frac{a^\prime(x)}{a(x)}+b(x)\right)w^\prime + a(x) c(x) w = 0.$$
It is not necessary to find the general solution $w(x)$.  If we can find a particular solution $w_1(x)$, and then use this to find a particular solution $y_1(x)$ to the original equation, then the general solution to the Riccati equation may be expressed as
$$y = y_1(x) + \frac{1}{v(x)},$$
where $v(x)$ is the general solution to
$$v^\prime + \big(b(x) + 2 a(x) y_1(x)\big)v = -a(x).$$
In your case $a(x) = 1$, $b(x) = 0$, and $c(x) = -g(x)$, so the Riccati equation reduces to
$$w^{\prime \prime} = g(x) w.$$
We can simplify $g(x)$ by substituting $t = x+1$.  Letting $\tilde{w}(t) = w(x)$, this yields the ODE
$$\frac{\tilde{w}(t)^{\prime \prime}}{\tilde{w}(t)} = t^2 - 10 t + 36 -60 t^{-1} + 42 t^{-2}.$$
Because we're only looking for a particular solution, we can try a functional form and hope to get lucky.  In this case, we try
$$\tilde{w}(t) = t^n \exp(a t^2 + b t + c).$$
This yields something of the correct form:
$$\frac{\tilde{w}^{\prime \prime}(t)}{\tilde{w}(t)} = 4 a^2 t^2 + 4 a b t + (2a + b + 4an) + 2bn t^{-1} + n(n-1)t^{-2}.$$
Matching coefficients, we find $a = -1/2$, $b = 5$, and $n = -6$.  Therefore we have the particular solution
$$\tilde{w}_1(t) = \frac{1}{t^6} \exp\left(5t-\frac{1}{2}t^2\right).$$
From this we compute $\tilde{y}_1(t) = -\tilde{w}_1^\prime(t)/\tilde{w}_1(t) = t - 5 + 6/t$.  Substituting back $t = x+1$ we have your particular solution
$$y_1(x) = \frac{(1-x)(2-x)}{1+x}.$$
For the general solution we must solve
$$\tilde{v}^\prime(t) + 2 \tilde{y}_1(t) \tilde{v}(t) = -1.$$
Finding a homogeneous solution to this is straightforward:
$$(\log \tilde{v}_h(t))^\prime = -2 \tilde{y}_1(t) = 2 (\log \tilde{w}(t))^\prime.$$
Therefore
$$\tilde{v}_h(t) = \tilde{w}(t)^2 = \frac{\exp(10t-t^2)}{t^{12}}.$$
Finally, we need a particular solution $\tilde{v}_1$.  The standard way to solve for $\tilde{v}_1$ is by multiplying by an integrating factor:
$$\tilde{\mu}(t) = \exp\left(\int^t 2 \tilde{y}_1(t)\,dt\right) = t^{12} \exp(t^2 - 10t).$$
Then
$$(\tilde{v}(t) \tilde{\mu}(t))^\prime = -\tilde{\mu}(t).$$
Integrating $\tilde{\mu}(t)$ explicitly is a bit messy: it involves polynomials with large coefficients and a variant of the error function.  So we'll just leave the particular solution $\tilde{v}_1(t)$ expressed as
$$\tilde{v}_1(t) = -\frac{1}{\tilde{\mu}(t)}\int^t \tilde{\mu}(s)\,ds.$$
Once this integral is evaluated, we may translate everything back into $x$ and write the general solution as
$$y(x) = y_1(x) + \frac{1}{v_1(x) + C v_h(x)} = \frac{(1-x)(2-x)}{1+x} + \frac{(1+x)^{12}}{(1+x)^{12} v_1(x) + C \exp((1+x)(9-x))}.$$
