function plot_runge(c,n,plot_f,linespec)
%Plots the Runge function (if plot_f is true) and the polynomial 
%approximation with coefficients c and degree n
%(with the given line specifier linespec)
%e.g. plot_runge(c,n,true,'r')

  a = -5;
  b = 5;

  fine = 500;
  x_fine = linspace(a, b, fine)';

  % Plot the exact solution
  if (plot_f)
    f = @(x)(1./(1. + x.^2));
    plot(x_fine,f(x_fine),'k');
    hold on;
  end
  
  % Compute the approximation
  p_n = zeros(fine,1);
  for i=1:(n+1)
    p_n = p_n + c(i)*x_fine.^(i-1);
  end
 
  % Plot the approximation
  plot(x_fine,p_n,linespec);