Re: Using FindRoot with free parameters
- To: mathgroup at smc.vnet.net
- Subject: [mg132572] Re: Using FindRoot with free parameters
- From: Bob Hanlon <hanlonr357 at gmail.com>
- Date: Sun, 13 Apr 2014 05:25:57 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-outx@smc.vnet.net
- Delivered-to: mathgroup-newsendx@smc.vnet.net
- References: <20140412091539.8767469FC@smc.vnet.net>
f[n_, x_] = Exp[-3 x^2 + 2] BesselI[n, 4 x]; xf[alpha_?NumericQ, n_?NumericQ] := Module[{x}, x /. FindRoot[f[n, x] - alpha, {x, 2}][[1]]] xf[3, 0] 1.11426 xf[alpha, n] /. {alpha -> 3, n -> 0} 1.11426 Bob Hanlon On Sat, Apr 12, 2014 at 5:15 AM, steviep2 <ssplotkin at gmail.com> wrote: > Hi, > I want to define a function of 2 parameters that uses FindRoot. I.e. I > have a known but complicated function f[n_,x_] = "complicated function of > (n,x)". I want to find the value of x where f[n,x] == alpha, and I want to > call this a function xf[alpha_,n_]. > > So my attempts (this is non-working code) looks something like this: > > xf[alpha_, n_] = Function[{x}, x /. FindRoot[f[n,x] - alpha, {x, 2}]] > > or > xf[alpha_, n_] = Function[x /. FindRoot[f[n, x] - alpha, {x, 2}]][alpha, > n] > > It seems this is a pretty simple question-- basically using FindRoot but > holding off on substituting in the parameters until later. Is there a > simple solution? > > Thanks, > StevieP > >
- References:
- Using FindRoot with free parameters
- From: steviep2 <ssplotkin@gmail.com>
- Using FindRoot with free parameters