why the error happened
Plus
has higher precedence than ReplaceAll
(see: Operator Input Forms >> Operator Precedence), so addition is performed before replacement.
{#, Precedence @ #} & /@ {Plus, Rule, ReplaceAll}
{{Plus, 310.}, {Rule, 120.}, {ReplaceAll, 110.}}
A simpler example that generates the same error is
a^5 /. sol[[1]] + 5
how to fix it
You can parenthesize the terms to make sure that ReplaceAll
is performed before Plus
:
sum = (a^5 /. sol[[1, 1]]) + (b^5 /. sol[[1, 2]]) + (c^5 /. sol[[1, 3]]);
N[sum]
4138. + 9.99201*10^-16 I
Alternatively, you can use the following which avoids precedence issues:
sum2 = Total[{a, b, c}^5] /. sol[[1]];
N[sum2]
4138. + 9.99201*10^-16 I