As per suggestions of the people from MathOverflow, I'm reposting my question here:
I'm currently trying to solve a linear system $Ax = B$, where the matrix $A$ is ill conditioned (i.e. nearly singular), with a condition number of $~10^7$. The aforementioned linear system arises from a finite difference discretization.
The mathematical model for my problem is a PDE with derivatives of $x$ and $t$. Therefore, I'm solving a linear system of a discretized mesh of points with interval $\Delta x$ for each time step $\Delta t$. I'm already using centered differences for time, but because the problem has mixed derivatives (i.e. dependent of both $x$ and $t$), the problem still falls into a linear system.
My question is: how can I find a solution to this linear system? The most common solution I saw is doing preconditioning on matrix $A$, so it gets better conditioned. But, due to my engineering background, I hardly understand what must be done to precondition matrix $A$. I saw many different methods (like Jacobi and ILU factorization), but I don't know how to apply them.
On a sidenote, I'm doing this on MATLAB, so if anyone know any in-built function that can help me, it would be very appreciated. I tried gmres but it didn't work (the solution still "exploded" after a few steps).
EDIT: Here is the equation as asked
$$ EIr\left[\frac{\partial^4\theta}{\partial x^4}-6\left(\frac{\partial\theta}{\partial x}\right)^2\frac{\partial^2\theta}{\partial x^2}\right]-EAr\left[\frac{\partial u_x}{\partial x}\frac{\partial^2\theta}{\partial x^2}+\frac{\partial^2 u_x}{\partial x^2}\frac{\partial\theta}{\partial x}+1.5r^2\frac{\partial^2\theta}{\partial x^2}\left(\frac{\partial\theta}{\partial x}\right)^2\right]-I_pr\omega\left[2\frac{\partial^2\theta}{\partial x \partial t}\frac{\partial\theta}{\partial x}+\frac{\partial\theta}{\partial t}\frac{\partial^2\theta}{\partial x^2}\right]-m_pr\frac{\partial u_x}{\partial x}\frac{\partial^2\theta}{\partial t^2}+m_pr\frac{\partial^2 u_x}{\partial t^2}\frac{\partial\theta}{\partial x}-(x+u_x)m_pr\frac{\partial^3\theta}{\partial x \partial^2 t}+(x+u_x)m_pr\left(\frac{\partial\theta}{\partial t}\right)^2\frac{\partial\theta}{\partial x}+m_pg\sin\theta = 0 $$