1
$\begingroup$

I have question about ReplaceRepeated. Consider

$\qquad\mathsf{FullSimplify}\left[\left\{\frac{q^5-q^4}{q^5-2 q^4+2 q^2-q}\right\}\text{//.}\, \left\{q^3\to 1\right\}\right]$

Evaluating the above expression gives

$\qquad\left\{\frac{q^3}{(q-1)^2 (q+1)}\right\}$

but the answer I want is 1/3.

How do I the answer in the form I want?

$\endgroup$
3
$\begingroup$

Try this

Simplify[(q^5-q^4)/(q^5-2q^4+2q^2-q)/.q^n_ -> q^Mod[n,3]]

which returns 1/3 instantly.

That is implicitly replacing each q^3 by 1.

$\endgroup$
  • $\begingroup$ Thank you so much $\endgroup$ – Junseong Jan 9 at 4:00
  • $\begingroup$ Also, (q^5 - q^4)/(q^5 - 2 q^4 + 2 q^2 - q) /. (q^n_ /; n > 2) -> q^(n - 3) // Simplify $\endgroup$ – Bob Hanlon Jan 9 at 4:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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