Solving large systems of equations with complex entries - Page 1
Forum section: electronics / beginners

author: MathWizard
author_rank: Super Contributor
timestamp: June 22, 2025, 04:55:25 am
content: I used openoffice speadsheet to solve an 8x8 matrix for a transfer function, and then copy and paste it for a large frequency span. So first I just symbolically entered labels for everything, as I did Gaussian elimination, and then filled in equations, and then back substituted for the node voltages.But now I need to do a 20x20 matrix, or even a 40x40. I've finished maybe 3/4 of the 20x20 matrix with my symbolic G.E, and it's tedious and prone to my human errors. And then there's a huge pile of constants to work out, before I'd get all the node voltages, to copy and paste for each frequency.OpenOffice can't use complex numbers in matrices, so I found a method to make a larger real matrix, in this case 40x40. But it seems the speadsheet won't or can't calculate the inverse, or the determinant. IDK if 40x40 is too large?? So far the search engines won't tell me the maximum size.I was looking at the math program Octave again. I'm not that familiar with it, or programming in general. I would like to enter all my variables, mainly RLC's and their inverses, into some array or matrix, and then using that to make a bunch more complex admittance's and currents. So far some of that seems harder than how I can do it with copy/paste in a spreadsheet.I was trying to import some constants into Octave, from a speedsheet converted from .ods to .xls, that didn't work. I might need some addon or plugin. I found the Octave Forge io-2.7.0.tar.gz, but so far IDK if that's even for windows, or where to install the folder. Trying to find info on Octave is not easy w/ search engines.Any tips or advice, or know any guides for octave or even matlab, that go over doing exactly this, setting up and solving big systems of linear equations with complex numbers, and then doing frequency analysis and plotting it?

author: IanB
author_rank: Super Contributor
timestamp: June 22, 2025, 05:31:15 am
content: Unless you are doing it for learning purposes, "roll your own" is always going to be more complicated.Could you not use an existing solution, like LTSpice?

author: voltsandjolts
author_rank: Unknown
timestamp: June 22, 2025, 09:03:25 am
content: Quote from: MathWizard on June 22, 2025, 04:55:25 amhttps://gnu-octave.github.io/packages/io/as per instructions given there, just paste this command to the octave prompt;Code:pkg install "https://downloads.sourceforge.net/project/octave/Octave%20Forge%20Packages/Individual%20Package%20Releases/io-2.7.0.tar.gz"

author: Siwastaja
author_rank: Super Contributor
timestamp: June 22, 2025, 09:48:02 am
content: For math things, learning Matlab (or the free equivalent Octave) is just obvious. Go for it, it won't be waste of time.

author: radiolistener
author_rank: Super Contributor
timestamp: June 22, 2025, 02:09:52 pm
content: here is example on how to use Octave with symbolic package to solve equation system:Code:pkg load symbolic;warning off all;% define symbolic variablessyms U0 U1 U2 U3 U4 U5 R;% define system of equationseqns = [0 == 0.001*U0 - 0.001*U5 + 2*U0/R - U1/R - U3/R + 8.3/R,0 == 0.003*U1 - 0.001*U2 - 0.001*U4 - 0.001*U5 - U0/R + U1/R - 5.0/R,0 == -0.001*U1 + 0.003*U2 - 0.001*U3 - 0.001*U4,0 == -0.001*U2 + 0.001*U3 - U0/R + U3/R - 3.3/R,0 == -0.001*U1 - 0.001*U2 + 0.003*U4 - 0.001*U5,0 == -0.001*U0 - 0.001*U1 - 0.001*U4 + 0.003*U5,0 == U0,0 == R - 0.001,];% list of variables to solve forvars = [U0, U1, U2, U3, U4, U5, R];% solve the systemsol = solve(eqns, vars);% print resultsfprintf('U0 = %g\n', double(sol.U0));fprintf('U1 = %g\n', double(sol.U1));fprintf('U2 = %g\n', double(sol.U2));fprintf('U3 = %g\n', double(sol.U3));fprintf('U4 = %g\n', double(sol.U4));fprintf('U5 = %g\n', double(sol.U5));fprintf('R = %g\n', double(sol.R));Result:Code:U0 = 0U1 = 5U2 = 4.11428U3 = 3.3U4 = 4.04285U5 = 3.01428R = 0.001To use symbolic package, you need to install it first, in order to install it, just execute from octave command prompt:Code:pkg install -forge symbolicit may take some time to download and install it.the same you can install any other packages, for example if you want to use DSP stuff, you need signal package:Code:pkg install -forge signalif you want to install io package:Code:pkg install -forge ioIf you want to update package to the latest version, just repeat the same command.Regarding to FFT plot, previously I've posted example on how to doFFT plot in Octave

author: radiolistener
author_rank: Super Contributor
timestamp: June 22, 2025, 02:20:41 pm
content: Regarding to loading data, you can do it in octave for different formats, but its better to use just a plain text file where each line contains a number. Then you can load it into vector in the following way:Code:b = load('coefs.txt');

author: MathWizard
author_rank: Super Contributor
timestamp: June 23, 2025, 01:02:39 pm
content: Ok thanks for the tips, I'll have to detour into learning more of the basics of Octave and how programmers do math. There's a lot more math I'd like to try on microcontrollers too, I should start there in Assembly.Even with packages installed and loaded, I still haven't been able to import from an .xls file. I'll try the text method.For the PSU I'm working on, yeah I'll use the LTSpice plot data, and carry on.

author: voltsandjolts
author_rank: Unknown
timestamp: June 23, 2025, 01:19:34 pm
content: Quote from: MathWizard on June 23, 2025, 01:02:39 pmAssembly would be challenging for the math you described in OP (matrix math etc.).If you want to test out math on a PC and then move it to a microcontroller, you might want to try MicroPython.It runs on PC and on MCUs, so you can experiment on the PC then transfer working code to the MCU.https://github.com/v923z/micropython-ulab/

author: Tation
author_rank: Regular Contributor
timestamp: June 23, 2025, 02:12:36 pm
content: Quote from: Siwastaja on June 22, 2025, 09:48:02 amUsing Python + numpy/scipy is another obvious choice.

author: rstofer
author_rank: Super Contributor
timestamp: June 23, 2025, 05:11:26 pm
content: It is worth knowing about symbolab.com for solving and desmos.com for graphing. Symbolab now uses Desmos for graphing (I think...)

author: ledtester
author_rank: Super Contributor
timestamp: June 25, 2025, 09:32:45 pm
content: Replies #2 and #3 of this thread:https://www.eevblog.com/forum/projects/experiment-using-matrix-equation-in-c-program/contain Python code which will solve circuits with voltage sources and impedances which may be complex.