Mathematica Notebooks have the ability to segment your work into logical groups by using identified headers which run from Title to Subsection. There are 6 of these headers. These groups will then collapse all lesser headers by double clicking on the vertical line shown to the right.

This organization can be accomplished after the mathematics of the problem are completed. This allows one to review the solution and annotate the steps. The readers of this document can then better understand your analysis.

List & Matrix Formation

 List Formation

A list is a group of variables and numbers separated by comma’s and enclosed by curly brackets. A list can be labelled as a variable name. An example of this is shown below:

AList = {1, a, 2, b}
{1, a, 2, b}

Also note that ending a statement with a semicolon tells Mathematica to not display the result.

BList = {c, 3, d, 4};
Using Lists to create Matrices

If one makes a List of Lists, you get a Matrix of values.

AMatrix = {AList, BList};

You can display this by using the directive MatrixForm[].


Note that this way of putting the lists together, they are formed as rows. If we wish them to be formed as columns we form the matrix as shown below:

BMatrix = {{AList},{BList}};

Or, we can create a matrix of 2 columns such as:

CMatrix = {{AList, BList}};


Getting an element of a list or matrix

We have the need to extract the one or more elements of a matrix. To do this in Mathematica we use double square brackets [[ element ]]. So, for example, if we want the first row of the AMatrix:

{1, a, 2, b}

To get the 3rd element in the first row we use:


Using this approach we can get any element in any matrix.

Replacement and tolerances

The final operations we need to use for WCA in Mathematica are the replacement rules, using the table function and how to enter tolerances. Entering tolerances allows us to evaluate both the upper and lower limits numerically with the same expression.
Replacement Rules
Once we have derived the desired equation with variables, we will need to enter the specific numerical values for our circuit. To accomplish this, we will use the replacement operator provided in Mathematica, which is a backslash and period followed by the replacement. Let show this for a simple case.
Suppose we have an equation, we will call eqA:

eqA = x2 + x
x + x2

We want to replace the x with the number 2 in a specific case:

eqA /. x → 2

So 22=4, plus 2 is 6. The beauty of this is that the original equation still exists as a variable equation.

x + x2
Creating Lists Using the Table Function

In some cases, we need to evaluate a series of values in a similar fashion. To do this repetitive task, it is much easier to create a list of values, using the Table function.
Lets say, we want to evaluate our eqA for x values from 1 to 9, we can do this by:

valA = Table[eqA, {x, 1, 9}]
{2, 6, 12, 20, 30, 42, 56, 72, 90}

Note that doing it this way, we do not need the replacement operator.  But also note that there is not a 1 to 1 relationship between the x and y values, so let’s modify the table function so we get ordered pairs:

valA = Table[{x, eqA}, {x, 1, 9}];
Matrix 4

Note that the original value of valA (a list) is now replaced with a 2 dimensional list. The original variable valA is overwritten .


We can plot this relationship using the ListPlot function, so we can see in graphical form what this looks like.

Plot 1

It would be helpful if we add labels to this graph, so:

ListPlot[valA, FrameLabel → {"input values (x)", "output values (y)"}]
Plot 2
And maybe we wish to connect the dots, then use ListLinePlot:
ListLinePlot[valA, FrameLabel → {"input values (x)", "output values (y)"}]

Plot 3


Adding tolerances shows a range of values that some circuit parameter can take on, usually minimum and maximum values. Suppose we have a 1 kΩ with a tolerance of ± 1%. To do this we will create a list of values in the following manner:

R23 = 1000 {1 - 0.01, 1 + 0.01}
{990., 1010.}

Note that the variable R23 now has two values associated with it, its resistive lower limit and its
resistive upper limit. We will use this technique to replace variables with their numerical values to
include tolerances. For example, lets replace x with R23 in eqA

eqA /. x → R23
{981 090., 1.02111 × 106}


This file, in Mathematica, is known as a NOTEBOOK. In future notebooks we will explore the basic steps in creating a Worst Case Analysis including how to 1) format the equations, 2) determine the maximum and minimum numerical values for these relationships, and 3) convey the results for a reviewer or customer.

This notebook introduced you to how to a) create matrices, b) extracting parts of matrix, c) replace variables with numbers, and d) creating a list of upper and lower limits for component parameters.

Up Next

In a future post we will look at how circuit analysis is normally performed. We will explore the mathematical format we normally put these equations in to solve them. And finally we will review an author created function which puts these equations into this form, which allows ease of viewing and the ability to double-check our work.