You are on page 1of 22

Solutions to the Exercises on

Functions

Laurenz Wiskott
Institut fur Neuroinformatik
Ruhr-Universitat Bochum, Germany, EU

2 February 2017

Contents

1 Scalar functions in one variable 3

1.1 Elementary transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.1.1 Exercise: Stepwise transformation of an elementary function . . . . . . . . . . . . . . 3

1.1.2 Exercise: Stepwise construction of a given function . . . . . . . . . . . . . . . . . . . . 5

1.1.3 Exercise: Stepwise construction of a given function . . . . . . . . . . . . . . . . . . . . 5

1.2 Combination of functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

1.2.1 Exercise: Combinations of functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

1.3 Composition of functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

1.3.1 Exercise: Composite functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

1.3.2 Exercise: Composite functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

1.3.3 Exercise: Analytical expressions for given function graphs . . . . . . . . . . . . . . . . 9

1.4 Logarithmic plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2 Scalar functions in two variables 10

2.1 Visualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2017 Laurenz Wiskott (homepage https://www.ini.rub.de/PEOPLE/wiskott/). This work (except for all figures from
other sources, if present) is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. To view
a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/. Figures from other sources have their own
copyright, which is generally indicated. Do not distribute parts of these lecture notes showing figures with non-free copyrights
(here usually figures I have the rights to publish but you dont, like my own published figures).
Several of my exercises (not necessarily on this topic) were inspired by papers and textbooks by other authors. Unfortunately,
I did not document that well, because initially I did not intend to make the exercises publicly available, and now I cannot trace
it back anymore. So I cannot give as much credit as I would like to. The concrete versions of the exercises are certainly my
own work, though.
These exercises complement my corresponding lecture notes available at https://www.ini.rub.de/PEOPLE/wiskott/

Teaching/Material/, where you can also find other teaching material such as programming exercises. The table of contents of
the lecture notes is reproduced here to give an orientation when the exercises can be reasonably solved. For best learning effect
I recommend to first seriously try to solve the exercises yourself before looking into the solutions.

1
2.1.1 Set of curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2.1.2 Contour graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2.1.3 3D-graphics / surface plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2.2 Elementary transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2.3 Linear coordinate transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2.3.1 Exercise: Stepwise transformation of a simple function . . . . . . . . . . . . . . . . . . 10

2.3.2 Exercise: Stepwise transformation of a simple function . . . . . . . . . . . . . . . . . . 11

2.3.3 Exercise: Simplify a function with stepwise transformations . . . . . . . . . . . . . . . 13

3 Vectorial functions in one variable 16

3.1 Visualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

3.1.1 Set of curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

3.1.2 Sequence of a vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

3.1.3 Trajectory in phase space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

3.1.4 Exercise: Trajectories in phase space . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

3.1.5 Exercise: Trajectories in phase space . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

3.1.6 Exercise: Analytical expressions for given trajectories . . . . . . . . . . . . . . . . . . 18

4 Vectorial functions in two variables 19

4.1 Visualization as a vector field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

4.1.1 Exercise: Vector field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

4.1.2 Exercise: Analytic expression for a given vector field . . . . . . . . . . . . . . . . . . . 20

4.1.3 Exercise: Analytic expression for a given vector field . . . . . . . . . . . . . . . . . . . 20

5 Differential operators 21

5.1 Partial derivatives and the Nabla operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

5.2 Gradient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

5.2.1 Exercise: Contour plot and gradient field . . . . . . . . . . . . . . . . . . . . . . . . . 21

5.2.2 Exercise: Gradient field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

5.3 Divergence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

2
1 Scalar functions in one variable

1.1 Elementary transformations

1.1.1 Exercise: Stepwise transformation of an elementary function

Construct the following functions step by step, for each intermediate step write down an equation and sketch
the graph.

(a) Begin with y = x3 ,

i) Shift the function 7 units to the left,


ii) Stretch the function vertically by a factor of 8,
iii) Flip the function at the y-axis.

Solution:
i) y = (x + 7)3 ,
ii) y = 8(x + 7)3 ,
iii) y = 8(x + 7)3 ,

0 10
1000

0 0

-1000

CC BY-SA 4.0
-10 -7 0 7

(b) Begin with y = cos(x),

i) Stretch the function horizontally by a factor of 2;


ii) Shift the function 3 units up;
iii) Flip the function at the x-axis.

Solution:

i) y = cos(x/2),
ii) y = cos(x/2) + 3,
iii) y = (cos(x/2) + 3).

3
4 4

2 2
1 1
0
-1 -1
-2 -2

-4 -4

6 5 4 3 2 0 2 3 4 5 6

CC BY-SA 4.0
(c) Begin with y = ex ,

i) Flip the function at the x-axis,


ii) Shift the function 5 units to the right and 12 units down,
iii) Flip the function at the diagonal y = x.

Solution:
i) y = ex ,
ii) y = e(x5) 12,
iii) A flip at the diagonal corresponds formally to a swap of the variables. But then we have to solve
the new equation for x.

x = e(y5) 12 (1)
(y5)
x + 12 = e (2)
(x + 12) = e(y5) (3)
ln((x + 12)) = y 5 (4)
ln((x + 12)) + 5 = y . (5)

-13 0

5 5

1
0
-1

-12
-13

-12 5
CC BY-SA 4.0
4
1.1.2 Exercise: Stepwise construction of a given function

Construct and draw the following functions by stepwise transformation of the underlying elementary function.
Illustrate each step.

(a) 3 sin(x + /4)


Solution: We start with sin(x).
A shift to the left by /4 yields sin(x + /4).
A vertical stretch by a factor of 3 yields 3 sin(x + /4).
A reflection at the x-axis yields 3 sin(x + /4).
3 5
4 4

-1

-3

7 1

CC BY-SA 4.0
4 4

(b) 1/[(x 2)3 1]


Solution: We start with x3 .
A shift to the right by 2 yields (x 2)3 .
A shift down by 1 yields (x 2)3 1.
Taking the reciprocal value corresponds to a nonlinear coordinate transformation by which the upper
half is reflected at the horizontal line y = 1 and distorted such that the interval (0, 1) is mapped onto
(1, ) and vice versa. Something analogous holds for the lower half. This results in 1/[(x 2)3 1].

1 3

0 0

-1

CC BY-SA 4.0
-1 2 3

1.1.3 Exercise: Stepwise construction of a given function

Construct and draw the following functions by stepwise transformation of the underlying elementary function.
Illustrate each step.

5
(a) e2(x3) + 7
Solution: We start with ex .
A flip at the ordinate yields ex .
A horizontal compression by a factor of 1/2 yields e2x .
A horizontal shift left by 3 yields e2(x+3) = e2(x3) .
A vertical shift up by 7 yields e2(x3) + 7.

-3 0

8
7 7

1
0 0

-3 0

CC BY-SA 4.0
3
x
(b) x3 +1
x3 1
Solution: First we realize that the function vanishes for x = 0 and simplifies to x3 +1 = 1+1/x3
otherwise. We start with x3 .
Taking the inverse yields 1/x3 .
A vertical shift up by 1 yields 1 + 1/x3 .
1
Taking the inverse again yields 1+1/x3 .
The main thing that is unclear is how the function behaves at x = 0. However, looking at the original
3
function x3x+1 , we see that the x3 in the denominator can be neglected for small x, so that the function
behaves like x3 around zero.
-1 1

2
1 1
0 0
-1

CC BY-SA 4.0
-1 0

1.2 Combination of functions

1.2.1 Exercise: Combinations of functions

Discuss the following functions intuitively, like in the lecture, and sketch them.

6
x2
(a) f (x) = cos (x) + 20 (sum of functions)
Solution: This function can be interpreted as a parbula with a superimposed oscillation. f (x) assumes
exactly the value of the parabula at the zero crossings of the cosine function while it deviates from the
parabula by 1 at the extrema of the cosine function. One can therefore first draw the parabula x2 /20
and mark the zero crossings of the cosine function on it. Then one can draw two parabulas shift by 1
vertically and finally draw an oscillation between these two auxiliary parabulas through the marked
zero crossings.

1
0
-1

4 3 2

CC BY-SA 4.0
0 2 3 4

(b) g(x) = x2 sin(x) (product of functions)


Solution: This function can be interpreted as a sine function that is modulated in its amplitude by
a quadratic function. One has to take care though that one does not move the zero crossings closer
together at small amplitudes. One can therefore first draw the envelop functions x2 , then mark the
zero crossings of the sine function on the x-axis, and finally draw the oscillation between the envelope
functions through the marked zero crossings.
11 7 3 5 9
2 2 2 2 2 2

9 5 3 7 11
0

CC BY-SA 4.0
2 2 2 2 2 2

1.3 Composition of functions

1.3.1 Exercise: Composite functions

Discuss the following functions intuitively, like in the lecture, and sketch them.

(a) ln(x2 )
Solution: Here it helps to see that ln(x2 ) = 2 ln(|x|). This implies that this function is actually simply
the logarithm vertically stretched by a factor of 2. In addition, negative arguments are permitted
resulting in a flipped copy of the logarithm on the left side.

7
0

CC BY-SA 4.0
-1 0 1

(b) esin x
Solution: This function can be interpreted as a sine function that is transformed by an exponential
function such that (i) it is shifted up by one since e0 = 1 and (ii) distorted in a way that the curve
becomes steeper at larger values and shallower at smaller values. For instance, there are no negative
values, whatever the argument of the exponential function might be.
3 5
2 2 2

1
e
0

5 3
0

CC BY-SA 4.0
2 2 2

(c) sin(1/x)
Solution: One possible way to interpret this function is to imagine a sine function with a nonlinear
coordinate transformation. If we consider only positive x, the transformation is a flip at x = 1 and a
compression of the interval x (1, ) onto the interval x (0, 1) and a stretch in the other direction.
Thus, 5 swaps with 1/5, 100 with 1/100, etc. One therefore has to draw infinitely many oscillations
towards zero while there is no full oscillation at all between one and infinity. The function then looks
as follows.
2 1 2
3

-1

2 1 2
0 3

8
CC BY-SA 4.0
1.3.2 Exercise: Composite functions

Discuss the following functions intuitively, like in the lecture, and sketch them.

2
+2)2
(a) e(x
Solution: Not available!
(b) ln(x)2
Solution: Not available!

1.3.3 Exercise: Analytical expressions for given function graphs

Find a formula for each of the following sketched functions:

(a) (b) (c)

(d) (e) (f)


CC BY-SA 4.0
Hint: You can use AnalyticalExpressionsForGivenGraphs-Exercise.ipynb and add the missing code to
verify your guesses.

Solution:

(a) This is obviously a linear function that has the value 4 at x = 0 and a slope of 4/3, i.e.
f (x) = 4 4/3x . (1)

(b) This is a parabula open to the top. Viewed from its minimum it reaches the value 1 only at 2, i.e.
the central term is x2 /4. This function is shifted down by 1 and left by 2, i.e.
f (x) = 1 + (x + 2)2 /4 . (2)

(c) This is essentially the absolute value function but vertically compressed by 2/3 and shifted right by 3,
i.e.
f (x) = 2/3|x 3| . (3)

(d) This function could be based on 1/x. However, one has to switch the sign, shift the function up by c,
and before all that stretch or compress it such that the function assumes the value 0 at 1, i.e.
f (x) = c b/x , (4)

9
with b chosen such that f (1) = 0. It is easy to see that b = c.
(e) This function goes to infinity at 0 and c. This can easily be achieved by adding 1/x und 1/x shifted
to the right by c, i.e.
f (x) = 1/x 1/(x c) . (5)
Alternatively one can multiply the two functions, resulting in a fraction with two poles,
1
f (x) = . (6)
x(c x)

The two functions are slightly different but both produce a graph of the given form.
(f) Such a function can be generated by inverting the tangent function and stretching it such that the
range lies between 1 and +1, i.e.

f (x) = arctan(x)/(/2) . (7)

Alternatively one can simply use the tanh,

exp(x) exp(x)
f (x) = tanh(x) := . (8)
exp(x) + exp(x)

See also AnalyticalExpressionsForGivenGraphs-Solution.ipynb.

1.4 Logarithmic plots

2 Scalar functions in two variables

2.1 Visualization

2.1.1 Set of curves

2.1.2 Contour graphics

2.1.3 3D-graphics / surface plot

2.2 Elementary transformations

2.3 Linear coordinate transformations

2.3.1 Exercise: Stepwise transformation of a simple function


p
Transform the function z = x2 + y 2 step by step as follows:

1. Compress the function by a factor 1/2 in the x-direction and stretch it by a factor 3 in the y-direction.

2. Shift the function horizontally 3 units to the left in x-direction and 1 unit up in y-direction.
3. Shift the function vertically 2 units down in z-direction.

For each step write a corresponding equation and sketch the final result if you combine all three steps.

Solution:

10
p
1. z = (2x)2 + (y/3)2
p
2. z = (2(x + 3))2 + ((y 1)/3)2
p
3. z = (2(x + 3))2 + ((y 1)/3)2 2

10

-5

-10
-10 -5 0 5 10

CC BY-SA 4.0
Notice that because we use absolute values (realized with a combination of square and square root) instead
of squared values, the equipotential lines are equidistant.

2.3.2 Exercise: Stepwise transformation of a simple function

Transform the function    


T 2 0 x
f (x) = x x, x= (1)
0 1 y
as follows:

1. Rotate the function clockwise by 30 degrees.



Hint: sin(/6) = 1/2, cos(/6) = 3/2.
2. Shift the function horizontally by a = (1, 2)T .

Write a corresponding equation for each step and sketch the final result. Use matrix notation as far as
possible.

Solution:

1. A rotation matrix can be written as


 
cos() sin()
R := . (2)
sin() cos()

It realizes a counterclockwise rotation by the angle .


In order to rotate the function clockwise by 30 degrees (/6) the
coordinates must be rotated counter-
clockwise by 30 degrees. With sin(/6) = 1/2 and cos(/6) = 3/2 we have
 
1 3 1
R30 = . (3)
2 1 3

11
Thus, the rotated function is
 
2 0
f (x) = xT RT30 R30 x (4)
0 1
   
(3) 1 T 3 1 2 0 1
3
= x x (5)
4 1 3 0 1 1 3
  
1 T 3 1 2
2 3
= x x (6)
4 1 3 1 3
 
1 T
= x
6+1 3 x (7)
4 3 2+3
 
1 T
= x 7 3 x . (8)
4 3 5

2. In order to shift the function horizontally by a = (1, 2)T the coordinates must be shifted by a, i.e.
 
T 7/4 3/4
f (x) = (x a) (x a) (9)
3/4 5/4
| {z }
=:A
(x a)T A(x a) .

= (10)

If you like you can multiply this out and bring it into a different form, namely

f (x) = (x a)T A(x a)



(11)
T T T T
= x Ax x Aa a Ax + a Aa (12)
T T T
= x Ax 2 a A x + a Aa}
| {z (since A is symmetric) (13)
| {z }
=:f T =:c

= c + f T x + xT Ax (14)
T
with c = a Aa (15)
  
3/4
7/4 1
= (1 2) (16)
3/4
5/4 2
 
= (1 2) 2 3)/4
(7
(17)
( 3 + 10)/4

= (7 2 3)/4 + 2( 3 + 10)/4 (18)

= 27/4 3 (19)
und f = 2 Aa (20)
  
7/4 3/4 1
= 2 (21)
3/4 5/4 2
 
(7 23)/4
= 2 (22)
(10 3)/4
 
(2
3 7)/2
= . (23)
( 3 10)/2

The function then looks as follows.

12
10

-5

-10
-10 -5 0 5 10

CC BY-SA 4.0
2.3.3 Exercise: Simplify a function with stepwise transformations

Consider the function


f0 (x, y) := 1/2 x + 5y + 3/2x2 + xy + 3/2y 2 . (1)

1. Write the function in matrix notation like

f0 (x) = c + f T x + xT Hx , (2)

with a scalar c, vectors f and x = (x, y), and a symmetric 2 2-matrix H.


Solution: Expanding (2) yields

f0 (x) = c + f T x + xT Hx (3)
2 2
= c + f1 x + f2 y + H11 x + (H12 + H21 )xy + H22 y . (4)

By comparison of coefficients with (1) we find

c = 1/2 (5)
 
1
f = (6)
5
 
1 3 1
H = . (7)
2 1 3

We have chosen H12 and H21 such that the matrix is symmetric. That is important further below.
However, H12 = 1 and H21 = 0 and many other combinations would correctly reproduce the function
as well.
The function can then be written in matrix notation like
 T  
1 1 T 3 1
f0 (x) = 1/2 + x+ x x. (8)
5 2 1 3

2. Find a horizontal shift a and a vertical shift b such that

f1 (x) := xT Vx := b + f0 (x a) (9)

for a symmetric matrix V.

13
Solution: We take the ansatz b + f0 (x a) and chose b and a such that the constant and the linear
term vanish.
(2)
b + f0 (x a) = b + c + f T (x a) + (x a)T H(x a) (10)
= b + c + f T x f T a + xT Hx xT
Ha} aT Hx + aT Ha
| {z (11)
= aT Hx
   
T T
= b + c f a + a Ha + f 2aT H x + xT Hx .
T
(12)

First we set the linear term to zero for all x and get
 
!
0 = f T 2aT H x x (13)
f T = 2aT H (14)
(6,7)
1 = 3a1 + a2 (15)
5 = a1 + 3a2 (16)
a2 = 3a1 1 (17)
5 = a1 + 3(3a1 1) (18)
= 3 8a1 (19)
a1 = 1 (20)
a2 = 2 (21)
a1 = 1 . (22)

Next we find the value of b by setting the constant term to zero,


!
0 = b + c f T a + aT Ha (23)
(5,6,7,21,22)
= b + 1/2 (1 + 10) + (3/2 1 1 + 6) (24)
= b5 (25)
b = 5. (26)

If we now consider equation (12) again, we find that

V = H. (27)

This is generally true. One can always shift a quadratic function horizontally and vertically such that
finally only the quadratic term remains, and the matrix H does not change.

3. Find a rotation  
cos() sin()
R := (28)
sin() cos()
of the coordinates such that matrix V0 of the function

f2 (x) := xT V0 x := f1 (Rx) (29)

becomes diagonal.
Solution: If we insert the rotation of the coordinates in f1 , we get

f1 (Rx) = xT RT VRx , (30)

and we must chose the angle such that the new matrix V0 becomes diagonal. To keep the equation

14
tidy we set s := sin() und c := cos(). We then find for V0
V0 = RT VR (31)
   
(28,27,28) c s 3/2 1/2 c s
= (32)
s c 1/2 3/2 s c
  
1 c s 3c + s c 3s
= (33)
2 s c c + 3s 3c s
 
1 c(3c + s) + s(c + 3s) c(c 3s) + s(3c s)
= (34)
2 s(3c + s) + c(c + 3s) s(c 3s) + c(3c s)
3c2 + sc + sc + 3s2 c2 3sc + 3sc s2
 
1
= (35)
2 3sc s2 + c2 + 3sc sc + 3s2 + 3c2 sc
3(c2 + s2 ) + 2sc c2 s2
 
1
= (36)
2 c2 s2 3(c2 + s2 ) 2sc
3 + 2sc c2 s2
 
1
= . (37)
2 c2 s2 3 2sc
This matrix becomes diagonal if (c2 s2 ) = 0, which is obviously the case if c = s, which in turn
corresponds to a rotation by /4 plus an integer mutliple of /2. One could have guessed that already
from the symmetry of V. Setting = /4 results in

c = s = 1/ 2 (38)
and
 
0 (37,38) 1 3+1 0
V = (39)
2 0 31
 
2 0
= . (40)
0 1

Thus
xT V 0 x
(29)
f2 (x) = (41)
 
(40) T 2 0
= x x (42)
0 1
= 2x2 + y 2 (43)

= ( 2x)2 + y 2 . (44)
This function is really
easy to understand. It is simply a parabula that is compressed in the x-direction
by a factor of 1/ 2, see the figure.

0
y

-2

-4

-4 -2 0 2 4
x
CC BY-SA 4.0
15
Please notice that matrix R describes a counterclockwise rotation but that the function is rotated
clockwise.
4. Sketch the function f0 (x, y) without using a calculator.
Solution: It is easiest to start from function f2 (x) of the last part and use the geometric transfor-
mations we have used for simplifying the function in the opposite order. Thus, we first rotate f2 (x)
counterclockwise by /4 = 45 and then move it horizontally by (1, 2)T and vertically by 5.

0
y
-2

-4

-4 -2 0 2 4
x
CC BY-SA 4.0
3 Vectorial functions in one variable

3.1 Visualization

3.1.1 Set of curves

3.1.2 Sequence of a vector

3.1.3 Trajectory in phase space

3.1.4 Exercise: Trajectories in phase space

Sketch the trajectories of the following functions without using a computer or pocket calculator.

(a) f (a) = (cos (a), sin (2a))


Solution: At first this may look like a simple circle, but the sine function of the y-component runs
twice as fast as the cosine function of the x-component. But at least the trajectory is periodic in a
with period 2. First plot cos(a) and sin(2a) together in one graph.

16
1 cos(a)
sin(2a)

0.5

-0.5

-1
0 1 2 3 4 5 6

CC BY-SA 4.0
a


If we go through a step by step we find that we pass the coordinates (1, 0), (1/ 2, 1), (0, 0), (1/ 2, 1),
etc. The trajectory then looks like this.

0.5
sin(2a)

-0.5

-1
-1 -0.5 0 0.5 1
cos(a)

CC BY-SA 4.0
(b) f (t) = (sin2 (6t) sin(t), sin2 (6t) cos(t))
Solution: At first this trajectory looks complicated. However, we can factor out sin2 (6t) and write
f (t) = sin2 (6t)(sin (t), cos (t)). This makes clear that we have a circular trajectory with an amplitude
modulated by sin2 (6t). Because of the square the amplitude oscillates 12 times between 0 and 1. The
trajectory starts at 0 (0, 1) for t = 0 and then circles through clockwise with the twelve oscillations.

0.5
sin2 (6t) cos(t)

-0.5

-1
-1 -0.5 0 0.5 1
sin2 (6t) sin(t)

CC BY-SA 4.0
3.1.5 Exercise: Trajectories in phase space

Sketch the trajectories of the following functions without using a computer or pocket calculator.

17
(a) f (t) = ((1 1/t) sin t, (1 1/t) cos t)T , 1t
Solution: This trajectory can be written as a product of a circle (sin t, cos t) with increasing radius
(1 1/t). The circle starts for t = 1 at about 2 oclock and runs clockwise; the radius starts at 0, first
grows quickly, and then more and more slowly approaches 1. Taken together the trajectory describes
a spiral.

0.5

-0.5

-1

CC BY-SA 4.0
-1 -0.5 0 0.5 1

2
(b) f (a) = (cos (2a) + a, cos (2a))T
2
Solution: The basic element of this trajectory is (cos (2a) , cos (2a)), an oscillation on a fixed
parabula of width 2 open to the right that goes through (1,1), (0,0), and (1,-1) for a = 0. The
oscillation frequency is 1 per time unit. With the additional term +a in the x-component the parabula
moves to the right at a rate of 1 per time unit.

0.5

-0.5

-1

CC BY-SA 4.0
0 0.5 1 1.5 2

3.1.6 Exercise: Analytical expressions for given trajectories

Invent functions f (t) = (x(t), y(t)) that generate trajectory plots like those below.

(a) (b) (c)


CC BY-SA 4.0
18
Hint: You can use AnalyticalExpressionsForGivenTrajectories-Exercise.ipynb and add the missing
code to verify your guesses.

Solution:

(a) The symmetry of the trajectory indicates that x(t) is an even function and y(t) is an odd function if
one uses a symmetric interval for t. It is also clear that y(t) grows slightly faster than x(t) for large |t|.
The x-component comes from +, moves towards zero, and returns to +, being slower near zero.
This can be achieved by x(t) = t2 . The y-component comes from , shoots over zero into positive
values, returns to negative values, and then moves to +. This can be achieved by something like
y(t) = t + t3 , thus
f (t) = (t2 , t + t3 ) . (1)
This produces the given trajectory for t [2, +2].
(b) The basic spiral can be generated as a clockwise circle with linearly increasing radius, such as f (t) =
(t sin(t), t cos(t)). The oscillation around this spiral has constant amplitude and constant spatial fre-
quency. The former can be easily achieved by adding a constant oscillation to the scaling factor t, e.g.
f (t) = ((t + sin(10t)) sin(t), (t + sin(10t)) cos(t)). However, this oscillation does not have constant spa-
tial frequency, because it has a constant number (in this case 10) of oscillations per revolution. Since
the radius increases linearly in time, the temporal frequency of the oscillation also needs to increase
linearly in time, in order to get a constant spatial frequency, thus we need to replace 10 by t and get

f (t) = ((t + sin(t2 )) sin(t), (t + sin(t2 )) cos(t)) . (2)

This produces the given trajectory for t [0, 20].


(c) An eight-shape can be produced by two oscillating functions x(t) and y(t), where the y-oscillation is
twice as fast as the x-oscillation, e.g. f (t) = (sin(t), sin(2t)). Scaling can be achieved by multiplying
this with t, and shifting upwards can be achieved by adding t to the y-component, resulting in

f (t) = (t sin(t), t + t sin(2t)) (3)


= t(sin(t), 1 + sin(2t)) . (4)

This produces the given trajectory for t [0, 50].

See also AnalyticalExpressionsForGivenTrajectories-Solution.ipynb.

4 Vectorial functions in two variables

4.1 Visualization as a vector field

4.1.1 Exercise: Vector field

Draw the vector field (y, x) .

Solution:

19
10

-5

-10
-10 -5 0 5 10

CC BY-SA 4.0
4.1.2 Exercise: Analytic expression for a given vector field

Find an analytic expression for the following vector field.

10

-5

-10
-10 -5 0 5 10

CC BY-SA 4.0
Solution: Let us assume it is a simple polynomial function. The vector field vanishes in the origin, thus
there is no constant term. The x-component of the function is zero along the x-axis, i.e. for y = 0, thus
the x-component probably contains a factor y. Similarly the y-component probably has a factor x. That
is already enough information, because if we try the vector field (y, x) we find that it generates the correct
flow field.

4.1.3 Exercise: Analytic expression for a given vector field

Find an analytic expression for the following vector field.

20
1

0.5

y
-0.5

-1
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
x

CC BY-SA 4.0
Solution: First we observe that the vector field does not depend on y and at least to a first approximation
the x-component seems to be a constant overall. Next we see that the vector field is periodic in x with a
periodicity of 2, so that terms like sin(x) or cos(x) might be involved. For x = 0 the y-component has its
maximum and is equal to the x-component. This hints at cos(x) rather than sin(x). If we try (1, cos(x))
we find that that generates the correct field.

5 Differential operators

5.1 Partial derivatives and the Nabla operator

5.2 Gradient

5.2.1 Exercise: Contour plot and gradient field

Consider the function


X(u, v) = u2 (u 1)2 + v 2 . (1)

1. Calculate the gradient field of the function.


Solution:
!
X(u,v)
X(u, v) = u
X(u,v) (2)
v
2u(u 1)2 + u2 2(u 1)
 
(1)
= (3)
2v
 
2u[(u 1) + u](u 1)
= (4)
2v
 
4u(u 1/2)(u 1)
= . (5)
2v

2. Sketch the function with a contour plot and draw the gradient field, both without the help of a
calculator.
Solution: To sketch the function and its gradient field it is useful to consider the profiles of u2 (u 1)2
and 4u(u 1/2)(u 1). It is clear that v 2 is simply a parabula.
u2 and (u 1)2 are parabulas centered at 0 and 1. The product is therefore a function with two
valleys at 0 and 1. In the direct vicinity of u = 0 one can assume that (u 1)2 = 1 and therefore
at (u, v) = (0, 0) the function X(u, v) simplifies to u2 + v 2 , which is a rotation symmetric parabula.
Something similar hold at (u, v) = (1, 0).

21
4u(u 1/2)(u 1) is obviously zero at 0, 1/2, and 1. For negative values of u all three factors are
negative and the function value is therefore negative as well. Above 0 the function values become
positive, because u changes sign. Above 1/2 the function values become negative again, because
(u 1/2) changes sign. Above 1 they are positive again. This information helps in sketching the
gradient field, see figure.

0.4

0.2

v
-0.2

-0.4

-0.5 0 0.5 1 1.5


u

CC BY-SA 4.0
5.2.2 Exercise: Gradient field

Calculate the gradient of the function f (x, y) = xy 12 y 2 . Sketch the gradient field and the level lines.

Solution: Not available!

5.3 Divergence

22

You might also like