Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue