clear all
close all
clc

x = linspace(0,pi/2);

h = @(x) 2*x-1./(1+x.^2);

plot(x,h(x),'b', x, zeros(size(x)),'k')
xa = fzero(h, 0.4);
fa = 2*xa;

f = @(x) x.^2;
g = @(x) atan(x);

plot(x,f(x),'r')
hold on
plot(x,g(x),'g')
plot(x, fa*(x-xa)+f(xa),'b')
plot(x, fa*(x-xa)+g(xa),'m')
grid on

%% Preg 2
clear all
close all
clc

m = 75;
g = 9.8;
b = 16;

dy = @(t,y) [y(2);g-b/m*y(2)];
[t,y] = ode45(dy, [0 15], [0 0]);
figure(1)
plot(t,y(:,1),'r')
title('posicion')
grid on
figure(2)
plot(t,y(:,2),'b')
title('velocidad')
grid on

h15seg = y(end,1)
v15seg = y(end,2)






