# MATLAB Newton non-linear equation

I have the following non-linear equation:

where $w0=0.25,w0=0.5,w0=0.75$. I have to prove that if $k$ is a root, then also $−k$ is a root and that there exists only one $k∈(0,1)$ root, but my MATLAB code doesn't return any solution.

Using wolframalpha I have computed the derivative of w0 and obtained, the constants w0=0.25=0.5=0.75 were ignored.

In MATLAB I have the following function to compute the roots of non-linear equations:

And my test file looks like this:

Any idea to make my code functional is appreciated.

## 1 Answer

You've written w1 = @(k) ((2*k)/(log((1+k)*(1-k))))-0.25; but your original function means this should be w1 = @(k) ((2*k)/(log((1+k)/(1-k))))-0.25; and similar for the other anonymous functions. The difference is division within the log rather than multiplication. Also note that there are singularities in this function at $k=\{-1, 0, 1\}$ and the function is complex valued outside of the range [0,1] so Newton's method will not be very reliable (especially since the roots are very close to the singularities at $\pm1$). You may be better off with a bracketing method such as bisection or false position.

Note that if your goal is to "prove" that if $k\in(0,1)$ is a root, then $-k$ is a root, finding the root numerically is not proof at all. You actually need to perform some (relatively simple) manipulations of the equation to show symmetry about $k=0$.