** solve()** function in R Language is used to solve linear algebraic equation. Here equation is like a*x = b, where b is a vector or matrix and x is a variable whose value is going to be calculated.

Syntax:solve(a, b)

Parameters:

a:coefficients of the equation

b:vector or matrix of the equation

**Example 1:**

`# R program to illustrate ` `# solve function ` ` ` `# Calling solve() function to ` `# calculate value of x in ` `# ax = b, where a and b is ` `# taken as the arguments ` `solve(` `5` `, ` `10` `) ` `solve(` `2` `, ` `6` `) ` `solve(` `3` `, ` `12` `) ` |

*chevron_right*

*filter_none*

**Output:**

[1] 2 [1] 3 [1] 4

**Example 2:**

`# R program to illustrate ` `# solve function ` ` ` `# Create 3 different vectors ` `# using combine method. ` `a1 <` `-` `c(` `3` `, ` `2` `, ` `5` `) ` `a2 <` `-` `c(` `2` `, ` `3` `, ` `2` `) ` `a3 <` `-` `c(` `5` `, ` `2` `, ` `4` `) ` ` ` `# bind the three vectors into a matrix ` `# using rbind() which is basically ` `# row-wise binding ` `A <` `-` `rbind(a1, a2, a3) ` ` ` `# print the original matrix ` `print` `(A) ` ` ` `# Use the solve() function ` `# to calculate the inverse ` `T1 <` `-` `solve(A) ` ` ` `# print the inverse of the matrix ` `print` `(T1) ` |

*chevron_right*

*filter_none*

**Output:**

[, 1] [, 2] [, 3] a1 3 2 5 a2 2 3 2 a3 5 2 4 a1 a2 a3 [1, ] -0.29629630 -0.07407407 0.4074074 [2, ] -0.07407407 0.48148148 -0.1481481 [3, ] 0.40740741 -0.14814815 -0.1851852

## Recommended Posts:

- Algebraic Operations on a Matrix in R
- Calculate the Root of a Equation within an interval in R Programming - uniroot() Function
- Fitting Linear Models to the Data Set in R Programming - glm() Function
- Perform Linear Regression Analysis in R Programming - lm() Function
- Linear Discriminant Analysis in R Programming
- Check if a Function is a Primitive Function in R Programming - is.primitive() Function
- Compute Density of the Distribution Function in R Programming - dunif() Function
- Apply a Function over a List of elements in R Programming - lapply() Function
- Search the Interval for Minimum and Maximum of the Function in R Programming - optimize() Function
- Compute the Natural Logarithm of the Absolute Value of Gamma Function in R Programming - lgamma() Function
- Compute the Logarithmic Derivative of the gamma Function in R Programming - digamma() Function
- Compute the Second Derivative of the Logarithmic value of the gamma Function in R Programming - trigamma() Function
- Get the List of Arguments of a Function in R Programming - args() Function
- Recursively apply a Function to a List in R Programming - rapply() function
- Apply a Function over a Ragged Array in R Programming - tapply() Function
- Applying a Function over an Object in R Programming - sapply() Function
- Compute the value of Cauchy Quantile Function in R Programming - qcauchy() Function
- Compute value of Logistic Quantile Function in R Programming - qlogis() Function
- Compute value of Log Normal Quantile Function in R Programming - qlnorm() Function
- Compute the Value of Poisson Quantile Function in R Programming - qpois() Function

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.