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

# interpolate(4rheolef)

Lagrange interpolation of a function

## NAME

**interpolate** - Lagrange interpolation of a function

## DESCRIPTION

 The function **interpolation** implements the\
  Lagrange interpolation of a function or a class-function.

## SYNOPSIS

 template \<class Function\>\
  field interpolate (const space& Xh, const Function& f);

## EXAMPLE

 The following code compute the Lagrange interpolation\
  **pi\_h\_u** of u(x).

```
  Float u(const point& x);
  ...
  geo omega("square");
  space Xh (omega, "P1");
  field pi_h_u = interpolate (Xh, u);

```

## ADVANCED EXAMPLE

It is possible the replace the function **u** by a variable of the **field** type that represents a picewise polynomial function: this invocation allows the reinterpolation of a field on another mesh or with another approximation.

```
  geo omega2 ("square2");
  space X2h (omega2, "P1");
  field uh2 = interpolate (X2h, pi_h_u);

```

## 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.
