I want to define a function as the result of FindRoot. This function will be used in other functions. For example:
f[a_] := FindRoot[2*x^2 + Log[x] - a, {x, 0.01}][[1, 2]];
g[a_] := 1 - f[a];
When I plug in numbers for a, there everything works perfectly:
f[1]
g[1]
0.787179
0.212821
The problem happens when I am defining other functions that will use f[a] and g[a] in symbolic terms:
h[a_]:=5*f[a];
h[a]
5 Log[x]
This happens because when I call f[a] in a symbolic way the result is the following, which is wrong:
f[a]
Log[x]
I am clearly not defining f[a] properly or calling it properly in symbolic terms. Any ideas? Thank you!
FindRoot[2*x^2 + Log[x] - a, {x, 0.01}][[1, 2]]
without a numeric value ofa
, then you get an error. $\endgroup$