Calculate a root
Enter a function of x. The derivative is estimated numerically with a central difference.
Supported mathematical syntax
Constants: x pi e
Functions: sin(x), cos(x), tan(x), asin(x), acos(x), atan(x),
sinh(x), cosh(x), tanh(x), sqrt(x), abs(x), exp(x),
log(x), ln(x), log10(x), floor(x), ceil(x), round(x)
Trigonometric functions use radians. Use explicit multiplication, such as 2*x rather than 2x. This calculator currently solves real-valued equations only.
Try an example
x^3 - x - 2
A real root is approximately 1.52138.
cos(x) - x
A root is approximately 0.739085.
exp(x) - 2
The root is ln(2), approximately 0.693147.
sqrt(x) - 3
The root is 9. Choose a positive initial guess.
How the Newton-Raphson method works
The Newton-Raphson method repeatedly uses the current estimate and the slope of the function to produce a new estimate. The iteration formula is:
Here, x₀ is the initial guess. Because this calculator does not require a derivative expression, it estimates the slope using a central difference:
The step size h is selected based on floating-point precision and the scale of the current estimate. Numerical differentiation is convenient, but can be less reliable for functions with discontinuities, severe cancellation, or very steep or flat regions.
Understanding errors
- Step error: the absolute difference between consecutive estimates.
- Relative step error: the step error divided by max(1, |new estimate|).
- Residual: |f(x)| at the candidate root. A small step alone does not prove that the equation is solved.
Why convergence can fail
Newton-Raphson is usually fast near a simple root, but it is not guaranteed to converge from every starting point. A near-zero derivative, an unsuitable initial guess, a discontinuity, or a cycle can prevent convergence. If the method fails, try a different initial guess or use a bracketing method such as bisection when you know an interval in which the function changes sign.
Frequently asked questions
What does this calculator find?
It estimates a real value of x for which f(x) = 0. Different initial guesses may lead to different roots, and some equations may have no real root.
Does it guarantee the correct root?
No. Newton-Raphson is an iterative numerical method. The calculator reports convergence only when both the update and the function residual are sufficiently small, but results still depend on the function evaluation and numerical derivative.
Why is the derivative estimated numerically?
This avoids requiring you to calculate and enter f′(x) separately. The trade-off is that numerical differentiation can introduce rounding error and may be unreliable near discontinuities or poorly scaled functions.
What should I do if the derivative is too small?
Try a different initial guess, inspect the graph of the function, or use a bracketing method. Dividing by a very small derivative can create an extremely large update.
What is a good tolerance?
A tolerance such as 0.000001 is a reasonable starting point for many ordinary examples. A smaller tolerance asks for a smaller update, but does not guarantee more accurate digits in every situation.
Are trigonometric functions measured in degrees?
No. The trigonometric functions use radians. Convert degrees to radians in your expression if needed.