d = (x^4 + 34 x^3 + 45) y^4
d /. y^u_ :> (x^3 + 2 x + 2)^(u/2) /; EvenQ[u]

picking this apart, /. y^u_
says replace every sub expression matching the pattern y
to an exponent, where the exponent can be anything. Whatever the exponent is, gets named u
. As a subtlety there must be an explicit exponent, ie. y
by itself is not recognized as y^1
All the way to the right the /; EvenQ[u]
is a Conditional
that says only apply this rule if u
is even.
The :>
is a RuleDelayed
, replace y^u
with the following expression using the specific value of u
at the time of the replacement. In this example the delayed rule is actually not needed. You will get the same if you use a regular rule: ->
For your very specific example you could have just done more simply
d /. y^4 -> (x^3 + 2 x + 2)^2
/.
and/;
. TheirFullForm
names areReplaceAll
andCondition
respectively. $\endgroup$ – Marius Ladegård Meyer Nov 18 '16 at 9:30:->
should just be:>
. ( It may also appear as a colon followed by a special arrow character, but not the three character sequence you have there ) $\endgroup$ – george2079 Nov 18 '16 at 18:09