I am trying to initialize a collection of abstract functions $\theta_k(t)$ in a variable $t$ where $1\leq k\leq n$.
I cannot define them explicitely; the entire point is that I want to numerically solve an ODE I can define with their derivatives. It's clear how I can do this if I had the array, but I don't know how to initialize the array.
If I only cared about a particular value for $n$, I could declare an array of functions explicitly like this:
thetas = Array[{theta1[t_], theta2[t_], ... , thetan[t_]}]
There should be a away to initialize an array of abstract functions in the variable $t$. Once I have such an array, thetas, I can likewise initialize a second array, derivs such that
For[i=0,i<n, ++i,
derivs[[i]]=Sum[matrix[[i,j]]Sin[Abs[thetas[[j]]-thetas[[i]]]],{j,0,n}]
]
and then use NDSolve as suggested in the comments:
NDSolve[derivs, thetas[0] = myInitialCondition, thetas, {t,0,reallyBigNumber}]
NDSolvecan directly handle it, see 3rd example in section Scope -> Ordinary Differential Equations of document ofNDSolve. – xzczd Dec 03 '22 at 01:34Forloop: https://mathematica.stackexchange.com/q/134609/1871 – xzczd Dec 03 '22 at 02:39n = 3;; thetas = Table[Symbol["theta" <> ToString[i]][t_], {i, n}]? – Daniel Huber Dec 03 '22 at 08:20Forin Mathematica. There is almost always a much better way. See here for details. Here, for instance, there is no need to pre-initialize your functions – they can be calculated when needed: see lazy evaluation. – Roman Dec 03 '22 at 10:36