Sign up ×
Physics Stack Exchange is a question and answer site for active researchers, academics and students of physics. It's 100% free.

Working with Kirchhoff's rules, I am attempting to device an algorithmic approach to finding the unknowns of the problems, I am of a Computer Science background and I am finding it difficult to identify proper closed loops within the circuit and I am curious if there is a generalized pice of sudo code applicable to these problems, or perhaps a matlab or sympy script available?

share|cite|improve this question
There is an electrical engineering stack exchange, which might be more appropriate. In short, it's easy enough to write such an algorithm (indeed, I've written one before), but the matrix math is often particularly sparse and programs that do this work can have trouble solving every kind of network. – Alan Rominger Jul 7 '12 at 19:13
There is also a beta site for scientific computation for which this question might be a little basic unless you can elaborate on the nature of the networks. As @AlanSE says, the basic problem is not too hard for a undergraduate course but the straight forward approach has pathological failure modes for some classes of networks. Phrases like "ill-conditioned" come up in discussions of the hard cases. – dmckee Jul 7 '12 at 19:16
That type of programming is my specialty! I simply find the manor in which physics is generally presented very difficult to comprehend. To be able to look at concise piece of code would do a lot for my understanding of these problems. I'll take a look on the electrical engineering stack exchange. – rudolph9 Jul 7 '12 at 19:17
To expand on @dmckee's suggestion, to give the basics you probably want to specify the components you want to include and give a few examples to demonstrate the intended scale. Understand that including some... uniquely nonlinear components could make solving the system basically unworkable. Even a pure voltage/current source easily results in combinations that are literal contradictions. – Alan Rominger Jul 7 '12 at 19:40
One approach is Modified Nodal Analysis: Qucs has a nice pedagogical discussion of implementation: – Steve B Jul 7 '12 at 22:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.