tian
(A BC)
February 13, 2014, 12:40am
1
Hi! I want to solve the following problem.
h[x_] := Module[{p, c}, {p, c} /. Last[NSolve[{e[x] == 0, f[x] == 0}, {p, c}]]]
where e and f are nonlinear equations for p and c.
When I input h[1], the output shows {p$150234, c$150234} .
Is there any mistake in the above usage of Module?
Is there any chance that NSolve isn’t finding a solution?
In[1]:= Module[{x}, x /. NSolve[x == 4, x]]
Out[1]= {4.}
In[2]:= Module[{x}, x /. NSolve[x == x + 1, x]]
Out[2]= x$305
iamorozov1
(Ivan Morozov)
February 13, 2014, 4:32am
3
Hi,
Not sure what you want to use as an argument for h , but here is an example where x is a parameter for some equation:
h[B_] := Module[
{X}, (* LOCALS *)
Evaluate[X /. NSolve[X^2 + B X + 1 == 0, X]]
]
h[2]
I.M.
tian
(A BC)
February 13, 2014, 5:14am
4
I see. Thank you!
The problem is solved already.