You are a guest. Restricted access. Read more


diff(function,x) differentiates function with respect to the symbolic variable x. The main variable of function is used if x is not provided. Functions defined by user programs can often be handled as well.

syms a,x
y=diff(a*x^3,x); printf('%f',y)

You can easily plot the result of differentiation as:

syms x % symbolic x
y=diff(x*cos(x),x) %  differentiate x*cos(x)
plot2d('minx=0;maxx=10;miny=-1;maxy=10')  % make canvas
draw2d(y) % plot the result

as explained in the section plotting

Let us consider few more example skipping the print statement:

syms a,x
y=diff(a*x^3,a); printf('%f',y)

syms x
y=diff(3*sqrt(exp(x)+2),x); printf('%f',y)

syms x
y=diff(sin(x));  printf('%f',y)     % no variable specified

syms x
y=diff(sin(x),x);  printf('%f',y)   % more reasonable

syms x
function y=ttwo(x) y=2*x; end

jmathlab/calculus/differentiation.txt · Last modified: 2015/05/10 17:18 (external edit)
Back to top
CC Attribution-Share Alike 3.0 Unported = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0