clear all; close all

% Use Symbolic Variable
syms x; 

% Declare f(x)
f = x^2 + 2*x +1;

% Differentiate f(x)
df = diff(f);

% Gradiant at (x0,y0)
x0 = 1; y0= 5;

m = subs(df,x0);

%compute c (y-axis Intercept)
c = y0 - m*x0;

%Declare 
tan_eqn = m*x + c;


%Plot f(x) and tangent at (x0,y0)

ezplot(tan_eqn,[-50 50]);

hold on;

ezplot(f,[-50 50]);

plot(x0,y0,'o','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',10);

shg