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,

and then use NDSolve as suggested in the comments:

NDSolve[derivs, thetas[0] = myInitialCondition, thetas, {t,0,reallyBigNumber}]

  • $\begingroup$ The question is unclear, please show us your specific problem. Anyway, if I have to guess: are you trying to handle implicit array? If so, in most cases you don't need any special treatment, NDSolve can directly handle it, see 3rd example in section Scope -> Ordinary Differential Equations of document of NDSolve. $\endgroup$
    – xzczd
    Dec 3, 2022 at 1:34
  • $\begingroup$ @xzczd Maybe I'm misunderstanding your meaning, but the third example (entitled "Directly specify a system of equations") does not do what I want; the author explicitly names the functions they are differentiating, that is, they specify ahead of time that they are defining a system of ODEs using three functions, x(t), y(t), and z(t). For any n, I want to initialize a collection of n functions; if they are in an array A, I can de-reference them with their index and define the system of ODEs with a For loop. I don't know how to tell Mathematica "A is an array of functions in the variable t" $\endgroup$
    – gdd
    Dec 3, 2022 at 2:21
  • $\begingroup$ I'm refering to "Solve for a vector-valued function". Notice there're separation lines between the examples. $\endgroup$
    – xzczd
    Dec 3, 2022 at 2:24
  • $\begingroup$ You can also find many examples in this site. Just a few examples: mathematica.stackexchange.com/q/144339/1871 mathematica.stackexchange.com/q/268249/1871 mathematica.stackexchange.com/q/25260/1871 Then, don't use For loop: mathematica.stackexchange.com/q/134609/1871 $\endgroup$
    – xzczd
    Dec 3, 2022 at 2:39
  • $\begingroup$ @xzczd Ah, apologies. I think I can do something with this. Thank you. $\endgroup$
    – gdd
    Dec 3, 2022 at 2:42

1 Answer 1


Looks with With could be used.

a way to initialize an array of abstract functions

With[{vars = Array[theta, 3]}, vars = {"a", "b", "c"}]

or with non-ordinal indices

With[{vars = {theta[4], theta[7], theta[8]}}, vars = {"a", "b", "c"}]





Not the answer you're looking for? Browse other questions tagged or ask your own question.