:orphan:
# KSPConvergedRateView
Displays the reason a `KSP` solve converged or diverged to a viewer 
## Synopsis
```
#include "petscksp.h" 
#include "petscmat.h" 
PetscErrorCode KSPConvergedRateView(KSP ksp, PetscViewer viewer)
```
Collective


## Input Parameters

- ***ksp    -*** iterative context obtained from `KSPCreate()`
- ***viewer -*** the viewer to display the reason



## Options Database Key

- ***-ksp_converged_rate -*** print reason for convergence or divergence and the convergence rate (or 0.0 for divergence)



## Notes
To change the format of the output, call PetscViewerPushFormat(viewer,format) before this call.

Suppose that the residual is reduced linearly, $r_k = c^k r_0$, which means $log r_k = log r_0 + k log c$. After linear regression,
the slope is $\log c$. The coefficient of determination is given by $1 - \frac{\sum_i (y_i - f(x_i))^2}{\sum_i (y_i - \bar y)}$,
see also https://en.wikipedia.org/wiki/Coefficient_of_determination




## See Also
 [](ch_ksp), `KSPConvergedReasonView()`, `KSPGetConvergedRate()`, `KSPSetTolerances()`, `KSPConvergedDefault()`

## Level
intermediate

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


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


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