1QALC(1) General Commands Manual QALC(1)
2
3
4
6 qalc - Powerful and easy to use command line calculator
7
9 qalc [options] [expression]
10
12 Qalculate! is a multi-purpose cross-platform desktop calculator. It is
13 simple to use but provides power and versatility normally reserved for
14 complicated math packages, as well as useful tools for everyday needs
15 (such as currency conversion and percent calculation). Features include
16 a large library of customizable functions, unit calculations and con‐
17 version, physical constants, symbolic calculations (including integrals
18 and equations), arbitrary precision, uncertainty propagation, interval
19 arithmetic, plotting, and a user-friendly interface. qalc is the com‐
20 mand line interface of Qalculate!.
21
23 -b, --base base
24 set the number base for results and, optionally, expressions
25
26 -c, --color
27 use colors to highlight different elements of expressions and
28 results
29
30 --defaults
31 load default settings
32
33 -e, --exrates
34 update exchange rates
35
36 -f, --file file
37 execute commands from a file first
38
39 -h, --help
40 display this help and exits
41
42 -i, --interactive
43 start in interactive mode
44
45 -l, --list [search term]
46 displays a list of all user-defined or matching variables,
47 functions, units, and prefixes.
48
49 --list-functions [search term]
50 displays a list of all or matching functions.
51
52 --list-prefixes [search term]
53 displays a list of all or matching prefixes.
54
55 --list-units [search term]
56 displays a list of all or matching units.
57
58 --list-variables [search term]
59 displays a list of all or matching variables.
60
61 -m, --time milliseconds
62 terminate calculation and display of result after specified
63 amount of time
64
65 -n, --nodefs
66 do not load any functions, units, or variables from file
67
68 --nocurrencies
69 do not load any global currencies from file
70
71 --nodatasets
72 do not load any global data sets from file
73
74 --nofunctions
75 do not load any global functions from file
76
77 --nounits
78 do not load any global units from file
79
80 --novariables
81 do not load any global variables from file
82
83 -p [base]
84 start in programming mode (same as -b "base base" -s "xor^",
85 with base conversion)
86
87 -s, --set "option value"
88 as set command in interactive program session (ex. --set "base
89 16")
90
91 -t, --terse
92 reduce output to just the result of the input expression
93
94 -/+u8 switch unicode support on/off
95
96 -v, --version
97 show application version and exit
98
99 The program will start in interactive mode if no expression and no file
100 is specified (or interactive mode is explicitly selected).
101
103 approximate
104 Equivalent to set approximation try exact.
105
106 assume assumptions
107 Set default assumptions for unknown variables (unknown, non-
108 zero, positive, negative, non-positive, non-negative + number,
109 real, rational, integer, boolean).
110
111 base base
112 Sets the result number base (equivalent to set base).
113
114 clear Clears the screen
115
116 clear history
117 Clears the expression history
118
119 delete name
120 Removes the user-defined variable or function with the speci‐
121 fied name.
122 Example: delete var1.
123
124 exact Equivalent to set approximation exact.
125
126 expand Expands the current result.
127
128 exrates Downloads current exchange rates from the Internet.
129
130 factor Factorizes the current result.
131
132 find, list [name]
133 Displays a list of variables, functions and units. Enter with
134 argument 'currencies', 'functions', 'variables', 'units', or
135 'prefixes' to show a list of all currencies, functions, vari‐
136 ables, units, or prefixes. Enter a search term to find matching
137 variables, functions, units, and/or prefixes. If command is
138 called with no argument all user-definied objects are listed.
139 Example: list functions.
140 Example: find dinar.
141 Example: find variables planck.
142
143 function name expression
144 Creates a function with the specified name and expression. Use
145 '\x', '\y', '\z', '\a', etc. for arguments in the expression.
146 Example: function func1 5*\x.
147
148 help [command]
149
150 info Displays information about a function, variable, unit, or pre‐
151 fix.
152 Example: info sin.
153
154 MC/MS/M+/M-
155 Memory operations (memory clear, memory store, memory plus,
156 memory minus). Recall the memory using the MR/MRC variable.
157
158 mode Displays the current mode.
159
160 partial fraction
161 Applies partial fraction decomposition to the current result.
162
163 save, store name [category] [title]
164 Saves the current result in a variable with the specified name.
165 You may optionally also provide a category (default "Tempo‐
166 rary") and a title. If name equals "mode" or "definitions",
167 the current mode and definitions, respectively, will be saved.
168 Example: store var1.
169
170 save definitions
171
172 save mode
173
174 set option value
175
176 to, convert, -> unit/"to"-command
177 Converts the previous result. Equivalent to using "to" at the
178 end of an expression. Example: to m/s
179 Example: to bin
180
181 variable name expression
182 Create a variable with the specified name and expression.
183 Example: variable var1 pi / 2.
184
185 quit/exit
186 Terminates the program.
187
188 Commands for RPN mode:
189
190 rpn state
191 (De)activates the Reverse Polish Notation stack and syntax.
192 "syntax" activates only the RPN syntax and "stack" enables the
193 RPN stack.
194
195 stack Displays the RPN stack.
196
197 clear stack
198 Clears the entire RPN stack.
199
200 copy [index]
201 Duplicates a value on the RPN stack to the top of the stack. If
202 no index is specified, the top of the stack is duplicated. In‐
203 dex 1 is the top of stack and negative index values count from
204 the bottom of the stack.
205
206 move index 1 index 2
207 Changes the position of a value on the RPN stack. Index 1 is
208 the top of stack and negative index values count from the bot‐
209 tom of the stack.
210 Example: move 2 4
211
212 pop [index]
213 Removes the top of the RPN stack or the value at the specified
214 index. Index 1 is the top of stack and negative index values
215 count from the bottom of the stack.
216
217 rotate [direction]
218 Rotates the RPN stack up (default) or down.
219
220 swap [index 1] [index 2]
221 Swaps position of values on the RPN stack. If no index is spec‐
222 ified, the values on the top of the stack (index 1 and index 2)
223 will be swapped and if only one index is specified, the value
224 at this index will be swapped with the top value. Index 1 is
225 the top of stack and negative index values count from the bot‐
226 tom of the stack.
227 Example: swap 2 4
228
229 When a line begins with '/', the text that follows is always inter‐
230 preted as a command.
231
233 Tab shows a list of functions, variables, and units that matches
234 the last object in the current expression
235
236 Ctrl+D terminates the program
237
238 Ctrl+E switches between approximation modes (exact, try exact, auto)
239
240 Ctrl+F switches between fraction modes (simple, decimal, auto)
241
242 Ctrl+A saves the current result in a temporary variable
243
244 Ctrl+L clears the screen
245
247 These settings are changed using the set command (e.g. set base 16) or
248 the -s, --set command line option (e.g. qalc -s "base 16"). Possible
249 values are shown in parenthesis. 1 and 0 can be used instead of on and
250 off, yes and no. If the value is left out, a value of 1 is generally
251 assumed. The default value is marked with '*'.
252
253 Algebraic mode:
254
255 algebra mode, alg (1* = expand, 2 = factorize)
256 Determines if the expression is factorized or not after calcu‐
257 lation.
258
259 assume nonzero denominators, nzd (on*, off)
260 Determines if unknown values will be assumed non-zero (x/x=1).
261
262 warn nonzero denominators, warnnzd (on*, off)
263 Display a message after a value has been assumed non-zero.
264
265 assumptions, asm (unknown*, non-zero, positive, negative, non-positive,
266 non-negative + number, real*, rational, integer, boolean)
267 Default assumptions for unknown variables.
268
269 Calculation:
270
271 angle unit, angle (0 = none, 1* = radians, 2 = degrees, 3 = gradians)
272 Default angle unit for trigonometric functions.
273
274 approximation, appr (-1* = auto, 0 = exact, 1 = try exact, 2 = approxi‐
275 mate, 3 = dual)
276 How approximate variables and calculations are handled. In ex‐
277 act mode approximate values will not be calculated.
278
279 interval arithmetic, ia (on*, off)
280 If activated, interval arithmetic determines the final preci‐
281 sion of calculations (avoids wrong results after loss of sig‐
282 nificance) with approximate functions and/or irrational num‐
283 bers.
284
285 interval calculation, ic (1* = variance formula, 2 = interval arith‐
286 metic)
287 Determines the method used for interval calculation / uncer‐
288 tainty propagation.
289
290 precision, prec (> 0) 10*
291 Specifies the default number of significant digits displayed
292 and determines the precision used for approximate calculations.
293
294 Enabled objects:
295
296 calculate functions, calcfunc (on*, off)
297
298 calculate variables, calcvar (on*, off)
299
300 complex numbers, cplx (on*, off)
301
302 functions, func (on*, off)
303
304 infinite numbers, inf (on*, off)
305
306 units (on*, off)
307
308 unknowns (on, off*)
309 Interpret undefined symbols in expressions as unknown vari‐
310 ables.
311
312 variables, var (on*, off)
313
314 variable units, varunits (on*, off)
315 If activated physical constants include units (e.g. c =
316 299 792 458 m∕s).
317
318 Generic display options:
319
320 abbreviations, abbr (on*, off)
321 Use abbreviated names for units and variables.
322
323 color (0 = off, 1* = default, 2 = light)
324 Use colors to highlight different elements of expressions and
325 results.
326
327 division sign, divsign (0* = /, 1 = division slash, 2 = division sign)
328
329 excessive parentheses, expar (on, off*)
330
331 minus last, minlast (on, off*)
332 Always place negative values last.
333
334 multiplication sign, mulsign (0 = *, 1 = multiplication dot, 2* = mul‐
335 tiplication x, 3 = middle dot)
336
337 short multiplication, shortmul (on*, off)
338
339 spacious, space (on*, off)
340 Add extra space around operators.
341
342 spell out logical, spellout (on*, off)
343
344 unicode, uni (on*, off)
345 Display Unicode characters.
346
347 vertical space, vspace (on*, off)
348 Add empty lines before and after result.
349
350 Numerical display:
351
352 base (-1114112 - 1114112, bin, oct, dec*, hex, sexa, time, roman)
353
354 base display, basedisp (0 = none, 1* = normal, 2 = alternative)
355
356 complex form, cplxform (0* = rectangular, 1 = exponential, 2 = polar, 3
357 = cis, 4 = angle)
358
359 decimal comma (locale*, off, on)
360 Determines the default decimal separator.
361
362 digit grouping, group (0* = off, 1 = standard, 2 = locale)
363
364 fractions, fr (-1* = auto, 0 = off, 1 = exact, 2 = on, 3 = mixed, 4 =
365 long, 5 = dual)
366 Determines how rational numbers are displayed (e.g. 5/4 = 1 +
367 1/4 = 1.25). 'long' removes limits on the size of the numerator
368 and denonimator.
369
370 hexadecimal two's, hextwos (on, off*)
371 Enables two's complement representation for display of negative
372 hexadecimal numbers.
373
374 imaginary j, imgj (on, off*)
375 Use 'j' (instead of 'i') as default symbol for the imaginary
376 unit.
377
378 interval display, ivdisp (0* = adaptive, 1 = significant, 2 = interval,
379 3 = plusminus, 4 = midpoint, 5 = lower, 6 = upper, 7 = concise, 8 =
380 relative)
381
382 lowercase e, lowe (on, off*)
383 Use lowercase e for E-notation (5e2 = 5 * 10^2).
384
385 lowercase numbers, lownum (on, off*)
386 Use lowercase letters for number bases > 10.
387
388 max decimals, maxdeci (-1 = off*, >= 0)
389
390 min decimals, mindeci (-1 = off*, >= 0)
391
392 rounding (0 = standard*, 1 = even, 2 = truncate)
393 Determines whether how approximate numbers are rounded (round
394 halfway numbers away from zero or towards the nearest even
395 digit, or round all numbers towards zero).
396
397 scientific notation, exp (0 = off, -1 = auto*, -3 = engineering, 1 =
398 pure, 3 = scientific, >= 0)
399 Determines how scientific notation is used (e.g. 5 543 000 =
400 5.543E6).
401
402 show ending zeroes, zeroes (on*, off)
403 If actived, zeroes are kept at the end of approximate numbers.
404
405 two's complement, twos (on*, off)
406 Enables two's complement representation for display of negative
407 binary numbers.
408
409 duodecimal symbols, duosyms (on, off*)
410 Use special symbols for digits 10 and 11 in numbers with base
411 12.
412
413 Parsing:
414
415 caret as xor, xor^ (on, off*)
416 Use ^ as bitwise exclusive OR operator.
417
418 concise uncertainty, concise (on, off*)
419 Allow input of uncertainty using concise notation.
420
421 decimal comma (locale*, off, on)
422 Determines the default decimal separator.
423
424 ignore comma (on, off*)
425 Allows use of ',' as thousands separator.
426
427 ignore dot (on, off*)
428 Allows use of '.' as thousands separator.
429
430 imaginary j, imgj (on, off*)
431 Use 'j' (instead of 'i') as default symbol for the imaginary
432 unit.
433
434 input base, inbase (-1114112 - 1114112, bin, oct, dec*, hex, roman)
435
436 limit implicit multiplication, limimpl (on, off*)
437
438 parsing mode, syntax (0* = adaptive, 1 = implicit first, 2 = conven‐
439 tional, 3 = chain, 4 = rpn)
440 See syntax section.
441
442 read precision, readprec (0* = off, 1 = always, 2 = when decimals)
443 If activated, numbers are interpreted as approximate with pre‐
444 cision equal to the number of significant digits (3.20 =
445 3.20+/-0.005).
446
447 Units:
448
449 all prefixes, allpref (on, off*)
450 Enables automatic use of hecto, deca, deci, and centi.
451
452 autoconversion, conv (0 = none, 1 = optimal*, 2 = base, 3 = optimalsi,
453 4 = mixed)
454 Controls automatic unit conversion of the result. 'optimalsi'
455 always converts non-SI units, while 'optimal' only converts to
456 more optimal unit expressions, with less units and exponents.
457
458 binary prefixes, binpref (on, off*)
459 If activated, binary prefixes are used by default for informa‐
460 tion units.
461
462 currency conversion, curconv (on*, off)
463 Enables automatic conversion to the local currency when optimal
464 unit conversion is enabled.
465
466 denominator prefixes, denpref (on*, off)
467 Enables automatic use of prefixes in the denominator of unit
468 expressions.
469
470 place units separately, unitsep (on*, off)
471 If activated, units are separated from variables at the end of
472 the result.
473
474 prefixes, pref (on*, off)
475 Enables automatic use of prefixes in the result.
476
477 show negative exponents, negexp (on, off*)
478 Use negative exponents instead of division for units in result
479 (m/s = m*s^-1).
480
481 sync units, sync (on*, off)
482
483 temperature units, temp (0 = hybrid*, 1 = absolute, 2 = relative)
484 Determines how expressions with temperature units are calcu‐
485 lated (hybrid acts as absolute if the expression contains dif‐
486 ferent temperature units, otherwise as relative).
487
488 update exchange rates, upxrates (-1 = ask*, 0 = never, > 0 = days)
489
490 Other:
491
492 clear history (yes, no*)
493 Do not save expression history on exit.
494
495 ignore locale (yes, no*)
496 Ignore system language and use English (requires restart).
497
498 rpn (on, off*)
499 Activates the Reverse Polish Notation stack.
500
501 save definitions (yes*, no)
502 Save functions, units, and variables on exit.
503
504 save mode (yes*, no)
505 Save settings on exit.
506
507 sigint action, sigint (0 = kill*, 1 = exit, 2 = interrupt)
508 Determines how the SIGINT signal (Ctrl+C) is handled.
509
511 Mathematical entities:
512
513 Numbers
514 These are the regular numbers composed by digits 0-9 and a deci‐
515 mal sign — a dot, or a comma if it is the default decimal point
516 in the locale/language used. If comma is used as decimal sign,
517 the dot is still kept as an alternative decimal sign, if not ex‐
518 plicitly deactivated. Numbers include integers, real numbers,
519 and complex numbers. The imaginary part of complex numbers are
520 written with as regular number followed by the special variable
521 "i" (can be changed to a "j"), which represents the square root
522 of -1. Spaces between digits are ignored ("5 5 = 55"). "E" (or
523 "e") can be considered as a shortcut for writing many zeroes and
524 is equivalent to multiplication by 10 raised to the power of the
525 right-hand value (e.g. "5E3 = 5000"). Sexagesimal numbers (and
526 time) can be entered directly using colons (e.g. "5:30 = 5.5").
527 A number immediately preceded "0b", "0o", "0d" or "0x" are in‐
528 terpreted as a number with base 2, 8, 12 or 16, respectively
529 (e.g. "0x3f = 63").
530
531 Intervals
532 A number interval can be entered using the interval() function,
533 the uncertainty() function, or using "±" or "+/-" (e.g. 5±1 =
534 uncertainty(5, 0.2) = interval(4, 6)). If the read precision op‐
535 tion is activated, decimal numbers are interpreted as an inter‐
536 val between the numbers that are normally rounded to the entered
537 number (e.g. 1.1 = 1.1±0.05). If interval calculation using
538 variance formula is activated (default), the interval represents
539 the standard uncertainty (deviation) of the value.
540
541 Vectors and Matrices
542 A matrix is a two-dimensional rectangular array of mathematical
543 objects. Vectors are matrices with only one row or column, and
544 thus one-dimensional sequences of objects. Vectors and matrices
545 are generated by various functions, or using syntax in the form
546 of [1 2 3 4] and [1 2; 3 4], with columns separated by space or
547 comma and rows separated by semi-colon, or (1, 2, 3, 4) and ((1,
548 2), (3, 4)).
549
550 Variables/Constants
551 See the list of variables in the GUI manual or using the command
552 .I list variables
553
554 Functions
555 See the list of functions in the GUI manual or using the command
556 .I list functions
557
558 Units and Prefixes
559 See the list of units and prefixes in the GUI manual or using
560 the command .I list units. Abbreviated, plural and singular
561 forms of unit names and prefixes are generally allowed. Prefixes
562 must be put immediately before the unit to be interpreted as
563 prefixes (eg. 5 mm = 0.005 m, but 5 m m = 5 m^2). For conve‐
564 nience units allow the power operator to be left out (e.g. 5 m2
565 = 5 m^2), with currencies excluded.
566
567 Unknowns
568 Unknowns are text strings without any associated value. These
569 are temporary unknown variables with default assumptions. Un‐
570 knowns can also be explicitly entered by placing a backslash (\)
571 before a single character (e.g. 5\a + 2\b) or using quotation
572 mark before and after a text string (e.g. 5 "apples" + 2 "ba‐
573 nanas"). If unknowns are activated characters without any asso‐
574 ciated variable, function or unit in an expression, will be re‐
575 garded as an unknown variable.
576
577 Date and Time
578 Date/time values are specified using quoted text string (quota‐
579 tion marks are not needed for function arguments), using stan‐
580 dard date and time format (YYYY-MM-DDTHH:MM:SS). Some local for‐
581 mats are also supported, but not recommended. The local time
582 zone are used, unless a time zone is specified at the end of the
583 time string (Z/UTC/GMT or +/-HH:MM). Date/time supports a small
584 subset of arithmetic operations. The time units represents cal‐
585 endar time, instead of average values, when added or subtracted
586 to a date.
587
588 Text
589 This category represent a number of different function argument
590 types, such as regular text and file names. They can, but do not
591 need to be put in quotes except when containing the argument
592 separator.
593
594 Comments
595 All text after a hashtag (e.g. (5*2)/2 #calculating triangle
596 area) is treated as a comment.
597
598 Operations and operators (word operators such as AND must be surrounded
599 by space):
600
601 Addition (+)
602
603 Subtraction (-)
604
605 Multiplication (*)
606
607 Division (/)
608
609 Remainder (%, rem) and modulo (%%, mod)
610 Returns the remainder after division.
611
612 Integer division (//, div)
613 Rounds the result of division towards zero.
614
615 Exponentiation (^, **)
616 Note that x^y^z equals x^(y^z), and not (x^y)^z. Note also that
617 for non-integer exponents with negative bases, the principal
618 root is returned and not the real root ((-8)^(1/3) equals 1 +
619 1.73i, and not -2). To calculate the real root for negative val‐
620 ues, use the cbrt() and root() functions.
621
622 10^x (E)
623
624 Parenthesis ((, ))
625
626 Parellel sum (∥, ||)
627 Returns the the reciprocal value of a sum of reciprocal values.
628 || is interpreted as parallel if units are used, otherwise as
629 logical OR.
630
631 Logical operators (!, NOT, ||, OR, &&, AND, XOR, NOR, NAND)
632
633 Bitwise operators (~, |, &, <<, >>, XOR)
634
635 Comparison operators (=, !=, <, <=, >, >=)
636 Returns 1 if expression is true and 0 if false. The x variable
637 is isolated if the expression does not evaluate as true or
638 false. Primarily used for equations and inequalities.
639
640 Dot product (.)
641
642 Element-wise operators (.*, ./, .^)
643
644 Save operator (:=, =)
645 Saves the expression to the right of the operator as a variable
646 or function (e.g. var1:=5, func1():=x+y, var1=ln(5)+2). If the
647 colon is omitted the expression is calculated before it is as‐
648 signed to the variable.
649
650 Evaluation priority order: parenthesis, 10^x, exponentiation, func‐
651 tions, bitwise NOT, logical NOT, multiplication/division/remainder,
652 parallel sum, addition/subtraction, bitwise NOT, bitwise shift, compar‐
653 isons, bitwise AND, bitwise XOR, bitwise OR, logical AND, logical OR.
654
655 The evaluation of short/implicit multiplication without any multiplica‐
656 tion sign (e.g. 5x, 5(2+3)), differs depending on the parsing mode. In
657 the conventional mode implicit multiplication does not differ from ex‐
658 plicit multiplication (12/2(1+2) = 12/2*3 = 18, 5x/5y = 5 * x/5 * y =
659 xy). In the parse implicit multiplication first mode, implicit multi‐
660 plication is parsed before explicit multiplication (12/2(1+2) = 12/(2 *
661 3) = 2, 5x/5y = (5 * x)/(5 * y) = x/y). The default adaptive mode works
662 as the parse implicit multiplication first mode, unless spaces are
663 found (1/5x = 1/(5 * x), but 1/5 x = (1/5) * x). In the adaptive mode
664 unit expressions are parsed separately (5 m/5 m/s = (5 * m)/(5 * (m/s))
665 = 1 s). Function arguments without parentheses are an exception, where
666 implicit multiplication in front of variables and units is parsed first
667 regardless of mode (sqrt 2x = sqrt(2x)).
668
669 In chain mode, expressions are calculated from left to right, ignoring
670 standard order of operations, like the immediate execution mode of a
671 traditional calculator (1+2*3 = (1+2)*3 = 9).
672
673 The "to"-operator is used for unit conversion and manipulation of how
674 the result is presented. Place " to " or a right arrow (e.g. "->") fol‐
675 lowed by one of expressions/commands listed below, at the end of an ex‐
676 pression.
677
678 Unit conversion
679 - a unit or unit expression (e.g. meter or km/h)
680 prepend with ? to request the optimal prefix
681 prepend with b? to request the optimal binary prefix
682 prepend with + or - to force/disable use of mixed units
683 - a variable or physical constant (e.g. c)
684 - base (convert to base units)
685 - optimal (convert to optimal unit)
686 - mixed (convert to mixed units, e.g. hours + minutes)
687
688 Number base conversion
689 - bin, binary (show as binary number)
690 - bin# (show as binary number with specified number of bits)
691 - oct, octal (show as octal number)
692 - duo, duodecimal (show as duodecimal number)
693 - hex, hexadecimal (show as hexadecimal number)
694 - hex# (show as hexadecimal number with specified number of
695 bits)
696 - sex, sexa2, sexa3, sexagesimal (show as sexagesimal number;
697 sexa2 hides and sexa3 rounds arcseconds)
698 - latitude, latitude2, longitude, longitude2 (show as sexagesi‐
699 mal latitude/longitude; latitude2 and longitude2 hide arcsec‐
700 onds)
701 - bijective (shown in bijective base-26)
702 - fp16, fp32, fp64, fp80, fp128 (show in binary floating-point
703 format)
704 - bcd (show as binary-coded decimal)
705 - roman (show as roman numerals)
706 - time (show in time format)
707 - unicode
708 - base # (show in specified number base)
709 - bases (show as binary, octal, decimal and hexadecimal number)
710
711 Complex format
712 - rectangular, cartesian (show complex numbers in rectangular
713 form)
714 - exponential (show complex numbers in exponential form)
715 - polar (show complex numbers in polar form)
716 - cis (show complex numbers in cis form)
717 - angle, phasor (show complex numbers in angle/phasor notation)
718
719 Time and date conversion
720 - UTC (show date and time in UTC time zone)
721 - UTC+/-hh[:mm] (show date and time in specified time zone)
722 - calendars
723
724 Other conversion commands
725 - fraction (show result as mixed fraction)
726 - factors (factorize result)
727
728 Similarly where (or alternatively "/.") can be used at the end (but be‐
729 fore "to"), for variable assignments, function replacements, etc. (e.g.
730 "x+y where x=1 and y=2", "x^2=4 where x>0", and "sin(5) where
731 sin()=cos()").
732
733 Note that to and where can only be applied to the whole expression. Ev‐
734 erything before the operator is always treated as the expression to
735 convert (or apply replacement to), and everything after as the conver‐
736 sion/replacement expression, regardless of any parentheses.
737
739 Note that semicolon can be replaced with comma, if comma is not used as
740 decimal or thousands separator.
741
742 Basic functions and operators
743
744 sqrt 4 = sqrt(4)
745 = 4^(0.5)
746 = 4^(1/2)
747 = 2
748
749 sqrt(25; 16; 9; 4)
750 = [5 4 3 2]
751
752 sqrt(32)
753 = 4 * sqrt(2) (in exact mode)
754
755 cbrt(-27)
756 = root(-27; 3)
757 = -3 (real root)
758
759 (-27)^(1/3)
760 = 1.5 + 2.5980762i (principal root)
761
762 ln 25 = log(25; e)
763 = 3.2188758
764
765 log2(4)/log10(100)
766 = log(4; 2)/log(100; 10)
767 = 1
768
769 5! = 1 * 2 * 3 * 4 * 5
770 = 120
771
772 5\2 (integer division)
773 = 5//2
774 = trunc(5/2)
775 = 2
776
777 5 mod 3 = mod(5; 3)
778 = 2
779
780 52 to factors
781 = 2^2 * 13
782
783 25/4 * 3/5 to fraction
784 = 3 + 3/4
785
786 gcd(63; 27)
787 = 9
788
789 sin(pi/2) - cos(pi)
790 = sin(90 deg) - cos(180 deg)
791 = 2
792
793 sum(x; 1; 5)
794 = 1 + 2 + 3 + 4 + 5 = 15
795
796 sum(i^2+sin(i); 1; 5; i)
797 = 1^2 + sin(1) + 2^2 + sin(2) + ... = 55.176162
798
799 product(x; 1; 5)
800 = 1 * 2 * 3 * 4 * 5 = 120
801
802 var1:=5 store value 5 in variable var1
803
804 5^2 #this is a comment
805 = 25
806
807 sinh(0.5) where sinh()=cosh()
808 = cosh(0.5) = 1.1276260
809
810 plot(x^2; -5; 5)
811 plots the function y=x^2 from -5 to 5
812
813 Units
814
815 5 dm3 to L
816 = 25 dm^3 to L
817 = 5 L
818
819 20 miles / 2h to km/h
820 = 16.09344 km/h
821
822 1.74 to ft = 1.74 m to ft
823 = 5 ft + 8.5039370 in
824
825 1.74 m to -ft
826 = 5.7086614 ft
827
828 100 lbf * 60 mph to hp
829 = 16 hp
830
831 50 Ω * 2 A
832 = 100 V
833
834 50 Ω * 2 A to base
835 = 100 kg*m^2*s^-3*A^-1
836
837 10 N / 5 Pa
838 = (10 N)/(5 Pa) = 2 m^2
839
840 5 m/s to s/m
841 = 0.2 s/m
842
843 500 EUR - 20% to USD
844 = 451.04 USD
845
846 500 megabit/s * 2 h to b?byte
847 = 419.09516 gibibytes
848
849 Physical constants
850
851 k_e / G * a_0
852 = (coulombs_constant / newtonian_constant) * bohr_radius
853 = 7.126e9 kg*H*m^-1
854
855 planck ∕ (compton_wavelength * c)
856 = 9.1093837e-31 kg
857
858 5 ns * rydberg to c
859 = 6.0793194E-8c
860
861 atom(Hg; weight) + atom(C; weight) * 4 to g
862 = 4.129e-22 g
863
864 (G * planet(earth; mass) * planet(mars; mass))/(54.6e6 km)^2
865 = 8.58e16 N (gravitational attraction between earth and mars)
866
867 Uncertainty and interval arithmetic
868 result with interval arithmetic activated is shown in parenthesis
869
870 sin(5+/-0.2)^2/2+/-0.3
871 = 0.460±0.088 (0.46+/-0.12)
872
873 (2+/-0.02 J)/(523+/-5 W)
874 = 3.824+/-0.053 ms (3.82+/-±0.075 ms)
875
876 interval(-2; 5)^2
877 = intervall(-8.2500000; 12.750000) (intervall(0; 25))
878
879 Algebra
880
881 (5x^2 + 2)/(x - 3)
882 = 5x + 15 + 47/(x - 3)
883
884 (\a + \b)(\a - \b) = ("a" + "b")("a" - "b")
885 = 'a'^2 - 'b'^2
886
887 (x + 2)(x - 3)^3
888 = x^4 - 7x^3 + 9x^2 + 27x - 54
889
890 factorize x^4 - 7x^3 + 9x^2 + 27x - 54
891 = x^4 - 7x^3 + 9x^2 + 27x - 54 to factors
892 = (x + 2)(x - 3)^3
893
894 cos(x)+3y^2 where x=pi and y=2
895 = 11
896
897 gcd(25x; 5x^2)
898 = 5x
899
900 1/(x^2+2x-3) to partial fraction
901 = 1/(4x - 4) - 1/(4x + 12)
902
903 x+x^2+4 = 16
904 x = 3 or x = -4
905
906 x^2/(5 m) - hypot(x; 4 m) = 2 m where x > 0
907 x = 7.1340411 m
908
909 cylinder(20cm; x) = 20L
910 x = (1 / (2pi)) m
911 x = 16 cm (height of 20 L cylinder with radius 20 cm)
912
913 asin(sqrt(x)) = 0.2
914 x = sin(0.2)^2
915 x = 0.039469503
916
917 x^2 > 25x
918 = x > 25 or x < 0
919
920 solve(x = y+ln(y); y)
921 = lambertw(e^x)
922
923 solve2(5x=2y^2; sqrt(y)=2; x; y)
924 = 32/5
925
926 multisolve([5x=2y+32, y=2z, z=2x]; [x, y, z])
927 = [-32/3 -128/3 -64/3]
928
929 dsolve(diff(y; x) - 2y = 4x; 5)
930 = 6e^(2x) - 2x - 1
931
932 Calculus
933
934 diff(6x^2)
935 = 12x
936
937 diff(sinh(x^2)/(5x) + 3xy/sqrt(x))
938 = (2/5) * cosh(x^2) - sinh(x^2)/(5x^2) + (3y)/(2 * sqrt(x))
939
940 integrate(6x^2)
941 = 2x^3 + C
942
943 integrate(6x^2; 1; 5)
944 = 248
945
946 integrate(sinh(x^2)/(5x) + 3xy/sqrt(x))
947 = 2x * sqrt(x) * y + Shi(x^2) / 10 + C
948
949 integrate(sinh(x^2)/(5x) + 3xy/sqrt(x); 1; 2)
950 = 3.6568542y + 0.87600760
951
952 limit(ln(1 + 4x)/(3^x - 1); 0)
953 = 4 / ln(3)
954
955 Matrices and vectors
956
957 [1, 2, 3; 4, 5, 6]
958 = ((1; 2; 3); (4; 5; 6))
959 = [1 2 3; 4 5 6] (2x3 matrix)
960
961 (1; 2; 3) * 2 - 2
962 = [(1 * 2 - 2), (2 * 2 - 2), (3 * 2 - 2)]
963 = [0 2 4]
964
965 [1 2 3].[4 5 6]
966 = dot([1 2 3]; [4 5 6])
967 = 32 (dot product)
968
969 cross([1 2 3]; [4 5 6])
970 = [-3 6 -3] (cross product)
971
972 [1 2 3; 4 5 6].*[7 8 9; 10 11 12]
973 = hadamard([1 2 3; 4 5 6]; [7 8 9; 10 11 12])
974 = [7 16 27; 40 55 72] (hadamard product)
975
976 [1 2 3; 4 5 6] * [7 8; 9 10; 11 12]
977 = [58 64; 139 154] (matrix multiplication)
978
979 [1 2; 3 4]^-1
980 = inverse([1 2; 3 4])
981 = [-2 1; 1.5 -0.5]
982
983 Statistics
984
985 mean(5; 6; 4; 2; 3; 7)
986 = 4.5
987
988 stdev(5; 6; 4; 2; 3; 7)
989 = 1.87
990
991 quartile([5 6 4 2 3 7]; 1)
992 = percentile((5; 6; 4; 2; 3; 7); 25)
993 = 2.9166667
994
995 normdist(7; 5)
996 = 0.053990967
997
998 spearman(column(load(test.csv); 1); column(load(test.csv); 2))
999 = -0.33737388 (depends on the data in the CSV file)
1000
1001 Time and date
1002
1003 10:31 + 8:30 to time
1004 = 19:01
1005
1006 10h 31min + 8h 30min to time
1007 = 19:01
1008
1009 now to utc
1010 = "2020-07-10T07:50:40Z"
1011
1012 "2020-07-10T07:50CET" to utc+8
1013 = "2020-07-10T14:50:00+08:00"
1014
1015 "2020-05-20" + 523d
1016 = addDays(2020-05-20; 523)
1017 = "2021-10-25"
1018
1019 today - 5 days
1020 = "2020-07-05"
1021
1022 "2020-10-05" - today
1023 = days(today; 2020-10-05)
1024 = 87
1025
1026 timestamp(2020-05-20)
1027 = 1 589 925 600
1028
1029 stamptodate(1 589 925 600)
1030 = "2020-05-20T00:00:00"
1031
1032 "2020-05-20" to calendars
1033 returns date in Hebrew, Islamic, Persian, Indian, Chinese, Ju‐
1034 lian, Coptic, and Ethiopian calendars
1035
1036 Number bases
1037
1038 52 to bin
1039 = 0011 0100
1040
1041 52 to bin16
1042 = 0000 0000 0011 0100
1043
1044 52 to oct
1045 = 064
1046
1047 52 to hex
1048 = 0x34
1049
1050 0x34 = hex(34)
1051 = base(34; 16)
1052 = 52
1053
1054 523<<2&250 to bin
1055 = 0010 1000
1056
1057 52.345 to float
1058 = 0100 0010 0101 0001 0110 0001 0100 1000
1059
1060 float(01000010010100010110000101001000)
1061 = 1715241/32768
1062 = 52.345001
1063
1064 floatError(52.345)
1065 = 1.2207031e-6
1066
1067 52.34 to sexa
1068 = 52°20'24"
1069
1070 1978 to roman
1071 = MCMLXXVIII
1072
1073 52 to base 32
1074 = 1K
1075
1076 sqrt(32) to base sqrt(2)
1077 = 100000
1078
1080 The manual of the graphical user interface at https://qalcu‐
1081 late.github.io/manual/index.html (includes more details about the syn‐
1082 tax and elements supported in mathematical expressions, and various op‐
1083 tions, and includes a complete list of functions, variables, and units)
1084
1086 Please report any bugs at https://github.com/Qalculate/libqalculate/is‐
1087 sues
1088
1090 Hanna Knutsson <hanna.knutsson@protonmail.com>.
1091
1092
1093
1094 13 July 2020 QALC(1)