Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,11 +0,0 @@
generic
type Number is digits <>;
package Euler is
type Waveform is array (Integer range <>) of Number;
function Solve
( F : not null access function (T, Y : Number) return Number;
Y0 : Number;
T0, T1 : Number;
N : Positive
) return Waveform;
end Euler;

View file

@ -1,17 +0,0 @@
package body Euler is
function Solve
( F : not null access function (T, Y : Number) return Number;
Y0 : Number;
T0, T1 : Number;
N : Positive
) return Waveform is
dT : constant Number := (T1 - T0) / Number (N);
begin
return Y : Waveform (0..N) do
Y (0) := Y0;
for I in 1..Y'Last loop
Y (I) := Y (I - 1) + dT * F (T0 + dT * Number (I - 1), Y (I - 1));
end loop;
end return;
end Solve;
end Euler;

View file

@ -1,18 +0,0 @@
with Ada.Text_IO; use Ada.Text_IO;
with Euler;
procedure Test_Euler_Method is
package Float_Euler is new Euler (Float);
use Float_Euler;
function Newton_Cooling_Law (T, Y : Float) return Float is
begin
return -0.07 * (Y - 20.0);
end Newton_Cooling_Law;
Y : Waveform := Solve (Newton_Cooling_Law'Access, 100.0, 0.0, 100.0, 10);
begin
for I in Y'Range loop
Put_Line (Integer'Image (10 * I) & ":" & Float'Image (Y (I)));
end loop;
end Test_Euler_Method;

View file

@ -1,17 +1,17 @@
print "Time ";
tiempo = 0.0
while tiempo <= 100.1
print rjust(string(tiempo), 5); " ";
tiempo += 10.0
print rjust(string(tiempo), 5); " ";
tiempo += 10.0
end while
print
print "Dif eq ";
tiempo = 0.0
while tiempo <= 100.1
temperatura = 20.0 + (100.0-20.0) * exp(-0.07*tiempo)
print rjust(left(string(temperatura), 5), 5); " ";
tiempo += 10.0
temperatura = 20.0 + (100.0-20.0) * exp(-0.07*tiempo)
print rjust(left(string(temperatura), 5), 5); " ";
tiempo += 10.0
end while
print
@ -21,14 +21,14 @@ call Euler(10)
end
subroutine Euler(paso)
tiempo = 0
temperatura = 100.0
print "Step "; rjust(string(paso), 2); " ";
tiempo = 0
temperatura = 100.0
print "Step "; rjust(string(paso), 2); " ";
while tiempo <= 100
if (tiempo mod 10) = 0 then print rjust(left(string(temperatura), 5), 5); " ";
temperatura += float(paso) * (-0.07*(temperatura-20.0))
tiempo += paso
end while
print
while tiempo <= 100
if (tiempo mod 10) = 0 then print rjust(left(string(temperatura), 5), 5); " ";
temperatura += float(paso) * (-0.07*(temperatura-20.0))
tiempo += paso
end while
print
end subroutine

View file

@ -2,37 +2,37 @@ using System;
namespace prog
{
class MainClass
{
const float T0 = 100f;
const float TR = 20f;
const float k = 0.07f;
readonly static float[] delta_t = {2.0f,5.0f,10.0f};
const int n = 100;
public delegate float func(float t);
static float NewtonCooling(float t)
{
return -k * (t-TR);
}
public static void Main (string[] args)
{
func f = new func(NewtonCooling);
for(int i=0; i<delta_t.Length; i++)
{
Console.WriteLine("delta_t = " + delta_t[i]);
Euler(f,T0,n,delta_t[i]);
}
}
public static void Euler(func f, float y, int n, float h)
{
for(float x=0; x<=n; x+=h)
{
Console.WriteLine("\t" + x + "\t" + y);
y += h * f(y);
}
}
}
class MainClass
{
const float T0 = 100f;
const float TR = 20f;
const float k = 0.07f;
readonly static float[] delta_t = {2.0f,5.0f,10.0f};
const int n = 100;
public delegate float func(float t);
static float NewtonCooling(float t)
{
return -k * (t-TR);
}
public static void Main (string[] args)
{
func f = new func(NewtonCooling);
for(int i=0; i<delta_t.Length; i++)
{
Console.WriteLine("delta_t = " + delta_t[i]);
Euler(f,T0,n,delta_t[i]);
}
}
public static void Euler(func f, float y, int n, float h)
{
for(float x=0; x<=n; x+=h)
{
Console.WriteLine("\t" + x + "\t" + y);
y += h * f(y);
}
}
}
}

View file

@ -6,39 +6,39 @@ typedef double (*deriv_f)(double, double);
void ivp_euler(deriv_f f, double y, int step, int end_t)
{
int t = 0;
int t = 0;
printf(" Step %2d: ", (int)step);
do {
if (t % 10 == 0) printf(FMT, y);
y += step * f(t, y);
} while ((t += step) <= end_t);
printf("\n");
printf(" Step %2d: ", (int)step);
do {
if (t % 10 == 0) printf(FMT, y);
y += step * f(t, y);
} while ((t += step) <= end_t);
printf("\n");
}
void analytic()
{
double t;
printf(" Time: ");
for (t = 0; t <= 100; t += 10) printf(" %7g", t);
printf("\nAnalytic: ");
double t;
printf(" Time: ");
for (t = 0; t <= 100; t += 10) printf(" %7g", t);
printf("\nAnalytic: ");
for (t = 0; t <= 100; t += 10)
printf(FMT, 20 + 80 * exp(-0.07 * t));
printf("\n");
for (t = 0; t <= 100; t += 10)
printf(FMT, 20 + 80 * exp(-0.07 * t));
printf("\n");
}
double cooling(double t, double temp)
{
return -0.07 * (temp - 20);
return -0.07 * (temp - 20);
}
int main()
{
analytic();
ivp_euler(cooling, 100, 2, 100);
ivp_euler(cooling, 100, 5, 100);
ivp_euler(cooling, 100, 10, 100);
analytic();
ivp_euler(cooling, 100, 2, 100);
ivp_euler(cooling, 100, 5, 100);
ivp_euler(cooling, 100, 10, 100);
return 0;
return 0;
}

View file

@ -1,45 +0,0 @@
DELEGATE-ID func.
PROCEDURE DIVISION USING VALUE t AS FLOAT-LONG
RETURNING ret AS FLOAT-LONG.
END DELEGATE.
CLASS-ID. MainClass.
78 T0 VALUE 100.0.
78 TR VALUE 20.0.
78 k VALUE 0.07.
01 delta-t INITIALIZE ONLY STATIC
FLOAT-LONG OCCURS 3 VALUES 2.0, 5.0, 10.0.
78 n VALUE 100.
METHOD-ID NewtonCooling STATIC.
PROCEDURE DIVISION USING VALUE t AS FLOAT-LONG
RETURNING ret AS FLOAT-LONG.
COMPUTE ret = - k * (t - TR)
END METHOD.
METHOD-ID Main STATIC.
DECLARE f AS TYPE func
SET f TO METHOD self::NewtonCooling
DECLARE delta-t-len AS BINARY-LONG
MOVE delta-t::Length TO delta-t-len
PERFORM VARYING i AS BINARY-LONG FROM 1 BY 1
UNTIL i > delta-t-len
DECLARE elt AS FLOAT-LONG = delta-t (i)
INVOKE TYPE Console::WriteLine("delta-t = {0:F4}", elt)
INVOKE self::Euler(f, T0, n, elt)
END-PERFORM
END METHOD.
METHOD-ID Euler STATIC.
PROCEDURE DIVISION USING VALUE f AS TYPE func, y AS FLOAT-LONG,
n AS BINARY-LONG, h AS FLOAT-LONG.
PERFORM VARYING x AS BINARY-LONG FROM 0 BY h UNTIL x >= n
INVOKE TYPE Console::WriteLine("x = {0:F4}, y = {1:F4}", x, y)
COMPUTE y = y + h * RUN f(y)
END-PERFORM
END METHOD.
END CLASS.

View file

@ -13,36 +13,36 @@ end
sub euler
cls
cursor 1, 1
wait
print "step: ", s
cls
cursor 1, 1
wait
print "step: ", s
let b = 100
let y = 100
let b = 100
let y = 100
for t = 0 to b step s
for t = 0 to b step s
print t, " : ", y
print t, " : ", y
let y = y + s * (-0.07 * (y - 20))
let y = y + s * (-0.07 * (y - 20))
gosub delay
gosub delay
next t
next t
alert "step ", s, " finished"
alert "step ", s, " finished"
return
sub delay
let w = clock
let w = clock
do
do
wait
wait
loop clock < w + 200
loop clock < w + 200
return

View file

@ -2,37 +2,37 @@
-export([main/0, euler/5]).
cooling(_Time, Temperature) ->
(-0.07)*(Temperature-20).
(-0.07)*(Temperature-20).
euler(_, Y, T, _, End) when End == T ->
io:fwrite("\n"),
Y;
io:fwrite("\n"),
Y;
euler(Func, Y, T, Step, End) ->
if
T rem 10 == 0 ->
io:fwrite("~.3f ",[float(Y)]);
true ->
ok
end,
euler(Func, Y + Step * Func(T, Y), T + Step, Step, End).
if
T rem 10 == 0 ->
io:fwrite("~.3f ",[float(Y)]);
true ->
ok
end,
euler(Func, Y + Step * Func(T, Y), T + Step, Step, End).
analytic(T, End) when T == End ->
io:fwrite("\n"),
T;
io:fwrite("\n"),
T;
analytic(T, End) ->
Y = (20 + 80 * math:exp(-0.07 * T)),
io:fwrite("~.3f ", [Y]),
analytic(T+10, End).
Y = (20 + 80 * math:exp(-0.07 * T)),
io:fwrite("~.3f ", [Y]),
analytic(T+10, End).
main() ->
io:fwrite("Analytic:\n"),
analytic(0, 100),
io:fwrite("Step 2:\n"),
euler(fun cooling/2, 100, 0, 2, 100),
io:fwrite("Step 5:\n"),
euler(fun cooling/2, 100, 0, 5, 100),
io:fwrite("Step 10:\n"),
euler(fun cooling/2, 100, 0, 10, 100),
ok.
io:fwrite("Analytic:\n"),
analytic(0, 100),
io:fwrite("Step 2:\n"),
euler(fun cooling/2, 100, 0, 2, 100),
io:fwrite("Step 5:\n"),
euler(fun cooling/2, 100, 0, 5, 100),
io:fwrite("Step 10:\n"),
euler(fun cooling/2, 100, 0, 10, 100),
ok.

View file

@ -1,29 +1,29 @@
// Function that takes differential-equation, initial condition,
// ending x, and step size as parameters
function eulersMethod(f, x1, y1, x2, h) {
// Header
console.log("\tX\t|\tY\t");
console.log("------------------------------------");
// Header
console.log("\tX\t|\tY\t");
console.log("------------------------------------");
// Initial Variables
var x=x1, y=y1;
// Initial Variables
var x=x1, y=y1;
// While we're not done yet
// Both sides of the OR let you do Euler's Method backwards
while ((x<x2 && x1<x2) || (x>x2 && x1>x2)) {
// Print what we have
console.log("\t" + x + "\t|\t" + y);
// While we're not done yet
// Both sides of the OR let you do Euler's Method backwards
while ((x<x2 && x1<x2) || (x>x2 && x1>x2)) {
// Print what we have
console.log("\t" + x + "\t|\t" + y);
// Calculate the next values
y += h*f(x, y)
x += h;
}
// Calculate the next values
y += h*f(x, y)
x += h;
}
return y;
return y;
}
function cooling(x, y) {
return -0.07 * (y-20);
return -0.07 * (y-20);
}
eulersMethod(cooling, 0, 100, 100, 10);

View file

@ -7,7 +7,7 @@ def euler_method(df; x1; y1; x2; h):
| [x1, y1]
| recurse( if ((.[0] < x2 and x1 < x2) or
(.[0] > x2 and x1 > x2)) then
[ (.[0] + $h), (.[1] + $h*df) ]
[ (.[0] + $h), (.[1] + $h*df) ]
else empty
end )
| .[1] ;

View file

@ -4,7 +4,7 @@ def euler_solution(df; x1; y1; x2; h):
| [x1, y1]
| recursion( if ((.[0] < x2 and x1 < x2) or
(.[0] > x2 and x1 > x2)) then
[ (.[0] + $h), (.[1] + $h*df) ]
[ (.[0] + $h), (.[1] + $h*df) ]
else empty
end )
| .[1] ;

View file

@ -14,14 +14,14 @@
{eulersMethod cooling 100 0 100 10}
->
0 100
10 44
20 27.2
30 22.16
40 20.648
50 20.194
60 20.058
70 20.017
80 20.005
90 20.002
100 20
0 100
10 44
20 27.2
30 22.16
40 20.648
50 20.194
60 20.058
70 20.017
80 20.005
90 20.002
100 20

View file

@ -10,8 +10,8 @@ NewtonCooling = function( t ) return -k * ( t - TR ) end
function Euler( f, y0, n, h )
local y = y0
for x = 0, n, h do
print( "", x, y )
y = y + h * f( y )
print( "", x, y )
y = y + h * f( y )
end
end

View file

@ -1,16 +1,16 @@
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;
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

View file

@ -26,11 +26,11 @@ analytic :: proc(){
main :: proc() {
fmt.println("Step: 2 Seconds")
ivp_euler(100.0, 2,100)
ivp_euler(100.0, 2,100)
fmt.println("Step: 5 Seconds")
ivp_euler(100.0, 5, 100)
fmt.println("Step: 10 Seconds")
ivp_euler(100.0, 10, 100)
ivp_euler(100.0, 10, 100)
fmt.println("Analytic")
analytic()
}

View file

@ -3,47 +3,47 @@ PROGRAM Euler;
TYPE TNewtonCooling = FUNCTION (t: REAL) : REAL;
CONST T0 : REAL = 100.0;
CONST TR : REAL = 20.0;
CONST k : REAL = 0.07;
CONST time : INTEGER = 100;
CONST step : INTEGER = 10;
CONST dt : ARRAY[0..3] of REAL = (1.0,2.0,5.0,10.0);
CONST T0 : REAL = 100.0;
CONST TR : REAL = 20.0;
CONST k : REAL = 0.07;
CONST time : INTEGER = 100;
CONST step : INTEGER = 10;
CONST dt : ARRAY[0..3] of REAL = (1.0,2.0,5.0,10.0);
VAR i : INTEGER;
VAR i : INTEGER;
FUNCTION NewtonCooling(t: REAL) : REAL;
BEGIN
NewtonCooling := -k * (t-TR);
END;
BEGIN
NewtonCooling := -k * (t-TR);
END;
PROCEDURE Euler(F: TNewtonCooling; y, h : REAL; n: INTEGER);
VAR i: INTEGER = 0;
BEGIN
WRITE('dt=',trunc(h):2,':');
REPEAT
IF (i mod 10 = 0) THEN WRITE(' ',y:2:3);
INC(i,trunc(h));
y := y + h * F(y);
UNTIL (i >= n);
WRITELN;
END;
VAR i: INTEGER = 0;
BEGIN
WRITE('dt=',trunc(h):2,':');
REPEAT
IF (i mod 10 = 0) THEN WRITE(' ',y:2:3);
INC(i,trunc(h));
y := y + h * F(y);
UNTIL (i >= n);
WRITELN;
END;
PROCEDURE Sigma;
VAR t: INTEGER = 0;
BEGIN
WRITE('Sigma:');
REPEAT
WRITE(' ',(20 + 80 * exp(-0.07 * t)):2:3);
INC(t,step);
UNTIL (t>=time);
WRITELN;
END;
VAR t: INTEGER = 0;
BEGIN
WRITE('Sigma:');
REPEAT
WRITE(' ',(20 + 80 * exp(-0.07 * t)):2:3);
INC(t,step);
UNTIL (t>=time);
WRITELN;
END;
BEGIN
WRITELN('Newton cooling function: Analytic solution (Sigma) with 3 Euler approximations.');
WRITELN('Time: ',0:7,10:7,20:7,30:7,40:7,50:7,60:7,70:7,80:7,90:7);
Sigma;
FOR i := 1 to 3 DO
Euler(NewtonCooling,T0,dt[i],time);
WRITELN('Newton cooling function: Analytic solution (Sigma) with 3 Euler approximations.');
WRITELN('Time: ',0:7,10:7,20:7,30:7,40:7,50:7,60:7,70:7,80:7,90:7);
Sigma;
FOR i := 1 to 3 DO
Euler(NewtonCooling,T0,dt[i],time);
END.

View file

@ -1,43 +0,0 @@
function euler (${f}, ${y}, $y0, $t0, $tEnd) {
function f-euler ($tn, $yn, $h) {
$yn + $h*(f $tn $yn)
}
function time ($t0, $h, $tEnd) {
$end = [MATH]::Floor(($tEnd - $t0)/$h)
foreach ($_ in 0..$end) { $_*$h + $t0 }
}
$time = time $t0 10 $tEnd
$time5 = time $t0 5 $tEnd
$time2 = time $t0 2 $tEnd
$yn10 = $yn5 = $yn2 = $y0
$i2 = $i5 = 0
foreach ($tn10 in $time) {
while($time2[$i2] -ne $tn10) {
$i2++
$yn2 = (f-euler $time2[$i2] $yn2 2)
}
while($time5[$i5] -ne $tn10) {
$i5++
$yn5 = (f-euler $time5[$i5] $yn5 5)
}
[pscustomobject]@{
t = "$tn10"
Analytical = "$("{0:N5}" -f (y $tn10))"
"Euler h = 2" = "$("{0:N5}" -f $yn2)"
"Euler h = 5" = "$("{0:N5}" -f $yn5)"
"Euler h = 10" = "$("{0:N5}" -f $yn10)"
"Error h = 2" = "$("{0:N5}" -f [MATH]::abs($yn2 - (y $tn10)))"
"Error h = 5" = "$("{0:N5}" -f [MATH]::abs($yn5 - (y $tn10)))"
"Error h = 10" = "$("{0:N5}" -f [MATH]::abs($yn10 - (y $tn10)))"
}
$yn10 = (f-euler $tn10 $yn10 10)
}
}
$k, $yr, $y0, $t0, $tEnd = 0.07, 20, 100, 0, 100
function f ($t, $y) {
-$k *($y - $yr)
}
function y ($t) {
$yr + ($y0 - $yr)*[MATH]::Exp(-$k*$t)
}
euler f y $y0 $t0 $tEnd | Format-Table -AutoSize

View file

@ -1,11 +1,11 @@
def euler(f,y0,a,b,h):
t,y = a,y0
while t <= b:
print "%6.3f %6.3f" % (t,y)
t += h
y += h * f(t,y)
t,y = a,y0
while t <= b:
print "%6.3f %6.3f" % (t,y)
t += h
y += h * f(t,y)
def newtoncooling(time, temp):
return -0.07 * (temp - 20)
return -0.07 * (temp - 20)
euler(newtoncooling,100,0,100,10)

View file

@ -1,25 +1,49 @@
/*REXX pgm solves example of Newton's cooling law via Euler's method (diff. step sizes).*/
e=2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138
numeric digits length(e) - length(.) /*use the number of decimal digits in E*/
parse arg Ti Tr cc tt ss /*obtain optional arguments from the CL*/
if Ti='' | Ti="," then Ti= 100 /*given? Default: initial temp in ºC.*/
if Tr='' | Tr="," then Tr= 20 /* " " room " " " */
if cc='' | cc="," then cc= 0.07 /* " " cooling constant. */
if tt='' | tt="," then tt= 100 /* " " total time seconds. */
if ss='' | ss="," then ss= 2 5 10 /* " " the step sizes. */
@= '' /*the character used in title separator*/
do sSize=1 for words(ss); say; say; say center('time in' , 11)
say center('seconds' , 11, @) center('Euler method', 16, @) ,
center('analytic', 18, @) center('difference' , 14, @)
$=Ti; inc= word(ss, sSize) /*the 1st value; obtain the increment.*/
do t=0 to Ti by inc /*step through calculations by the inc.*/
a= format(Tr + (Ti-Tr)/exp(cc*t),6,10) /*calculate the analytic (exact) value.*/
say center(t,11) format($,6,3) 'ºC ' a "ºC" format(abs(a-$)/a*100,6,2) '%'
$= $ + inc * cc * (Tr-$) /*calc. next value via Euler's method. */
end /*t*/
end /*sSize*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
exp: procedure expose e; arg x; ix= x%1; if abs(x-ix)>.5 then ix=ix+sign(x); x= x-ix; z=1
_=1; w=1; do j=1; _= _*x/j; z= (z+_)/1; if z==w then leave; w=z
end /*j*/; if z\==0 then z= e**ix * z; return z
-- 18 Sep 2025
include Setting
say "EULER METHOD FOR ODE y'=-0.07(y-20)"
say version
say
call Task 0,100,2,100
call Task 0,100,5,100
call Task 0,100,10,100
call Timer
exit
Task:
-- Euler method
procedure expose Memo.
arg x0,xn,dx,y0
say 'From' x0 'to' xn 'step' dx
say ' x Calc y True y Abs error Rel error'
x=x0; y=y0
do until x > xn
if x//10 = 0 then
call Show x,y
y+=dx*Dy(y); x+=dx
end
say
return
Show:
-- Display a line
procedure expose Memo.
arg xx,yy
yt=True(xx)
say Format(xx,3,0) Format(yy,3,7) Format(yt,3,7),
Left(Std(Abs(yy-yt)),9) Left(Std(Abs(yy/yt-1)),9)
return
Dy:
-- Differential equation
procedure
arg yy
return -0.07*(yy-20)
True:
-- Real solution
procedure expose Memo.
arg xx
return 20+(100-20)*Exp(-0.07*xx)
include Math

View file

@ -6,20 +6,20 @@ TR := 20.0;
k := 0.07;
main(args(2)) :=
let
results[i] := euler(newtonCooling, T0, 100, stringToInt(args[i]), 0, "delta_t = " ++ args[i]);
in
delimit(results, '\n');
let
results[i] := euler(newtonCooling, T0, 100, stringToInt(args[i]), 0, "delta_t = " ++ args[i]);
in
delimit(results, '\n');
newtonCooling(t) := -k * (t - TR);
euler: (float -> float) * float * int * int * int * char(1) -> char(1);
euler(f, y, n, h, x, output(1)) :=
let
newOutput := output ++ "\n\t" ++ intToString(x) ++ "\t" ++ floatToString(y, 3);
newY := y + h * f(y);
newX := x + h;
in
output when x > n
else
euler(f, newY, n, h, newX, newOutput);
let
newOutput := output ++ "\n\t" ++ intToString(x) ++ "\t" ++ floatToString(y, 3);
newY := y + h * f(y);
newX := x + h;
in
output when x > n
else
euler(f, newY, n, h, newX, newOutput);

View file

@ -1,13 +1,13 @@
ODESolver>>eulerOf: f init: y0 from: a to: b step: h
| t y |
t := a.
y := y0.
[ t < b ]
whileTrue: [
Transcript
show: t asString, ' ' , (y printShowingDecimalPlaces: 3);
cr.
t := t + h.
y := y + (h * (f value: t value: y)) ]
| t y |
t := a.
y := y0.
[ t < b ]
whileTrue: [
Transcript
show: t asString, ' ' , (y printShowingDecimalPlaces: 3);
cr.
t := t + h.
y := y + (h * (f value: t value: y)) ]
ODESolver new eulerOf: [:time :temp| -0.07 * (temp - 20)] init: 100 from: 0 to: 100 step: 10

View file

@ -2,8 +2,8 @@ proc euler {f y0 a b h} {
puts "computing $f over \[$a..$b\], step $h"
set y [expr {double($y0)}]
for {set t [expr {double($a)}]} {$t < $b} {set t [expr {$t + $h}]} {
puts [format "%.3f\t%.3f" $t $y]
set y [expr {$y + $h * double([$f $t $y])}]
puts [format "%.3f\t%.3f" $t $y]
set y [expr {$y + $h * double([$f $t $y])}]
}
puts "done"
}

View file

@ -1,5 +1,5 @@
PROGRAM "Euclidean rhythm"
VERSION "0.0001"
PROGRAM "Euclidean rhythm"
VERSION "0.0001"
IMPORT "xma"
DECLARE FUNCTION Entry ()
@ -29,15 +29,15 @@ FUNCTION Entry ()
END FUNCTION
FUNCTION Euler (paso)
tiempo! = 0
temperatura! = 100.0
PRINT FORMAT$ ("Step ## ", paso);
tiempo! = 0
temperatura! = 100.0
PRINT FORMAT$ ("Step ## ", paso);
DO WHILE tiempo! <= 100
IF (tiempo! MOD 10) = 0 THEN PRINT FORMAT$ ("####.##", temperatura!);
temperatura! = temperatura! + SINGLE(paso) * (-0.07 * (temperatura! - 20.0))
tiempo! = tiempo! + paso
LOOP
PRINT
DO WHILE tiempo! <= 100
IF (tiempo! MOD 10) = 0 THEN PRINT FORMAT$ ("####.##", temperatura!);
temperatura! = temperatura! + SINGLE(paso) * (-0.07 * (temperatura! - 20.0))
tiempo! = tiempo! + paso
LOOP
PRINT
END FUNCTION
END PROGRAM