Homepage > Man Pages > Category > General Commands

Homepage > Man Pages > Name > W# wcalc

## man page of wcalc

### wcalc: a natural-expression command-line calculator

Homepage > Man Pages > Name > W

## NAME

wcalc- a natural-expression command-line calculatorSYNOPSIS

wcalc[options] [expression ...]## DESCRIPTION

wcalc is a command-line calculator designed to accept all valid mathematical expressions. It supports all standard mathematical operations, parenthesis, brackets, trigonometric functions, hyperbolic trig functions, logs, and boolean operators. wcalc accepts input in a variety of manners. I it will evaluate If no mathematical expression is given at the commandline, it will evaluate the contents of an environment variable namedwcalc_inputif one exists. If that variable is not set, wcalc will try to read input from standard input (i.e. piped input). If there is no input from that, wcalc enters "interactive" mode. Interactive mode has more features. Within wcalc, detailed information about commands, functions, symbols, and variables can be obtained by executing:\explain thing-to-explain OPTIONS -Hor--helpPrints a help usage message to standard output, then exits.-ESpecifies that numerical output should be in scientific notation.-EESpecifies that numerical output should NOT be in scientific notation.-PXXXSets the precision to beXXX. This setting only affects output, not internal representations. A setting of -1 means formats output in whatever precision seems appropriate. Precision is set to autoadjust (-1) by default. Example: wcalc -P6-vor--versionPrints the version number and exits.-dor-decor--decimalResults are printed in decimal (base 10). This option is the default, and does not have a default prefix to indicate that numbers are in base 10.-hor-hexor--hexadecimalResults are printed in hexadecimal (base 16). Numbers printed in hexadecimal have a prefix of0xunless the-por--prefixesoption is used.-oor-octor--octalResults are printed in octal (base 8). Numbers printed in octal have a prefix of0unless the-por--prefixesoption is used.-bor-binor--binaryResults are printed in binary (base 2). Numbers printed in binary have a prefix of0bunless the-por--prefixesoption is used.-por--prefixesToggles printing prefixes for hexadecimal, octal, and binary forms.-lor--lenientMakes the parser assume that uninitialized variables have a value of zero.-ror--radiansToggles whether trigonometric functions assume input (and output) is in radians. By default, trigonometric functions assume input is in degrees.-qor--quietToggles whether the equals sign will be printed before the results.-cor--conservativeToggles precision guards. Because of the way floating point numbers are stored, some operations, like 1-.9-.1, can return an extremely small number that is not zero but is less than the official precision of the floating point number and thus for all intents and purposes, it is 0. The precision guard will round numbers to zero if they are less than the official precision of the floating point number. However, sometimes numbers that small or smaller need to be displayed, and thus the precision guard should be turned off.--rememberToggles whether or not expressions that produce errors are remembered in the history. Does not affect command-line math.--round={none|simple|sig_fig} Wcalc can attempt to warn you when numbers have been rounded in the output display. It has two methods of keeping track---either by using significant figures (sig_fig), or by a simple digit-counting algorithm. Rounding in the command-line version is denoted by a tilde before the equals sign (~=). Rounding in the GUI version is denoted by changing the text color to red. In some cases, Wcalc may think that the number has been rounded even if it shouldn't have been necessary (this is because of the way floating point numbers are represented internally).--dsep=XSets the decimal separator character to be X.--tsep=XSets the thousands separator character to be X.--idsep=XSets the input-only decimal separator character to be X.--itsep=XSets the input-only thousands separator character to be X.--bitsXXXXSets the number of bits of precision that will be used to internally represent numbers to beXXXX. The default is 1024. Set higher if you need more precision, set lower if you want to use less memory.--intsToggles whether long integers will be abbreviated or not. This conflicts with engineering notation for large numbers, but not for decimals.## USER-DEFINED VARIABLES

Variables are supported and may be assigned using the = operator. To assign a variable use the form: foo = anylegalexpression Thereafter, that variable name is the same as the literal value it represents. Expressions can be stored in variables like this: foo = 'anylegalexpression' Expressions stored this way will be interpreted at evaluation time, rather than assignment-time. Note that these cannot be recursive. All variables may also be stored with a description of what they are. This description is added in the form of a quoted string after the assignment, like this: foo = 'anylegalexpression' 'description'ACTIVE VARIABLESActive variables are designed to give a functionality similar to user- defined functions. They are variables that rather than representing a value, represent an expression that is evaluated whenever the variable is evaluated. This expression may contain other variable names. For example, after the following sequence of commands: foo=5 bar='foo+4' The variablebarwill evaluate to 9, or four more than whateverfooevaluates to be. These can be stacked, like so: baz='sin(bar)+foo' In this case,bazwill evaluate to be 5.15643, or the sin of whateverfoo+4 is plus whateverfoois. To demonstrate the utility of these active variables, here are two functions written by Stephen M. Lawson. The first computes the weekday of a given day (dy) in a given month (mo) in a given year (yr). The value it returns is in the range of 1 to 7, where 1 is Sunday, 2 is Monday, 3 is Tuesday, and so forth. weekday='(((floor((yr - floor(0.6 + 1 / mo)) / 400) - floor((yr - floor(0.6 + 1 / mo)) / 100) + floor((5 * (yr - floor(0.6 + 1 / mo))) / 4) + floor(13 * (mo + 12 * floor(0.6 + 1 / mo) + 1) / 5)) - (7 * floor((floor((yr - floor(0.6 + 1 / mo)) / 400) - floor((yr - floor(0.6 + 1 / mo)) / 100) + floor((5 * (yr - floor(0.6 + 1 / mo))) / 4) + floor(13 * (mo + 12 * floor(0.6 + 1 / mo) + 1) / 5)) / 7)) + 1) + 5 + dy) % 7 + 1' The second function computes what day Easter will be for a given year (yr) and returns an offset from March 31st. For example, for the year 2005, it returns -4, which means March 27th. Because of leap-year problems, this only works from the year 1900 to 2099, but is a good demonstration nevertheless. easter='((19 * (yr - 19 * floor(yr / 19)) + 24) - floor((19 * (yr - 19 * floor(yr / 19)) + 24) / 30) * 30) + ((2 * (yr - 4 * floor(yr / 4)) + 4 * (yr - 7 * floor(yr / 7)) + 6 * ((19 * (yr - 19 * floor(yr / 19)) + 24) - floor((19 * (yr - 19 * floor(yr / 19)) + 24) / 30) * 30) + 5) - floor((2 * (yr - 4 * floor(yr / 4)) + 4 * (yr - 7 * floor(yr / 7)) + 6 * ((19 * (yr - 19 * floor(yr / 19)) + 24) - floor((19 * (yr - 19 * floor(yr / 19)) + 24) / 30) * 30) + 5) / 7) * 7) - 9'## BUILT-IN SYMBOLS

There are two basic kinds of built-in symbols in wcalc: functions and constants.FUNCTIONSThe functions supported in wcalc are almost all self-explanatory. Here are the basic descriptions.sin cos tan cotThe standard trigonometric functionsasin acos atan acotorarcsin arccos arctan arccotorsin^-1 cos^-1 tan^-1 cot^-1The standard arc- trigonometric functions.sinh cosh tanh cothThe standard hyperbolic trigonometric functions.asinh acosh atanh acothorarcsinh arccosh arctanh arccothorsinh^-1 cosh^-1 tanh^-1 coth^-1The standard arc- hyperbolic trigonometric functions.log ln logtwoLog-base-ten, log-base-e and log-base-two, respectively. Remember, you can also construct log-base-X of number Y by computing log(Y)/log(X).roundReturns the integral value nearest to the argument according to the typical rounding rules.absReturns the absolute value of the argument.ceil ceiling floorReturns the ceiling or floor of the argument.sqrt cbrtThe square and cube root functions.randReturns a random number between 0 and the number given.irandReturns a random integer between 0 and the number given.factReturns the factorial of a number.GammaReturns the value of the Gamma function at that value.lnGammaReturns the value of the log Gamma function at that value.zetaReturns the value of the Riemann zeta function at that value.sincReturns the sinc function (for sinus cardinalis) of the input, also known as the interpolation function, filtering function or the first spherical Bessel function, is the product of a sine function and a monotonically decreasing function.CONSTANTSWcalc supports a lot of constants. Some are special (likepi), and some are simply mathematical or physical constants that have been hardcoded in. The physics constants are taken from//physics.nist.gov/constants, and should all be in predictable SI units. The value ofpiis special, as it is calculated to however many bits of precision have been specified with the\bitscommand. The default number of bits is 1024, or a value of: 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245869974724822361502823407955151120558811684656967313093357387193011055974127397801166600823447367841524950037348489795545416453901986117572722731871388422643588974212021713194956805142308399313566247553371620129340026051601856684677033122428187855479365508702723110143458240736806341798963338923286460351089772720817919599675133363110147505797173662675795471777702814318804385560929672479177350549251018537674006123614790110383192502897923367993783619310166679013187969315172579438604030363957033826325935372151289640167976948453904619615481368332936937026831888367580239969088932697527811653282224950410336573385944190516446146423694037380609059088222036945727944116946240616684848934170304346480406820774078369140625 Similarly, all values that rely on the value ofpi, like mu0, have the same level of precision. Here is a complete list of the symbols used to represent the constants hardcoded into wcalc:eThe logarithm constant: 2.718281828459045235360287471352662497757247093699959574966gammaEuler's Constant: 0.57721566490153286060651209008240243104215933593992359880576723488486772677766467093694706329174674951463144724980708248096050401448654283622417399764492353625350033374293733773767394279259525824709491600873520394816567KCatalan Constant: 0.91596559417721901505460351493238411077414937428167213426649811962176301977625476947935651292611510624857442261919619957903589880332585905943159473748115840699533202877331946051903872747816408786590902gAcceleration due to gravity: 9.80665 m/s/sCcCoulomb's Constant: 8987551787.37Universal Constants Z0orZzeroImpedance of Vacuum: 376.730313461 ohmsepsilon0orepsilonzeroPermittivity of Free Space: 8.854187817e-12 F/mmu0ormuzeroPermeability of Free Space calculated as 4*pi*10^-7.GGravitational Constant: 6.67259e-11hPlanck Constant: 6.6260755e-34cSpeed of Light: 299792458Electromagnetic Constants muBBohr Magneton: 5.78838174943e-11 J/TmuNNuclear Magneton: 3.15245123824e-14 J/TG0Conductance Quantum: 7.748091733e-5 SecElementary Charge: 1.60217653e-19KjJosephson Constant: 483597.879e9 Hz/VRkVon Klitzing Constant: 25812.807449 omegaAtomic and Nuclear Constants MalphaAlpha Particle Mass: 6.6446565e-27 kga0Bohr Radius: 5.291772108e-11 mMdDeuteron Mass: 3.34358335e-27 kgMeElectron Mass: 9.1093897e-31 kgreElectron Radius: 2.817940325e-15 meVElectron Volt: 1.602177250e-12 JGfFermi Coupling Constant: 1.16638e-5 GeV^-2alphaFine Structure Constant: 7.29735253327e-3ehHartree Energy: 4.35974417e-18 JMhHelion Mass: 5.00641214e-27 kgMmuMuon Mass: 1.88353140e-28 kgMnNeutron Mass: 1.67492728e-27 kgMpProton Mass: 1.67262171e-27 kgRinfRydberg Constant: 10973731.568525 1/mMtTau Mass: 3.16777e-27 kgPhysio-Chemical Constants uAtomic Mass Constant: 1.66053886e-27 kgNaorNAAvogadro's Constant: 6.0221367e23kBoltzmann Constant: 1.3806505e-23FFaraday Constant: 96485.3383 C/molc1First Radiation Constant: 3.74177138e-16 W m^2n0ornzeroLoschmidt Constant: 2.6867773e25 m^-3RMolar Gas Constant: 8.314472VmorNAkMolar Volume of Ideal Gas: 22.413996e-3 (m^3)/molc2Second Radiation Constant: 1.4387752e-2 m KsigmaStefan-Boltzmann Constant: 5.670400e-8bWien Displacement Law Constant: 2.8977686e-3 m KRandom Constants randomA Random ValueirandomA Random Integer## COMMANDS

There are several commands that are supported in wcalc.\pXXXSets the precision toXXX. This setting only affects output, not internal representations. A setting of -1 means formats output in whatever precision seems appropriate.\eor\engor\engineeringRotates between always using scientific notation, never using scientific notation, and choosing to do scientific notation when convenient. Can also take an argument that is one ofalways,never, andautomaticto choose a mode directly.\helpor?Displays a help screen.\prefsPrints out the current preference settings.\lior\listor\listvarsPrints out the currently defined variables.\ror\radiansToggles between using and not using radians for trigonometric calculations.\consor\conservativeToggles precision guards. Because of the way floating point numbers are stored, some operations, like 1-.9-.1, can return an extremely small number that is not zero but is less than the official precision of the floating point number and thus for all intents and purposes, it is 0. The precision guard will round numbers to zero if they are less than the official precision of the floating point number. However, sometimes numbers that small or smaller need to be displayed, and thus the precision guard should be turned off.\por\pickyor\lor\lenientToggles variable parsing rules. When wcalc is "picky" it will complain if you use undefined variables. If it is "lenient", wcalc will assume a value of 0 for undefined variables.\reor\rememberor\remember_errorsToggles whether or not expressions that produce errors are remembered in the history.\preor\prefixor\prefixesToggles the display of prefixes for hexadecimal, octal, and binary output.\bor\binor\binaryResults are printed in binary (base 2). Numbers printed in binary have a prefix of0bunless the\prefixescommand is used.\dor\decor\decimalResults are printed in decimal (base 10). This option is the default, and does not have a default prefix to indicate that numbers are in base 10.\hor\xor\hexor\hexadecimalResults are printed in hexadecimal (base 16). Numbers printed in hexadecimal have a prefix of0xunless the\prefixescommand is used.\oor\octor\octalResults are printed in octal (base 8). Numbers printed in octal have a prefix of0unless the\prefixescommand is used.\round none|simple|sig_figWcalc can attempt to warn you when numbers have been rounded in the output display. It has two methods of keeping track---either by using significant figures (sig_fig), or by a simple digit- counting algorithm. Rounding in the command-line version is denoted by a tilde before the equals sign (~=). Rounding in the GUI version is denoted by changing the text color to red. In some cases, Wcalc may think that the number has been rounded even if it shouldn't have been necessary (this is because of the way floating point numbers are represented internally).\dsepXSets the decimal separator character to beX.\tsepXSets the thousands-place separator character to beX.\idsepXSets the input-only decimal separator character to beX.\itsepXSets the input-only thousands-place separator character to beX.\hlimitXSets the limit (X) on the length of the history.\openXXXXXLoads fileXXXXX.\saveXXXXXSaves the history and variable list to a file,XXXXX.\bitsXXXXSets the number of bits of precision that will be used to internally represent numbers to beXXXX. The default is 1024. Set higher if you need more precision, set lower if you want to use less memory.\intsToggles whether long integers will be abbreviated or not. This conflicts with engineering notation for large numbers, but not for decimals.\prefsor\preferencesDisplays the current preference settings.\convert unit1 unit1Converts the previous answer fromunit1tounit2.\store variablenameSaves the specified variable in the preload file, ~/.wcalc_preload\explain objectExplains the specified object. The object can be a variable, constant, function, or command.\verboseVerbose mode displays the expression to be calculated before calculating it.\delor\delimor\delimitersDisplay delimiters in numerical output.\cmodToggle between C-style modulus operation and a more flexible method.## PREFERENCES

Preferences and settings can be retained between invocations of wcalc by storing them in the file~/.wcalcrcThe format of the file is that each line is either blank or an assignment. Comments are ignored, and are defined as anything to the right of and including a hash mark (#). Assignments are of the form:key=valueThe possible keys are:precisionA number defining the display precision. Equivalent to the\Pcommand, where -1 means "auto" and anything else specifies the number of decimal places. This does not affect the behind-the- scenes precision.show_equalsEither true ("yes" or "true") or false (anything else). Equivalent to the--quietargument. Specifies whether answers will begin with an equals sign or not.engineeringEither "always", "never", or "automatic". Equivalent to the\engineeringcommand. Specifies whether answers will be displayed in engineering notation or not.use_radiansEither true ("yes" or "true") or false (anything else). Equivalent to the\radianscommand. Specifies whether trigonometric functions accept input in radians or degrees.print_prefixesEither true ("yes" or "true") or false (anything else). Equivalent to the\prefixescommand. Specifies whether base prefixes (e.g. 0x for hexadecimal numbers) are used when displaying output.save_errorsEither true ("yes" or "true") or false (anything else). Equivalent to the\remember_errorscommand. Specifies whether lines that contain a syntax error are added to the history or not.precision_guardEither true ("yes" or "true") or false (anything else). Equivalent to the\conservativecommand. Specifies whether the display will attempt to eliminate numbers too small to be accurate (hopefully, these are only errors created by the binary approximation of the inputs).print_integersEither true ("yes" or "true") or false (anything else). Equivalent to the\intscommand. Specifies whether whole integers will be printed un-abbreviated or not. This conflicts with engineering notation for large integers, but not for decimals.print_delimitersEither true ("yes" or "true") or false (anything else). Equivalent to the\delimiterscommand. Specifies whether delimiters will be added to output when displaying.thousands_delimiterUses the next character after the equals sign as its value. Equivalent to the\tsepcommand. Specifies what the thousands delimiter is, and can affect output ifprint_delimitersis enabled.decimal_delimiterUses the next character after the equals sign as its value. Equivalent to the\dsepcommand. Specifies what the decimal delimiter is.input_thousands_delimiterUses the next character after the equals sign as its value. Equivalent to the\itsepcommand. Specifies what the input-only thousands delimiter is, and cannot affect output.input_decimal_delimiterUses the next character after the equals sign as its value. Equivalent to the\idsepcommand. Specifies what the input-only decimal delimiter is, and cannot affect output.history_limitEither "no", for no limit, or a number. Equivalent to the\hlimitcommand.output_formatEitherdecimal,octal,binary,hex, orhexadecimal.rounding_indicationEitherno,simple, orsig_fig. Equivalent to the\roundingcommand.c_style_modEither true ("yes" or "true") or false (anything else). Equivalent to the\cmodcommand. Specifies whether the modulo operator (%) will behave as it does in the C programming language, or whether it will use a more flexible method. This only affects modulo operations where negative numbers are involved. As an example, withc_style_modset to true (the default): -340 % 60 == -40; 340 % -60 == 40; -340 % -60 == -40 However, withc_style_modset to false: -340 % 60 == -40; 340 % -60 == -20; -340 % -60 == 20PRELOAD

Wcalc uses a file,~/.wcalc_preload, to store persistent information between instances. Typically, this is used to store variables that are frequently defined. This file can be edited by hand with a standard text editor. There is also a command within wcalc (\store) to append a variable definition to the end of this file. Any variable defined in this file is defined and available for use in any subsequent invocation of wcalc.## COPYRIGHT

wcalc is Copyright (C) 2000-2007 Kyle Wheeler. It is distributed under the GPL, version 2, or (at your option) any later version..## SUGGESTIONS AND BUG REPORTS

Any bugs found should be reported to Kyle Wheeler at kyle-wcalc@memoryhole.net. WCALC(1)

Copyright © 2011–2018 by topics-of-interest.com . All rights reserved. Hosted by all-inkl.

Contact · Imprint · Privacy

Page generated in 39.18ms.

tier-bedarf.com | doomsdaydude.com | Internet and Network