# 2.7: Untitled Page 19

## Chapter 2

### where

is the ambient pressure. One should note that the gauge pressure may o

p

be negative if the pressure in the system is less than

.

o

p

2.5 Array Operations

In general, one needs more than one quantity or number to define the properties of an object. For example, to define the density of a solution one needs both the mass and the volume, and to define the position of a point in three-dimensional space one needs a set of three numbers known as coordinates.

When defining the chemical composition of mixtures, one must specify the concentration of each of the species present in the mixture. A gaseous mixture is not specified simply stating that it contains ten moles. One must specify, for example, that there are three moles of water, two moles of oxygen, and five moles of hydrogen.

To deal with the multi‐dimensional aspects of the real world, one needs to organize sets of numbers (or symbols, names, functions, etc.) into ordered, recognizable structures and one needs to define ways to perform mathematical operations on these structures. In other words, one needs to define an algebra associated with the structures so that one can add, subtract, multiply, and divide the elements of the structure. To represent groups of numbers, we will often work with arrays which are ordered sets of numbers. Two‐dimensional arrays are organized into rows and columns while higher dimension arrays are organized in pages similar to the pages of a spreadsheet. Unlike matrices, the numbers forming the elements of an array may be of a totally different kind.

Some of the numbers may represent pressures, other temperatures, and some may represent concentrations. The only requirement for the definition of an array is that all elements are organized in a pre‐determined manner.

There are many array operations that are crucial to the efficient use of computers. In this text, we identify arrays by the use of braces, { } , and three examples of one‐dimensional arrays are given by

 1

c

c

a a a a  ,

b b b b

2

1

2

3

4

1

2

3

4

,

(2‐20)

c

 3 

c

 4 

In terms of the first two arrays, we define the operation of addition according to

Units

25

1

a

a 2 a 3 a 4 

 1 b 2 b 3 b 4 b

(2‐21)

  

1

a

1

b

a 2

2

b

a 3

3

b

a 4

4

b

However, we cannot add the following arrays

 1

c

c

 

 

1

a

a 2 a 3 a 4 

2

Error!

(2‐22)

c

 3 

c

 4 

because array addition is only defined for conforming arrays. In order for arrays to conform, they must have the same number of rows and columns, thus the following addition of arrays is possible:

1

a

1

c

1

a

c 1 

a

c

a c

2

2

2

2

  

  

(2‐23)

a

 3

c

 3 

 3

a

c 3 

a

4 

c 4 

a 4 c 4 

This type of operation is common in many types of analysis, and when the arrays, or lists, become very large the computational problem becomes very tedious. Any repetitive computation can be accomplished by software programs, and in the following paragraph we list several array operations that are especially useful.

Array multiplication by a scalar is defined according to s

1

a

a 2 a 3 a 4 

s 1 a sa 2 sa 3 sa 4 

(2‐24)

while array multiplication by an array takes the form

1

a

a 2 a 3 a 4   1

b

2

b

3

b

4

b

 1 a 1 b a 2 2 b 3 a 3 b a 4 4 b  (2‐25) Array division by a scalar is defined in the obvious manner, while array division by an array takes the form

 1 a a 2 a 3 a 4 

  1

a / 1

b

a 2 / 2

b

a 3 / 3

b

a 4 / 4

b

(2‐26)

1

b

2

b

3

b

4

b

An array can be raised to a scalar power according to b

b

b

b

b

1

a

a 2 a 3 a 4 

 1 a a 2 a 3 a 4 

(2‐27)

26