# The SpeedCrunch Handbook

Ariya
Hidayat
Jonathan
Jesse
Wolf
Lammen
2007
Ariya Hidayat
&FDLNotice;
2009-03-06
0.11

SpeedCrunch is a multiplatform desktop calculator for power users

SpeedCrunch
calculator

## Introduction

This document describes &app; version 0.11, a multiplatform desktop calculator for power users.

Have fun with &app;!

## Installation

### Installation for &Microsoft; &Windows;

To install &app; on &Microsoft; &Windows;, download the installer from the &app; website. Once the installer is downloaded, launch the application to install &app;. By default &app; is found in the Start Menu, under All Programs, &app; and is stored in C:\Program Files\Speedcrunch.

### Installation for &Mac; OS X

To install &app; on &Mac; OS X (10.3 (Panther), 10.4 (Tiger), and 10.5 (Leopard)), download the installer from the &app; Website. Once the file is downloaded, click on the binary file, and then follow the step-by-step instructions.

### Installation for &Linux;

To install &app; on &Linux; please follow the directions specific to the distribution you use. If your distribution is not listed, then either find the appliacation in the package manager which your distribution uses or use the instructions to compile your own version.

#### Installation for OpenSUSE

Trivial, isn't it?

#### Installation for &kubuntu;

SpeedCrunch is part of default &kubuntu; installation since &kubuntu; 5.10. It is located in the K Menu, Utilities, Calculator (SpeedCrunch).

If it is not available yet, SpeedCrunch can be installed using the following terminal command:

    apt-get install speedcrunch

#### Installation for &ubuntu;

&app; is installed by default as a part of &kubuntu;, however in &ubuntu;, it is as simple as sudo apt-get install speedcrunch.

    apt-get install speedcrunch

#### Installation for Fedora Core

&app; is part of Fedora Extras and is provided by the package `speedcrunch`. This package can be installed either with the graphical software management program Pirut, or with the terminal command:

    yum install speedcrunch

To update SpeedCrunch to the latest version, use the terminal command:

    yum update speedcrunch

#### Installation for Debian

Installation on Debian is as simple as:

    apt-get install speedcrunch

### Compilation from source code

To compile SpeedCrunch from source code, the following tools are required:

- CMake version 2.4.4 or newer (http://www.cmake.org/)

- Nokia's &Qt; framework version 4.4 or newer (http://www.qtsoftware.com/)

- C++ compiler

It is necessary to create a build folder which specifies the target location for the buid process. In this build folder, CMake should be invoked. The input for CMake will be the src folder in the source tree. The exact steps to do all these will depend on the operating system.

As an example, to compile and build SpeedCrunch on &Linux; using GCC, use the following commands:

    tar zxvf speedcrunch-0.11.tar.gz
    cd speedcrunch-0.11
    mkdir build
    cd build
    cmake ../src
    make

## Using Functions

### Alphabetical listing of functions

abs (x)

  Returns |x|, turning negative numbers into positive ones, and leaving positive ones unchanged.

acos (x)

  Returns the arc cos (x), the inverse function to cos y

  The return value is dependent on the degree setting; if "degrees" is enabled, the return value is from the range 0 <= result <= 180, else from 0 <= result <= π.

and (x1; x2; ...)

  Performs a bitwise logical AND on the submitted parameter(s) (one or more). All parameters have to be integers from the range -2^255 to +2^256-1 (signed or unsigned 256 bit integers). The result is from -2^255 to +2^255-1 (signed integer). Note that and(x) is not the identity, because the unsigned +2^255 is mapped to the signed -2^255, for example. An error is returned, if the parameters are not from the valid range.

arcosh (x)

  Computes the area hyperbolic cosine of x, the inverse fuction to cosh y. arcosh (x) is the positive solution to cosh(y)=x. Except for 1, there exists a second solution to this equation: -arcosh (x). The parameter x has to be >=1.

arsinh(x)

  Computes the area hyperbolic sine of x, the inverse function to sinh y. arsinh (x) is the only solution to sinh(y)=x.

artanh (x)

  Computes the area hyperbolic tangens of x, the inverse function to tanh y. artanh (x) is the only solution to tanh (y) = x. The parameter x has to fulfil -1 < x < 1.

asin (x)

  Returns the arc sin (x). The inverse function to sin. The return value is dependent on the degree setting; if "degrees" is enabled, the return value is from the range -90 <= result <= 90, else from -pie/2 <= result <= pie2.

atan (x)

  Returns the arc tan (x), the inverse function to tan y. The return value is dependent on the degree setting; if "degrees" is enaled, the return value is from the range -90 < result < 90, else from -pie/2 < result < pie/2.

  The arc tan(x) is the principal solution to the equation tan (y) = x. Other solutions are (radians): arc tran (x) + n*pie for all integers n; or (degrees): arc tan (x) + n*180 for all integers n.

average (x1; x2; ...)

  Computes the average, or mean value of the sumitted parameter(s) (one or more).

bin (n)

  Displays n in binary format, without globally changing the output format. A fractional part of n is cut off efore conversion, and the remaining integral part has to be from the range -2^255 to +2^256-1.

binomcdf (max; trails; p)

  Trials is a non-negative integer, max a positive integer, and 0 <= p <= 1. This function determines the probability, that in a series of 'trials' independent probabilistic tests, each resulting in an event with probaility p, at most 'max' events occur.

binommean (trials; p)

  Trials is a non-negative integer, 0 <= p <= 1. If you have 'trials' independent tests each of them resulting in a given event with a probability p, this number tells you how many events you will have on average.

binompmf (hits; trials; p)

  Trials is a non-negative integer, max a positive integer, and 0 <= p <= 1. This function determines the probability, that in a series of 'trials' independent probabilistic tests, each resulting in an event with probability p, exactly 'hits' events occur.

binomvar (trials; p)

  Trials is a non-negative integer, 0 <= p <= 1. The variance of the binominal distribution function, based on 'trials' independent tests, each resulting in an event with probability p. In other words, it tells how 'good' the result of binommean is.

cbrt(x)

  Computes the third (cubic) root x. This function operates on negative numbers as well. The inverse function is y^3.

ceil (x)

  Finds the smalles integer greater then or equal to x, the ceiling of x.

cos (x)

  Evaluates the cosine of x. The result is dependent on the degree setting. If "degrees" is active, the paramter x is assumed to be an arc from a 360 degree circle, otherwise a full circle is represented by 2*pie. The inverse function is acos(y). Although the cosine is mathematically defined for all x, for x beyond approximately 1e77, the periodicity of the cosine is not recognized any more, so &app; issues an error then.

cosh (x)

  Finds the hyperbolic cosine of x. This function overflows for |x| > 1236190959.52. The inverse function is arcosh.

cot (x)

  Evaluates the cotangent of x. The result is dependent on the degree setting. If "degrees" is active, the parameter x is assumed to be an arc from a 360 degree circle, otherwise a full circle is repsented by 2*pie. Although the cotangent is mathematically defined for all x, for x beyond approximately 1e77, the periodicity of the cotangent is not recognized any more so &app; issues an error.

csc (x)

  Evaulates the cosecant of x. The result is dependent on the degree setting. If "degrees" is active, the paramter x is assumed to be an arc from a 360 degree circle, otherwise a full circle is represented by 2*pie. Although the cosecant is mathematically defined for all x, for x beyond approximately 1e77, the periodicity of the cosecant is not reconginized any more, so &app; issues an error.

dec (x)

  Displays x in decimal format, without globally changing the output format. This function is useful when you changed the output format to a binary format.

degrees (x)

  Converts an angle measured in radian to degrees. This function is especially useful, if you want to override the current angle mode for just one expression.

erf (x)

  Determines the normalized error function of x, the cumulative distribution function to the normal distribution (bell cure, Gaussian distribution).

erfc (x)

  Determines the normalized complementary error function of x, related to the cumulative probability function of the normal distribution (bell curve, Gaussian distribution). Erfx(x) + erf(x) is always 1.

exp (x)

  Evalutes the natural exponential function to the base e == 2.7182

floor (x)

  Finds the greatest integer less or equal to x, the floor of x.

frac (x)

  Cuts off the integral part of a real number

gamma (x)

  An extension of factorials, the same as (x-1)!

gcd (n1; n2; ...)

  Returns the greatest common divisor of the integers n1, n2 ... (2 or more). You can use this function to reduce a rational number. If a rational number is given as p/q, its reduced form is (p/gcd(p;q))/(q/gcd(p;q)). Related to the gcd function is the lcm function (least common multplier). You can find the lcm of two values by: lcm(n1;n2) = n1*n2/gcd(n1;n2).

geomean (x1; x2; ...)

  Finds the geometric mean of the positive numbers x1, x2, ... (one or more parameters). Non-positive parameters are not allowed.

hex (n)

  Displays n in hexagesimal format, without globally changing the output format. A fractional part of of n is cut of before converstion

hypercdf (max; total; hits; trials)

  All parameters are integers, 0 <= max <= hits <= trials <= trials <= total, and 0 < total. Assume there are 'hits' events in a series of 'total' tests. Then this function evaluates the probability, that you will find up to max events of them in a subseries of 'trials' tests.

hypermean (total; hits; trials)

  All parameters are integers, 0 <= hits <= total, 0 <= trials <= total, and 0 < total. Assume there are ' hits' events in a series of 'total' tests. Then this function evalutes the expected count of events in a subseries of 'trials' tests.

hyperpmf (count; total; hits; trials)

  All parameters are integers, 0 <= max <= hits <= total, 0 <= trials <= total, and 0 < total.

hypermean (total; hits; trials)

  All paramters are integers, 0 <= max <= hits <= total, 0 <= trials <= total, and 0 < total. Assume there are 'h its' events in a series of 'total tests. Then this function evalutates the variance of the count of events in a subseries of 'trials' tests. Or, in other words, it tells, how 'good' the result of hypermean is matched on the average, if you repeat your subseries of trials very often.

idiv (dividend; divisor)

  Evaluates the integer part of divdend/divisor. The result is always exact. Since &app; can hold integers up to 78 digits, this function overflows even if the ordinary division operator would yeild an approximate (but huge) quotient.

  It is possible to apply the idiv function to non-integers as well, but be aware that rounding errors might be lead to off-by-one erros. If idiv detects, that a result depends on the validity of the guard digits, it returns a NaN as a warning.

int (x)

  Returns the signed integer part of x.

lg (x)

  Returns the base 2 logarathim of of x, where x has to be positive. The inverse function is exp (y).

lngamma (x)

  Evaluates ln(factorial(x-1)). Returns a result even when the ! operator overflows.

log (x)

  Returns the base 10 logarathm of x where x has to be positive.

mask (n; bits)

  Returns the lower 'bits' bits of the integer n. The result is always unsigned. N has to be from -2^255 to +2^256-1 (signed or unsigned 256 bit integers), bits is an integer ranging from 1 to 255 inclusive. One application of this function is to find the two complement representation of a value. So hex (mask (-1; 16)) returns 0xFFFF, the 16-bit two's complement bit pattern of -1.

max (x1; x2; ...)

  Takes one or more parameter(s), which returns the maximum value of the submitted parametrs. Example max(17; log 1000; exp(3)).

min(x1; x2; ...)

  Takes one or more paramater(s) and returns the maximum value of the submitted parameters. Example: min(-0.4; log 0.1; exp(-3)).

mod (value; modulo)

  Evaluates the value mod modulo, which is the remainder after finding the integer quootient value / modulo. This function always returns an exact result, if the paramters are exact. 'Modulo' has to be non-zero and if the remainder is non-zero, it takes the sign of value. You can use this function with non-integers as well, but rounding errors might lead to off-by-one errros. This function can potentially be very time consuming, so mod is restricted to at most 250 division loops.

nCr (x1; x2)

  For integer paramaters this function is equal to the number of combinations (order is of no importance) of x2 elements from an x1-sized of elements or to the binominal coefficient x1 over x2.

  For arbitrary real valued x1, x2 the result is 1/(x1+1)*B(x2+1,x1-x2+1)), where B(a,b) is the complete Beta function.

not (n)

  Evaluates the bitwise (one-) complement of n. The result is a signed 256-bit integer. n has to be an integer from the range -2^255 to +2^256-1 (signed or unsigned 256 bit integers).

nPr (x1; x2)

  For integer paramaters this function is equal to the number of permutations (order is of importance) of x2 elements from an x1-sized of elements.

  For real-valued paramaters this function is equal to gamma(x1+1)/gamma(x2).

oct (n)

  Displays n in octal format, without globally changing the output format. A fractional part of n is cut off before conversion, and the reamining integral part has to be from the range -2^255 to +2^256 -1.

or (x1; x2; ...)

  Performs a bitwise logical OR on the submitted parameter(s) (one or more). All parameters have to be integers from the range -2^255 to +2^255 -1 (signed integer). Note that or(x) is not the identity, because the unsigned +2^255 is mapped to the signed -2^255, for example.

poicdf (events; avgevents)

  'events' is a non-negative integer, 'avgevents' a positive real number.

  If you have on the average 'avgevents' independent events in an interval, this function returns the probability, that you will see up to 'events' events when you test an interval.

poimean (avgevents)

  avgevents >=0. Returns the average number of events in an interval, when this average is 'avgevents'.

pipmf (events; avgevnts)

  'events' is a non-negative integer, 'avgevents' a positive real number. If you have on the average 'avgevents' independent events in an interval, this function returns the probability, that you will see exactly 'events' events when you test an interval.

poivar (avgevents)

  avgevents >= 0. The Poisson distribution assumes, that the variance equals the expected value 'avgevnts'.

radians (x)

  Converts an angle measured in degrees to radians. This function is especially useful, if you want to ovrride the current angle mode for just one expression.

round (x; digits)

  Rounds x to 'digits' decimial places after the decimal point where 'digits' has to be an integer.

sec (x)

  Evaluates the secant of x. The result is dependent on the degree setting. If "degrees" is active, the parameter x is assumed to be from a 360 degree circle.

  Although the secant is mathematically defined for all x, for x beyond approximately 1e77, the periodicity of the secant is not recognized any more, so &app; issues an error.

shl (n, bits)

  Shifts the bit pattern of n 'bits' to the left, if 'bits' >=0, otherwise shifts n arithmetically by -'bits' to the right. 255 <= bits <= 255, and n has to be an integer from the range -2^255 to +2^256-1 (signed or unsigned 256 bit integers). The result is from -2^255 to +255-1 (signed integer).

  On a shift left, zero bits are fed in to the right, and shifted out bits are dropped on the left. On a shift right, bit 255 (the leftmost bit) is copied and shifted in from the left, and shifted out bits on the right are dropped.

shr (n, bits)

  Shifts the bit pattern of n 'bits' to the right, if 'bits' >=0, otherwise shifts n arthmetically by -'bits' to the left.

  On a shift left, zero bits are fed in to the right, and shifted out bits are dropped on the left. On a shift right, bit 255 (the leftmost bit) is copied and shifted in from the left, and shifted out bits on the right are dropped.

sign (x)

  Returns the sign of x, -1 if negative, 1 if positive, and 0 for 0.

sin (x)

  Evaluates the sine of x, which is dependent on the degree setting. If "degress" is active, the parameter x is assumed to be an arc from a 360 degree circle. The inverse function is asin(y).

  Although the sine is mathematically defined for all x, for x beyond approximately 1e77, the periodicity of the sine is not recognized any more, so &app; issues an error.

sinh (x)

  Finds the hyperbolic sine of x, with the inverse function being arsinh.

sqrt (x)

  Computes the square root of x, which is not defined for x < 0.

tan (x)

  Evaultes the tangent of x. The result is dependent on the degree setting. If "degress" is active, the paramater x is assumed to be an arc from a 360 degree circle. The inverse function is atan(y).

  Although the tangent is mathematically defined for all x, for x beyond approximately 1e77, the periodicity of the tangent is not recognized any more, so &app; issues an error.

tanh (x)

  Finds the hyperbolic sine of x, where the inverse function is artanh.

trunc (x; digits)

  truncates x after 'digits' decimal places behind the decimal point where 'digits' has to be an integer.

unmask (n; bits)

  Takes the lower 'bits bits of n and sign-extends them to full 256 bit, meaning bit number 'bits'-1 is copied to all upper bits. n has to be an integer from the range -2^255 to +2^256-1 (signed or unsigned 256 bit integers), and 'bits' is an integer with 1 <= bits <= 255. This function can revert the effect of a mask function in many cases.

  If you are given a negative integer in two's complement notation, it is not possible to enter it directly as a constant, because binary, hex or octal encoded constants are always recognized as unsigned in &app;.

xor (x1; x2; ...)

  Performs a bitwise logical XOR on the submitted parameter(s) (one or more). All paramters have to be integers from the range -2^255 to +2^255-1 (signed integer). Note that xor(x) is not the identity, because the unsigned +2^255 is mapped to the signed -2^255, for example.

## Questions and Answers

What is ans?

Ans is a special variable which holds the last calculation result.

## Credits and License

Program Copyright © 2004-2008 Ariya Hidayat

Program Copyright © 2005-2006 Johan Thelin

Program Copyright © 2007-2008 Helder Correia

Program Copyright © 2007-2008 Wolf Lammen

Documentation Copyright © 2007 Ariya Hidayat.

Documentation Copyright © 2008 Wolf Lammen.

&underFDL; &underGPL;