(*Video 1: Velocity *)

x[t_]:=t^3-4t^2+2 
(* Physical interpretation;
x[t] = position at time t,
x'[t] = velocity at time t,
x''[t] = acceleration at time t *)
Plot[{x[t],x'[t],x''[t]},{t,0,5}]
(*units: x = meters; t = second; x/t = x'[t] = meters/second,  x''[t] = meters/second^2.
*)

(*Auxiliary function to plot motion*)
plot1dmotion[x_]:={Blue,PointSize[0.02],Point[{x,0}]};

Manipulate[Graphics[plot1dmotion[x[t]],Axes->{True,False},PlotRange->{{-10,10},{0,1}}],{t,0,5},Dynamic[{"x[t]=",x[t]}],Dynamic[{"x'[t]=",x'[t]}]]

(*Average velocity from t0 to t1: ratio between displacement in x, and in t*)
(x[t1]-x[t0])/(t1-t0)

(* (Instantaneous) velocity: limit of the above as t1-->t0: x'[t0] = dx/dt [t0]*)

Limit[(x[t1]-x[t0])/(t1-t0),t1->t0]

x'[t](*Velocity at time t*)

Solve[-8 t+3 (t^2)==0,t](*When does the particle change direction? At time t=8/3 s.*)

(*Acceleration: x''[t]*)

x''[t]

(*Video 2: Product and Quotient rules *)

(*Product Rule*)
TraditionalForm[HoldForm[(f[x]g[x])']==Simplify[D[f[x]g[x],x]]]

(*Quotient Rule*)
TraditionalForm[HoldForm[(f[x]/g[x])']==Simplify[D[f[x]/g[x],x]]]

(*Example*)
f[x_]:=x^4+3x^2+1
g[x_]:=x^3-x+3

f'[x]
g'[x]

f[x]g[x]
Expand[f[x]g[x]]

D[f[x]g[x],x](*using the product rule*)
D[3-x+9 (x^2)-2 (x^3)+3 (x^4)+2 (x^5)+(x^7),x](*expanding the product of polynomials*)

Expand[(3-x+(x^3)) (6 x+4 (x^3))+(-1+3 (x^2)) (1+3 (x^2)+(x^4))](*It matches!*)

Simplify[D[f[x]/g[x],x]]

Simplify[f'[x]g[x]-f[x]g'[x]]

(*Note: quotient rule is a particular case of the product rule!*)

f[x]/g[x]==f[x](1/g[x])

(*We need the following fact, which follows from the Chain rule -- to be seen next class
*)

D[1/(g[x]),x]

(*Applying product rule to f[x](1/g[x]) we then recover the quotient rule:*)
Simplify[f'[x](1/g[x])+f[x]D[1/(g[x]),x]]

Simplify[D[f[x]/g[x],x]]