The error will become larger and larger if you try to put function in the "Fixed relations" page instead of define a function.

You might need to have some background about numerical method in order to fully understand it.

I will try to explain it starts with how EJS works:

1. EJS will read "Variables" page: it will ask computer to allocate memory for each variables defined and assing value to the memory. for example x=5.; it will put 0.05 to memory assigned for x.

2. EJS will read "Initialization" page: This is an optional page. EJS will do whatever java command

3. EJS will read "Evolution" page: This is the page to move time step forward and cacculate variable value at the next time step. EJS will use user selected "solver" method to solve the ODE.

4. EJS will read "Fixed relation" page: The system has been moved from time t to t+dt. And java code in this page will be executed. But all the command execute here is done after step 3.

5. EJS will show all the GUI elements according to value assigned to element's properties.

6. EJS will go back to step 3 if it in play mode and continue process 3-4-5 cycles, otherwise it will stop.

Let me use a simple hormonic motion as examples to explain why relations for derivatives can not be defined in the "Fixed relation page".

If the equestion we try to solve is

F=m*d[sup]2[/sup]x/dt[sub]2[/sub]= -k*x-b*vx;

we will change the above second order differtial equation into two first order differential equations:

dx/dt=vx;

dvx/dt=-k/m*x-b/m*vx;

You need to select Runge-Kutta (4th) order to reduce the error.

If the Euler's method were selected , the error will accumuate will soon.

The middle method will reduced error to 10% of the Euler's method .

The error for Runge-Kutta (4th) order is 0.00% of the Euler's method.

And this is the best method for most of the cases.

If you change the above equestions to

dx/dt=vx;(STEP 3 )

dvx/dt=ax; (STEP 3)

and define ax=-k/m*x-b/m*vx; at fixed relation page (STEP 4)

The error will be the same as Euler's method even if Runge-Kutta (4th) order was selectd.

Because EJS use the above equation to move time from t to t+dt (STEP3 to STEP4)

But vx(t) is not the same as vx(t+dt), and x(t) is not the same as x(t+dt)

For Euler's method :

x(t+dt)=x(t)+vx*dt;

vx(t+dt)=vx(t)+k/m*x(t)-b/m*x(t);

For midpoint method:

Two time steps(t+dt/2 and t+dt) were calculated to move from t-> t+dt.

For Runge-kutta 4th order method:

Four time steps were calculated to reduced the error to 1/10000 as Euler's method.

The right hand side need to be evaluate 4 times. If the correct formula is only available at STEP4.

The right hand side will always be the same , the Runge-kutta 4th order method is not calculated with correct value. The error move back to the same as Euler's method.

You need to read document about Runge-kutta 4th order method to fully understand how the numerical method works and why it can reduced the error.

You need to define function or write the equations into the right hand side of the evolution page, if the right hand side contain variables which is also in the left hand side (like x and vx in the above examples.).

If the right hand side did not contain any variables at the left hand side, like k,b,m are all constant . Then, you can defined those at fixed relation page.