JMathLabTutorial:Differentiation

From jWork.ORG
Revision as of 20:17, 27 December 2016 by Jworkorg (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Limitted access. Reguest membership or login to this link first if you are already a member
Contents


Differentiation

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

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
y=diff(ttwo(sin(x)),x)
printf('%f',y)