I would like to do something like
But I don't want that definition of f to change if the definition of g changes later.
How can I proceed?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.Sign up to join this community
g[x] evaluates to what you need, you can define
f with either
f[x_] = g[x]; (f[x_] := #) &[g[x]]
If a single evaluation of
g doesn't return all that matters, assign it to another symbol whose definitions are to be kept fixed:
UpValues[g2] = UpValues[g] /. g -> g2; DownValues[g2] = DownValues[g] /. g -> g2; Attributes[g2] = Attributes[g] /. g -> g2; Options[g2] = Options[g] /. g -> g2; SubValues[g2] = SubValues[g] /. g -> g2; FormatValues[g2] = FormatValues[g] /. g -> g2;
g2 in your definition for
Here's a simple idea of how you can explore the use of functions:
g[x_?NumericQ] := x f[x_] := g[x]