The idea of Euler method is to use an approximation yn stands for the real y(xn) and then use the inverse multiply a step to calculate the yn+1. When we use a small step ‘h’, we will gain a curve similar to the real line. For more accurate, we improve the Euler method and it let us calculate with less works.
We first use the Euler method to get a yn+1 in the Improved Euler method. Then we use another method to amend the yn+1 to let it more similar to the real yn+1.
We express this new Improved Euler method by these two formulas:
yn+1 = yn + hf (xn , yn )
yn+1 = yn + h*[f (xn , yn )+f (xn+1 , yn+1 )]/2
When use computer for calculation in some engineering field, you should show the relationship between ‘y’ and ‘x’. You need also give a ‘h’.
A example to use Improved Euler method for solving heat transfer problem:(Use Matlab)
Question: As the figure shows. T∞=1500℃,Tw=500 ℃, T0=20℃, a thermocouple which diameter is 1mm exposed in the air. The surface coefficient of heat transfer h=200W(m2/K),ε=0.2. Thermocouple oxidation will create energy at a rate of q=1000W/m3. Determine the relation ship between temperature of thermocouple and time. [additional properties of thermocouple:ρ=8000kg/m3,c=0.38kJ/(kg*K),λ=50W/(m*K)]
Answer: We use Improved Euler Question to solve this problem. www.zhangpeng.info
The source code in Matlab here:
function [x,y]=eulerg(x,y,h,N)
x=zeros(1,N+1);
y=zeros(1,N+1);
x(1)=0;
y(1)=293;
for n=1:N
x(n+1)=x(n)+h;
ybar=y(n)+h*dyfun(x(n),y(n));
y(n+1)=y(n)+(h/2)*(dyfun(x(n),y(n))+dyfun(x(n),ybar));
end
plot(x,y,'red');
function m=dyfun(x,y)
m=1/304+75/19*(1773-y)+(6.804e-8)/304*(1773^4-y^4);
To create a new file in Matlab writing these codes and save it. Input some properties, for example eulerg(0,293,0.001,1000), and you will gain the relationship line between ‘y’ and ‘x’.
You can transfer this example in any other similar work process by just change some part of this example function. I’m glad to discuss with you if you have any questions.