14.18. Numeric Methods Homework

Save all of the commands entered into MATLAB and the output to a text file to submit on Canvas.

  1. Use the fzero function to find where f(x) = 5 + 10x - x^2 is equal to zero in the range -5 \leq x \leq 15.

  2. Use the following code to make 8 (x, y) points. Then use the interp1 function to expand the data to 32 data points. Generate a 2{\times}2 subplot with the smooth function, 8 point plot, 32 point plots with linear and pchip interpolation.

    >> f = @(x) cos(x) + 0.7*sin(x);
    >> x = linspace(-pi,pi,8);
    >> y = f(x);
    >> plot(x,y)
    
  3. Using the trapezoid rule (20 subintervals), Simpson rule (20 subintervals), the adaptive integral algorithm presented in Recursive Adaptive Integral, and MATLAB’s integral function compute the definite integral \int_0^{10} x^2 e^{-x} dx

  4. Use the anonymous function f = @(t,y) t.^2 .* exp(-t); let y'(t) = f(t), y(0) = 0 define a differential equation. Use ode45 to plot y(t), 0 \leq t \leq 20.