function [ output_args ] = Untitled1( input_args )
%UNTITLED1 Summary of this function goes here
% Detailed explanation goes here
clc;
clear;
h=0.1;
a=0;
b=1;
ya=1;
N=(b-a)/h;
T=linspace(a,b,N+1);
Y=zeros(1,N+1);
Y(1)=ya;
%Euler法
for j=1:N
Y(j+1)=Y(j)+h*(Y(j)-T(j)*Y(j)^2);
end
plot(T,Y,'g');grid on;
hold on;
%Euler改进法
for j=1:N
Y(j+1)=Y(j)+(h/2)*(Y(j)-T(j)*Y(j)^2+ (Y(j)+h*(Y(j)-T(j)*Y(j)^2))-T(j+1)*(Y(j)+h*(Y(j)-T(j)*Y(j)^2))^2 );
end
plot(T,Y,'r');
hold on;
%精确解
Y=1./(T-1+2*exp(-T));
plot(T,Y);
xlabel('x');
ylabel('f(x)');
title('Euler(绿色)、Euler改进法(红色)及精确解(蓝色)的比较');