DS401 - Optimization for Data Science
Assignment-1
Assigned Date: 04/02/2023
11:59pm, Due Date:13/02/2023
Instructions
• Work on the assignments on your own. You are free to discuss among your selves,but
don’t copy. If we find the assignments of a group of (two or more) students very similar,
the group will get zero points towards this assignment. Plagiarism will be cheked with
tools. Please use Python for writing code. You can submit the code as a Jupyter notebook
and For the theory questions, please submit your work to TAs. Use slack to discuss, if
you have any doubts.
1 Programming
• Q1(12 Marks)-Let f : R2 → R, (x1 , x2 ) 7→ − cos(x21 + x22 + x1 x2 )
1. Create a contour plot of f in the range [−2, 2] × [−2, 2] with Python.
2. Compute ∇f and Compute ∇2 f
Now, we define the restriction of f to Sr = {(x1 , x2 ) ∈ R2 | x21 + x22 + x1 x2 < r} with
r ∈ R, r > 0, i.e., f|Sr : Sr → R, (x1 , x2 ) 7→ f (x1 , x2 ).
4. Show that f|Sr with r = π/4 is convex.
5. Find the local minimum x∗ of f|Sr (Identify on the cotour plot)
6. Is x∗ a global minimum of f ?
• Q2(10 Marks)- Implement the gradients for the following functions in 2 methods 1) Us-
ing derivative function 2) Numerical gradient (hint is given)
1
– With a sufficiently small value of epsilon, this function should be a good approxi-
mation of the gradient. Verify that both gradients (the numerical computation and
the one implemented with derivative functions) as the same
2 Theory
1. Q1(10 marks) Consider the bivariate function f : R2 → R, (x1 , x2 ) 7→ x21 +0.5x22 +x1 x2 .
(a) Find the direction of greatest increase of f at x = (1, 1).
(b) Find the direction of greatest decrease of f at x = (1, 1).
(c) Find a direction in which f does not instantly change at x = (1, 1).
(d) Assume there exists a differentiable parametrization of a curve x̃ : R → R2 , t 7→
x̃(t) such that ∀t ∈ R : f (x̃(t)) = f (1, 1). Show that at each point of the curve x̃
the tangent line ∂∂tx̃ is perpendicular to the gradient ∇f (x̃).
(e) Interpret (d), (e) geometrically
2. Q2(10 marks) Consider two convex functions f, g : R → R.
(a) Show that f + g : R → R, x 7→ f (x) + g(x) is convex.
(b) Now, assume that g is additionally non-decreasing, i.e., g(y) ≥ g(x) ∀x ∈ R, ∀y ∈
R with y > x. Show that g ◦ f is convex.
3. Q3(10 marks) Consider the bivariate function f : R2 → R, (x1 , x2 ) 7→ exp(π · x1 ) −
sin(π · x2 ) + π · x1 · x2
(a) Compute the gradient of f for an arbitrary x.
(b) Compute the Hessian of f for an arbitrary x.
(c) State the first order taylor polynomial T1,a (x) expanded around the point a = (0, 1).
(d) State the second order taylor polynomial T2,a (x) expanded around the point a =
(0, 1).
(e) Determine if T2,a is a convex function.
4. Q4(10 marks) Let f : [−1, 2] → R, x 7→ exp(x3 − 2x2 )
(a) Compute f ′
(b) Plot f and f ′ with Python
(c) Find all possible candidates x∗ for maxima and minima.
Hint: exp is a strictly monotone function.
(d) Compute f ′′
(e) Determine if the candidates are local maxima, minima or neither.
(f) Find the global maximum and global minimum of f