## Find the polynomial approximation to the exponential to an arbitrary order.
## Visualize and quantify how fast the expansion converges to the real function
## Usage : ex=exponential(N,x)

function ex=exponential(N,x)

  ex=ones(size(x));
  
  for n=1:N
    ex+=x.^n/prod([1:n]);
    plot(x,exp(x),';Exact exponential;',x,ex,';Taylor expansion;')

    ## Output a measure of error to quantify how with every order the error decreases.
    err=sum((exp(x)-ex)./exp(x))/length(x)
    
    ## Wait for user to hit any key on the keyboard
    pause
  endfor

endfunction
