The “length” of a object (heuristic complexity)
MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.
MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.
length(object) returns an integer indicating
the complexity of the object.
The (heuristic) complexity of an object may be useful in algorithms that need to predict the complexity and time for manipulating objects. E.g., a symbolic Gaussian algorithm for solving linear equations prefers Pivot elements of small complexity.
The length of an object is determined as follows:
Objects of domain type
DOM_PROC_ENV are regarded as “atomic”. They have length 1. In particular, the length of identifiers and real floating-point numbers is 1.
The length of an integer is (a close approximation of) the number of decimal digits, including the sign.
The length of a string is the number of its characters.
length() yields 0.
length does not return
the number of elements or entries in sets, lists or tables. Use
Intuitively, the length measures the complexity of an object:
length(1 + x) < length(x^3 + exp(a - b)/ln(45 - t) - 1234*I)
We compute the lengths of some simple objects:
length(1.2), length(-1234.5), length(123456), length(-123456)
length(17), length(123), length(17/123)
length(12), length(123), length(12 + 123*I)
length(x), length(x^2), length(x^12345)
The length of an array is the sum of the lengths of all its elements plus 1:
A := array(1..2, [x, y]): length(A) = length(x) + length(y) + 1
A := 12345: length(A) = length(12345) + length(y) + 1
A := hfarray(1..10, [1.0 $ 10]): length(A) = 10*length(1.0) + 1
A := hfarray(1..10, [1.0 + 2.0*I $ 10]): length(A) = 10*length(1.0 + 2.0*I) + 1
Beware: If only one complex number is contained in an hfarray, then all entries are regarded as complex numbers, even if they are real:
A := hfarray(1..10, [2.0 $ 9, 2.0 + 3.0*I]): length(A) = 10*length(2.0 + 3.0*I) + 1
The operands of a table are the equations associating indices and entries. The length of each operand is the length of the index plus the length of the corresponding entry plus 1:
T := 45: T
length(T) = length(1 = 45) + 1
An arbitrary MuPAD® object