Re: how to differentiate a list?
- To: mathgroup at smc.vnet.net
- Subject: [mg25956] Re: how to differentiate a list?
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Tue, 14 Nov 2000 03:46:50 -0500 (EST)
- References: <8ug96o$id9@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Rob: If you will have your list, say data = Table[s[i], {i, 0, 1, .2}] {s[0], s[0.2], s[0.4], s[0.6], s[0.8], s[1.]} Then Drop[data, 1] - Drop[data, -1] {-s[0] + s[0.2], -s[0.2] + s[0.4], -s[0.4] + s[0.6], -s[0.6] + s[0.8], -s[0.8] + s[1.]} or ListConvolve[ {1, -1}, data] {-s[0] + s[0.2], -s[0.2] + s[0.4], -s[0.4] + s[0.6], -s[0.6] + s[0.8], -s[0.8] + s[1.]} Alternatively, with numerical data, we can get an interpolating function and differentiate it. data2 = Table[{i, Sin[i]}, {i, 0, 2 Pi, 0.1 Pi}]; f = Interpolation[data2] InterpolatingFunction[{{0., 6.28319}}, "<>"] Plot[{f[x], f'[x]}, {x, 0, 2Pi}] -- Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565 "Rob" <piovere at pdq.net> wrote in message news:8ug96o$id9 at smc.vnet.net... > I needed to get the derivative of a time varying pulse to do some > numerical > operations. As seen below, the only way I could figure how to do it > was to generate two lists, shifted by one sample and then subtract them: > > *************** > del = 0.002; a = 12\[Pi]; b = \[Pi]; > ( s[t] is a function of t defining the pulse ) > > sd = Table[N[s[t]], {t, 0, 1, del}]; > sd1 = Table[N[s[t]], {t, del, 1 + del, del}]; > diff = sd - sd1; > **************** > > I looked all over and I didn't find a list operation available to do > this. I bet > you Mathematica gurus know how to do this. If so, could you enlighten me? > > Thanks, Rob > > >