keisoku

Halley's Method Solver

Solve f(x)=0 with Halley's method. Enter the expression, an initial guess, a tolerance, and the iteration limit to get the approximate root, f(root), iteration count, error, an iteration table, and a convergence chart.

Input

e.g. x^2 - 2, cos(x) - x, exp(x) - 3x, sin(x). Supports + - * / ^, functions like sin/cos/log/sqrt, and the constants pi and e.

e.g. 1e-10

Result

Approximate root x

1.41421356237

Converged within the tolerance.

f(root) value

4.4409e-16

Iterations

3

Final step size

3.6438e-7


Convergence of the residual |f(x)| (log-scale vertical axis)

1e-61e-51e-41e-31e-21e-11e0123Iteration

Iteration steps

nxf(x)Step |Δx|
11-10.3999999
21.39999990456-0.0400002670.014213293
31.414213198-1.0306e-63.6438e-7

Note: the derivatives f′ and f″ are approximated by central-difference numerical differentiation. Depending on the shape of f(x) the iteration may not converge, so placing the initial guess near the root makes it more stable.

How it works

  • Enter a function f(x), an initial guess x₀, a tolerance, and a maximum iteration count, and the tool finds an approximate root of f(x)=0 using Halley's method.
  • Expressions may use the four basic operations (+ - * /), exponentiation (^ or **), parentheses, the variable x, the constants pi and e, plus functions such as sin, cos, tan, exp, log (natural log), sqrt, and abs. Implicit multiplication like 2x or 2sin(x) is also understood.
  • Halley's method is an iterative scheme that uses the first and second derivatives, giving cubic convergence that is faster than Newton's method (quadratic convergence). Near the root, the number of correct digits roughly triples with each iteration.
  • Alongside the approximate root, the tool shows the value of f(root), the iteration count, and the final step size, and lets you inspect x and the residual at each iteration in a table and convergence chart.
  • If the initial guess is far from the root, or depending on the shape of the function, the method may not converge. In that case, move the initial guess closer to the root or revise the tolerance and iteration count.
  • The derivatives are approximated by central-difference numerical differentiation, so the results are approximate values that contain a small amount of error.