Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
21
Task/Euler-method/ALGOL-W/euler-method.alg
Normal file
21
Task/Euler-method/ALGOL-W/euler-method.alg
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
begin % Euler's method %
|
||||
% Approximates y(t) in y'(t)=f(t,y) with y(a)=y0 and t=a..b and the step size h. %
|
||||
real procedure euler ( real procedure f; real value y0, a, b, h ) ;
|
||||
begin
|
||||
real y, t;
|
||||
y := y0;
|
||||
t := a;
|
||||
while t < b do begin
|
||||
write( r_format := "A", r_w := 8, r_d := 4, s_w := 0, t, ": ", y );
|
||||
y := y + ( h * f(t, y) );
|
||||
t := t + h
|
||||
end while_t_lt_b ;
|
||||
write( "done" );
|
||||
y
|
||||
end euler ;
|
||||
|
||||
% Example: Newton's cooling law %
|
||||
real procedure newtonCoolingLaw ( real value time, t ) ; -0.07 * (t - 20);
|
||||
|
||||
euler( newtonCoolingLaw, 100, 0, 100, 10 )
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue