# eig(A,?,?,?)

``````..  eig(A,[irange,][vl,][vu,][permute=true,][scale=true]) -> D, V

Computes eigenvalues and eigenvectors of ``A``. See :func:`eigfact` for
details on the ``balance`` keyword argument.

.. doctest::

julia> eig([1.0 0.0 0.0; 0.0 3.0 0.0; 0.0 0.0 18.0])
([1.0,3.0,18.0],
3x3 Array{Float64,2}:
1.0  0.0  0.0
0.0  1.0  0.0
0.0  0.0  1.0)

``eig`` is a wrapper around :func:`eigfact`, extracting all parts of the
factorization to a tuple; where possible, using :func:`eigfact` is
recommended.``````

## Examples

In the Julia programming language, the `eig(A, B)` function computes the generalized eigenvalues and eigenvectors of matrix `A` with respect to matrix `B`. It is a wrapper around the `eigfact` function, extracting all parts of the factorization into a tuple. However, it is recommended to use `eigfact` directly whenever possible.

Here are some common examples of using the `eig(A, B)` function:

1. Compute generalized eigenvalues and eigenvectors:

``````julia> A = [1 2; 3 4];
julia> B = [5 6; 7 8];
julia> D, V = eig(A, B);
julia> D
2-element Array{Complex{Float64},1}:
-0.3722813232690143 + 0.0im
5.372281323269014 + 0.0im

julia> V
2×2 Array{Complex{Float64},2}:
-0.5615528128088303+0.0im  -0.24347053680771607-0.0im
0.8276707946526256+0.0im  -0.9701425001453313 +0.0im``````

This example computes the generalized eigenvalues and eigenvectors of matrices `A` and `B` and stores them in `D` and `V` respectively.

2. Compute generalized eigenvalues only:
``````julia> A = [1 2; 3 4];
julia> B = [5 6; 7 8];
julia> D = eig(A, B)[1];
julia> D
2-element Array{Complex{Float64},1}:
-0.3722813232690143 + 0.0im
5.372281323269014 + 0.0im``````

In this example, only the generalized eigenvalues are computed and stored in `D`.

Remember, it is typically recommended to use `eigfact` instead of `eig` for better performance and flexibility.