$35
Problem 1: Compute the following sum,
X
10
i=0 X
i
j=0
sin(i
2
) cos(j
2
)
!
Hint: The first sum is from i = 0 to i = 10, however, the second
inner sum is from j = 0 to j = i. In other words, after you choose
a value of i, the limits of summation are determined for the inner
sum. What this means is that you can think of the inner sum as
S(i), as something that depends on i. Therefore, the sum is equal
to,
X
10
i=0
S(i) where S(i) = X
i
j=0
sin(i
2
) cos(j
2
)
You will need to write a “double loop” i.e. a loop within a loop.
Answer: 1.483231
Problem 2: Create a function called ID. This function takes as
an input a vector x and arranges the vector into an “anti-diagonal
matrix” ID(x). Instead of the diagonal matrix going from the
upper-left to the lower-right, the anti-diagonal matrix goes from
the upper-right to the lower-left.
1