# Solution of numerical vector equation

Suppose I have a vector equation:

Y'[t]==rhs[Y[t]]


and

Y[0]==ConstantArray[0,n]


where "rhs[Y[t]]" is a black box function which numerically calculates a N-length vector given a N-length vector Y[t].

How can I solve such an equation in "NDSolve" ?

Update: Say my rhs is :

rhs[{x_?NumberQ,y_?NumberQ]={x,y}

-
An example of exactly this kind of equation is in my answer to "I'd like to display field lines for a point charge in 3 dimensions". The equation for a field line is exactly of the type you mention. If you need more details on what I did there, let me know. – Jens Jul 6 '12 at 5:00
Many Thanks. It would be great if you let me know more. Let me tell you what I am not looking for, – user1505725 Jul 6 '12 at 5:26
I just added an answer with the relevant parts of my earlier link, applied to a simple example rhs. The added ingredient here is to use Array to generate the vectors. – Jens Jul 6 '12 at 5:32
Sorry that I did not make my question clear. I want to know if rhs[Y[t]] does not have a symbolic form. That is what I meant by "numerically calculates". – user1505725 Jul 6 '12 at 5:47
Hello & welcome! If you register for this site you will be able to access more features, for example voting. – Vitaliy Kaurov Jul 6 '12 at 5:49

This is a classic example from documentation center. I will modify this slightly, to make it more complex.

A = RandomReal[{0, 1}, {5, 5}];


Now you can actually mix scalar and vector functions - 'NDSolve' will understand it:

fs = x /.First[NDSolve[{x'[t] == 1 - Norm[x[t]] A.Sin[x[t]],
x[0] == RandomReal[1, 5]}, x, {t, 0, 23}]];


Visualize typically:

Plot[fs[t], {t, 0, 23}, ColorFunction -> Hue, PlotStyle -> Thick,
Frame -> True, FillingStyle -> Opacity[0.05], Filling -> 0]


Or visualize in an interesting way:

ParametricPlot3D[ fs[t][[#1 ;; #2]] & @@@ {{1, 3}, {2, 4}, {3, 5}}, {t, 0, 23},
PlotRange -> All, PlotStyle -> Thick, ColorFunction -> Hue,
ImageSize -> 450] /. Line[pts_, rest___] :> Tube[pts, 0.1, rest]


-
It works perfectly, – user1505725 Jul 6 '12 at 5:52
Many thanks it works. – user1505725 Jul 6 '12 at 5:55