Ah. The problem is that you're using an invalid variable name. The underscore character in Mathematica is used as a shortcut for Pattern
. When you did this:
index_a = 0
you actually created a replacement rule for expressions that have a
as their head. That doesn't really have anything to do with the iteration variable in Do
, because Do
will localize that automatically. Still, Do
expects a symbol as the iteration variable, not a Pattern
expression.
To fix both of these issues, choose a variable name that doesn't include reserved characters.
Having said that, I notice that these error messages are different than what you reported before, so we still haven't figured out what was going wrong before.