0
|
6767 Views
|
3 Replies
|
2 Total Likes
View groups...
Share
GROUPS:

# How to Speed Up Linear System of ODE

Posted 11 years ago
 Hi All,I am trying to solve PDE by using Method of lines. My code is very slow, I would like to run it at least n=100 to get good graph.That means I need to solve 100X100 matrix. Can we improve my code?Can we use                         sol = NDSolve[{system, initc}, U[t], t]I am attaching it..Thanks in advance..Selahittin.. Attachments:
3 Replies
Sort By:
Posted 11 years ago
 I have come up with new version of my code. Man this is much much faster. It takes a Just second.. Attachments:
Posted 11 years ago
 Thanks for your suggestion, it is definetly faster than my code. Do you think it might still improve?I am attaching my final code..Selahittin.. Attachments:
Posted 11 years ago
 Hi, For linear systems of ODEs you can get an exact solution with MatrixExp[].  (* NDSolve *) In[27]:= sol = DSolve[{system, initc}, U[t], t]; // AbsoluteTiming Out[27]= {20.089043, Null} (* MatrixExp *) In[25]:= sol2 = MatrixExp[t A].Table[1, {n + 1}]; // AbsoluteTiming Out[25]= {0.046551, Null} (* Compare *) i = 3; line1 = First[Subscript[u, i - 1][t] /. sol];line2 = sol2[[i]];Plot[{line1, line2}, {t, 0, 4}]Plot[{line1 - line2}, {t, 0, 4}]I.M.