# 3.10. Periodic Functions¶

A function is periodic with period :

Then you can shift the integration limits by the period :

If you integrate from to , you can shift in by any constant :

# 3.11. Polar Coordinates¶

Polar coordinates (radial, azimuth) are defined by

## 3.11.1. Example¶

When evaluating integrals of the type:

we write and using polar coordinates:

and then use the periodicity of :

comparing to:

we can see that because the integral is symmetric, we can just set and then replace . The above method does everything algebraically, but you can use this symmetry argument to remember what to do, or even skip the calculation if you are sure that you didn’t make a mistake in the “symmetry argument”.

# 3.12. Spherical Coordinates¶

Spherical coordinates radial (), zenith (), azimuth ():

(3.12.1)¶

Note: this meaning of is mostly used in the USA and in many books. In Europe people usually use different symbols, like , and others.

The motivation is to first write and using polar coordinates:

and then write and the projection of onto the plane using polar coordinates:

so by combining these two we get:

## 3.12.1. Example I¶

To transform differential operators such as into spherical coordinates, we make use of the chain rule:

where , and are functions of , , to be expressed by inverting (3.12.1):

At the end, the derivatives are expressed using , , again. For example

Finally we obtain

(3.12.1.1)¶

These expressions can be combined to obtain more complicated objects such as Laplacian (in spherical coordinates). However straightforward this approach is, it is also rather cumbersome; an alternative is discussed in the Spherical Coordinates section of differential geometry (where it is shown, that the coefficients in (3.12.1.1) are simply the matrix elements of the inverse Jacobian).

## 3.12.2. Example II¶

When evaluating integrals of the type:

we write and using polar coordinates:

and simplify:

comparing to:

we can see that because the integral is symmetric, we can just set , and then replace .

# 3.13. Argument function, atan2¶

Argument function is any such that

Obviously is unique up to any integer multiple of . By taking the principal value of the function, e.g. fixing to the interval (so that the branch cut is on the negative -axis, as usual), we get the function:

then , where . We can then use the following formula to easily calculate for any (except , i.e. , where it is not defined):

Finally we define as:

The angle is the angle of the point on the unit circle (assuming the usual conventions), and it works for all quadrants ( only works for the first and fourth quadrant, where , but in the second and third qudrant, gives the wrong angles, while gives the correct angles). So in particular:

This convention () is used for example in Python, C or Fortran. Some people might interchange with in the definition (i.e. ), but it is not very common.

The following useful relations hold:

We now prove them. The following works for all except for :

Tangent is infinite for , which corresponds to , so the following works for all :

Finally:

In the above, we used the following double angle formulas:

to simplify the following expressions:

Finally, for all we get:

The symmetry property can be proven by:

To prove the derivatives, we do:

Code:

```
>>> from sympy import atan, sqrt, var
>>> var("x y")
(x, y)
>>> (2*atan(y/(sqrt(x**2+y**2)+x)).diff(y)).simplify()
x/(x**2 + y**2)
>>> (2*atan(y/(sqrt(x**2+y**2)+x)).diff(x)).simplify()
-y/(x**2 + y**2)
```

An example of an application:

where

Another application

# 3.14. Multiple Argument Formulas¶

## 3.14.1. sin(a x)¶

Systematic way to derive all multiple argument formulas is to use the following relation:

where are the Chebyshev polynomials of the second kind, first few are:

Code:

```
>>> from sympy import chebyshevu, var
>>> var("x")
>>> for i in range(7): print "U_%d(x) = %s" % (i, chebyshevu(i, x))
U_0(x) = 1
U_1(x) = 2*x
U_2(x) = -1 + 4*x**2
U_3(x) = -4*x + 8*x**3
U_4(x) = 1 - 12*x**2 + 16*x**4
U_5(x) = 6*x - 32*x**3 + 32*x**5
U_6(x) = -1 + 24*x**2 - 80*x**4 + 64*x**6
```

One can then use this to calculate:

Code:

```
>>> from sympy import chebyshevu, var, sin, cos
>>> var("x")
>>> for n in range(1, 7): print "sin(%d*x) = %s" % (n, chebyshevu(n-1, cos(x))*sin(x))
sin(1*x) = sin(x)
sin(2*x) = 2*cos(x)*sin(x)
sin(3*x) = -(1 - 4*cos(x)**2)*sin(x)
sin(4*x) = (-4*cos(x) + 8*cos(x)**3)*sin(x)
sin(5*x) = (1 - 12*cos(x)**2 + 16*cos(x)**4)*sin(x)
sin(6*x) = (6*cos(x) - 32*cos(x)**3 + 32*cos(x)**5)*sin(x)
```

## 3.14.2. cos(a x)¶

Similarly as above, we use:

where are the Chebyshev polynomials of the first kind, first few are:

Code:

```
>>> from sympy import chebyshevt, var
>>> var("x")
>>> for i in range(7): print "T_%d(x) = %s" % (i, chebyshevt(i, x))
T_0(x) = 1
T_1(x) = x
T_2(x) = -1 + 2*x**2
T_3(x) = -3*x + 4*x**3
T_4(x) = 1 - 8*x**2 + 8*x**4
T_5(x) = 5*x - 20*x**3 + 16*x**5
T_6(x) = -1 + 18*x**2 - 48*x**4 + 32*x**6
```

One can then use this to calculate:

Code:

```
>>> from sympy import chebyshevt, var, cos
>>> var("x")
>>> for n in range(7): print "cos(%d*x) = %s" % (n, chebyshevt(n, cos(x)))
cos(0*x) = 1
cos(1*x) = cos(x)
cos(2*x) = -1 + 2*cos(x)**2
cos(3*x) = -3*cos(x) + 4*cos(x)**3
cos(4*x) = 1 - 8*cos(x)**2 + 8*cos(x)**4
cos(5*x) = 5*cos(x) - 20*cos(x)**3 + 16*cos(x)**5
cos(6*x) = -1 + 18*cos(x)**2 - 48*cos(x)**4 + 32*cos(x)**6
```