# error DSolve::dsfun: cannot be used as a function

I tried to solve system of ODEs, but something was wrong.

Clear[P]
Clear[A]
A = {1, 0, 0}
P[t_] = {P1[t], P2[t], P3[t]}
Q[t_] = {Q1[t], Q2[t], Q3[t]}
sol3 = DSolve[{P'[t] == Cross[A, Q[t]], Q'[t] == Cross[A, P[t]],
P[0] == {0.5, 0.5, 0.3}, Q[0] == {0.1, 0.2, 0.3}}, {P[t], Q[t]}, t]


The result is

 DSolve::dsfun: {P1[t],P2[t],P3[t]} cannot be used as a function. >>


What interesting for me is that when I try to solve only one equation (not a system), everything is OK:

sol2 = DSolve[{P'[t] == Cross[A, P[t]], P[0] == {0.5, 0.5, 0.3}},
P[t], t]
{{P1[t] -> 0.5, P2[t] -> 0.5 Cos[t] - 0.3 Sin[t],
P3[t] -> 0.3 Cos[t] + 0.5 Sin[t]}}


I don't understand how it works...

Update:

Threading is not needed, thanks to comment by Michael below. Both solution work ofcourse, but Michael's sugestion is simpler, just Flatten the list if dependent variables:

Clear[P, A, t]
A = {1, 0, 0}
P[t_] = {P1[t], P2[t], P3[t]}
Q[t_] = {Q1[t], Q2[t], Q3[t]}
sol3 = DSolve[{P'[t] == Cross[A, Q[t]], Q'[t] == Cross[A, P[t]],
P[0] == {0.5, 0.5, 0.3}, Q[0] == {0.1, 0.2, 0.3}}, Flatten@{P[t], Q[t]}, t]


Clear[P, A, t]
A = {1, 0, 0}
P[t_] := {P1[t], P2[t], P3[t]}
Q[t_] := {Q1[t], Q2[t], Q3[t]}
ic = {Thread[P[0] == {0.5, 0.5, 0.3}], Thread[Q[0] == {0.1, 0.2, 0.3}]}
sol3 = DSolve[Flatten@{eq, ic}, Flatten@{P[t], Q[t]}, t]


• Thanks, it works. But why do I need to do this? And why does it work with one equation?
– newt
Mar 8, 2015 at 7:20
• @newt Actually the only necessary change is to flatten the list of functions: Flatten@{P[t], Q[t]}. Now that's because DSolve is not programmed to construct arbitrary expressions in terms of the solutions; in particular, it thinks you want two functions, each of which is a vector of the form {P1[t], P2[t], P3[t]} composed of three solutions -- or rather, because {P1[t], P2[t], P3[t]} is not of the form symbol or symbol[t]. Mar 8, 2015 at 17:45
• @MichaelE2 ok, thanks
– newt
Mar 9, 2015 at 6:15
• @Nasser yes, thanks, I got it.
– newt
Mar 10, 2015 at 18:40