import numpy as np

def cart2spherical(x, y, z):
    xy_sq = x**2 + y**2
    r = np.sqrt(xy_sq +z**2)
    theta = np.arctan2(np.sqrt(xy_sq), z)
    phi = np.arctan2(y, x)
    return r, theta, phi
    
def spherical2cart(r, theta, phi):
    x = r*np.cos(phi)*np.sin(theta)
    y = r*np.sin(phi)*np.sin(theta)
    z = r*np.cos(theta)
    return x, y, z
