 		float inverseR = rsqrtf(rsq);
         float r = 1.0f / inverseR;
 		position = r * eam_data.rdr;
-		int shift = (typei>=typej)?(int)(0.5f * (2 * ntypes - typej -1)*typej + typei) * nr:(int)(0.5f * (2 * ntypes - typei -1)*typei + typej) * nr;
+		int shift = (typei>=typej)?(int)((2 * ntypes - typej -1)*typej/2 + typei) * nr:(int)((2 * ntypes - typei -1)*typei/2 + typej) * nr;
         float2 pair_potential = tex1D(pairPotential_tex, position + shift + 0.5f);
 		float pair_eng =  pair_potential.x * inverseR;
 

		// read the current neighbor index (MEM TRANSFER: 4 bytes)
		// prefetch the next value and set the current one
		cur_neigh = next_neigh;
		next_neigh = nlist.list[nlist.pitch*(neigh_idx+1) + idx_global];

		// get the neighbor's position (MEM TRANSFER: 16 bytes)
		float4 neigh_pos = tex1Dfetch(pdata_pos_tex, cur_neigh);

	float* atomDerivativeEmbeddingFunction)
	{
	// start by identifying which particle we are to handle
	volatile int idx = blockIdx.x * blockDim.x + threadIdx.x;

	if (idx >= pdata.local_num)
		return;

	// load in the length of the list (MEM_TRANSFER: 4 bytes)
	int n_neigh = nlist.n_neigh[idx];

	// read in the position of our particle. Texture reads of float4's are faster than global reads on compute 1.0 hardware
	// (MEM TRANSFER: 16 bytes)
	float4 pos = tex1Dfetch(pdata_pos_tex, idx);

	// initialize the force to 0
	float4 force = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
