fork download
  1. var v = 0.0
  2. var x = start_dx
  3. let dt = 0.1
  4. while t <= 2.0 {
  5. let as_x = analyticalSolution(t:t)
  6. print(t, x * 1000, as_x * 1000, (x - as_x) * 1000)
  7.  
  8. let F = -k * x
  9. let a = F / m
  10. let dv = a * dt
  11. let dx = v * dt
  12. v += dv
  13. x += dx
  14. t += dt
  15. }
  16.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.swift:2:9: error: use of unresolved identifier 'start_dx'
var x = start_dx
        ^~~~~~~~
prog.swift:4:7: error: use of unresolved identifier 't'
while t <= 2.0 {
      ^
prog.swift:2:5: note: did you mean 'x'?
var x = start_dx
    ^
prog.swift:3:5: note: did you mean 'dt'?
let dt = 0.1
    ^
prog.swift:1:5: note: did you mean 'v'?
var v = 0.0
    ^
prog.swift:5:16: error: use of unresolved identifier 'analyticalSolution'
    let as_x = analyticalSolution(t:t)
               ^~~~~~~~~~~~~~~~~~
prog.swift:5:37: error: use of unresolved identifier 't'
    let as_x = analyticalSolution(t:t)
                                    ^
prog.swift:6:11: error: use of unresolved identifier 't'
    print(t, x * 1000, as_x * 1000, (x - as_x) * 1000)
          ^
prog.swift:8:14: error: use of unresolved identifier 'k'
    let F = -k * x
             ^
prog.swift:9:9: note: did you mean 'a'?
    let a = F / m
        ^
prog.swift:2:5: note: did you mean 'x'?
var x = start_dx
    ^
prog.swift:1:5: note: did you mean 'v'?
var v = 0.0
    ^
prog.swift:9:17: error: use of unresolved identifier 'm'
    let a = F / m
                ^
prog.swift:8:9: note: did you mean 'F'?
    let F = -k * x
        ^
prog.swift:2:5: note: did you mean 'x'?
var x = start_dx
    ^
prog.swift:1:5: note: did you mean 'v'?
var v = 0.0
    ^
prog.swift:14:5: error: use of unresolved identifier 't'
    t += dt
    ^
<unknown>:0: error: error opening input file 'prog.o' (No such file or directory
)
clang: error: no such file or directory: 'prog.o'
clang: error: no such file or directory: '@prog.autolink'
stdout
Standard output is empty