2021-11-23 19:42:12 UTC, Juan Luis Varona: > > In the expression (5^x)^2-7*5^x+4, I want to substitute x^5 by t. > > With sagemath 7.2 (or another old versions), I can do > ((5^x)^2-7*5^x+4).subs(5^x==t) > and I get t^2 - 5*t + 4 > > But sagemath 9.4 does not change the first 5^x and he gives > 5^(2*x) - 7*t + 4 > > Why? > > (In both cases, var("t") has been previously used) > > Yours, > Juan Luis Varona
In recent versions of Sage, defining: ``` sage: t, x = SR.var('t, x') sage: a = (5^x)^2-7*5^x+4 ``` automatically groups exponents and gives: ``` sage: a 5^(2*x) - 7*5^x + 4 ``` in which `5^x` is only seen once as such (old versions of Sage possibly did not group exponents, thus keeping two visible occurrences of `5^x` in the resulting `a`). This means that only one `5^x` gets replaced by `t` when we do the following substitution: ``` sage: aa = a.subs(5^x == t) sage: aa 5^(2*x) - 7*t + 4 ``` To work around this, we can instead think of rewriting `x` as `log(t, 5)` as in the following substitution, which gives the expected result: ``` sage: ab = a.subs(x == log(t, 5)) sage: ab t^2 - 7*t + 4 ``` Now we have a polynomial expression in t and we can use corresponding tools. --Samuel -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/7c160408-2c14-43c0-a22d-8fd01dbd3ec4n%40googlegroups.com.