## Visualizing coordinate transformations

Here is some sage code to help you visualize coordinate transformations. I give three examples:

Polar coordinates:

```# polar coordinates
var('u','v')

X(u,v) = v*cos(u)
Y(u,v) = v*sin(u)

# create plots where v is fixed and u ranges
uplot = parametric_plot( (X(u,0),Y(u,0)), (u,-pi,pi))
for k in [0..4]:
uplot = uplot+parametric_plot( (X(u,k),Y(u,k)), (u,-pi,pi))

# create plots where u is fixed and v ranges
vplot = parametric_plot( (X(0,v),Y(0,v)), (v,0,4))
for k in [-10..10]:
vplot = vplot+parametric_plot( (X(k*pi/10,v),Y(k*pi/10,v)), (v,0,4.5), color = "red")

# plot all the plots
mainplot = uplot + vplot
mainplot.show(xmin=-5, xmax=5, ymin=-5, ymax =5, axes_labels = ["\$x\$","\$y\$"])
```

Hyperbolic coordinates:

```# hyperboloidal coordinates
var('u','v')

X(u,v) = v*cosh(u)
Y(u,v) = v*sinh(u)

uplot = parametric_plot( (X(u,0),Y(u,0)), (u,-2,2))
for k in [0..4]:
uplot = uplot+parametric_plot( (X(u,k),Y(u,k)), (u,-2,2))

vplot = parametric_plot( (X(0,v),Y(0,v)), (v,0,4))
for k in [-5..5]:
vplot = vplot+parametric_plot( (X(k*.2,v),Y(k*.2,v)), (v,0,4), color = "red")

mainplot = uplot + vplot
mainplot.show(xmin=-5, xmax=5, ymin=-5, ymax =5, axes_labels = ["\$x\$","\$y\$"])
```

One more fun example:

```# crazy example coordinates
var('u','v')

X(u,v) = u^2 - v^2
Y(u,v) = 2*u*v

# create plots where v is fixed and u ranges
uplot = parametric_plot( (X(u,0),Y(u,0)), (u,0,4))
for k in [-4..4]:
uplot = uplot+parametric_plot( (X(u,k),Y(u,k)), (u,0,4))

# create plots where u is fixed and v ranges
vplot = parametric_plot( (X(0,v),Y(0,v)), (v,0,4))
for k in [0..10]:
vplot = vplot+parametric_plot( (X(k,v),Y(k,v)), (v,-4,4), color = "red")

# plot all the plots
max = 20
mainplot = uplot + vplot
mainplot.show(xmin=-max, xmax=max, ymin=-max, ymax =max, axes_labels = ["\$x\$","\$y\$"])<span id="mce_SELREST_start" style="overflow:hidden;line-height:0;">&#65279;</span>
```
This entry was posted in Calculus 3, Sage. Bookmark the permalink.