Output formats, and conversions to radians etc.
In general, Euler either sets an output format for all numbers of a specific type, or uses functions to print a value in some format. E.g., one can select fracformat or use printfrac.
Note that the default format for Euler is longformat with 12 digits of precision. Zero rounding is on so that very small numbers print as 0. Dense output is on. This prints row vectors in a very dense form with brackets.
function rad () rad(d[,min,sec]) converts to radians rad(x) transfers degree x to radians. If min and sec are present, these will be used to set minutes and seconds of the angle. x° works too instead of rad(x). See:
degprint (Output Formats)
function deg (x:real) deg(x) transfers radians x to degrees See:
rad (Output Formats),
degprint (Output Formats)
function degprint (x : real scalar, dms:integer=1) Print radians x in degrees. This function returns a string with a representation of the radial angle x in degrees. By default, the function will print minutes and seconds. Turn this off with <dms. See:
degformat (Output Formats)
function degformat (on:integer=1) Use degree format from now on. This calls _useformat with the degprint function. See:
userformat (Euler Core),
degprint (Output Formats)
function polarprint (x:complex scalar, format="%g") Print x in polar form, if it is complex. Prints the complex number in the form (r,phi°). The format for r can be set with format="...". >load format; polarprint(1+I,format="%0.12g") (1.41421356237,45°) See:
polarformat (Output Formats),
polar (Mathematical Functions),
polar (Maxima Documentation)
function polarformat (on:integer=1) Sets the format to polar form. See:
userformat (Euler Core),
polarprint (Output Formats)
function ipmprint (x:interval scalar) Print an interval using plus-minus notation. >ipmprint(~1,2~) 1.5±0.5 See:
ipmformat (Output Formats)
function ipmformat (on:integer=1) Set the format to plus-minus notation See:
ipmprint (Output Formats)
function print (x:real scalar, digits:integer=2, length:integer=10, .. unit:string="") Print the real number x formatted. The default format is two digits after the comma, and a total length of 10 digits. An optional unit can be added. Note that "x="+x is also a very nice way to print the variable x. Morever, "type x" will print the variable x. For units, there is the conversion operator ->. >print(101/891,unit="%") 0.11% >2.5miles->" km" 4.02336 km See:
printf (Euler Core),
printf (Maxima Documentation)
function format format(n,m) sets the output format to m digits and width n. Turns zero rounding and dense output off. Then calls the builtin function _format, which sets the output width to n places, and the precision digits to m. >format(6,2); (1:10)/3, longformat; // reset to default 0.33 0.67 1.00 1.33 1.67 2.00 2.33 2.67 3.00 3.33 >format(20,5); (1:4)'/3, longformat; // reset to default 0.33333 0.66667 1.00000 1.33333 See:
zerorounding (Euler Core),
denseoutput (Euler Core)
function goodformat goodformat(n,m) sets the output format to m digits and width n. This turn zero rounding on and dense output on. Then it calls the builtin function _goodformat, which sets the width to m digits and the precession to n digits. The width will only be used for matrix output with more than one row due to the dense output format. The difference to format is that the output uses no decimal dot, if possible. Moreover, the dense output prints row vectors with brackets. >goodformat(6,2); (1:10)/3, longformat; // reset to default [ 0.33 0.67 1 1.3 1.7 2 2.3 2.7 3 3.3 ] >goodformat(6,2); (1:4)'/3, longformat; // reset to default 0.33 0.67 1 1.3 See:
zerorounding (Euler Core),
denseoutput (Euler Core)
function expformat expformat(n,m) sets the output format to m digits and width n. Turns zero rounding off and dense output on. This works like format, but uses exponential output always. It calls the builtin function _expformat. >expformat(6,2); (1:10)/3, longformat; // reset to default [ 3.33e-001 6.67e-001 1.00e+000 1.33e+000 1.67e+000 2.00e+000 2.33e+000 2.67e+000 3.00e+000 3.33e+000 ] See:
zerorounding (Euler Core),
denseoutput (Euler Core)
function fixedformat fixedformat(n,m) sets the output format to m digits and width n. This works like expformat, but always uses fixed point format. It calls the builtin function _fixedformat. Turns zero rounding on. Zero rounding is used to round very small numbers to 0. See:
zerorounding (Euler Core),
denseoutput (Euler Core)
function longestformat Sets a very long format for numbers. Turns zero rounding and dense output off. Uses a format, that allows to see the internal accuracy of IEEE double precision. See:
zerorounding (Euler Core),
denseoutput (Euler Core)
function longformat Sets a long format for numbers This is the default format for Euler with 12 digits precision. Turns zero rounding and dense output on, and uses a good format, which does not show a decimal dot if possible. See:
goodformat (Output Formats)
function shortformat Sets a short format for numbers. See:
longformat (Output Formats)
function shortestformat Sets a very short format for numbers. See:
longformat (Output Formats)
function fracformat (n:integer=0, eps=1e-10) Sets the fractional format. Turns zero rounding on. If n>0 it turns dense output off. A continued fraction is used to approximate the numbers with fractions. The accuracy can be set with eps. >fracformat; (1:10)/3, longformat; [ 1/3 2/3 1 4/3 5/3 2 7/3 8/3 3 10/3 ] >fracformat(10); (1:4)'/3, longformat; 1/3 2/3 1 4/3
function fracprint (x:numerical, n:integer=10, eps=1e-10) Prints x in fractional format with n places. Uses a temporary format to print a value in fractional format. The format is then reset to the default longformat. >fracprint(pi,eps=0.01) 22/7
function frac (x:numerical, mixed:integer=0) Returns a string containing the fractional representation of x. This can be used to convert a number to a fraction contained in a string. If mixed, then the integer part is separated from the fractional part. The function uses the builtin function _frac to find a continued fraction, which approximates the number. The function can also be used for vectors and matrices to convert decimals into good fractions, e.g. for Maxima. >frac(2/3+5/4,>mixed) 1+11/12 >(1:4)/3; &% [0.33333333333333, 0.66666666666667, 1, 1.333333333333333] >frac((1:4)/3); &% 1 2 4 [-, -, 1, -] 3 3 3 See:
fracformat (Output Formats)