1
$\begingroup$

i have a code which gives an output of this kind:

rrr=2*f+1;

Now i define a simple function:

f[x_]:=3*x+2;
  1. How should i do if i want the variable f to be replaced by the function f[x_] ?
  2. If i want to do the inverse process: from the function f[x_] to f ?
$\endgroup$
0

1 Answer 1

1
$\begingroup$
rrr2 = rrr /. f -> f[x]

1 + 2 (2 + 3 x)

rrr2 /. f[x] -> f

1 + 2 f

$\endgroup$
2
  • $\begingroup$ ah yes using conditions, i did not try in this way. Thanks $\endgroup$
    – siderius
    Commented Oct 24, 2018 at 22:34
  • 1
    $\begingroup$ @siderius -- these are not "conditions" --- the command /. is a short form of ReplaceAll, which is exactly what you are asking for, to replace f with f[x] or vice versa. $\endgroup$
    – bill s
    Commented Oct 25, 2018 at 2:28

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.