RC calculated using Forward and Backward Euler Integration.

This web page allows you to explore what happens when the step size is smaller, greater and much greater than the time constant, RC=1.
TimeStep,h:
join points using gradient: ,extras:


Plots of various h/RC showing Forward Euler blowing up.

h/RC=0.5. The numerical solution tracks the intended solution.


h/RC=0.9. The numerical solution is strugling to track.


h/RC=1.9. The numerical solution is overshooting.


h/RC=2.1. The numerical solution is blowing up.


h/RC=2.9. The numerical solution blows up and is NOT what was intended.


NOTE: ForwardEuler (2-h/rc) is an observation that there is a relationship in that every other point equals those of the Forward Euler. Also there is a relationship. Compare the plots for -h/rc and ( 2-h/rc).

NOTE: Try using a negative timestep. Note that the lines will go from right to left.

// Forward Euler:
 next_Vc = Vc_now + timeStep * dVc_now/ dt
 next_Vc = Vc_now - timeStep * Vc_now/RC

// Backward Euler:
 next_Vc = Vc_now + timeStep * dnext_Vc/ dt
 next_Vc = Vc_now - timeStep * next_Vc/RC

Plotted using FLOT

FLOT @ http://code.google.com/p/flot/

BackTrack Forward Euler Integration

We take the gradient where we are and predict forward. We go to the predicted position. What happens if we work out the gradient at the new position and predict backwards to see what error has been interoduced. We work out the new position for timestep, h and also the position we have come from by using -timeStep and -h. We back track, and we can see what error we have introduced. Would it be possible to adjust the timeStep to minimise the errors.
// Forward Euler:
 next_Vc = Vc_now + timeStep * dVc_now/ dt

// Forward Euler backtrack:
 last_Vc = Vc_next + (- timeStep) * dVc_next/ dt
 

// Forward Euler using dVc = -timeStep/RC:
 next_Vc = Vc_now - timeStep * Vc_now/RC

// Forward Euler backtrack:
 last_Vc = next_Vc - ( -timeStep * next_Vc/RC)




Ccompare Vc_now to lastVc, which should be the same, but for the error introduced by the integration.

// Forward Euler using dVc = -timeStep/RC:
 next_Vc = Vc_now - timeStep * Vc_now/RC

// Forward Euler backtrack:
 last_Vc = Vc_next - ( -timeStep * Vc_next/RC)




// Forward Euler using dVc = -timeStep/RC:
 next_Vc = Vc_now - timeStep * Vc_now/RC

// Forward Euler backtrack:
 last_Vc = Vc_now - timeStep * Vc_now/RC - ( -timeStep * (Vc_now - timeStep * Vc_now/RC)/RC)
	 = Vc_now - timeStep * Vc_now/RC +timeStep * Vc_now/RC  - timeStep * Vc_now/RC/RC)
	 = Vc_now *( 1- timeStep /RC/RC)
 
 
last_Vc should be the same as Vc_now, but is not by -timeStep/RC^2

image