Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #16790

Re: Using FindRoot with free parameters

From Bob Hanlon <hanlonr357@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Using FindRoot with free parameters
Date 2014-04-13 09:25 +0000
Message-ID <lidl6v$hl$1@smc.vnet.net> (permalink)
References <20140412091539.8767469FC@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


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@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
>
>

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar


Thread

Re: Using FindRoot with free parameters Bob Hanlon <hanlonr357@gmail.com> - 2014-04-13 09:25 +0000

csiph-web