# Solve a non-linear differential equations system?

Posted 2 years ago
3477 Views
|
10 Replies
|
2 Total Likes
|
 Hey guys, I have some problems with this system of non-linear differential equations. This system is from the Winfree model from his "The Geometry of Biological Time". I'm new with mathematica and I couldn't find a solution yet. Here I post the code I wrote it. eqns = Table[θ[i]'[t] == RandomInteger[{0, 1}] - (0.65/10) (Cos[θ[i][t]]) (Sin[θ[i][t]]), {i,1, 10}] NDSolve[{eqns, Table[θ[i][0] == RandomReal[{0, 2}], {i, 1, 10}]}, {t, 10}] It shows me this message error : "NDSolve::argm: NDSolve called with 2 arguments; 3 or more arguments are expected." Thanks to anyone who will read and help me with it!
Answer
10 Replies
Sort By:
Posted 2 years ago
 Here's a simple example using NDSolve In[3]:= NDSolve[{x'[t] == y[t], y'[t] == -x[t], x[0] == 0, y[0] == 1}, {x, y}, {t, 0, 1}] Out[3]= {{x -> InterpolatingFunction[{{0., 1.}}, <>], y -> InterpolatingFunction[{{0., 1.}}, <>]}} 
Answer
Posted 2 years ago
 eqns = Table[θ[i]'[t] == RandomInteger[{0, 1}] - (0.65/10) (Cos[θ[i][t]]) (Sin[θ[i][t]]), {i, 1, 10}]; sol = NDSolve[{eqns, Table[θ[i][0] == RandomReal[{0, 2}], {i, 1, 10}]}, Table[θ[i][t], {i, 1, 10}], {t, 0, 10}]; Plot[Evaluate[Table[\[Theta][i][t], {i, 1, 10}] /. sol], {t, 0, 10},PlotLegends -> "Placeholder"] 
Answer
Posted 2 years ago
 Thanks to Frank and mostly thanks to you Mariusz for helping me to find a solution. I have another question if you are so kind to listen to it. I would need that the independent variable of the cosine function and the subsequent respect to the variable of more of the same equation sine function, in essence:Cos[theta[i+1][t]] * Sin[theta[i][t]] or equally Cos[theta[i][t]] * Sin[[i-1][t]]The main problem in this is that in one case or in the other I will put an extra indipendent variable in the system and the function NDSolve it shows me : "NDSolve::underdet: There are more dependent variables, {[Theta][1][t],[Theta][2][t],[Theta][3][t],[Theta][4][t],[Theta][5][t],[Theta][6][t],[Theta][7][t],[Theta][8][t],[Theta][9][t],[Theta][10][t],[Theta][11][t]}, than equations, so the system is underdetermined."How can I fix this issue? Thanks again for support!
Answer
Posted 2 years ago
 The code now is this one: eqns = Table[\[Theta][i]'[t] == RandomInteger[{0,1}] - (0.65/10) (1 +Cos[\[Theta][i + 1][t]]) (Sin[\[Theta][i][t]]), {i, 1, 10}] sol = NDSolve[{eqns,Table[\[Theta][i][0] == RandomReal[{0, 2}], {i, 1, 10}]}, Table[\[Theta][i][t], {i, 1, 10}], {t, 0, 500}] Ande the messagge error is this one: "NDSolve::underdet: There are more dependent variables, {[Theta][1][t],[Theta][2][t],[Theta][3][t],[Theta][4][t],[Theta][5][t],[Theta][6][t],[Theta][7][t],[Theta][8][t],[Theta][9][t],[Theta][10][t],[Theta][11][t]}, than equations, so the system is underdetermined.".That's why I think is probably fault of the last indipendent variable theta[11][t]. Anyway I hope someone will help me again!
Answer
Posted 2 years ago
 You have message error because does not include enough equations to specify a solution. Must add additional equation, for example: θ[11][t] == 1(*e.g*) eqns = Table[θ[i]'[t] == RandomInteger[{0, 1}] - (0.65/10) (1 + Cos[θ[i + 1][t]]) (Sin[θ[i][t]]), {i, 1, 10}] sol = NDSolve[{eqns, θ[11][t] == 1, Table[θ[i][0] == RandomReal[{0, 2}], {i, 1, 10}]}, Table[θ[i][t], {i, 1, 10}], {t, 0, 500}] 
Answer
Posted 2 years ago
 Thanks again for your answer Mariusz, you were very kind! At the moment I'm studying another way to implement the model, but I'm having some difficulties. I have to solve this sytem with boundaries conditions on Theta and Omega. For example conditions could be : theta[i][0]== RandomReal[{0,2}] omega[i][0]==1 .The system is attached ad image because I wasn't sure how to type it in the best way possible! PS: k is constant between 0,11 and 0,78 and N is the number of the oscillators.Thanks again on helping me! Attachments:
Answer
Posted 2 years ago
 I think that it should be, but I'm not sure....  n = 10; m = 10; k = 0.65; eqns = Table[θ[i]'[t] == RandomInteger[{0, 1}] - (k/n) *Sum[(1 + Cos[θ[j][t]]) *Sin[θ[i][t]], {j, 1, n}], {i, 1, m}] sol = NDSolve[{eqns, Table[θ[i][0] == RandomReal[{0, 2}], {i, 1, m}]}, Table[θ[i][t], {i, 1, m}], {t, 0, 500}] Plot[Evaluate[Table[\[Theta][i][t], {i, 1, m}] /. sol], {t, 0, 10}, PlotLegends -> "Placeholder"] 
Answer
Posted 2 years ago
 Thanks again Mariusz! It works perfectly unitl m=n=200 . I should be test for m=n=1000 . It shows me severals error messages! Another tip if you are not bored of me : If I want to evalute for example all the thetas ( I mean theta[1], theta[2], theta[3], ... , theta[n] ) for a particular value of indipendent variable t , let's say 500, how can I do it? And for only one theta? Thanks again, hope I'm not annoying you!
Answer
Posted 2 years ago
 @Gabriele Cinci, is it that hard to look up documentation on NDSolve and see how to get the values? First examples there show you need something like θ[2][500]/. sol You can even see it from Plot examples of helpful replies by Mariusz. So what are you doing to learn? It seems like you just keep asking questions without any effort to read though documentation. Please look at the rules of the forum: http://wolfr.am/READ-1STQuoting: Check Documentation for examples relevant to your issue. Do not bluntly solicit for help...
Answer
Posted 2 years ago
 Method -> {"EquationSimplification" -> "Residual"} in NDSolve helps.  n = 300; m = 300; k = 0.65; eqns = Table[θ[i]'[t] == RandomInteger[{0, 1}] - (k/n)*Sum[(1 + Cos[θ[j][t]])*Sin[θ[i][t]], {j, 1, n}], {i, 1, m}]; sol = First@NDSolve[{eqns, Table[θ[i][0] == RandomReal[{0, 2}], {i, 1, m}]}, Table[θ[i][t], {i, 1, m}], {t, 0, 500}, Method -> {"EquationSimplification" -> "Residual"}]; For example ,only one theta:  {θ[299][t]} /. sol /. t -> 500 few theta's: {θ[1][t], θ[2][t], θ[3][t]} /. sol /. t -> 500 all theta's (n=m=300): Table[θ[w][t], {w, 1, n}] /. sol /. t -> 500 in Multicolumn format: Multicolumn[Table[θ[w][t], {w, 1, n}] /. sol /. t -> 500, 10, Frame -> All, Spacings -> {1, 1}, Background -> {Automatic, {{LightOrange, White}}}, Frame -> All, FrameStyle -> White, Alignment -> Center] 
Answer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments