I have a function, say
f, that needs to take one of two symbolic forms depending on the value of its inputs. This function is part of a very large expression, and I'd like to evaluate the entire superexpression symbolically (in order to write it to a
.m file for future numeric evaluation).
I find that since my function contains an
If statement, I cannot get it to evaluate the arguments of
If symbolically. As a minimal example, take
f[x1] = a; f[x2] = b; g[y_] := If[y > 0, f[x1], f[x2]];
I find that
g[y] evaluates to
If[y > 0, f[x1], f[x2]], but I would like it to evaluate to
If[y > 0, a, b]. How can I make this happen?