Search code examples
matlabdiffsymbolic-math

Differentiate function without Symbolic Math Toolbox


If I want to differentiate a function, I would do the following:

syms x
f(x) = sin(x^2);
df = diff(f)

,but that requires the use of the Symbolic Math Toolbox (for the syms function). Is there a workaround (an alternative) to this method without the use of the Symbolic Toolbox?


Solution

  • If you have a numerical vector and you'd like to differentiate it, then the gradient function is your friend.

    If you want to differentiate a symbolic expressing then the Symbolic Math Toolbox is the only way to go within Matlab. If pen&paper together with wolframalpha.com does not serve you, there is no way around to buy the toolbox or use alternatives like Wolframs Mathematica, Maple, Maxima, Sympy, Sage etc..