%%
%Differentiation
%%creating a symbolic expression
syms x 
f = cos(x^2);

%differentiation with respect to x
df_dx = diff(f)

%% 
%Evaluation 
%vpa - variable precision arithmetic
vpa(subs(df_dx,2.0),6)

%%
%higher derivatives
second_deriv = diff(f,2);

%%
%functions of several variables

syms s t

g = sin(s^2 + t^2);

%partial derivatives

diff(g,t)

diff(g,s)

%%
%Differentiating annoymus functions
clear
f1 = @(x)(sin(x^2));
syms x
df1 = diff(f1(x));
%df1 is unfortunately a symbolic function
%We can convert it to a function handle

df1 = matlabFunction(df1);
%and evaluate or pass to another function
df1(2)
%%
%Integration

clear
syms x

f = x/(1+x^2);

F  = int(f)

vpaintegral((exp(x^2)),x,0,1)
%
%%

