I need to know how to represent the following as a mathematical formula using proper math notation:
I have a $1\times n$-matrix of $3$-tuples $[a, r, x]$. I need to represent the following logic mathematically:
for each element in the matrix set $x = a r-a+1$ then $X = x_0 \cdot x_1\cdot\ldots\cdot x_n$ $A = \operatorname{average}(a_0,\ldots,a_n)$ $Z = X \cdot A$
In C#:
struct Element { public double a; public double r; public double x; } private void button15_Click(object sender, EventArgs e) { // define the matrix Element[] matrix = new Element[3]; Element elem; // populate the matrix with something matrix[0] = new Element { a = 1, r = 0.9 }; matrix[1] = new Element { a = 0.75, r = 0.2 }; matrix[2] = new Element { a = 1, r = 1 }; // for each element, calculate x for (int i = 0; i < matrix.Length; i++) { elem = matrix[i]; elem.x = elem.a * elem.r - elem.a + 1; } // determine X and A elem = matrix[0]; double X = elem.x; double A = elem.a; // calculate for each element, starting at 1 for (int i = 1; i < matrix.Length; i++) { elem = matrix[i]; X *= elem.x; A += elem.a; } A /= matrix.Length; // X is equal to matrix[0].x * matrix[1].x * matrix[2].x // A is equal to Average(matrix[0].a, matrix[1].r, matrix[2].r) double Z = X * A; }