Message Boards Message Boards

0
|
5544 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How to use Module with NSolve?

Posted 11 years ago
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?
POSTED BY: A BC
3 Replies
Posted 11 years ago
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
POSTED BY: Bill Simpson
Hi,

Not sure what you want to use as an argument for h[x_] , 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.
POSTED BY: Ivan Morozov
Posted 11 years ago
I see. Thank you!
The problem is solved already.
POSTED BY: A BC
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract