Euler-Jacobi formula for double points and applications to quadratic and cubic systems