I have a function of the form -
$F = \phi u + \frac{1}{2} \frac{d^2u}{dt^2} + |u|^2u $ where $u = u(t)$ is a complex-valued vector of length $N$ and $\phi$ is a variable (single number).
I would like to find the root ($F=0$) of this function using Newton's method (which is probably not the best technique, but I'd like to try it anyway). The solution is expected to calculate both $\phi$ and $u(t)$.
This is not a deterministic system of equations because there is one variable more than the number of equations. This system has a solution $u = sech(t)$ and $\phi = -0.5$ which can be confirmed through substitution.
My problem at the moment is in finding the Jacobian of the system, specifically when it involves the second term in the function (the second derivative of $u$).
Here's what I have done so far -
$\frac{d}{du}\frac{d^2u}{dt^2} = \frac{dt}{du}\frac{d}{dt}(\frac{d^2u}{dt^2}) = \frac{dt}{du}\frac{d^3u}{dt^3}$.
I tried implementing the right side by doing the following -
First, I calculate $\frac{du}{dt}$ and then do a 1./(dudt) on MATLAB. Then I perform element-wise multiplication of that with $\frac{d^3}{dt^3}$. This yields many NaN terms which is not very surprising.
I am not sure how to proceed now. I'd appreciate any hints/solutions or even possible alternatives to find the root of my function.