:orphan:
# DMComputeL2Diff
This function computes the L_2 difference between a function u and an FEM interpolant solution u_h.
## Synopsis
```
#include "petscdm.h"
#include "petscdmlabel.h"
#include "petscds.h"
PetscErrorCode DMComputeL2Diff(DM dm, PetscReal time, PetscErrorCode (**funcs)(PetscInt, PetscReal, const PetscReal[], PetscInt, PetscScalar *, void *), void **ctxs, Vec X, PetscReal *diff)
```
Collective
## Input Parameters
- ***dm -*** The `DM`
- ***time -*** The time
- ***funcs -*** The functions to evaluate for each field component
- ***ctxs -*** Optional array of contexts to pass to each function, or NULL.
- ***X -*** The coefficient vector u_h, a global vector
## Output Parameter
- ***diff -*** The diff ||u - u_h||_2
## Developer Notes
This API is specific to only particular usage of `DM`
The notes need to provide some information about what has to be provided to the `DM` to be able to perform the computation.
## See Also
[](ch_dmbase), `DM`, `DMProjectFunction()`, `DMComputeL2FieldDiff()`, `DMComputeL2GradientDiff()`
## Level
developer
## Location
src/dm/interface/dm.c
## Examples
src/snes/tutorials/ex12.c
src/snes/tutorials/ex13.c
src/snes/tutorials/ex63.c
src/snes/tutorials/ex75.c
src/tao/tutorials/ex1.c
src/tao/tutorials/ex2.c
src/ts/tutorials/ex47.c
## Implementations
DMComputeL2Diff_pforest(DM dm, PetscReal time, PetscErrorCode (**funcs) in src/dm/impls/forest/p4est/pforest.h
DMComputeL2Diff_Plex(DM dm, PetscReal time, PetscErrorCode (**funcs) in src/dm/impls/plex/plexfem.c
---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/dm/interface/dm.c)
[Index of all DM routines](index.md)
[Table of Contents for all manual pages](/manualpages/index.md)
[Index of all manual pages](/manualpages/singleindex.md)