The Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.


Math Forum » Discussions » Inactive » comp.soft-sys.math.mathematica

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Numerical solution from Module
Replies: 1   Last Post: May 12, 2014 12:44 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Yuk Chai

Posts: 7
Registered: 12/11/04
Numerical solution from Module
Posted: May 9, 2014 2:07 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


Hello every one,



Here is a simple question. Say I define a function



In[14]:= f[x_] := a*x^2 + b*x + c



Then I use Module to frame the solution of f[x] ==0



In[15]:= soln[a_, b_, c_] := Module[{}, xsoln = Solve[f[x] == 0 , x]; x /.
xsoln]



When I enter numerical values for parameters a, b, and c in the module, f[x]
never sees these numerical values, and returns a symbolic solution.



In[11]:= soln[1, -3, 2]



Out[11]= {(-b - Sqrt[b^2 - 4 a c])/(2 a), (-b + Sqrt[b^2 - 4 a c])/(2 a)}



But I want the module to return a numerical solution as:

{{x -> 1}, {x -> 2}}



My question is: without bringing f[x] explicitly into the Module function,
and without redefining f as f[a_,b_,c_][x] := a*x^2+b*x+c, how can I get the
module to return a numerical solution?



Thanks - Rob Chai





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.