# KSPInitialResidual
Computes the residual. Either b - A*C*u = b - A*x with right preconditioning or C*(b - A*x) with left preconditioning; the latter residual is often called the "preconditioned residual". 
## Synopsis
```
#include "petscksp.h" 
PetscErrorCode KSPInitialResidual(KSP ksp, Vec vsoln, Vec vt1, Vec vt2, Vec vres, Vec vb)
```
Collective


## Input Parameters

- ***vsoln    -*** solution to use in computing residual
- ***vt1, vt2 -*** temporary work vectors
- ***vb       -*** right-hand-side vector



## Output Parameters

- ***vres     -*** calculated residual





## Note
This routine assumes that an iterative method, designed for
```none
A x = b
```
will be used with a preconditioner, C, such that the actual problem is either
```none
AC u = b (right preconditioning) or
```
```none
CA x = Cb (left preconditioning).
```
This means that the calculated residual will be scaled and/or preconditioned;
the true residual
```none
b-Ax
```
is returned in the vt2 temporary.


## See Also
 [](chapter_ksp), `KSP`, `KSPSolve()`, `KSPMonitor()`

## Level
developer

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/interface/itres.c.html#KSPInitialResidual">src/ksp/ksp/interface/itres.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/ksp/ksp/interface/itres.c)


[Index of all KSP routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
