fork download
  1. vel = -0.1
  2. x = 1
  3. base = 1
  4. accel = 0
  5. k = 0.02
  6. sk = 0.06
  7.  
  8. function nx()
  9. f = (x-base) * k
  10. accel = -f + vel*sk
  11. x = x + vel
  12. vel = vel + accel
  13. end
  14.  
  15.  
  16. for i = 0,100 do
  17. nx()
  18. print(x.." speed:"..vel)
  19. end
  20.  
Success #stdin #stdout 0s 2832KB
stdin
Standard input is empty
stdout
0.9 speed:-0.106
0.794 speed:-0.11036
0.68364 speed:-0.1128616
0.5707784 speed:-0.113306096
0.457472304 speed:-0.11152002976
0.34595227424 speed:-0.1073606776256
0.2385915966144 speed:-0.10072136376794
0.13787023284646 speed:-0.0915364775263
0.046333755320164 speed:-0.079786070834807
-0.033452315514644 speed:-0.065499910191299
-0.098952225705943 speed:-0.048760858492484
-0.14771308419843 speed:-0.029707465487914
-0.17742054968634 speed:-0.0085356517332208
-0.18595620141956 speed:0.014500620156513
-0.17145558126305 speed:0.039089781394295
-0.13236579986875 speed:0.064864279903213
-0.067501519965541 speed:0.091403452694781
0.02390193272924 speed:0.11823769025578
0.14213962298502 speed:0.14485391301654
0.28699353600156 speed:0.17070235533783
0.45769589133939 speed:0.19520462593807
0.65290051727747 speed:0.21776298566757
0.87066350294503 speed:0.23777075446207
1.1084342574071 speed:0.2546237296709
1.363057987078 speed:0.26773246830301
1.630790455381 speed:0.27653525665963
1.9073257120406 speed:0.28051156295159
2.1878372749922 speed:0.27919574248787
2.4670330174801 speed:0.2721907415373
2.7392237590174 speed:0.25918152567993
2.9984052846973 speed:0.23994794204038
3.2383532267377 speed:0.21437671286886
3.4527299396066 speed:0.18247225110623
3.6352021907128 speed:0.14436598738048
3.7795681780933 speed:0.10032390280905
3.8798920809023 speed:0.050751973415727
3.930644054318 speed:-0.0038007497973759
3.9268433045207 speed:-0.062641675871579
3.8642016286491 speed:-0.12493704251429
3.7392645861348 speed:-0.18971729763813
3.5495472884967 speed:-0.25588562721911
3.2936616612776 speed:-0.32222971062219
2.9714319506554 speed:-0.38743672648507
2.5839952241703 speed:-0.45011156908729
2.133883655083 speed:-0.50879816771593
1.6250854873671 speed:-0.56200373088055
1.0630817564865 speed:-0.60822566448072
0.45485609200583 speed:-0.64598083947929
-0.19112474747347 speed:-0.67383681168817
-0.86496155916164 speed:-0.69044452543999
-1.5554060846016 speed:-0.69457196578315
-2.2499780503848 speed:-0.68513816203811
-2.9351162124229 speed:-0.6612468907527
-3.5963631031756 speed:-0.62221937994941
-4.218582483125 speed:-0.56762528068286
-4.7862077638079 speed:-0.49731114786133
-5.2835189116692 speed:-0.41142566145685
-5.694944573126 speed:-0.31044082291088
-6.0053853960369 speed:-0.19516838082301
-6.2005537768599 speed:-0.066770775751655
-6.2673245526116 speed:0.073234053240444
-6.1940904993712 speed:0.2229745874871
-5.971115911884 speed:0.38023487272375
-5.5908810391603 speed:0.54247128332486
-5.0484097558354 speed:0.70683718110756
-4.3415725747279 speed:0.87021560709072
-3.4713569676372 speed:1.0292599950107
-2.4420969726264 speed:1.1804427340641
-1.2616542385623 speed:1.3201112375605
0.058456998998135 speed:1.4445509965854
1.5030079955835 speed:1.5500549164005
3.053062911984 speed:1.6329980514729
4.6860609634569 speed:1.6899166763216
6.3759776397784 speed:1.7175904576317
8.0935680974102 speed:1.7131263322941
9.8066944297042 speed:1.6740425502835
11.480736979988 speed:1.5983512147064
13.079088194694 speed:1.4846375479891
14.563725742683 speed:1.3321340369745
15.895859779658 speed:1.1407875643393
17.036647343997 speed:0.91131762260653
17.947964966604 speed:0.64526373308298
18.593228699687 speed:0.34502025773588
18.938248957422 speed:0.013856899206306
18.952105856629 speed:-0.34407666598976
18.608029190639 speed:-0.72376338308172
17.884265807557 speed:-1.1193497698794
16.764916037678 speed:-1.5241960722233
15.240719965455 speed:-1.9309461573103
13.309773808144 speed:-2.331617326058
10.978156482086 speed:-2.7177098417843
8.2604466403019 speed:-3.0803355619331
5.1801110783688 speed:-3.4103646284552
1.7697464499136 speed:-3.6985887277298
-1.9288422778162 speed:-3.9358989803919
-5.8647412582081 speed:-4.1134760736591
-9.9782173318672 speed:-4.2229898129145
-14.201207144782 speed:-4.256804855052
-18.458011999834 speed:-4.2081890034595
-22.666201003293 speed:-4.0715201036704
-26.737721106964 speed:-3.8424872898247