Why does this ReplaceAll not work in math

I have

Table[{x1, 1, 2, 3}^i, {i, 0, 3}] /. x1 -> 1/2

But the following does not work, since x1 is not replaced by 1/2

Table[{x1, 1, 2, 3}^i, {i, 0, 3}] // Inverse /. x1 -> 1/2

Can someone tell me why and how to fix it? Many thanks!

+3
source share
1 answer

Look at TreeFormto see how your expression is parsed.

TreeForm@Hold[Table[{x1, 1, 2, 3}^i, {i, 0, 3}] // Inverse /. x1 -> 1/2]
(source: yaroslavvb.com )

Everything after //is considered a functional head, which is used with Postfix notation. So you need some brackets

(Table[{x1, 1, 2, 3}^i, {i, 0, 3}] // Inverse) /. x1 -> 1/2
+8
source

Source: https://habr.com/ru/post/1786552/


All Articles