USE MATH

COMPONENT Integracion

	DATA
		REAL mu = 10
		REAL delta_t = 0.01
		BOOLEAN explicitmethod = TRUE
	DECLS
		REAL x
		DISCR REAL x_next
		DISCR REAL x_t
		BOOLEAN sample
		
	INIT
	   sample = TRUE
		x= 1
	   x_t = x
	   x_next = x
	
	DISCRETE
	
		WHEN ( sample == TRUE AND explicitmethod == TRUE ) THEN
			x_t = x_next
			x_next = x_t + (-mu*x_t)*delta_t
			
			sample = FALSE
			sample = TRUE AFTER delta_t
		END WHEN
		
		WHEN ( sample == TRUE AND explicitmethod == FALSE ) THEN
		   x_t = x_next
			x_next = x_t / (1 + mu*delta_t)
			
			sample = FALSE
			sample = TRUE AFTER delta_t
		END WHEN
		
	CONTINUOUS
		x' = -mu*x 
	
END COMPONENT