# Help solving a system [closed]

I am trying to solve this system for r and c but I get an error "Solve::ivar: r is not a valid variable.". What is wrong here?

Solve[2 c+2 r==2 s && (c+p+2 r)/c==(b+p+r)/(-b+r),{r ,c }]


Thanks.

-

## closed as too localized by István Zachar, Artes, ssch, rm -rf♦Apr 7 '13 at 16:36

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Clear[r] first and then run your code. –  xzczd Apr 7 '13 at 11:23

Solve::ivar: r is not a valid variable.

but

Solve::ivar: (* something, probably a number *) is not a valid variable.

And, if you delete some parts of your code, for example:

Look, do you feel something strange? If not, compare it with this one:

Now you must notice the difference, yeah, the colorings of r are different.

The colorings in Mathematica do make sense. Blue means that the global symbol has no value, including OwnValues, DownValues, SubValues, UpValues… and when the symbol gets either of the values, it turns black. One should always pay attention to the coloring. For your case, try the following code:

r = 1
Solve[2 c + 2 r == 2 s && (c + p + 2 r)/c == (b + p + r)/(-b + r), {r, c}]
(* The code above gives a warning *)
Clear[r]
Solve[2 c + 2 r == 2 s && (c + p + 2 r)/c == (b + p + r)/(-b + r), {r, c}]
(* Now you get what you expect. *)


The issue of values really involves a lot, I'd like not to (and in fact, not be able to… ) cover the whole. You can get more information by checking the document and searching in this site.

-
 In[1]:= Solve[2 c + 2 r == 2 s && (c + p + 2 r)/c == (b + p + r)/(-b + r), {r, c}]

Out[1]= {{r -> 1/2 (-p - Sqrt[2 b p + p^2 + 4 b s + 2 p s]), c -> 1/2 (p + 2 s + Sqrt[(2 b + p) (p + 2 s)])}, {r ->1/2 (-p + Sqrt[2 b p + p^2 + 4 b s + 2 p s]), c -> 1/2 (p + 2 s - Sqrt[(2 b + p) (p + 2 s)])}}


it works well in mathematica 8.0 !

-
by me too ! (mathematica 8.0.4) –  andre Apr 7 '13 at 12:14

I think the correct approach here should be:

Reduce[2 c + 2 r ==
2 s && (c + p + 2 r)/c == (b + p + r)/(-b + r), {r, c}]

-