# Solve matrix equation

I have this 4x4 Matrix to which I apply the Solve function:

A = FullSimplify[Solve[Aux == 0, {r10, r20, r30}]]


Essentialy, it has just 3 independent inputs, which define a system of 3 equations and 3 variables:

(c30 - r30)/4==0
1/4 (c10 (-1 + p)^2 - c20 (-1 + p)^2 - r10 + r20)==0
1/4 (c10 (-1 + p)^2 + c20 (-1 + p)^2 - r10 - r20)==0


I got the solution:

{{r10 -> c10 (-1 + p)^2, r20 -> c20 (-1 + p)^2, r30 -> c30}}


Which is perfect.

But when I define the values of c10, c20 and c30, for example:

 c10=0.1 ; c20=0.1 ; c30=0.9


The solve command returns:

{}


I did the calculations on paper and there is a well defined result. Also I tried to put the equations inside the Solve function and it also gives the correct result. Which is the problem???

• Unanswerable if you don't give us the expression for Aux. – J. M.'s torpor Apr 13 '18 at 17:30
• Ok, here it goes! – Cosapocha Apr 13 '18 at 17:53

eqns = {(c30 - r30)/4 == 0,
1/4 (c10 (-1 + p)^2 - c20 (-1 + p)^2 - r10 + r20) == 0,
1/4 (c10 (-1 + p)^2 + c20 (-1 + p)^2 - r10 - r20) == 0};

sol = Solve[eqns, {r10, r20, r30}][[1]] // Simplify

(* {r10 -> c10 (-1 + p)^2, r20 -> c20 (-1 + p)^2, r30 -> c30} *)


Verifying the solution

And @@ (eqns /. sol)

(* True *)

values = {c10 -> 0.1, c20 -> 0.1, c30 -> 0.9} // Rationalize;


Solving with the assigned values

sol2 = Solve[eqns /. values, {r10, r20, r30}][[1]] // Simplify

(* {r10 -> 1/10 (-1 + p)^2, r20 -> 1/10 (-1 + p)^2, r30 -> 9/10} *)


sol2 is identical to that given by sol with the values inserted

sol2 === (sol /. values)

(* True *)


To verify sol2 the eqns must use the assigned values either before or after sol2 is used

And @@ (eqns /. values /. sol2)

(* True *)

And @@ (eqns /. sol2 /. values)

(* True *)


Once you have your seeked solutions and you want to assign the values to the constants c10, c20 and c30, just use replacement rules:

sol = {{r10 -> c10 (-1 + p)^2, r20 -> c20 (-1 + p)^2, r30 -> c30}};
sol /. {c10 -> 0.1, c20 -> 0.1, c30 -> 0.3}

(* {{r10 -> 0.1 (-1 + p)^2, r20 -> 0.1 (-1 + p)^2, r30 -> 0.9}} *)

• I think you forgot some code – m_goldberg Apr 14 '18 at 2:04
• Oh, well spotted !! Sorry for my previous comment :) (deleted at once!!)...Now, my answer is corrected. – José Antonio Díaz Navas Apr 14 '18 at 12:46

Working with MMA 8.0, there are no problems. Clear all parameter definitions like that:

ClearAll["Global*"];
c10 = 0.1; c20 = 0.1; c30 = 0.9;
sol=FullSimplify[First@Solve[{(c30 - r30)/4 == 0,
1/4 (c10 (-1 + p)^2 - c20 (-1 + p)^2 - r10 + r20) == 0,
1/4 (c10 (-1 + p)^2 + c20 (-1 + p)^2 - r10 - r20) == 0}, {r10, r20,
r30}]]

(*   {r10 -> (0.316228- 0.316228 p)^2,
r20 -> (0.316228- 0.316228 p)^2, r30 -> 0.9}   *)


Edit: Expand shows, this is the same result as at the other answers:

sol // Expand

(*   {r10 -> 0.1- 0.2 p + 0.1 p^2,
r20 -> 0.1- 0.2 p + 0.1 p^2, r30 -> 0.9}   *)

{{r10 -> 0.1 (-1 + p)^2, r20 -> 0.1 (-1 + p)^2, r30 -> 0.9}} // Expand

(*   {{r10 -> 0.1- 0.2 p + 0.1 p^2,
r20 -> 0.1- 0.2 p + 0.1 p^2, r30 -> 0.9}}   *)

• To @José Antonio Díaz Navas. My answer is not wrong. Do //Expand `and you get the same as yours. See Edit. Please check this before making changes. – Akku14 Apr 14 '18 at 20:32
• No problem. Your code did not give your result, but mine in MMA 11.3. Anyway, the OP wants substitute values when getting the general solution, not a particular one. – José Antonio Díaz Navas Apr 14 '18 at 21:28
• The OP already has a general solution. When he defines definite values, he has problems with the solve command, as he told. – Akku14 Apr 29 '18 at 5:53