03-Oct-2012 1> realmax ans = 1.7977e+308 2> realmin ans = 2.2251e-308 3> eps ans = 2.2204e-16 4> 2^(-53) ans = 1.1102e-16 5> a = 1 a = 1 6> toascii('~') ans = 126 7> % per battere "~": tenenere abbassato il tasto ALT e 7> % digitare 126 sul tastierino numerico 7> while 1 ~= 1 + a a = a/2; end; 8> a a = 1.1102e-16 9> b = 1/10 b = 0.10000 10> for k = 1:20 b = b*11-1, end; b = 0.10000 b = 0.10000 b = 0.10000 b = 0.10000 b = 0.10000 b = 0.10000 b = 0.10000 b = 0.10000 b = 0.10000 b = 0.10000 b = 0.10000 b = 0.10003 b = 0.10028 b = 0.10307 b = 0.13373 b = 0.47101 b = 4.1812 b = 44.993 b = 493.92 b = 5432.1 11> format long 12> b = 1/10 b = 0.100000000000000 13> for k = 1:20 b = b*11-1, end; b = 0.100000000000000 b = 0.100000000000001 b = 0.100000000000011 b = 0.100000000000118 b = 0.100000000001300 b = 0.100000000014304 b = 0.100000000157346 b = 0.100000001730808 b = 0.100000019038893 b = 0.100000209427825 b = 0.100002303706079 b = 0.100025340766873 b = 0.100278748435598 b = 0.103066232791576 b = 0.133728560707335 b = 0.471014167780683 b = 4.18115584558752 b = 44.9927143014627 b = 493.919857316090 b = 5432.11843047698 14> help format `format' is a built-in function -- Command: format -- Command: format options Reset or specify the format of the output produced by `disp' and Octave's normal echoing mechanism. This command only affects the display of numbers but not how they are stored or computed. To change the internal representation from the default double use one of the conversion functions such as `single', `uint8', `int64', etc. By default, Octave displays 5 significant digits in a human readable form (option `short' paired with `loose' format for matrices). If `format' is invoked without any options, this default format is restored. Valid formats for floating point numbers are listed in the following table. `short' Fixed point format with 5 significant figures in a field that is a maximum of 10 characters wide. (default). If Octave is unable to format a matrix so that columns line up on the decimal point and all numbers fit within the maximum field width then it switches to an exponential `e' format. `long' Fixed point format with 15 significant figures in a field that is a maximum of 20 characters wide. As with the `short' format, Octave will switch to an exponential `e' format if it is unable to format a matrix properly using the current format. `short e' `long e' Exponential format. The number to be represented is split between a mantissa and an exponent (power of 10). The mantissa has 5 significant digits in the short format and 15 digits in the long format. For example, with the `short e' format, `pi' is displayed as `3.1416e+00'. `short E' `long E' Identical to `short e' or `long e' but displays an uppercase `E' to indicate the exponent. For example, with the `long E' format, `pi' is displayed as `3.14159265358979E+00'. `short g' `long g' Optimally choose between fixed point and exponential format based on the magnitude of the number. For example, with the `short g' format, `pi .^ [2; 4; 8; 16; 32]' is displayed as ans = 9.8696 97.409 9488.5 9.0032e+07 8.1058e+15 `short eng' `long eng' Identical to `short e' or `long e' but displays the value using an engineering format, where the exponent is divisible by 3. For example, with the `short eng' format, `10 * pi' is displayed as `31.4159e+00'. `long G' `short G' Identical to `short g' or `long g' but displays an uppercase `E' to indicate the exponent. `free' `none' Print output in free format, without trying to line up columns of matrices on the decimal point. This also causes complex numbers to be formatted as numeric pairs like this `(0.60419, 0.60709)' instead of like this `0.60419 + 0.60709i'. The following formats affect all numeric output (floating point and integer types). `+' `+ CHARS' `plus' `plus CHARS' Print a `+' symbol for nonzero matrix elements and a space for zero matrix elements. This format can be very useful for examining the structure of a large sparse matrix. The optional argument CHARS specifies a list of 3 characters to use for printing values greater than zero, less than zero and equal to zero. For example, with the `+ "+-."' format, `[1, 0, -1; -1, 0, 1]' is displayed as ans = +.- -.+ `bank' Print in a fixed format with two digits to the right of the decimal point. `native-hex' Print the hexadecimal representation of numbers as they are stored in memory. For example, on a workstation which stores 8 byte real values in IEEE format with the least significant byte first, the value of `pi' when printed in `native-hex' format is `400921fb54442d18'. `hex' The same as `native-hex', but always print the most significant byte first. `native-bit' Print the bit representation of numbers as stored in memory. For example, the value of `pi' is 01000000000010010010000111111011 01010100010001000010110100011000 (shown here in two 32 bit sections for typesetting purposes) when printed in native-bit format on a workstation which stores 8 byte real values in IEEE format with the least significant byte first. `bit' The same as `native-bit', but always print the most significant bits first. `rat' Print a rational approximation, i.e., values are approximated as the ratio of small integers. For example, with the `rat' format, `pi' is displayed as `355/113'. The following two options affect the display of all matrices. `compact' Remove blank lines around column number labels and between matrices producing more compact output with more data per page. `loose' Insert blank lines above and below column number labels and between matrices to produce a more readable output with less data per page. (default). See also: fixed_point_format, output_max_field_width, output_precision, split_long_rows, rats Additional help for built-in functions and operators is available in the on-line version of the manual. Use the command `doc ' to search the manual index. Help and information about Octave is also available on the WWW at http://www.octave.org and via the help@octave.org mailing list. 15> format bit 16> 1/10 ans = 0011111110111001100110011001100110011001100110011001100110011010 17> -1/10 ans = 1011111110111001100110011001100110011001100110011001100110011010 18> eps ans = 0011110010110000000000000000000000000000000000000000000000000000 19> format 20> eps ans = 2.2204e-16 21> eps/2*11^20 ans = 7.4690e+04 22> 2^(-54)*11^20 ans = 3.7345e+04 23> % cancellazione numerica, Quarteroni-Saleri, p. 7 23> x = 1.e-100 x = 1.0000e-100 24> ((1+x)-1)/x ans = 0 25> x = 1.e-16 x = 1.0000e-16 26> ((1+x)-1)/x ans = 0 27> x = 1.e-8 x = 1.0000e-08 28> ((1+x)-1)/x ans = 1.00000 29> x = 1.e-12 x = 1.0000e-12 30> ((1+x)-1)/x ans = 1.0001 31> x = 1.e-14 x = 1.0000e-14 32> ((1+x)-1)/x ans = 0.99920 33> x = linspace(1-1.e-8, 1+1.e-8); 34> y = (x-1).^7; 35> plot(x,y) 36> p = poly([1 1 1 1 1 1 1]) p = 1 -7 21 -35 35 -21 7 -1 37> yy = polyval(p,x); 38> hold on 39> plot(x,yy,'r') 40> realmax + 1 ans = 1.7977e+308 41> realmax + 2 ans = 1.7977e+308 42> realmax + 100 ans = 1.7977e+308 43> 2*realmax ans = Inf 44> 0/0 warning: division by zero ans = NaN 45> 4:7 ans = 4 5 6 7 46> 4:2:7 ans = 4 6 47> 4:0.5:7 ans = 4.0000 4.5000 5.0000 5.5000 6.0000 6.5000 7.0000 48> 7:-0.5:4 ans = 7.0000 6.5000 6.0000 5.5000 5.0000 4.5000 4.0000 49> for k = 1:4 k^2, end ans = 1 ans = 4 ans = 9 ans = 16 50> k = 1 51> while k^2<30 k^3, k=k+1; end ans = 1 ans = 8 ans = 27 ans = 64 ans = 125 52> quit