This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 下列 Dart 程式, 利用 Runge Kutta 迭代運算法, 解常微分方程式 | |
| // 設 t 為時間, x 則設為物體的位移 | |
| // 假設要解 F=ma 的單一質量加上彈簧 (常數為 k) 與黏滯阻尼 (常數為 b) | |
| // f 為沿位移方向的施力 | |
| // dx/dt = v, dv/dt = (f-kx-bv)/m | |
| // dx / dt = (t - x)/2, 起始值 t0=0, x0=1, 求 t=2 時的 x 值 | |
| // | |
| // 已知起始值 t0 與 x0 後, 可以利用下列 rungeKutta 函式, 以 | |
| // h 為每步階增量值, 求 dxdt 常微分方程式任一 t 的對應值 x | |
| // 定義函式 rungeKutta, 共有四個輸入變數 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int i; | |
| int sum; | |
| main(){ | |
| sum = 0; | |
| for(i=1;i <= 10 ;i++){ | |
| sum += i; | |
| print("$sum"); | |
| } | |
| print('sum = $sum'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| print("hello world"); | |
| } |