0
$\begingroup$
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.

$\endgroup$
2
$\begingroup$

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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