close all
clear all
clc

x=0:0.01:pi/2;
f=x.^2;
g=atan(x);
Df=2*x;
Dg=1./(x.^2+1);

figure(1)
plot(x,Df,'--b',x,Dg,'--r','linewidth',2.0)
legend('Df','Dg')
grid on
cero=fzero(@(x)(1./(x.^2+1)-2*x),[0 pi/2])

figure(2)
rtf=(cero^2)+(2*cero).*(x-cero);
rtg=atan(cero)+(1/(cero^2+1)).*(x-cero);
plot(x,f,'b',x,g,'r',x,rtf,'--g',x,rtg,'--k','linewidth',2.0)
legend('f','g','recta tangente f','recta tangente g')
grid on

