def dEdL(E, L, P, Q, R):
    """ 
    we know: E^2*P + E*Q + P = 0 
    therefore:
    dEdL = E' = -(E^2*P' + E*Q' + R')/(2*E*P + Q)
    input
    P, Q, R: three polynomials that depend on L
    E: the energy
    L: the independent (scaling) variable
    """
    Pp = P.deriv(1)(L)
    Qp = Q.deriv(1)(L)
    Rp = R.deriv(1)(L)
    return -(E**2*Pp + E*Qp + Rp) / (2*E*P(L) + Q(L))