Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
166 views
avar_string = "" deg = 4 for i in range(deg): avar_string += "a" avar_string += str(i) avar_string += ", " avar_string += "a" avar_string += str(deg) R.<A,B,C> = QQ['A,B,C'] RR = R[avar_string] a = RR.gens() RRR.<x,y> = RR['x,y'] f = sum([a[i] * x^(deg-i) * y^i for i in range(deg+1)]) QF = A*x^2 + B*x*y + C*y^2 Lap_f = C*derivative(f,x,2) - B * derivative(f,x,y) + A * derivative(f,y,2) Lap_f.coefficients() Lap_f.coefficients()[0] Lap_f.coefficients()[1] Lap_f.coefficients()[2] Lap_f.coefficients()[2].coefficients() print"\n" Lap_f.coefficient(x^2) (Lap_f.coefficient(x^2)).change_ring(RR).coefficient(a[0]) print "\n" [[Lap_f.coefficient(mon).coefficient(a[j]) for mon in [x^2, x*y, y^2]] for j in range(deg+1)]
[12*C*a0 + (-3*B)*a1 + 2*A*a2, 6*C*a1 + (-4*B)*a2 + 6*A*a3, 2*C*a2 + (-3*B)*a3 + 12*A*a4] 12*C*a0 + (-3*B)*a1 + 2*A*a2 6*C*a1 + (-4*B)*a2 + 6*A*a3 2*C*a2 + (-3*B)*a3 + 12*A*a4 [2*C, -3*B, 12*A] 12*C*a0 + (-3*B)*a1 + 2*A*a2
Error in lines 23-23 Traceback (most recent call last): File "/projects/sage/sage-7.6/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 995, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> File "/projects/sage/sage-7.6/local/lib/python2.7/site-packages/sage/rings/polynomial/multi_polynomial_element.py", line 866, in coefficient raise ValueError("You must pass a dictionary list or monomial.") ValueError: You must pass a dictionary list or monomial.
f = sum([a[i] * x^(deg-i) * y^i for i in range(deg+1)]) QF = A*x^2 + B*x*y + C*y^2 Lap_f = C*derivative(f,x,2) - B * derivative(f,x,y) + A * derivative(f,y,2) matrix([[Lap_f.coefficients()[j].coefficient(a[i]) for i in range(deg+1)] for j in range(3)])