# Is it possible to evaluate this algebraic expression ?

a +b == Subscript[q,1]n + Subscript[r,1]
b + c == Subscript[q,2]n + Subscript[r,2]
Subscript[r,1] + c == Subscript[q, 3]n + Subscript[r,3]
Expand[a+b+c]


I want to get the result of a+b+c which should be (q1+q3)n + r3 (from 1 and 3). Is it possible to get this result evaluated automatically ? If so what command should i use , instead of Expand.

Somtimes the use of subscript is dangerous, so I avoid it if possible.

You have three equations

eqn = {a + b == q1 n + r1, b + c == q2 n + r2, r1 + c == q3 n + r3}


which can easily be solved for {a,b,c}

sol = Solve[eqn, {a, b, c}][[1]]
a+b+c /.sol
(* n (q1 + q3) + r3 *)

Reduce[{a + b == Subscript[q, 1] n + Subscript[r, 1],
b + c == Subscript[q, 2] n + Subscript[r, 2],
Subscript[r, 1] + c == Subscript[q, 3] n + Subscript[r, 3],
a + b + c == d}]

(*   d == n Subscript[q, 1] + n Subscript[q, 3] + Subscript[r, 3] &&
c == n Subscript[q, 3] - Subscript[r, 1] + Subscript[r, 3] &&
b == n Subscript[q, 2] - n Subscript[q, 3] + Subscript[r, 1] +
Subscript[r, 2] - Subscript[r, 3] &&
a == n Subscript[q, 1] - n Subscript[q, 2] + n Subscript[q, 3] -
Subscript[r, 2] + Subscript[r, 3]   *)

s = Solve[{a + b == Subscript[q, 1] n + Subscript[r, 1], b + c == Subscript[q, 2] n + Subscript[r, 2], Subscript[r, 1] + c == Subscript[q, 3] n + Subscript[r, 3]}, {a, b, c}]
a + b + c /. s