f=inline('x.^2');
g=inline('atan(x)');
fp=inline('2*x');
gp=inline('1./(1+x.^2)');
fp_gp=inline('2*x-(1./(1+x.^2))');
xx=linspace(0,pi/2);
y=feval(fp_gp,xx);
plot(xx,y)
grid
x_ast=fzero(fp_gp,0.4);
r1=fp(x_ast)*(xx-x_ast)+f(x_ast);
r2=gp(x_ast)*(xx-x_ast)+g(x_ast);
plot(xx,feval(f,xx),xx,feval(g,xx),xx,r1,xx,r2)