Tip 88. Sparse matrix in Mathcad

  

Fig. 88. Two-dimensional approximation by sparse matrix

In the fig. 88 the program is aimed for approximation (smoothing) a tabular dependence of a function of two arguments: the function is given by user but the program gives its coefficients.

We have considered  the same function for solution one-dimensional problem in T tip 81: fig. 88.  But it evolution of the problem in the fig. 81 for two-dimensional problem[1].

Initial tabular data are noted in a matrix M in the fig. 88. Empty places in the matrix are elements that equal infinity (10307) and have the style “in white and white” but not empty place of the sparse matrix (the operator of input the matrix M is duplicated on pink background so that all its elements were visible). When we decompose the matrix M on the vectors X, Y and Z the given “infinite” elements are ignored. So in the fig. 88 there are thirty initial elements in the matrix M (5 lines and 6 columns), but there 25 elements in the vectors X, Y and Z.

By this fig. 88 we finish the series of tips that touch the theme “Invisible symbol on the display”. Such symbol helps us:

·        to have blank as the symbol of the sum operator[2] (the tip 13);

·        to introduce into calculations invisible functions and, for example, to simulate “Roman” arithmetic with help of them (the tip 19);

·        to output the value of zero dimensional variable sine unit of measure (the tip 60);

·        to work with degree Celsius and Fahrenheit degree without any problems (the tip 64);

·        to leave out the description of Boolean constant in infinite cycle (see first function Root in the fig. 84);

·        to add empty programming lines for separation the line’s group of operators  in Mathcad-programs (for it we write some numerical constant with the style “in white and white” on the line);

·        to simulate sparse matrixes and vectors (fig. 88).



[1] Solution of two-dimension problem interpolation with help of spline is showed in the fig. 52.

[2] This is user’s method. Built-in method is the blank instead of multiplication sign (see the tip 9).