Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
38
Task/Euler-method/XPL0/euler-method.xpl0
Normal file
38
Task/Euler-method/XPL0/euler-method.xpl0
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
include c:\cxpl\codes; \intrinsic 'code' declarations
|
||||
|
||||
proc Euler(Step); \Display cooling temperatures using Euler's method
|
||||
int Step;
|
||||
int Time; real Temp;
|
||||
[Text(0, "Step "); IntOut(0, Step); Text(0, " ");
|
||||
Time:= 0; Temp:= 100.0;
|
||||
repeat if rem(Time/10) = 0 then RlOut(0, Temp);
|
||||
Temp:= Temp + float(Step) * (-0.07*(Temp-20.0));
|
||||
Time:= Time + Step;
|
||||
until Time > 100;
|
||||
CrLf(0);
|
||||
];
|
||||
|
||||
real Time, Temp;
|
||||
[Format(6,0); \display time heading
|
||||
Text(0, "Time ");
|
||||
Time:= 0.0;
|
||||
while Time <= 100.1 do \(.1 avoids possible rounding error)
|
||||
[RlOut(0, Time);
|
||||
Time:= Time + 10.0;
|
||||
];
|
||||
CrLf(0);
|
||||
|
||||
Format(3,2); \display cooling temps using differential eqn.
|
||||
Text(0, "Dif eq "); \ dTemp(time)/dtime = -k*<2A>Temp
|
||||
Time:= 0.0;
|
||||
while Time <= 100.1 do
|
||||
[Temp:= 20.0 + (100.0-20.0) * Exp(-0.07*Time);
|
||||
RlOut(0, Temp);
|
||||
Time:= Time + 10.0;
|
||||
];
|
||||
CrLf(0);
|
||||
|
||||
Euler(2); \display cooling temps for various time steps
|
||||
Euler(5);
|
||||
Euler(10);
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue