Consider the following system -
$\phi u + \frac{1}{2}\frac{d^2u}{dt^2} + u^3 = 0$
The task is to find $\phi$ and $u$ that satisfies the above differential equation. This is just a problem given to train me in some numerical methods and not the actual problem I will be working on.
The given equation has a solution $\phi=-0.5$ and $u = sech(t)$.
I define $t$ as an N dimensional vector and therefore, $u = u(t)$ is also an N dimensional vector. $\phi$ is a scalar quantity.
Instead of solving the problem itself, my primary task is calculate the value of the function and the Jacobian for some initial $\phi_0$ and $u_0$. Assume I am using some sort of finite difference method to calculate the derivative in the equation. And let the derivative matrix be $\textbf{D}$.
My question is - how do I calculate the Jacobian?
I assumed that the Jacobian will be $\phi \textbf{I} + \textbf{D} + \textbf{u}_3\textbf{I}$ where I is the identity matrix and $\textbf{u}_3$ is row vector form of u which has been elementwise cubed.
I am not sure if this is correct because the part that bothers me the most is the D. It does make sense if I assume that my method of differentiation is finite-difference based, but I am not satisfied with it I am using some other technique like spectral differentiation where D is a lot more complicated.
I calculated the Jacobian this way and found that I found the solution to be close to the analytical solution, but I was told that often, an incorrect Jacobian might still yield the right solution.
Is what I have done correct? Is there any way to verify it?
The calculation of the Jacobian is important to me because I will be performing some stability analysis using eigenvalues of the Jacobian.