VOOZH about

URL: https://www.geeksforgeeks.org/r-language/find-the-power-of-a-matrix-in-r/

⇱ Find the power of a matrix in R - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Find the power of a matrix in R

Last Updated : 5 Apr, 2021

In this article, we are going to see how to compute the power of a matrix in R Programming Language. Matrix is an arrangement of numbers into rows and columns.

Different ways of finding the power of matrix in R programming:

  • By using %^%.
  • By using a power function.

Method 1: By using %^%

Before using this we need to import expm library into our R studio.

Installing expm library into R studio:

Step 1: First you need to select tools.

👁 Image

Step 2: After selecting the tool you need to press install packages:

👁 Image

Below is the implementation:

We Import the expm and assigned values into the mat by using the matrix function. After that, we are finding the power of the matrix.

Output:

👁 Image

Method 2: By using a power function.

For using the power function we need to install matrixcalc package into our Rstudio

Below is the implementation:

Here we import the matrixcalc and assigned values into the mat by using matrix function. After that, we are finding the power of matrix by using power function.

Output:

👁 Image
Comment

Explore