	function dfromm(vm,ptsq,a,ca,cc,cd,pp,e)
c     calcs derivative of efromm with respect to the beam energy
c
	include '/u1/gcf/e350/crystal/cb/type'
c
	include '/u1/gcf/e350/crystal/cb/beam'
c
	d=vm-cd
	b=ca*d
	c=.25*d**2+pp*ptsq+cc
	dadeb=2.*amp
	dbdeb=vm-cd+2.*e*(am2i+ptsq)
	dcdeb=amp*(cd-vm)+2.*e*(am2i+ptsq)
	ddd=sqrt(b*b-4.*a*c)
	eee=1./ddd
	dfromm=.5*dbdeb*(b*eee-1.)/a-dcdeb*eee-(eee+(b-ddd)*.5/(a*a))
& *dadeb
	return
c
	end
