Re: FindRoot with a parameter
- To: mathgroup at smc.vnet.net
- Subject: [mg88883] Re: [mg88858] FindRoot with a parameter
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Tue, 20 May 2008 02:27:32 -0400 (EDT)
- Reply-to: hanlonr at cox.net
FindRoot requires a numeric value for a. You must then use SetDelayed ( := ) instead of Set ( = ) and require only numeric inputs to the function call. Clear[K]; K[a_?NumericQ] := Module[{x}, x /. FindRoot[a*x == 1/2, {x, 1}]]; Plot[K[a], {a, -1, 1}] However, for a simple function you don't need numeric techniques and Solve can avoid these issues. Clear[K]; K[a_] = Module[{x}, x /. Solve[a*x == 1/2, x][[1]]] 1/(2 a) Plot[K[a], {a, -1, 1}] Bob Hanlon ---- Aaron Fude <aaronfude at gmail.com> wrote: > Hi, > > How does one accomplish something like this: > > K[a_] = FindRoot[a*x == 1/2, {x, 1}] > > My intention is to plot how the zero of a function depends on > parameters. > > Thanks! > > Aaron >