[Math] Numerical Methods for Algebraic Equations – Non root finding

numerical methods

I'm researching a topic for solving general algebraic equations using numerical method. My numerical recipe knowledge is rather rusty with the Bisection to Newton's methods but I don't think those could be applied for equations such as:

$$
\frac{x^2}{2+x}+\cos(x+1)=x^2\times \sin\left(\frac{\sqrt x}{x^2}\right)
$$

with an approximated numerical solutions:
$$
x_1\approx0.531709
$$
and
$$
x_2\approx3.401750
$$
I know matlab has the vpasolve function for numerical approximation of the unknown variable but I can't find any details regarding the used method or even if such a numerical method exist that can be used to approximate the unknown variable for any given equation with one unknown var. At first I tried applying Newton Raphson's method but stuck right at the beginning since:

  1. I'm not searching for a solution in the form of $f(x)=0$.
  2. I don't know the derivative for the equation and I don't want to apply symbolic algorithms.

Thank you for the tips!
Cheers!

Best Answer

As already said in answers and comments, consider that you look for the zero's of the function $$f(x)=\frac{x^2}{2+x}+\cos(x+1)-x^2\times \sin\left(\frac{\sqrt x}{x^2}\right)$$ and apply Newton method which, starting from a "reasonable" guess $x_0$, will update it according to $$x_{n+1}=x_n-\frac{f(x_n)}{f'(x_n)}$$ For the function, let me be very lazy and choose $x_0=5$; the successive iterates will then be $$x_1=2.63695$$ $$x_2=3.65956$$ $$x_3=3.40642$$ $$x_4=3.40175$$ which is the solution for six significant figures.

For sure, you need the derivative of the function. But, may be, you do not want to establish its analytical expression. Then, just compute it using finite differences such as $$f'(x_n)=\frac{f(x_n+\epsilon)-f(x_n)} \epsilon$$ or, better $$f'(x_n)=\frac{f(x_n+\epsilon)-f(x_n-\epsilon)} {2\epsilon}$$ using, for example, $\epsilon=\frac{x_n}{1000}$. This will work fine.