I am trying to define a function inside a module as following
test1[a_] := Module[{sol1, g1, y},
sol1 = Reduce[a + x^2 == y, x];
g1[y_] := Evaluate@sol1[[1, -1]];
Print[Definition[g1]];
g1[33]
]
This gives the output
Attributes[g1$28580]={Temporary}
g1$28580[y$_]:=-Sqrt[-3+y$28580]
-Sqrt[-3 + y$28588]
As you can see this does not work. The y in the body of the function is y$28580, but not y$. Is there any way to make this work?
Blockinstead ofModuledoes that solve the problem? – Jason B. Nov 30 '18 at 19:09SetDelayed @@ {g1[y_], sol1[[1, -1]]}and read this: Enforcing correct variable bindings – Kuba Nov 30 '18 at 21:31