Name

root

Synopsis

int root(double (*f)(double x), double (*g)(double x), double *x, int *n, 
    double delta)

Return Value

0 if a root is found, -1 otherwise.

Description

Computes the root of f to which Newton’s method converges given an initial iteration point. This point is specified in x[0]. The derivative of f is specified in g. The argument n is the maximum number of iterations to perform. The argument delta is the difference between successive approximations at which to stop iterating. Upon return, successive values of x calculated during the iteration process are returned in the x array. Upon return, n contains the number of values in array x. It is the responsibility of the caller to manage the storage associated with x.

Complexity

O (n), where n is the maximum number of iterations the caller wishes to perform.

Get Mastering Algorithms with C now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.