I would like to define a function like
myfunc[f_] := Simplify[(f/g)]
where g will be substituted/replaced with the current value of g at the time of definition. In practise, g will be complicated and myfunc will be defined over and over again. However, between these redefinitions I want it to be statically set. If
g=1+x^2
then I want the equivalent of typing
myfunc[f_] := Simplify[(f/(1+x^2))]
The following works but seems pretty arcane:
myfuncA[f_] := Evaluate[With[{yy = g}, Hold[Simplify[f/yy]]]]
myfunc[f_] := ReleaseHold[myfuncA[f]]
How to accomplish this simple task?
{}
button above the edit window. The edit window help button?
is also useful for learning how to format your questions and answers. You may also find this this meta Q&A helpful $\endgroup$myfunc[f_] := Simplify[(f/g)] /. (g -> 1 + x^2)
$\endgroup$