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$
1
$\begingroup$
rrr2 = rrr /. f -> f[x]

1 + 2 (2 + 3 x)

rrr2 /. f[x] -> f

1 + 2 f

$\endgroup$
  • $\begingroup$ ah yes using conditions, i did not try in this way. Thanks $\endgroup$ – siderius Oct 24 '18 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 Oct 25 '18 at 2:28

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.