%
%  Math 340 * Victor Matveev * April 20, 2012
%  See solution to homework #10 for details
%
%  dY
%  -- = cos(x)
%  dx
%

hold on;
set(gca,'fontsize',11);

y0 = 0.1;
xx = linspace(0,3.5,80);
yy = y0 + sin(xx);
plot(xx, yy, 'r-', 'linewidth', 3); % Plot exact solution

x = linspace(0,pi,10);
y = linspace(-pi,pi,10);
[X, Y] = meshgrid(x,y);
F = ones(size(X));
G = cos(X);
quiver(X, Y, F, G);   % Plot the direction field using "quiver"
axis tight;

legend('Solution', 'Direction field');
xlabel('x'); ylabel('Y(x)');
title('dY/dx = cos(x);  Y(0)=0.1');

