# Doubt about the entries for calculating the matricial equation Ax = b

**URL:** <https://root-forum.cern.ch/t/doubt-about-the-entries-for-calculating-the-matricial-equation-ax-b/56221>\
**Category:** Newbie\
**Created:** [August 30, 2023, 12:21pm UTC](https://root-forum.cern.ch/t/doubt-about-the-entries-for-calculating-the-matricial-equation-ax-b/56221 "2023-08-30T12:21:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![guilherme\_morett](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/g/edb3f5/32.png) [@guilherme\_morett](https://root-forum.cern.ch/u/guilherme_morett)\
**Post date:** [August 30, 2023, 12:21pm UTC](https://root-forum.cern.ch/t/doubt-about-the-entries-for-calculating-the-matricial-equation-ax-b/56221/1 "2023-08-30T12:21:15Z")

</div>

Hi!  
In my program, I have to solve a matricial equation of the type M\*a = ra. Where the entries are the Matrix M (10 \* 10) and the vector ra. I read the chapter 16.6 Matrix Decompositions and I found the command TVectorD Solve(const TVectorD &b,Bool\_t &ok) which is the most direct manner to calculate the solution. But how to add the matrix A as a parameter of the command Solve. In this example there is only the vector b as the function argument? Do I have to apply the LU decompostion before in the M matrix?

Is that the correct way to solve the matricial equation M\*a = ra?

```auto
TDecompLU lu(M);
   Bool_t ok;
   lu.Solve(ra,ok);

```

---

<div class="post-metadata">

**Author:** ![Eddy\_Offermann](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eddy_offermann/32/25079_2.png) [@Eddy\_Offermann](https://root-forum.cern.ch/u/Eddy_Offermann)\
**Post date:** [August 30, 2023, 1:02pm UTC](https://root-forum.cern.ch/t/doubt-about-the-entries-for-calculating-the-matricial-equation-ax-b/56221/2 "2023-08-30T13:02:29Z")

</div>

Solve is a method of the decomposition class and returns a TVectorD solution.  
So in your case do:

```auto
   TDecompLU lu(M);
   Bool_t ok;
   const TVectorD a = lu.Solve(ra,ok);

```
