0
$\begingroup$

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???

$\endgroup$
2
  • $\begingroup$ Unanswerable if you don't give us the expression for Aux. $\endgroup$ Apr 13, 2018 at 17:30
  • $\begingroup$ Ok, here it goes! $\endgroup$
    – Cosapocha
    Apr 13, 2018 at 17:53

3 Answers 3

2
$\begingroup$
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 *)
$\endgroup$
1
$\begingroup$

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}} *)
$\endgroup$
3
  • $\begingroup$ I think you forgot some code $\endgroup$
    – m_goldberg
    Apr 14, 2018 at 2:04
  • $\begingroup$ Oh, well spotted !! Sorry for my previous comment :) (deleted at once!!)...Now, my answer is corrected. $\endgroup$ Apr 14, 2018 at 12:46
  • $\begingroup$ c30 -> 0.9, not 0.3 $\endgroup$
    – lotus2019
    Jul 30, 2022 at 8:34
0
$\begingroup$

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}}   *)
$\endgroup$
3
  • $\begingroup$ 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. $\endgroup$
    – Akku14
    Apr 14, 2018 at 20:32
  • $\begingroup$ 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. $\endgroup$ Apr 14, 2018 at 21:28
  • $\begingroup$ The OP already has a general solution. When he defines definite values, he has problems with the solve command, as he told. $\endgroup$
    – Akku14
    Apr 29, 2018 at 5:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.