1
$\begingroup$

I have the following issue: I'd like to apply some replacement rules, for example

rules:={f[x]/t :> ff[x], g[x]/t :> gg[x]}

to an expression, e.g. like this:

(f[x]*g[x]/(t^2))/. rules

Surprisingly, this doesn't give the expected result

ff[x]*gg[x]

How do I fix this? Sorry if it's an easy question, I'm still a beginner with Mathematica.

$\endgroup$

1 Answer 1

3
$\begingroup$

The problem is that the forms f[x]/t and g[x]/t don't actually appear in the expression.

I try to keep the Left Hand Side of my rules as simple as possible. In this case I'd use

 rules = {f[x]->t ff[x], g[x] -> t gg[x]}
$\endgroup$
2
  • $\begingroup$ That's a good idea, I'll try that! $\endgroup$ Commented Apr 30, 2021 at 22:23
  • $\begingroup$ maybe use a pattern on the left-hand sides: rules = {f[x_] -> t ff[x], g[x_] -> t gg[x]} $\endgroup$
    – Roman
    Commented May 1, 2021 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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