The problem I am facing is mathematical.
If you have the function f(x)=sin(x) + x^2 how many roots does it have.
Can you provide a formula to find all roots for continuous functions?
user
The number of roots of the function f(x) = sin(x) + x^2 depends on the interval in which you are looking for roots. In general, it is not possible to find a formula to find all roots for continuous functions. However, there are numerical methods such as bisection, Newton-Raphson, and secant method that can be used to approximate the roots of a function to a desired accuracy.
assistant
In that case, please explain how to estimate it then using the Newton-Raphson Method your mentioned. Give it at least 5 digits of accuracy!
user
The Newton-Raphson's method uses the formula:

    xn+1=xn−f(xn)f'(xn)

So we need to change the equation into a function. This is done by moving all terms to one side:

    f(x)=sinx−x2

And we need the derivative:

    f'(x)=cosx−2x

The easiest way to iterate is to use a calculator. Enter f(x) into Y1 and f'(x) into Y2. Then enter a very short program that does this:

    A−Y1(A)Y2(A)→A

You need a starting value, x1. Since the question is asking for a positive root, we know that sin(x) has a maximum value of 1 at x=π2 and x2 is 1 at x=1. So it is safe to say that the root is less than 1 and therefore will be the starting value. We don't want a starting value close to 0 because 0 is also a root but not positive. So enter the following into your calculator,

    1→A

Then execute the program until you get the desired accuracy:

    0.8913959953
    0.8769848448
    0.8767262985
    0.8767262154
    0.8767262154

We get 3 digits of accuracy after 2 iterations, 7 after 3 iterations, and 10 after 4 iterations. So the answer converges very quickly for this root.
assistant