1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Using Node-Voltage method in the phasor domain

  1. Dec 4, 2012 #1
    I was wondering if there is an easier way to solve circuits using matrix inversion if I have complex numbers. So far I've been doing them by hand with 2x2 matrices. It isn't hard, but it takes a while. I have a test coming up in about a week which will have 10 questions that have to be solved in 1 hour. My teacher said that I may have to solve 3x3 or 4x4 matrices. If I have to do it by hand I don't think I'll finish on time
  2. jcsd
  3. Dec 5, 2012 #2

    The Electrician

    User Avatar
    Gold Member

    If you can have a laptop with you, your school probably has Matlab or something like it on the school network.

    If you can't do that, you better get yourself a calculator that can do complex matrices, such as a TI89 or an HP48G, HP49G+ or HP50G.

    You'll never be able to do a 4x4! :cry:
  4. Dec 5, 2012 #3


    User Avatar
    Science Advisor

    Gaussian elimination works just fine for 4x4 matrices. It wouldn't be fast, but it works.

    Alternatively, do dimension reduction to get to a 3x3 matrix. Observe that if [itex]\sum_{j=1}^NA_{ij}x_j=b_i[/itex] then the following holds for x1.

    [tex]x_1 = \frac{b_1 - \sum_{j=2}^NA_{1j}x_j}{A_{11}}[/tex]

    If you substitute this back into the system, you get the reduced system.


    This will let you reduce a 4x4 to 3x3 and 3x3 to 2x2.

    3x3 matrix can also be attacked directly. Cramer's rule for 3x3 is not that bad. It's just 1 3x3 determinant and 9 2x2 determinants. Even with complex numbers, not all that terrible. It does involve 9 complex divisions, though, to get the final result.

    None of this is trivial, but it's not that complicated and can be done even with regular calculator. If you have one that does complex numbers, you can fly through them. And remember, people used to do this stuff with logarithmic slide rules. Be glad you are not them.

    Octave does anything Matlab does and is free.
  5. Dec 5, 2012 #4

    The Electrician

    User Avatar
    Gold Member

    I think you're being overly optimistic. He said he does the computations "by hand" (so far), and he says that even a 2x2 "takes a while". He will have to do 10 such problems, some of which involve 3x3 and 4x4 complex matrices, in an hour. If he does them "by hand", as he has done so far, carefully so as to make no numerical mistakes, I think he's unlikely to get them all done in an hour.

    Matlab will also be free to him if it's on the school network.
  6. Dec 5, 2012 #5


    User Avatar
    Science Advisor

    Perhaps. But if he's not allowed a computer or a calculator with sufficient capabilities, it's better than nothing.

    Some schools don't. My university has a Mathemtaica license for student machines, but not a Matlab one. Of course, Mathematica will power through these just as easily. In either case, though, Octave is always an option.

    I'm just trying to cover all the bases. Not saying your advice is bad. If he has an opportunity to use it, he should. If he doesn't, and he has to do it by hand, he'll get through more of them by utilizing some shortcuts.
  7. Dec 5, 2012 #6

    The Electrician

    User Avatar
    Gold Member

    What makes you think he doesn't know some shortcuts?

    Furthermore, you seriously underestimate the difficulty of inverting a 4x4 complex matrix by hand, even with the aid of a simple calculator.

    My copy of Golub & Van Loan gives the flop counts for various matrix operations, but for convenience I found a reference on the web. Consider:


    Look at table 5-1 on page 5-5.

    To invert a 4x4, non-complex matrix takes about 384 flops (floating point operations, in case the OP doesn't know what a flop is) using the method of cofactors; the better (for 4x4 and larger matrices) Gauss-Jordan method takes 256 flops. If the operations involve complex numbers, and we're doing them by hand with a simple 4 banger calculator, each complex multiplication will take 4 real multiplies and 2 real additions; each complex addition will take two real additions. The number of real flops to invert a 4x4 complex matrix will certainly be greater than 4*256 real flops.

    In addition, if using a calculator without built-in matrix operations, a person will have to write down (and keep track of) a large number of intermediate results and re-enter them on the calculator at various points during the calculations.

    If the calculator can do complex arithmetic (but without built-in matrix operations), it still takes 256 complex flops to calculate the inverse of a 4x4 complex matrix. To do that in an hour would require making a calculation every 14 seconds, and that would include typing in the complex numbers and writing down intermediate results (and not making any mistakes in procedure or reading and writing a lot of numbers).

    The OP won't be able to invert even one 4x4 matrix in an hour doing things the way he has been, much less also solve 9 more (possibly lesser) problems. He won't be able to do it even with a calculator that can do complex arithmetic without built-in complex matrix operations.

    He better get a calculator that can do complex matrix arithmetic or access to an appropriate mathematical software package.
  8. Dec 5, 2012 #7


    User Avatar
    Science Advisor

    You see how Cramer's rule (cofactor method) has a huge jump fro 3x3 to 4x4? Exploit that. It takes 27 flops to go from 4x4 to 3x3, giving you 80 flop computation for a 4x4 matrix. It's not an efficient general algorithm, but it is the most efficient way to do 4x4 case.

    I can do 80 complex operations on a slide rule in half an hour. A calculator with built in complexes should get you done in less than 20 if you have a system.

    If that's one problem out of a set of 10, this is entirely reasonable.
  9. Dec 6, 2012 #8

    The Electrician

    User Avatar
    Gold Member

    You want to start with a complex 4x4 matrix:


    And calculate a reduced 3x3 matrix like this:


    I see that each element of the reduced matrix requires 1 complex multiplication, 1 complex division and 1 complex subtraction. I think this would require 15 real flops. And to do the 9 repetitions will require a total of 135 real flops.

    Next, calculating the inverse of the 3x3 reduced matrix will require an additional 54 complex flops. I haven't determined the mix of multiplications, additions and divisions for this, but taking 3.5 real flops per complex flop, we would need 189 more real flops for a total of 324 real flops. If a full hour is allocated to this massive computation, one flop will have to be calculated every 11.1 seconds, no stopping, and this includes writing down intermediate results, and keeping them straight, and making no mistakes.

    I don't think the OP would be able to do this using a calculator that can only do real arithmetic.

    And, even if he has a calculator that can do complex arithmetic, he still must write down all those complex intermediate results and keep them straight, which takes longer that the calculations.. One of the very great advantages of a calculator that can do matrix arithmetic is not having to keep track of all those intermediate results.

    His original problem was to calculate the inverse of a 4x4 complex matrix. Having calculated the inverse of the reduced 3x3 matrix, how much more computation is needed to get the inverse of the original 4x4 matrix? Just how does he do that?

    What kind of operations? Multiplications, additions, divisions? As you know, you can't do addition on a slide rule. The additions will have to be done some other way.

    If we assume a mix of operations similar to the OP's problems of 3.5 real flops per complex flop, you would be doing 280 real flops in a half hour--that's 6.4 seconds per real flop, and the matrix reduction would also require writing down and keeping track of the intermediate results.

    I'm skeptical.

    With a calculator, keying in an operand (and fairly often, keying in two) and then writing down the result will dominate each calculation. Any calculator can do +,-,/,and * in a small fraction of a second.

    If I were the OP, I'd get myself a calculator that can do complex arithmetic, including matrix operations. He'll need it if he continues in an EE curriculum.

    Attached Files:

    • Red1.png
      File size:
      805 bytes
    • Red2.png
      File size:
      1.2 KB
    Last edited: Dec 6, 2012
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook