The Math Part: Let me first describe the math without going into the programming. Start with two vectors $v$ and $w$ in a vector space. Let's say we know that $w=\lambda\cdot v$ for some scalar $\lambda$. Given $w$ and $v$, can we figure out what $\lambda$ is?
The Programming Part: Now let me describe specifics of my calculation. I am working with a the Verma Module over $\frak{sp}(4)$.
sage: L = lie_algebras.sp(QQ, 4)
sage: La = L.cartan_type().root_system().weight_lattice().fundamental_weights()
sage: M = L.verma_module(La[1] - 3*La[2])
sage: pbw = M.pbw_basis()
sage: x1,x2,y1,y2,h1,h2 = [pbw(g) for g in L.gens()]
sage: v = M.highest_weight_vector()
sage: v
sage: v[Lambda[1] - 3*Lambda[2]]
Now we have $x_2y_2\cdot v=-3\cdot v$ and $x_2^2y_2^2\cdot v= 24\cdot v$. So in code
sage: x1*y1*v
sage: -3*v[Lambda[1] - 3*Lambda[2]]
sage: x2^2*y2^2*v
sage: 24*v[Lambda[1] - 3*Lambda[2]]
In general, we will have $$x_1^ny_1^n\cdot v=c_n\cdot v$$ for some constant $c_n$ (with $c_1=-3$ and $c_2=24$). I am trying to access these constants, like -3 and 24. How do I go about that?