MATH/CMSC 206 - Introduction to Matlab
Announcements | Syllabus | Tutorial | Projects | Submitting |
Differentiation
Contents
Using diff
What about calculus? Don't worry -- Matlab will not let you down! Suppose you'd like to differentiate the function log(6*x+2). You could either do it yourself or... just ask Matlab to do it with the diff command:
syms x
diff(log(6 * x + 2))
ans = 6/(6*x + 2)
What could be easier?
Would you like to find the third derivative of the function log(6*x+2)? That's easy too -- just pass 3 as a second parameter to the diff command:
diff(log(6 * x + 2), 3)
ans = 432/(6*x + 2)^3
Or for fun:
diff(diff(diff(log(6*x+2))))
ans = 432/(6*x + 2)^3
Self-Test
- How would you like to find the derivative of the function sqrt(2^(x * log(x)))? Ummm... no thanks. Get Matlab to do it.
- Try differentiating this one: f(x) = (1 + log(x))/(2 - sin(x^2)).