## Organization

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

**, you get a Matrix of values.**

*Lists*AMatrix = {AList, BList};

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

MatrixForm[AMatrix]

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}};

MatrixForm[BMatrix]

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

CMatrix = {{AList, BList}};

MatrixForm[CMatrix]

##### ◼ 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:

AMatrix[[1]]

{1, a, 2, b}

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

AMatrix[[1,3]]

2

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

### Replacement and tolerances

##### ◼ Replacement Rules

Suppose we have an equation, we will call eqA:

eqA = x^{2}+ x

x + x^{2}

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

eqA /. x → 2

6

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

eqA

x + x^{2}

##### ◼ 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}]; MatrixForm[valA]

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

### Plotting

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

ListPlot[valA]

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

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

ListLinePlot[valA, FrameLabel → {"input values (x)", "output values (y)"}]

##### ◼ Tolerances

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 × 10^{6}}

#### Review

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.