# Solving equations with subscripted variables

A student of mine tried:

Solve[1/R == 1/Subscript[R, 1] + 1/Subscript[R, 2], R]


which did not work. We then tried:

Solve[1/R == 1/R1 + 1/R2, R]


(* {{R -> (R1 R2)/(R1 + R2)}} *)


So, why doesn't Solve handle variables with subscripts?

• Well, it sees the R inside the Subscript, and so it sees three instances of the variable R in the equation. Since there are no algebraic rules for extracting R from a Subscript, Solve doesn't know what to do. Subscript[R, 1] is not interpreted as being a variable independent of R. – march Jan 21 '16 at 17:07
• @march is right: Solve[1/R == 1/Subscript[Rr, 1] + 1/Subscript[Rr, 2], R] gives the correct result; it's not Subscript per se. – egwene sedai Jan 21 '16 at 17:09
• This is why one should only use Subscript for printing stuff unless you know what you are doing. Indexing is easier done with r[i] etc. – Marius Ladegård Meyer Jan 21 '16 at 17:53
• The reason this doesn't work is that R is a symbol in its own right even when appearing Subscript, so that Mathematica thinks you're trying to solve for a variable R that also appears in the "function" named Subscript. It can't "invert" that function and therefore fails to solve for it. You have to avoid this misunderstanding by choosing a different symbol inside Subscript, or just using only Strings when doing subscripts. That's one of the safest approaches. E.g., Solve[1/R==1/Subscript["R",1]+1/Subscript["R",2],R] works fine. Caveat: avoid capital single-letter names. – Jens Jan 21 '16 at 19:20
• Solve[1/Subscript[R,""]==1/Subscript[R,1]+1/Subscript[R,2],Subscript[R,""]] – matrix89 Sep 20 '18 at 2:34

Starting in version 10 you can used Indexed to make use of subscript formatting of list indices.

sol = Solve[1/y == 1/Indexed[r, 1] + 1/Indexed[r, 2], y]
(* {{y -> (Indexed[r, {1}] Indexed[r, {2}])/(Indexed[r, {1}] + Indexed[r, {2}])}} *) You can then replace r by its list directly.

sol /. r -> {q, w}
(* {{y -> (q w)/(q + w)}} *) Hope this helps.

• PS: If you would like to subscript formatting in your input cell then you can select the Indexed function (e.g. Indexed[r, 1] and press <kbd>Ctrl</kbd> +<kbd>Shift</kbd> + <kbd>Enter</kbd>. This will evaluate in place and show the subscript format of Indexed. – Edmund Jan 21 '16 at 19:10

As mentioned in the comments, the problem is that Solve thinks that the R in Subscript[R, 1]is the same R as in the 1/R term. It's like trying to solve:

f[x, 1] + x == 0


where the function f is unknown. Basically, you should never try to solve for the variable inside of a Subscript.

The other answer both switched Subscript to Indexed, and more importantly changed the name of the symbol. Using Indexed without changing the name of the subscripted variable would still not have worked:

Solve[1/R == 1/Indexed[R, 1] + 1/Indexed[R, 2], R]


Solve::itdim: The variable R has inconsistent dimensionality.

Solve[1/R == 1/Indexed[R, {1}] + 1/Indexed[R, {2}], R]

So, one must change the name of the subscripted variable. Now, since both R and "R" look the same, you could use a string R in the Subscript instead:

Solve[1/R == 1/Subscript["R",1] + 1/Subscript["R",2], R] //TeXForm


$\left\{\left\{R\to \frac{\text{R}_1 \text{R}_2}{\text{R}_1+\text{R}_2}\right\}\right\}$

and Mathematica will have no issues.