I want to solve a system of simple differential equations. At some point I need to solve non-linear system of algebraic equations with Newton method. I would like to efficiently create a right hand side vector using Table[] or similar command. The problem is that the system consists of two equations, so what I need is:
F=Table[
(*do something*)
,{i,1,k}]
but in fact $F$ should have $2k$ entries. For example for $k=5$ Length[F]
should return $10$. How to achieve that efficiently?
I know I can create different values for odd indexes and even, but then I need additional If[]
or to break the whole code into two Table[]
executions what I would like to avoid. I could possibly also create two element lists {a,b}, and flatten it at the end...
But It still seems quite expensive.
Flatten
is expensive? Did you time it? $\endgroup$