:orphan:
# VecNormalize
Normalizes a vector by its 2-norm.
## Synopsis
```
#include "petscvec.h"
PetscErrorCode VecNormalize(Vec x, PetscReal *val)
```
Collective
## Input Parameter
- ***x -*** the vector
## Output Parameter
- ***val -*** the vector norm before normalization. May be `NULL` if the value is not needed.
## See Also
[](ch_vectors), `Vec`, `VecNorm()`, `NORM_2`, `NormType`
## Level
intermediate
## Location
src/vec/vec/interface/rvector.c
## Examples
src/ksp/ksp/tutorials/ex49.c
src/ksp/ksp/tutorials/ex67.c
src/snes/tutorials/ex62.c
src/snes/tutorials/ex63.c
src/snes/tutorials/ex69.c
src/snes/tutorials/ex76.c
src/ts/tutorials/ex76.c
src/ts/tutorials/ex77.c
---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/vec/vec/interface/rvector.c)
[Index of all Vec routines](index.md)
[Table of Contents for all manual pages](/manualpages/index.md)
[Index of all manual pages](/manualpages/singleindex.md)