Re: Using NDSolve and Finding a specific Value
- To: mathgroup at smc.vnet.net
- Subject: [mg85366] Re: Using NDSolve and Finding a specific Value
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Thu, 7 Feb 2008 06:32:19 -0500 (EST)
- Organization: The Open University, Milton Keynes, UK
- References: <foek87$i3s$1@smc.vnet.net>
Tara.Ann.Lorenz at gmail.com wrote:
> I am having an issue related to the NDSolve function (I am using
> Version 6). The following example illustrates the problem I am
> having:
>
> Input:
> sols = NDSolve[{i'[t] == (1/8.516011) (-i[t] + 0.596120754),
> i[1] == 0.219319}, i[t], {t, 1, 4}]
>
> Output:
> {{i[t]->InterpolatingFunction[{{1.,4.}},<>][t]}}
>
> I then would like to solve i[t] for t=3.8
> According to the Mathematica website, I should be able to enter the
> following input to receive my answer:
>
> i[3.8]/.sols
>
> However, my output is simply i[3.8] and not a numerical value. What
> else can I try to get a numerical value from the interpolating
> function.
To use the above syntax, you must specify the function without any
variable name, i.e. just 'i' rather than 'i[t]'. (Note that this is
commonly regarded as good practice when using DSolve/NDSolve))
In[1]:= sols =
NDSolve[{i'[t] == (1/8.516011) (-i[t] + 0.596120754),
i[1] == 0.219319}, i, {t, 1, 4}]
i[3.8] /. First@sols
Out[1]= {{i->InterpolatingFunction[{{1.,4.}},<>]}}
Out[2]= 0.324902
Yet, if you prefer the syntax function + variable name, you can use an
additional transformation rule to get the numeric value at a specific point.
In[3]:= sols =
NDSolve[{i'[t] == (1/8.516011) (-i[t] + 0.596120754),
i[1] == 0.219319}, i[t], {t, 1, 4}]
i[t] /. First@sols /. t -> 3.8
Out[3]= {{i[t]->InterpolatingFunction[{{1.,4.}},<>][t]}}
Out[4]= 0.324902
Regards,
--
Jean-Marc