# eigh_tridiagonal#

ivy.eigh_tridiagonal(alpha, beta, /, *, eigvals_only=True, select='a', select_range=None, tol=None)[source]#

Compute the eigenvalues and eigenvectors of a Hermitian tridiagonal matrix.

Parameters:
• alpha (`Union`[`Array`, `NativeArray`]) – A real or complex array of shape (n), the diagonal elements of the matrix. If alpha is complex, the imaginary part is ignored (assumed zero) to satisfy the requirement that the matrix be Hermitian.

• beta (`Union`[`Array`, `NativeArray`]) – A real or complex array of shape (n-1), containing the elements of the first super-diagonal of the matrix. If beta is complex, the first sub-diagonal of the matrix is assumed to be the conjugate of beta to satisfy the requirement that the matrix be Hermitian.

• eigvals_only (`bool`) – If False, both eigenvalues and corresponding eigenvectors are (default: `True`) computed. If True, only eigenvalues are computed. Default is True.

• select (`str`) – Optional string with values in {‘a’, ‘v’, ‘i’} (default is ‘a’) that (default: `'a'`) determines which eigenvalues to calculate: ‘a’: all eigenvalues. ‘v’: eigenvalues in the interval (min, max] given by select_range. ‘i’: eigenvalues with indices min <= i <= max.

• select_range (`Optional`[`Union`[`Tuple`[`int`, `int`], `List`[`int`], `Array`, `NativeArray`]]) – Size 2 tuple or list or array specifying the range of eigenvalues to (default: `None`) compute together with select. If select is ‘a’, select_range is ignored.

• tol (`Optional`[`float`]) – Optional scalar. Ignored when backend is not Tensorflow. The absolute (default: `None`) tolerance to which each eigenvalue is required. An eigenvalue (or cluster) is considered to have converged if it lies in an interval of this width. If tol is None (default), the value eps*|T|_2 is used where eps is the machine precision, and |T|_2 is the 2-norm of the matrix T.

Return type:

`Union`[`Array`, `Tuple`[`Array`, `Array`]]

Returns:

• eig_vals – The eigenvalues of the matrix in non-decreasing order.

• eig_vectors – If eigvals_only is False the eigenvectors are returned in the second output argument.

• Both the description and the type hints above assumes an array input for

• simplicity, but this function is *nestable, and therefore also accepts*

• `ivy.Container` instances in place of any of the arguments.

Examples

With `ivy.Array` input:

```>>> alpha = ivy.array([0., 1., 2.])
>>> beta = ivy.array([0., 1.])
>>> y = ivy.eigh_tridiagonal(alpha, beta)
>>> print(y)
ivy.array([0., 0.38196, 2.61803])
```
```>>> alpha = ivy.array([0., 1., 2.])
>>> beta = ivy.array([0., 1.])
>>> y = ivy.eigh_tridiagonal(alpha,
...     beta, select='v',
...     select_range=[0.2,3.0])
>>> print(y)
ivy.array([0.38196, 2.61803])
```
```>>> ivy.set_backend("tensorflow")
>>> alpha = ivy.array([0., 1., 2., 3.])
>>> beta = ivy.array([2., 1., 2.])
>>> y = ivy.eigh_tridiagonal(alpha,
...     beta,
...     eigvals_only=False,
...     select='i',
...     select_range=[1,2]
...     tol=1.)
>>> print(y)
(ivy.array([0.18749806, 2.81250191]), ivy.array([[ 0.350609  , -0.56713122],
[ 0.06563006, -0.74146169],
[-0.74215561, -0.0636413 ],
[ 0.56742489,  0.35291126]]))
```

With `ivy.Container` input:

```>>> alpha = ivy.Container(a=ivy.array([0., 1., 2.]), b=ivy.array([2., 2., 2.]))
>>> beta = ivy.array([0.,2.])
>>> y = ivy.eigh_tridiagonal(alpha, beta)
>>> print(y)
{
a: ivy.array([-0.56155, 0., 3.56155]),
b: ivy.array([0., 2., 4.])
}
```
```>>> alpha = ivy.Container(a=ivy.array([0., 1., 2.]), b=ivy.array([2., 2., 2.]))
>>> beta = ivy.Container(a=ivy.array([0.,2.]), b=ivy.array([2.,2.]))
>>> y = ivy.eigh_tridiagonal(alpha, beta)
>>> print(y)
{
a: ivy.array([-0.56155, 0., 3.56155]),
b: ivy.array([-0.82842, 2., 4.82842])
}
```
Array.eigh_tridiagonal(self, beta, /, *, eigvals_only=True, select='a', select_range=None, tol=None)#

ivy.Array instance method variant of ivy.eigh_tridiagonal. This method simply wraps the function, and so the docstring for ivy.eigh_tridiagonal also applies to this method with minimal changes.

Parameters:
• self (`Union`[`Array`, `NativeArray`]) – An array of real or complex arrays each of shape (n), the diagonal elements of the matrix.

• beta (`Union`[`Array`, `NativeArray`]) – An array or of real or complex arrays each of shape (n-1), containing the elements of the first super-diagonal of the matrix.

• eigvals_only (`bool`) – If False, both eigenvalues and corresponding eigenvectors are computed. (default: `True`) If True, only eigenvalues are computed. Default is True.

• select (`str`) – Optional string with values in {‘a’, ‘v’, ‘i’} (default: `'a'`) (default is ‘a’) that determines which eigenvalues to calculate: ‘a’: all eigenvalues. ‘v’: eigenvalues in the interval (min, max] given by select_range. ‘i’: eigenvalues with indices min <= i <= max.

• select_range (`Optional`[`Union`[`Tuple`[`int`, `int`], `List`[`int`], `Array`, `NativeArray`]]) – Size 2 tuple or list or array specifying the range of (default: `None`) eigenvalues to compute together with select. If select is ‘a’, select_range is ignored.

• tol (`Optional`[`float`]) – Optional scalar. Ignored when backend is not Tensorflow. The (default: `None`) absolute tolerance to which each eigenvalue is required. An eigenvalue (or cluster) is considered to have converged if it lies in an interval of this width. If tol is None (default), the value eps*|T|_2 is used where eps is the machine precision, and |T|_2 is the 2-norm of the matrix T.

Return type:

`Union`[`Array`, `Tuple`[`Array`, `Array`]]

Returns:

• eig_vals – The eigenvalues of the matrix in non-decreasing order.

• eig_vectors – If eigvals_only is False the eigenvectors are returned in the second output argument.

Examples

```>>> alpha = ivy.array([0., 1., 2.])
>>> beta = ivy.array([0., 1.])
>>> y = alpha.eigh_tridiagonal(beta)
>>> print(y)
ivy.array([0., 0.38196, 2.61803])
```
Container.eigh_tridiagonal(self, beta, /, *, eigvals_only=True, select='a', select_range=None, tol=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)#

ivy.Container instance method variant of ivy.eigh_tridiagonal. This method simply wraps the function, and so the docstring for ivy.eigh_tridiagonal also applies to this method with minimal changes.

Parameters:
• self (`Container`) – A container of real or complex arrays each of shape (n), the diagonal elements of the matrix.

• beta (`Union`[`Array`, `NativeArray`, `Container`]) – An array or a container of real or complex arrays each of shape (n-1), containing the elements of the first super-diagonal of the matrix.

• eigvals_only (`bool`) – If False, both eigenvalues and corresponding eigenvectors are computed. (default: `True`) If True, only eigenvalues are computed. Default is True.

• select (`str`) – Optional string with values in {‘a’, ‘v’, ‘i’} (default is ‘a’) that (default: `'a'`) determines which eigenvalues to calculate: ‘a’: all eigenvalues. ‘v’: eigenvalues in the interval (min, max] given by select_range. ‘i’: eigenvalues with indices min <= i <= max.

• select_range (`Optional`[`Union`[`Tuple`[`int`, `int`], `List`[`int`], `Array`, `NativeArray`]]) – Size 2 tuple or list or array specifying the range of eigenvalues to (default: `None`) compute together with select. If select is ‘a’, select_range is ignored.

• tol (`Optional`[`float`]) – Optional scalar. Ignored when backend is not Tensorflow. The absolute (default: `None`) tolerance to which each eigenvalue is required. An eigenvalue (or cluster) is considered to have converged if it lies in an interval of this width. If tol is None (default), the value eps*|T|_2 is used where eps is the machine precision, and |T|_2 is the 2-norm of the matrix T.

Return type:

`Union`[`Container`, `Tuple`[`Container`, `Container`]]

Returns:

• eig_vals – The eigenvalues of the matrix in non-decreasing order.

• eig_vectors – If eigvals_only is False the eigenvectors are returned in the second output argument.

Examples

```>>> alpha = ivy.Container(a=ivy.array([0., 1., 2.]), b=ivy.array([2., 2., 2.]))
>>> beta = ivy.array([0.,2.])
>>> y = alpha.eigh_tridiagonal(beta)
>>> print(y)
{
a: ivy.array([-0.56155, 0., 3.56155]),
b: ivy.array([0., 2., 4.])
}
```
```>>> alpha = ivy.Container(a=ivy.array([0., 1., 2.]), b=ivy.array([2., 2., 2.]))
>>> beta = ivy.Container(a=ivy.array([0.,2.]), b=ivy.array([2.,2.]))
>>> y = alpha.eigh_tridiagonal(beta)
>>> print(y)
{
a: ivy.array([-0.56155, 0., 3.56155]),
b: ivy.array([-0.82842, 2., 4.82842])
}
```