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

1 Answer 1

0
$\begingroup$

Perhaps this is what you want:

Simplify[AA, W == ww]

3 + 2 ww

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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