Polar Coordinates

Description

Polar coordinates are a coordinate system similar to our standard Cartesian coordinates, however instead we have the radius from the origin $r$ and an angle $\theta$ in radians. We define $\theta$ to be zero when the points are on the x-axis and to the right of the origin, and positive angles are in the counter-clockwise direction. To translate our standard Cartesian coordinates into polar coordinates we can use the functions

(1)
\begin{align} r = \sqrt{ x^2 + y^2 } \\ \theta = \tan^{-1} \left(\frac{ y }{ x }\right). \end{align}

The following Sage interact converts Cartesian coordinates into polar coordinates. The default values are $(x,y) = (1,1)$.

Code

@interact
def _(x = input_box(default=1), y=input_box(default=1)):
    r = sqrt( x^2 + y^2 )
    t = arctan(y/x)
    pretty_print(html(r"$x = %s$" %x))
    pretty_print(html(r"$y = %s$" %y))
    pretty_print(html(r"$r = %s$" %r))
    pretty_print(html(r"$t = %s$" %t))

Sage Cell

Option

We can also convert polar coordinates back into Cartesian coordinates using the formulas

(2)
\begin{align} x = r \cos \theta \\ y = r \sin \theta. \end{align}

The Sage interact below converts polar coordinates into Cartesian coordinates. The default values are $(r,\theta) = (2, \frac{ \pi}{2})$.

Code

@interact
def _(r = input_box(default=2), t=input_box(default= pi/2 )):
    x = r*cos(t)
    y = r*sin(t)
    pretty_print(html(r"$r = %s$" %r))
    pretty_print(html(r"$t = %s$" %t))
    pretty_print(html(r"$x = %s$" %x))
    pretty_print(html(r"$y = %s$" %y))

Options

Primary Tags:

Secondary Tags:

Tags

Any related cells go here. Provide a link to the page containing the information about the cell.

Related Cells

Permalink:

Author:

Attribute

Date: 30 Oct 2018 17:31

Submitted by: James A Phillips

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License