1
$\begingroup$

I have a code which gives this kind of output :

W = Sum[v[j]*b[j], {j, 1, 3}];
AA = (v[1]*b[1] + v[2]*b[2] + v[3]*b[3])*2 + 3 ;

I know that if i want to substitute, for example, v[1] with 2 I have to do:

AA = (v[1]*b[1] + v[2]*b[2] + v[3]*b[3])*2 + 3  /. v[1] -> 2

But if i want to substitute the expression of W how should i do? Because if i do this:

    W = Sum[v[j]*b[j], {j, 1, 3}];
AA = (v[1]*b[1] + v[2]*b[2] + v[3]*b[3])*2 + 3  /. 
  W -> (b[1] v[1] + b[2] v[2] + b[3] v[3])

I unfortunately obtain:

3 + 2 (b[1] v[1] + b[2] v[2] + b[3] v[3])

Please help me.

$\endgroup$
0
$\begingroup$

Perhaps this is what you want:

Simplify[AA, W == ww]

3 + 2 ww

| improve this answer | |
$\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.