%% Differentiation

syms x
f(x) = x^2*cos(x)/(1+x^2);
g(x) = exp(-3*x);
dfg(x) = diff(f(x)*g(x),x)
simplify(dfg(x))
d2f(x) = simplify(diff(f(x),x,2))

%
%% Integration

f(x) = x^2*exp(-3*x);
F(x) = int(f(x),x)

%
%% Integration with limits

f(x) = x^3/sqrt(9-x^2);
g(x) = exp(cos(x));
fA = int(f(x),x,0,2)
gA = int(g(x),x,-1,4)
gAn = vpa(gA,8)

%
%% Taylor series

f(x) = log(4+x);
g(x) = sin(x)/x;
fT1(x) = taylor(f(x),x,1)
fT2(x) = taylor(f(x),x,-3,'Order',10)
g4(x) = taylor(g(x),x,0,'Order',4);
g6(x) = taylor(g(x),x,0,'Order',6);
g8(x) = taylor(g(x),x,0,'Order',8);
fplot(g(x),'b-','LineWidth',2)
hold on
fplot(g4(x),'b-')
hold on
fplot(g6(x),'r--')
hold on
fplot(g8(x),'ko')
hold off
xlim([-4 4])
%fplot([g(x) g4(x) g6(x) g8(x)])