we try to build a function which oscillates towards a certain value p1.

we have position p0, velocity v0

we do that with a differential equation, in which we describe the power needed at a time t.

F[t]=m*a[t]; a[t]=p''[t];

-> p''[t]=F[t]/m;

we assume that the mass is 1 and only think about how much power is needed to oscillate to the value.

first we think of p''[t]==energy (p1- p[t])

than we just get a sin-wave and add some sort of damping depending on the velocity v[t].

we have to subtract that from the sin. to simplify the result we come to the formula:

p''[t]==energy (p1- p[t])- 2 damping p'[t]

for positive we could be satisfied with the first formula.

but for negative values under the square root we need to modify the formula into something which works with real values. (we don't want to calculate complex in delphi..)

it's simpler to modify the second complex function-description into the three different functions in real space for the cases

{ > 0, < 0, == 0 }

let's look at :

because the Indeterminate expression Arg[0] and 1/0 at the beginning of the formula we will look at the third case (== 0 ) later.

but now we're in the comfortable position to simplify our formula for the first two cases:

for >0:

= 1

for < 0:

= ⅈ

let's take a look at the third case == 0

== 0 ->

we put that into our differential equation:

we put the three cases together to define p[t]:

we need to be able to calculate the exact current velocity v[t]: (because if a new input comes we have to set this as v0)

we do some simple tests on our formulas:

very well..

let's program a function which decides which function branch to take and let's take a look at the graphs of some examples.

we want to know the best position of the infinte possible positions p1c == ... p1, p1+1, p1+2, ...

for this we assume that the best position is that which is accessible with the lowest initial acceleration a[0]

therefore we need to know acceleration a[t]..

we don't need to simplify the formula further. we just set t=0..

ok, now we know the optimal postion. but we nee to know the best cyclic position (in the neighbourhood of ?)

therefore we look how a0 changes if we walk away from the optimal position.

a0[p1] is just a linear equation. the higher the energy the higher the initial acceleration.

that means if we go from in both directions abs(a0[p1]) gets linearly bigger (starting with 0). its irrelevat if we go to the left or to the right.

we just have to pick the nearest cyclic point ( = p1 + n, n ε Integers).

≈ p1 + n -> n = round( - p1)

-> = p1 + round( - p1)

after testing the algorithms it became clear that the first case is not good implemented because COSH gets very big and gets very small after a time (multiplied they give a moderate value).

this behaviour leads to an algorithms which breaks down after a while. in fact the problem isn't the very small value but the COSH which results +INF for input values bigger than 11000. if we put in 100 seconds and a big damping (120) then the algorithm will fail. the problem is that with bigger damping the filter will take a longer time to go to p1, so that the fail becomes visible.

in the following i will concentrate on this first case.

let's look if we can substitute cosh back to something with to melt it with .

tried on our first case:

we now have a function which allows us to describe the first case with ⅇ-functions only.

the new description of the whole function:

the velocity of the first case:

the new description of the whole velocity function:

the goal of this chapter is to modify the functions in a way that the parameters describe how long the filter will need to go to a minimal distance to p1 (p1 ± ξ) and how much cycles are passes per second.

we name them FilterTime and CyclesPerSecond.

p[FilterTime] == p1 ± ξ --> Abs[p[FilterTime] - p1] == ξ

first let's take a look at the simplest formula, the third case:

but seams to be an uncontrolleable function. probably because we handled a too specific case and didn't take a look on the final velocity.

lets test another method (which also includes a velocity check) on the whole function..

this didn't lead to any result and i'll give up.

nevertheless damping seams to determine the filtertime in a certain way. let's look if we find a simple aproximate way to define filtertime.

if we look at the not optimised description of p(t) we see it's always something like p1+:

let's look at which time this multiplier is very small:

i'll define FilterTime as . ->

since damping is a real value, is always positive and if we want to cover all cases with the timebased parameterization, we have to define CyclesPerSecond as a complex number (better: a positive real number or a positive imaginary number) to get also negative values for (this would lead us to the first case >0 and we could describe the hyperbolic non oscillating function with imaginary CyclesPerSecond). in the algorithm we'll simply interpret negative CyclesPerSecond given by the user as imaginary values.

for the second (oscillating) and the third case the FilterTime defintion seams to be a good aproximation, but for the first case nor the FilterTime neither CyclesPerSecond make sense.

we have to find the main multiplier here.

since > 0 in the first case, will have more influence on the output than eminus. let's look when eplus is very small.

let's define CyclesPerSecond in another way, so that we don't have to handle imaginary CyclesPerSeconds.

Simplifying of Algorithms through Substitution

precalculations for cyclic mode will not be optimised:

Converted by