Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
26
Task/Euler-method/Maple/euler-method-2.maple
Normal file
26
Task/Euler-method/Maple/euler-method-2.maple
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
f := y -> (-0.07) * (y - 20):
|
||||
|
||||
EulerMethod := proc(f, start_time, end_time, y0, h) # y0: initial value #h: step size
|
||||
local cur, y, rate:
|
||||
cur := start_time;
|
||||
y := y0;
|
||||
while cur <= end_time do
|
||||
printf("%g %g\n", cur, y);
|
||||
cur := cur + h;
|
||||
rate := f(y);
|
||||
y := y + h * rate;
|
||||
end do;
|
||||
return y;
|
||||
end proc:
|
||||
|
||||
# step size = 2
|
||||
printf("Step Size = %a\n", 2);
|
||||
EulerMethod(f, 0, 100, 100, 2);
|
||||
|
||||
# step size = 5
|
||||
printf("\nStep Size = %a\n", 5);
|
||||
EulerMethod(f, 0, 100, 100, 5);
|
||||
|
||||
# step size = 10
|
||||
printf("\nStep Size = %a\n", 10);
|
||||
EulerMethod(f, 0, 100, 100, 10);
|
||||
Loading…
Add table
Add a link
Reference in a new issue