Re: Values from InterpolatingFunction
- To: mathgroup@smc.vnet.net
- Subject: [mg11883] Re: Values from InterpolatingFunction
- From: Allan Hayes <hay@haystack.demon.co.uk>
- Date: Fri, 3 Apr 1998 03:45:39 -0500
- References: <6fskub$gsc@smc.vnet.net>
Volker Doerr wrote: > > Hello to all, > > I have the following > > InterpolatingFunction[{{0.,365.}},<>][t] > > produced by Function D from another InterpolatingFunction, and want > simply to get the approximate values at specific points. I cannot find > a direct solution, probably because the function has symbolic form. > > Anybody out there who can help me? > vd@cascade.de Volker (1) First I'll get an interpolating function. NDSolve[{y'[t]== Sin[t], y[0]== 1}, y[t], {t,0,Pi}] {{y[t]->]InterpolatingFunction[{{0.,3.14159}},"<>"][t]}} Get the formula y[t]/.%[[1]] InterpolatingFunction[{{0.,3.14159}},"<>"][t] Differentiate wrt dyt=D[%,t] InterpolatingFunction[{{0.,3.14159}},"<>"][t] All the code is stored in InterpolatingFunction[[..] (ds will only evaluate when t is numeric and real - this is why we can use D[..] above) This is the position that you are in Now we can either use replacement dyt/. t-> Pi/3 0.866035 or extract the function s = dyt[[0]] InterpolatingFunction[{{0.,3.14159}},"<>"] and use it like any other function s[Pi/3] 0.866035 (2) At any stage we can use functions instead of formulas NDSolve[{y'[t]== Sin[t], y[0]== 1}, y, {t,0,Pi}] {{y->InterpolatingFunction[{{0.,3.14159}},"<>"]}} Get the function y/.%[[1]] InterpolatingFunction[{{0.,3.14159}},"<>"] Differentiate s=%' InterpolatingFunction[{{0.,3.14159}},"<>"] s[Pi/3] 0.866035 -- Allan Hayes Training and Consulting Leicester, UK hay@haystack.demon.co.uk http://www.haystack.demon.co.uk voice: +44 (0)116 271 4198 fax: +44 (0)116 271 8642