CompSciHW7

From Predictive Chemistry
Jump to: navigation, search

Introduction To Scientific Computing Homework 7 (Fall, 2016)

Due Friday, April 1.

1) Write a function to add two polynomials that have been specified by vectors of their coefficients,
   z(t) = x(t) + y(t)
   where x(t) = a_0 + a_1 t + a_2 t^2 + ...
         y(t) = b_0 + b_1 t + b_2 t^2 + ...
         z(t) = c_0 + c_1 t + c_2 t^2 + ...
  The function should return the vector, c.  Be sure to handle the case where the lengths
  of a and b are different.

2) Write a function to multiply two input functions - each of which have been
   specified by their values at the same set of points, x_n, n=0, 1, ..., N-1.
   i.e. z(x_n) = f(x_n) g(x_n)
   Handle the case where the lengths of a and b are different by assuming
   that the functions are zero wherever a point is not provided.

3) Write a function to compute the volume and perimeter of 2D and 3D rectangular boxes.
   The boxes are specified by lengths along each dimension.  The function should return a tuple,
   (Area : float, Volume : float)

4) Write a function to compute the set of inner products, <a_n, b> where
    a_n are row-vectors of an input matrix, A (n by m) and b is a vector of length m.

5) Re-write the last function, assuming a_n are column vectors of an input matrix, A (m by n).