[Hans Blom, 970318]
Bill, thanks for the help in correcting my open loop theodolite
program. I must have had a blind spot when I made the test program.
Your correction is, indeed, exact -- but only in this example...
To give others an idea of the models' performances: when the "unit"
theodolite (J=1) is given a constant acceleration a=1, its true
position after 2 seconds is 2. Bill's model also gives this same
result, independent of the value of dt, whereas my model gives the
following results:
dt=0.1 x=1.900 error=0.1
dt=0.01 x=1.990 error=0.01
dt=0.001 x=1.999 error=0.001
There is, however, a problem with Bill's extra correction term: it is
exact only in this particular example. The following program gives a
demonstration; now the acceleration is not constant but increases
linearly with time (a=t). Three solutions are printed by the program,
the exact one, and the results of Bill's and my own formulas.
program open_loop_theodolite;
var
a, v, xa, x1, x2, t, dt: real;
c: integer;
begin
c := 0; dt := 0.01;
x1 := 0.0; x2 := 0.0;
v := 0.0; t := 0.0;
repeat
xa := t * t * t / 6.0; {exact solution}
if (c mod 10) = 0 then {show results}
writeln (t:12:3, v:12:3, x1:12:3, x2:12:3, xa:12:3);
x1 := x1 + v * dt; {my formula}
x2 := x2 + v * dt + 0.5 * a * dt * dt; {your formula}
v := v + a * dt; {this we agree on}
t := t + dt;
c := c + 1;
until t > 2.0001
end.
If we look at the outcome after 2 seconds again, we find that the
true solution of the differential equation is x = 8/6 = 1.333,
whereas the results of Bill's and my formulas are
Hans Bill
dt=0.1 1.140 1.235
dt=0.01 1.313 1.323
dt=0.001 1.331 1.332
Now Bill's solution isn't exact either, and _is_ dependent on the
choice of dt. A general feature of both models is that, as expected,
they become more accurate as dt decreases.
Is all this relevant? Yes. The theodolite controller does not operate
under conditions of constant acceleration. The program above
demonstrates that, contrary to what Bill intuited, it is not possible
_generally_ to translate a differential equation model into an
exactly equivalent difference equation model. Modeling/sampling
theory says so, and the program above gives an example. If an exact
equivalent _were_ possible, designers of programs such as Simcon,
Tutsim and Matlab wouldn't have the problems they do have. Their
solution is invariably to choose a sufficiently small dt (on the fly,
preferably).
Is all this talk about a "correction term" relevant? Not really. In
the theodolite controller, we happened to stipulate a control
trajectory where -- if control would be exact -- the acceleration
would be zero almost everywhere (because either x must be constant or
v must be constant), except in 4 discrete points (when the theodolite
is given its speed and when it stops, and when the disturbance starts
and when it ends). Thus, due to the control, in the actual theodolite
controller Bill's correction term 0.5*a*dt*dt turns out to be zero or
almost zero almost everywhere -- and can effectively be neglected, as
the MCT controller demonstrated with its almost perfect control.
Bill's "correction term" simply cannot explain the failure of his
implementation of the MCT controller. There must be another reason...
But first things first. Bill, do you want to try again in finding an
"exact" (acceleration independent) theodolite model that we should
use to generate the MCT and PCT controller's perceptions? Warning:
theory says that no exact computer model is possible; only
approximations, whose quality improves as dt decreases, are. But
theory isn't holy, of course ;-). Want to try again and correct the
correction term?
Other readers may think this is much ado about nothing. Maybe it is.
Yet, dotting an i may provide some insight, occasionally.
Greetings,
Hans
···
a := t; {linearly increasing acceleration}