The Euler-Bernoulli beam equation is as follows:
$$q = \dfrac{\partial^2}{\partial x^2}\left(EI\dfrac{\partial^2 \delta}{\partial x^2}\right)$$
where $q$ is the distributed load along the beam, $\delta$ is the deflection, and $EI$ is the beam's stiffness (assumed constant). So, the deflection is the fourth integral of the applied load. From this we can derive that, for the case of a uniform load along the entire beam of uniform stiffness:
$$\begin{align}
Q &= \int q\text{d}x \\
&= qx + Q_0 \\
M &= \int Q\text{d}x \\
&= \dfrac{1}{2}qx^2 + Q_0x + M_0 \\
\theta &= \dfrac{1}{EI}\int M\text{d}x \\
&= \dfrac{1}{6}qx^3 + \dfrac{1}{2}Q_0x^2 + M_0x + \theta_0 \\
\delta &= \int \theta\text{d}x \\
&= \dfrac{1}{24}qx^4 + \dfrac{1}{6}Q_0x^3 + \dfrac{1}{2}M_0x^2 + \theta_0x + \delta_0 \\
\end{align}$$
where $q$ is the constant uniform load and $Q_0$, $M_0$, $\theta_0$ and $\delta_0$ are the shear force, bending moment, rotation and deflection at the beam's origin, respectively.
So, the problem you're having is that your initial equation is incorrect: a beam under a UDL's deflection is a quartic function. And for small deflections and rotations, you are correct: we can approximate the rotations (in radians) as equal to the tangent of the deflection, i.e. its derivative.