Solving a set of equations with Newton-Raphson I want to solve this set of equations with Newton-Raphson.
Can anybody help me?
$$ \cos(x_1)+\cos(x_2)+\cos(x_3)= \frac{3}{5} $$
$$ \cos(3x_1)+\cos(3x_2)+\cos(3x_3)=0 $$
$$ \cos(5x_1)+\cos(5x_2)+\cos(5x_3)=0 $$
Best regards.
 A: I am going to jump start you, but you need to show some work.
The regular Newton-Raphson method is initialized with a starting point $x_0$ and then you iterate $x_{n+1}=x_n-\dfrac{f(x_n)}{f'(x_n)}$. 
In higher dimensions, there is an exact analog. We define:
$$F\left(\begin{bmatrix}x_1\\x_2\\x_3\end{bmatrix}\right) = \begin{bmatrix}f_1(x_1,x_2,x_3) \\  f_2(x_1,x_2,x_3)  \\ f_3(x_1,x_2,x_3)\end{bmatrix} = \begin{bmatrix}\cos x_1 + \cos x_2 + \cos x_3 -\dfrac{3}{5} \\   \cos 3x_1 + \cos 3x_2 + \cos 3x_3  \\ \cos 5x_1 + \cos 5x_2 + \cos 5x_3  \end{bmatrix}= \begin{bmatrix}0\\0\\0\end{bmatrix}$$
The derivative of this system is the $3x3$ Jacobian given by:
$$J(x_1,x_2,x_3) = \begin{bmatrix} \dfrac{\partial f_1}{\partial x_1} & \dfrac{\partial f_1}{\partial x_2} & \dfrac{\partial f_1}{\partial x_3}\\ \dfrac{\partial f_2}{\partial x_1} & \dfrac{\partial f_2}{\partial x_2} & \dfrac{\partial f_2}{\partial x_3} \\ \dfrac{\partial f_3}{\partial x_1} & \dfrac{\partial f_3}{\partial x_2} & \dfrac{\partial f_3}{\partial x_3}\end{bmatrix} = \begin{bmatrix} -\sin x_1 & -\sin x_2 & -\sin x_3 \\ -3\sin 3x_1 & -3\sin 3x_2 & -3\sin 3x_3 \\ -5\sin 5x_1 & -5\sin 5x_2 & -5\sin 5x_3 \end{bmatrix}$$
The function $G$ is defined as:
$$G(x) = x - J(x)^{-1}F(x)$$
and the functional Newton-Raphson method for nonlinear systems is given by the iteration procedure that evolves from selecting an initial $x^{(0)}$ and generating for $k \ge 1$,
$$x^{(k)} = G(x^{(k-1)}) = x^{(k-1)} - J(x^{(k-1)})^{-1}F(x^{(k-1)}).$$
We can write this as:
$$\begin{bmatrix}x_1^{(k)}\\x_2^{(k)}\\x_3^{(k)}\end{bmatrix} = \begin{bmatrix}x_1^{(k-1)}\\x_2^{(k-1)}\\x_3^{(k-1)}\end{bmatrix} + \begin{bmatrix}y_1^{(k-1)}\\y_2^{(k-1)}\\y_3^{(k-1)}\end{bmatrix}$$
where:
$$\begin{bmatrix}y_1^{(k-1)}\\y_2^{(k-1)}\\y_3^{(k-1)}\end{bmatrix}= -\left(J\left(x_1^{(k-1)},x_2^{(k-1)},x_3^{(k-1)}\right)\right)^{-1}F\left(x_1^{(k-1)},x_2^{(k-1)},x_3^{(k-1)}\right)$$
Here is a starting vector:
$$x^{(0)} = \begin{bmatrix}x_1^{(0)}\\x_2^{(0)}\\x_3^{(0)}\end{bmatrix} = \begin{bmatrix}1\\2\\3\end{bmatrix}$$
You should end up with a solution that looks something like:
$$\begin{bmatrix}x_1\\x_2\\x_3\end{bmatrix} = \begin{bmatrix} 4.094047142323228 \\ 1.2318378396357232 \\ -0.5601417633888767 \end{bmatrix}$$
Of course, for a different starting vector you are going to get a different solution and perhaps no solution at all.
A: I attempted the same iteration using Excel starting with an initial guess of $x = [1,2,3]$.  The final result was $x = [-60.64267241, 76.62997198, 43.42206157]$. However, when I started with an initial guess closer to your final result, Excel yielded similar results.
