I have this code:
using Pkg; n = 1.0; function yfc(t) # x in here is actually t from before cos(1/3 * t^3 + n*t) end; const t0 = 0; const tf = 1000; const N = 10000000; const dt = 1000 / N; t = t0:dt:tf; const x = 0.0 ; for i in 1:N; k1 = dt * yfc(t[i]); k2 = dt * yfc(t[i] + 1/2*dt); k4 = dt * yfc(t[i+1]); x = x + 1.0/6.0 * k1 + 2.0/3.0 * k2 + 1.0/6.0 * k4 ; end
and I’m getting the error:
ERROR: LoadError: UndefVarError: x not defined Stacktrace:  top-level scope at /data/GitHub/mine/math/julia-scripts/airy-ai-approx.jl:24 [inlined]  top-level scope at ./none:0  include(::String) at ./client.jl:403  top-level scope at none:0 in expression starting at /data/GitHub/mine/math/julia-scripts/airy-ai-approx.jl:20
which confuses me. x is defined, originally as a constant and then as a variable that is updated over the loop. What is the problem here?