integrate algorithm