---
name: "newton"
section: "4rheolef"
platform: "linux"
package: "librheolef-dev"
version: "7.0-2+b1"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/newton/4rheolef"
---

# newton(4rheolef)

## NAME

**newton** -- Newton nonlinear algorithm

## DESCRIPTION

Nonlinear Newton algorithm for the resolution of the following problem:

```
       F(u) = 0

```

A simple call to the algorithm writes:

```
    my_problem P;
    field uh (Vh);
    newton (P, uh, tol, max_iter);

```

The **my\_problem** class may contains methods for the evaluation of F (aka residue) and its derivative:

```
    class my_problem {
    public:
      typedef value_type;
      value_type residue          (const value_type& uh)  const;
      Float dual_space_norm  (const value_type& mrh) const;
      void update_derivative      (const value_type& uh)  const;
      value_type derivative_solve (const value_type& mrh) const;
    };

```

The **dual\_space\_norm** returns a scalar from the weighted residual field term **mrh** returned by the **residue** function: this scalar is used as stopping criteria for the algorithm. The **update\_derivative** and **derivative\_solver** members are called at each step of the Newton algorithm. See the example **p\_laplacian.h** in the user's documentation for more.

## IMPLEMENTATION

```
template <class Problem, class Field>
int newton (const Problem& P, Field& uh, Float& tol, size_t& max_iter, odiststream *p_derr = 0) {
    if (p_derr) *p_derr << "# Newton:" << std::endl << "# n r" << std::endl << std::flush;
    for (size_t n = 0; true; n++) {
      Field rh = P.residue(uh);
      Float r = P.dual_space_norm(rh);
      if (p_derr) *p_derr << n << " " << r << std::endl << std::flush;
      if (r <= tol) { tol = r; max_iter = n; return 0; }
      if (n == max_iter) { tol = r; return 1; }
      P.update_derivative (uh);
      Field delta_uh = P.derivative_solve (-rh);
      uh += delta_uh;
    }
}

```

## COPYRIGHT

Copyright (C) 2000-2018 Pierre Saramito \<Pierre.Saramito@imag.fr\> GPLv3+: GNU GPL version 3 or later \<http://gnu.org/licenses/gpl.html\>. This is free software: you are free to change and redistribute it.  There is NO WARRANTY, to the extent permitted by law.
