I have a complicated expression that contains N variables.
I want to create a function of N-1 that solves for one of those variables
Toy example:
expr = a^2-Sin[a*b]
astar[b_] := NSolve[expr==0, a, Reals]
astar[1]
does not work. I hoped it was equivalent to
NSolve[(expr/.{b->1})==0,a, Reals]
which does work.
I also tried
expr = a^2-Sin[a*b]
astar[b_] := NSolve[(expr/.{b->b})==0, a, Reals]
astar[1]
but that also doesn't work.
astar[v_] := NSolve[(expr /. b -> v) == 0, a, Reals]
works - yourb->b
didn't work because that will become1->1
due to evaluation order. $\endgroup$