14-440-127 Recitation 12 Problems- Solutions

14-440-127 Recitation 12 Problems- Solutions - 14:440:127...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Problems for Students to Attempt in Recitation 12- Solutions 1) Calculate the derivative of 15x3 – 22x2 +15x -12 syms x ; diff(15*x^3 - 22*x^2 +15*x -12) 2) Calculate the integral of 35x3 – 22x2 syms x ; int(35*x^3 - 22*x^2) 3) Solve the equation x2 + 10x – 6 = 22 - x2, for x syms x ; solve( 'x^2 + 10*x - 6 = 22 - x^2' ) 4) x = [1 3 5 7 9], and y = [ 6 62 358 1086 2438 ] Find the (3rd degree) polynomial that best fits these points, and display the answer symbolically x = [1 3 5 7 9]; y = [ 6 62 358 1086 2438 ]; c = round(polyfit(x,y,3)); disp(poly2sym(c)) 5) Find the limit of sin(x) / x as x approaches -inf, and as x approaches +inf syms x ; disp(limit(sin(x)/x,inf)) disp(limit(sin(x)/x,-inf)) 6) Calculate the definite integral of 3x2 from x=5 to x=15 syms x ; disp(int(3*x^2,5,15)) 7) Write your own function myrecursivesum that takes a vector as input and recursively calculates the sum of that vector. Note that you may not use a loop. Also, you may find it helpful to note that x(2:end) creates a vector containing all but the first element of x. A good base case for this problem is summing a vector with no elements, or with one element (you pick). function s = myrecursivesum(v) if (length(v)==1) s = v(1); else s = v(1) + myrecursivesum(v(2:end)); end 8) Write your own recursive version of exponentiation-- call your function pow . It should take two arguments: a number, and a power that the number is raised to. function
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

14-440-127 Recitation 12 Problems- Solutions - 14:440:127...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online