Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
15
Task/Euler-method/BASIC/euler-method-1.basic
Normal file
15
Task/Euler-method/BASIC/euler-method-1.basic
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
PROCeuler("-0.07*(y-20)", 100, 0, 100, 2)
|
||||
PROCeuler("-0.07*(y-20)", 100, 0, 100, 5)
|
||||
PROCeuler("-0.07*(y-20)", 100, 0, 100, 10)
|
||||
END
|
||||
|
||||
DEF PROCeuler(df$, y, a, b, s)
|
||||
LOCAL t, @%
|
||||
@% = &2030A
|
||||
t = a
|
||||
WHILE t <= b
|
||||
PRINT t, y
|
||||
y += s * EVAL(df$)
|
||||
t += s
|
||||
ENDWHILE
|
||||
ENDPROC
|
||||
24
Task/Euler-method/BASIC/euler-method-2.basic
Normal file
24
Task/Euler-method/BASIC/euler-method-2.basic
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
'Freebasic .9
|
||||
'Custom rounding
|
||||
#define round(x,N) Rtrim(Rtrim(Left(Str((x)+(.5*Sgn((x)))/(10^(N))),Instr(Str((x)+(.5*Sgn((x)))/(10^(N))),".")+(N)),"0"),".")
|
||||
|
||||
#macro Euler(fn,_y,min,max,h,printoption)
|
||||
Print "Step ";#h;":":Print
|
||||
Print "time","Euler"," Analytic"
|
||||
If printoption<>"print" Then Print "Data omitted ..."
|
||||
Scope
|
||||
Dim As Double temp=(min),y=(_y)
|
||||
Do
|
||||
If printoption="print" Then Print temp,round(y,3),20+80*Exp(-0.07*temp)
|
||||
y=y+(h)*(fn)
|
||||
temp=temp+(h)
|
||||
Loop Until temp>(max)
|
||||
Print"________________"
|
||||
Print
|
||||
End Scope
|
||||
#endmacro
|
||||
|
||||
Euler(-.07*(y-20),100,0,100,2,"don't print")
|
||||
Euler(-.07*(y-20),100,0,100,5,"print")
|
||||
Euler(-.07*(y-20),100,0,100,10,"print")
|
||||
Sleep
|
||||
14
Task/Euler-method/BASIC/euler-method-3.basic
Normal file
14
Task/Euler-method/BASIC/euler-method-3.basic
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
x = euler(-0.07,-20, 100, 0, 100, 2)
|
||||
x = euler-0.07,-20, 100, 0, 100, 5)
|
||||
x = euler(-0.07,-20, 100, 0, 100, 10)
|
||||
end
|
||||
|
||||
FUNCTION euler(da,db, y, a, b, s)
|
||||
print "===== da:";da;" db:";db;" y:";y;" a:";a;" b:";b;" s:";s;" ==================="
|
||||
t = a
|
||||
WHILE t <= b
|
||||
PRINT t;chr$(9);y
|
||||
y = y + s * (da * (y + db))
|
||||
t = t + s
|
||||
WEND
|
||||
END FUNCTION
|
||||
Loading…
Add table
Add a link
Reference in a new issue