I am using NLsolve to solve systems of nonlinear equations. Everything works fine, but I want to understand what this function does:
function f!(F, x)
F[1]=x[1]^2+3*x[2]^2-9
F[2]=17*x[2]-14*x[1]^2+49
end
f! appears to be a function which changes F but leaves x unchanged, and it assumes that both F and x are 2-tuples. Why, then, can I not say
a=(1.1,1.2)
b=(2.1,2.2)
f!(b,a)
? How would I pass a and b to f! such that b is modified in terms of a? If I do it, I get
MethodError: no method matching setindex!(::Tuple{Float64, Float64}, ::Float64, ::Int64)
Stacktrace:
[1] f!(F::Tuple{Float64, Float64}, x::Tuple{Float64, Float64})
@ Main ./In[94]:2
[2] top-level scope
@ In[103]:1
[3] eval
@ ./boot.jl:360 [inlined]
[4] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base ./loading.jl:1116