y=a^x
take natural logs (also written as ln or log base e) of both sides
lny=lna^x
by logarithms rules lna^x=xlna
lny=xlna
Now differentiate implicitly
1/y = (dx/dy)lna
Note here lna is just a constant, then rearranging we have
dy/dx = ylna
and since y=a^x
dy/dx = a^x(lna)