4.C] Write the code to find the curl of \vec{F} = xy^2\hat{i} + 2x^2yz \hat{j} - 3yz^2 \hat{k}
Answer:
from sympy.physics.vector import ReferenceFrame, curl from sympy import var, symbols, display # Declare variables x, y, z = var('x y z') # Define reference frame v = ReferenceFrame('v') # Define vector field F F = v[0]*v[1]**2*v.x + 2*v[0]**2*v[1]*v[2]*v.y - 3*v[1]*v[2]**2*v.z # Compute the curl of F C = curl(F, v) # Substitute v[0], v[1], v[2] with x, y, z in F F = F.subs([(v[0], x), (v[1], y), (v[2], z)]) print('Given vector field F =') display(F) # Substitute v[0], v[1], v[2] with x, y, z in the curl result C = C.subs([(v[0], x), (v[1], y), (v[2], z)]) print('Curl of F =') display(C)