Forums > MaxMSP

### Derivation

Jun 08 2010 | 9:58 am

Hello,

I would like to know what is the more efficient way to get the derivation of a continuous stream of data (real time) :

I am using (f(X+h)-f(x))/h as it can be seen here :

``````
-- Pasted Max  Patch, click to expand. --

```
Another idea ?
Thanks
Mathieu
```
Jun 08 2010 | 10:45 am

do u mean deviation: http://en.wikipedia.org/wiki/Absolute_deviation
i get the feeling "derivation" is faux-amis?

also AFAIK u cant put formulas as arguments for maths objets (as is the case with the divide), u need to use expr for that.

Jun 08 2010 | 11:30 am

Oops sorry I mean "to differentiate" :

f'(x)= (f(x+h)-f(x))/h or (f(x[i+1])-f(x[i-1)])/(x[i+1]-x[i-1])

Jun 08 2010 | 12:31 pm

well here is an attempt at translating the equation to expr, but it’s broken…
i suspect my algebra is not up to scratch or the equation isnt right. either way the process should at least demonstrate how to translate equations into expr.

i didnt try the second equation… also it may be useful to explain the context of the equations, as this might make it easier for others to help.

hope that’s vaguely useful, sorry dont have much time to look into this.

j

``````
-- Pasted Max  Patch, click to expand. --

```
```
Jun 08 2010 | 2:14 pm

Thanks justin,

I finally found a way to solve the problem :

Here is my solution :

``````
-- Pasted Max  Patch, click to expand. --

```
(With a low pass filter at the end to smooth the values)
Maybe there is a better way
Mathieu
```
Jun 08 2010 | 2:53 pm

think [bucket 2 1] might be better, cos it outputs current value and previous value. otherwise it outputs previous and one before previous (ignores current value)… look at float number boxes and it should explain better!

``````
-- Pasted Max  Patch, click to expand. --

```
```
Jun 08 2010 | 2:58 pm

Thanks I was just thinking about that problem ! =)

Now my input data and differential data are sync.

Jun 08 2010 | 3:47 pm

de rien ;)

Viewing 8 posts - 1 through 8 (of 8 total)

Forums > MaxMSP