<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Smith Sphere
The smith chart is a nomogram used frequently in RF/Microwave Engineering. Since its inception it has been recognised that projecting the chart onto the reimen sphere [1].
[1]H. . Wheeler, “Reflection Charts Relating to Impedance Matching,” IEEE Transactions on Microwave Theory and Techniques, vol. 32, no. 9, pp. 1008–1021, Sep. 1984.
Step1:  Starting with an impedance vector $z$, defined by a vector in the impedance plane  $B_z$, this vector has two scalar components ( $z^r$, $z^x$) known as resistance and reactance
Step2:  stereographically  up-projecting this onto the sphere to point $p$,
Step3:  If we stereo-project this back onto the impedance plane
<ASSISTANT_TASK:>
Python Code:
#from IPython.display import SVG
#SVG('pics/smith_sphere.svg')
from galgebra.printer import Format, Fmt
from galgebra import ga
from galgebra.ga import Ga
from sympy import *
Format()
(o3d,er,ex,es) = Ga.build('e_r e_x e_s',g=[1,1,1])
(o2d,zr,zx) = Ga.build('z_r z_x',g=[1,1])
Bz = er^ex # impedance plance 
Bs = es^ex # reflection coefficient plane
Bx = er^es
I = o3d.I()
def down(p, N):
    '''
    stereographically project a vector in G3 downto the bivector N
    '''
    n= -1*N.dual()
    return -(n^p)*(n-n*(n|p)).inv() 
def up(p):
    '''
    stereographically project a vector in G2 upto the space G3
    '''
    if (p^Bz).obj == 0:
        N = Bz
    elif  (p^Bs).obj == 0:
        N = Bs
        
    n = -N.dual()
    
    return   n + 2*(p*p + 1).inv()*(p-n)
    
a,b,c,z,s,n = [o3d.mv(k,'vector') for k in ['a','b','c','z','s' ,'n']]
Explanation: Smith Sphere
The smith chart is a nomogram used frequently in RF/Microwave Engineering. Since its inception it has been recognised that projecting the chart onto the reimen sphere [1].
[1]H. . Wheeler, “Reflection Charts Relating to Impedance Matching,” IEEE Transactions on Microwave Theory and Techniques, vol. 32, no. 9, pp. 1008–1021, Sep. 1984.
End of explanation
Bz.dual()
Bz.is_zero()
z = z.proj([er,ex])
z
Explanation: Starting with an impedance vector $z$, defined by a vector in the impedance plane  $B_z$, this vector has two scalar components ( $z^r$, $z^x$) known as resistance and reactance
End of explanation
p = up(z)
p
simplify(p.norm2())
Explanation: stereographically  up-projecting this onto the sphere to point $p$,
End of explanation
down(p, Bz)
down(p,Bs).simplify()
(z-er)*(z+er).inv()
p
R=((-pi/4)*Bx).exp()
R
R*p*R.rev()
down(R*p*R.rev(),Bz)
Explanation: If we stereo-project this back onto the impedance plane
End of explanation
<END_TASK>