Introduction to MATLAB Exercise 2



Symbolic calculations


  1. Find the roots of the polynomial x5+x4+1=0 in three different ways: You can convert symbolic variable to floating point numbers using double.
  2. Validate the following indefinite integral symbolically, either using int to integrate or diff to differentiate the right hand side. (Remember in MATLAB the natural logarithm is log and the inverse tangent function is atan). You may also have to simplify your answer, to confirm the results clearly.
  3. Evaluate the following definite integrals symbolically (using int): sinxxdx,0111+x2dx,0ex2dx,01ln(x+1)x2+1dx,01x111lnxdx.
  4. Use symsum (symbolic sum) to validate the following sums (use inf for ) n=113nn=log32,n=1n3n=34,n=11n4=π490.
  5. Use symprod to evaluate the following infinite product (notice the starting value of n in each expressions):

Graphics


  1. Plot more heart curves written in different formats (choose the right plotting functions): Hint: use abs for the absolute value, and choose the proper range of the axis for the implicit plot.
  2. The equation for a hypocycloid is given by x=r(k1)cosθ+rcos((k1)θ),y=r(k1)sinθrsin((k1)θ). Plot the curve for r=1.0,k=3.0.

    You may have to add axis equal to make the aspect ration equal.
  3. In this exercise, you are going to plot the function (x1)13 on the interval [0.9,1.1] in two ways: (1) evaluate (x1)13 directly; (2) evaluate its expansion (in polynomial) x1313x12+13x1. You can convert the symbolic exression of (x1)13 into polynomial using sym2poly (you will get a vector for the coefficients of the polynomial, instead of calculating them by yourself), and then evaluate the polynomial using polyval. The function is plotted more accurately in which way, when evaluated as (x1)13 or as the polynomial expansion?
      
    syms z;
    p = sym2poly((z-1)^13); % get the coefficients for the polynomial (z-1)^13
    x = linspace(0.9,1.1,51);
    % plot the data from polynomial evaluation, using the style "*" or "."