EMRFD Message Archive 11296

Message Date From Subject
11296 2015-07-04 11:46:17 Nick Kennedy Math tools for electronics
I've been cautiously trying to expand my horizons with regard to math recently.  First in reducing systems of linear equations with complex symbolic coefficients down to a solution set and secondly if desired, taking that "transfer function" and obtaining numerical results and plotting them.

The first part (symbolic solutions) I know how to do  with pencil and paper "in theory", but the matrix reductions can get pretty complicated in a hurry, especially when complex expressions ("1/jwC") are included.  Above 2x2 gets pretty error likely for me.

I was looking for math programs to help me cheat a bit on that task, but free or cheap ones are rare.  I settled on Wolfram
11297 2015-07-04 12:12:12 Dan Mills Re: Math tools for electronics
I like the free scilab for attacking random linear algebra problems, but Mathworks have some interesting licensing options on matlab for personal use an another option if you need heavy lifting and don't mind paying for it. 

Regards, Dan.


11298 2015-07-04 12:27:38 Thomas S. Knutsen Re: Math tools for electronics


2015-07-04 20:39 GMT+02:00 Nick Kennedy kennnick@gmail.com [emrfd] <emrfd@yahoogroups.com>:
 

I've been cautiously trying to expand my horizons with regard to math recently.  First in reducing systems of linear equations with complex symbolic coefficients down to a solution set and secondly if desired, taking that "transfer function" and obtaining numerical results and plotting them.

The first part (symbolic solutions) I know how to do  with pencil and paper "in theory", but the matrix reductions can get pretty complicated in a hurry, especially when complex expressions ("1/jwC") are included.  Above 2x2 gets pretty error likely for me.

Depending on what you wish to analyze and what domain you want the results in (time, frequency) there are several methods of simplification and simulation, but they must be applied with caution, what works for one problem, may not work for another. 
As for manual calculations, it's just practice. 2x2 or 3x3 should be quite possible by hand and given enough time, but you need to know your complex algebra. 
 
11299 2015-07-04 12:33:04 Cecil Bayona Re: Math tools for electronics
Microsoft Mathematica 4 it's free, and Octave.

11303 2015-07-05 06:47:25 Nick Kennedy Re: Math tools for electronics
Thanks for the informative and useful responses on math programs.

One comment,

 "That said, there must be something wrong with your input if you get WolframAlpha to give up at a 4x4 matrix, I regularly use it with calculations much larger than that. If you can provide some more info, we can probably figure out if its syntax or if WolframAlpha finally have become self aware."

Be aware that I'm trying to get W-A to crank out a symbolic solution, not a numerical one.  It does that fairly well up through 3x3.  Through trial and error, I've picked up a few rules that seem to help:

Don't use two-character variables like RS, RF, C1, C2 and so on as Wolfram might interpret them as R*S and so on.  Don't put any spaces in your equation.  Makes it hard to read but seems to help.

With systems of linear equations, sometimes you can just type in the equations separated by commas and ask for a solution.  But the most reliable method seems to be to enter an expression for the inverse of the coefficient matrix times the constant matrix (vector).  Such as:

inv{coefficient matrix}*{constants vector}

And it will perform the operations indicated.

Syntax for a matrix is -- opening brace, opening brace for first row, elements of the row separated by commas, closing brace for first row, comma and opening brace for second row (if applicable) and so on.

As a test case for a 4x4, I just drew out a ladder network that produces four loops.  Going left to right:  source v, shunt C, series L, shunt D, series M, shunt E, shunt R.  C, D and E are capacitors and L & M are inductors.  My expression looks like this:

inv{{1/(i*w*C),-1/(i*w*C),0,0},{-1/(i*w*C),1/(i*w*C)+i*w*L+1/(i*w*D),-1/(i*w*D),0},{0,-1/(i*w*D),1/(i*w*D)+1/(i*w*E)+i*w*M,-1/(i*w*E)},{0,0,-1/(i*w*E),1/(i*w*E)+R}}*{{v},{0},{0},{0}}

Fun to read, eh?  I mostly check to make sure I don't have any missing (or extra) commas, braces or parentheses and have four elements in each row and in the column vector.

Like I said, I may be near the limit on how useful this can be even if it spits out an answer.  The answer may be too huge to play with.  So other methods would be preferable. 

73-

Nick, WA5BDU 
11304 2015-07-05 09:31:22 Cecil Bayona Re: Math tools for electronics
Missing braces ({}) ? Mathematics 4 is complaining about opening braces not matching closing braces, just for curiosity I'm trying it out.

11306 2015-07-05 13:32:46 Neil Martinsen-Bu... Re: Math tools for electronics
WolframAlpha is an amazing demonstration of the capabilities of Mathematica, but it is almost useless as mathematical software. Getting an answer relies on tricking it into giving you the answer that you want. I encourage you to use a proper free, open-source symbolic mathematics program to get the answers that you want.

Octave and Scilab are fine but have dated user interfaces. I would suggest a more modern project called Sage which is an omnibus collection of a tremendous amount of open source mathematical software. (For example, the symbolic capabilities of Sage come from a computer algebra system called Maxima http://maxima.sourceforge.net which has been packaged inside of the Sage user interface.)

The Sage project has a version that runs "in the cloud" which can do these sorts of computations online for free: cloud.sagemath.org. You can even share the "worksheets" that you create publicly for others to view and even copy into their own projects.  Go to <https://cloud.sagemath.com/projects/1afbe358-68e0-4bcf-8d18-93352cc69a4b/files/2015-07-05-145230.sagews> to see the worksheet that I created to find the symbolic inverse of the matrix that you gave.

Another example worksheet is <https://cloud.sagemath.com/projects/abd5f94a-f20f-4bae-8a22-52ecd9edaa79/files/jfet_testing.sagews> which I created when testing some JFETs using a method from Todd VE7BPO's QRP Homebuilder site.

My students often wanted to use WolframAlpha to help with their homework, but they often were frustrated later in the semester. Those who put in the time to learn Sage first had a powerful tool that would serve them throughout the class (and their careers!).

-Neil N0FN
(former professor of mathematics)

11307 2015-07-05 14:31:16 Nick Kennedy Re: Math tools for electronics
Wow, that's truly amazing.  Thanks very much for the link to https://cloud.sagemath.com which I don't think ever popped up as I was doing searches for symbolic math capable software.

73-

Nick, WA5BDU

11942 2015-12-05 12:21:48 Nick Kennedy Re: Math tools for electronics
After being shown sagemath, I also came across wxMaxima which appears to be related, but resides on your PC.

Today while browsing the LTspice discussion group, I saw mention of SapWin3. It allows you to draw the schematic and then will derive the transfer function and perform similar functions. Options to keep it symbolic or use actual component values.  I haven't really played with it but a few minutes but thought I'd add it to this old discussion thread.


73-

Nick, WA5BDU