programming exercise 1.

\(
\def\Real{\mathbb{R}}
\def\Comp{\mathbb{C}}
\def\Rat{\mathbb{Q}}
\def\Field{\mathbb{F}}
\def\Fun{\mathbf{Fun}}
\def\e{\mathbf{e}}
\def\f{\mathbf{f}}
\def\bv{\mathbf{v}}
\)

Use any language or library. The assignments are due by midnight of 3.14 (Monday).

3 credits students

Consider the piecewise linear function \(f\) on \([-4,4]\)
with nodes at the integer points \(-4,-3,\ldots, 3, 4\) (it means that the function is continuous and linear on each interval \([k,k+1]\), such that \(f(k)\) is the \((k+5)\)-th digit of your UIN.

Piecewise linear function (red) is approximated (not especially well) by a polynomial (blue).

Piecewise linear function (red) is approximated (not especially well) by a polynomial (blue).

Find the polynomial
\[
p=a_o+a_1x+\ldots+a_4x^4
\]
of degree \(4\) minimizing the mean square error
\[
\int_{-4}^4 |p(x)-f(x)|^2 dx.
\]
Submit the solution in the following format:

  • text file with the first line giving the coefficients of \(f\),

    [a_o a_1 a_2 a_3 a_4]

    followed by

  • the code and
  • the execution output.
  • Also attach a pdf ¬†where \(f\) and \(p\) are plotted on \([-4,4]\) simultaneously.


4 credits students

Consider the spring networks: a network of points, \(p_{ij}, i=0,\ldots,10, j=0,\ldots,10,\), where two points \(p_{ij}\) and \(p_{kl}\) are connected by a spring if either \(i=k, |j-l|=1\) (horizontal neighbors) or \(|i-k|=1, j=l\) (vertical neighbors).

Rectangular grid to embed.

Rectangular network to embed.


A configuration is a 2D placement of the network nodes, that is an assignment of two coordinates,
\[
(x_{ij}, y_{ij})
\]
to each node \(p_{ij}\).

The task is to minimize
\[
f=\frac12\left(\sum_{(i,j)\sim (k,l)}(x_{ij}-x_{kl})^2+(y_{ij}-y_{kl})^2\right),
\]
(the summation is over all neighboring pairs of nodes), subject to constraints
\[
x_{0,0}=0,y_{0,0}=0,x_{0,10}=0,y_{0,10}=10,x_{10,0}=10,y_{10,0}=0,x_{10,10}=10,y_{10,10}=10,
\]
and
\[
x_{5,5}=A_e, y_{5,5}=A_o,
\]
where \(A_e\) is the sum of digits of your UIN at even places, and \(A_o\) is the sum of digits of your UIN at odd places.

Submit the solution in the following format:

  • text file with the coefficients \(x_{ij}\):

    x=[x(0,0) x(0,1) ... x(0,10); x(1,0) ... x(10,10)]

    followed by coefficients \(y_{ij}\):

    y=[y(0,0) y(0,1) ... y(0,10); y(1,0) ... y(10,10)];

  • the code and
  • the execution output.

16 Responses to programming exercise 1.

  1. John February 27, 2016 at 10:46 am #

    When is this due? Thanks.

    • yuliy February 29, 2016 at 10:00 pm #

      Due date posted.

  2. George February 27, 2016 at 6:00 pm #

    Hello professor.

    One question about the 4 credit problem. What is the set in which the assigned coordinate numbers should belong? Integer pairs in [0,10]x[0,10]?

    • yuliy February 29, 2016 at 10:01 pm #

      x’s and y’s are real numbers.

  3. Jiading February 29, 2016 at 2:07 pm #

    Hello, professor! I wonder in the 4-credit problem, should I create the configuration table myself? If so, is there any constraints to follow? Or should it be completely random?

    • yuliy February 29, 2016 at 10:02 pm #

      You have to find the optimal x’s and y’s, not random.

  4. Ravi March 1, 2016 at 4:46 pm #

    Hello Professor Yuliy,

    I have a doubt regarding the Programming Exercise-01 -4 credits problem. Actually, I could not understand how each x and y have i,j co-ordinates. Are there 2 different planes, one plane called as X plane and the other Y-plane with A_e and A_o separately for each of them respectively. Then the springs would be along X-plane and Y-plane separately without interfering each other. It looks like a finite element topology optimization problem. Even the stiffness of the spring is not given., does that mean that I have to assume a stiffness with the co-ordinates at the 4 corners and the center fixed as per the problem constraints.

    If possible can you elaborate on the problem?

    • yuliy March 6, 2016 at 11:56 pm #

      x(i,j) and y(i,j) are variables indexed by i,j.

      Stiffnesses of the springs are equal.

  5. Anon March 5, 2016 at 4:58 pm #

    I have a question about the submission format.

    It says to submit it by:
    x=[x(0,0) x(0,1) … x(10,0); x(1,0) … x(10,10)]

    but should this be
    x=[x(0,0) x(0,1) … x(0,10); x(1,0), x(1,1), …, x(1,10); x(2,0), x(2,1), …, x(2,10); x(3, 0) … x(10,10)]

    • yuliy March 6, 2016 at 11:55 pm #

      Thank you! corrected.

  6. Chen March 5, 2016 at 7:07 pm #

    For credit 4 problem, we can solve x and y separately as they are independent. Am I right?

    • yuliy March 6, 2016 at 11:53 pm #

      Yes.

  7. Ann March 8, 2016 at 4:53 pm #

    Hi Professor, how should we submit our assignment? There seems to be no place to submit it on compass2g.

    • yuliy March 14, 2016 at 12:08 am #

      Compass has the assignment now.

  8. Quan March 11, 2016 at 9:53 pm #

    Hi Professor,

    Is iterative method for the 3 credits problem acceptable? Am I supposed to find a better algorithm in order to get full credits?

    • yuliy March 14, 2016 at 12:08 am #

      Yes – but you will have to indicate why you believe your solution is a good one (criteria of convergence).

Leave a Reply