update meta data

This commit is contained in:
Ingy döt Net 2013-04-11 12:07:39 -07:00
parent f3a896c724
commit 90e15ed6ce
3307 changed files with 1674 additions and 7 deletions

View file

@ -0,0 +1,50 @@
Euler's method numerically approximates solutions of first-order ordinary differential equations (ODEs) with a given initial value. It is an explicit method for solving initial value problems (IVPs), as described in [[wp:Euler method|the wikipedia page]].
The ODE has to be provided in the following form:
:<math>\frac{dy(t)}{dt} = f(t,y(t))</math>
with an initial value
:<math>y(t_0) = y_0</math>
To get a numeric solution, we replace the derivative on the LHS with a finite difference approximation:
:<math>\frac{dy(t)}{dt} \approx \frac{y(t+h)-y(t)}{h}</math>
then solve for <math>y(t+h)</math>:
:<math>y(t+h) \approx y(t) + h \, \frac{dy(t)}{dt}</math>
which is the same as
:<math>y(t+h) \approx y(t) + h \, f(t,y(t))</math>
The iterative solution rule is then:
:<math>y_{n+1} = y_n + h \, f(t_n, y_n)</math>
<math>h</math> is the step size, the most relevant parameter for accuracy of the solution. A smaller step size increases accuracy but also the computation cost, so it has always has to be hand-picked according to the problem at hand.
'''Example: Newton's Cooling Law'''
Newton's cooling law describes how an object of initial temperature <math>T(t_0) = T_0</math> cools down in an environment of temperature <math>T_R </math>:
:<math>\frac{dT(t)}{dt} = -k \, \Delta T</math>
or
:<math>\frac{dT(t)}{dt} = -k \, (T(t) - T_R)</math>
It says that the cooling rate <math>\frac{dT(t)}{dt}</math> of the object is proportional to the current temperature difference <math>\Delta T = (T(t) - T_R)</math> to the surrounding environment.
The analytical solution, which we will compare to the numerical approximation, is
:<math>T(t) = T_R + (T_0 - T_R) \; e^{-k t}</math>
'''Task'''
The task is to implement a routine of Euler's method and then to use it to solve the given example of Newton's cooling law with it for three different step sizes of 2 s, 5 s and 10 s and to compare with the analytical solution.
The initial temperature <math>T_0</math> shall be 100 °C, the room temperature <math>T_R</math> 20 °C, and the cooling constant <math>k</math> 0.07. The time interval to calculate shall be from 0 s to 100 s.
A reference solution ([[#Common Lisp|Common Lisp]]) can be seen below. We see that bigger step sizes lead to reduced approximation accuracy.
[[Image:Euler_Method_Newton_Cooling.png|center|750px]]