An Exact, Fractions and Quadratics Calculator 2019 April 2

The interactive calculator uses arbitrary precision numbers to a very large number of digits and decimal places.

Set the Working precision (number of decimal places) to a larger value to see more decimal places, up to several hundred. Spaces are ignored in all input values. The buttons will convert values and fill in the appropriate boxes too. Exact values, using recurring parts of a decimal and recurring parts of a CF are given when using the Fraction and CF conversion buttons.

Try these examples...
Select an example. Input boxes will then be filled in for you. Press the ARROW button that has then been changed to or to see the live conversion.

For more help on Expressions, Fractions and Quadratics use the buttons below the Calculator.

Multi-precision and Exact Decimal and Continued Fraction C A L C U L A T O R

Quadratic:
x2 + x +
Fraction:
+


Continued Fraction:
[
;
   ]
Recurring part
Convergents

Alternate

Reverse

Decimal:

Recurring part

Expression:
Working precision is decimal places.

R E S U L T S



Number of decimal places
You can control the precision (number of decimal places) of all results by altering the value in the Working Precision input box. Altering the value and then pressing the appropriate Calculation button will recompute values to the new precision.
Numbers
  • Must begin with a digit or a sign. A decimal point (.) is optional. Spaces are ignored.
  • For scientific notation use e or E to mean times 10 to the power of which must be preceded AND followed by an optionally signed integer
    for example 1 000 = +0.1e4 =1E3 = 10000E-1 are all valid forms for a decimal number.
  • For numbers in bases other than 10, from 2 to 35, enclose the digits in single quotes (') and follow the second quote by the base, for example '101'2 is the binary value 1012 = 5.
    Digits after 9 in bases 11 to 35 are the letters a to z or A to Z as the case does not matter. For example, 'a'12 is a12 which is 10 in base 10 and 'z'36 is 3510
  • Numbers in other bases can include a 'decimal' point. For example '1010.101'2 = 10.625 = 85/8 = 10+5/8
  • To convert a base 10 number to another base, use the tobase function - see below.
Arithmetic operators
Use +, -, / as usual but use * for all multiplications. + and - may be unary operators as in -(2+3)
^ means to the power of
Note that 2^3 means 2 to the power of 3 = 2*2*2=8 whereas 2e3 means 2 times 10 to the power of 3 = 2*10^3 = 2000.
Rules a^(-b) = 1/a^b; a^(b+c) = a^b*a^c. Examples:
// (quotient) and % (remainder)
// means "integer divide" so that a//b means the integer part of a/b or the whole number quotient.
The remainder when a is divided by b is a%b = mod(a,b)
Theorems
Since a/b = quotient + remainder/b then we always have
Theorems (Rules): (a−a%b)/b = a//b = trunc(a/b); a//b*b+a%b = a
For example: 21/5 is 4 and 1/5 so the quotient 21//5 is 4 and the remainder 21%5 is 1.
Negative a or b
The quotient a//b is negative if and only if only one of a and b is negative; the remainder always has the same sign as a.
This assures that the Rules above are always true for all values of a (the dividend) and b (the divisor).
Priority of operators
Operator priority (binding power):
Highest . . . . . . . . . . Lowest
unary +
unary −
^ *
/
%
//
binary +
binary −
If @ and Δ are two operators then
@ binds more tightly than Δ means the same as
@ has a higher priority than Δ
so that 2 @ 1 Δ 3 means (2 @ 1) Δ 3.
Brackets are needed for the expression: 2 @ (1 Δ 3).
If on the other hand Δ had a higher priority than @ then 2 @ 1 Δ 3 would mean 2 @ (1 Δ 3) and brackets would be needed for (2 @ 1 ) Δ 3.
Equal priority operators act from the left (they are left-associative) so that 2-3-4 means (2-3)-4 = -5
2^3^3 = (2^3)^3 = 8^3 = 512
2*4%5 = (2*4)%5 = 3
For example -2^4 means (-2)^4 = 16; use -(2^4) otherwise
2^1/2 mean (2^1)/2; use 2^(1/2) or 2^0.5 or sqrt(2) for the square-root of 2.
Constants
The only built-in constants are:
  • Pi or pi = 3.14159... . This is computed as 4*arctan(1) to the Working precision.
  • E or e = 2.71828... : E = [2; 1,2,1, 1,4,1, 1,6,1, 1,8,1, 1,10,1, ...]
  • Phi and phi the golden ratios, Phi = (sqrt(5) + 1)/2 = 1.618... and phi = (sqrt(5) − 1)/2 = 0.618..
    These values are connected and defined by Phi = 1/phi = phi+1; phi = 1/Phi = Phi − 1
    Phi = [1; 1 ];
Apart from Phi and phi, constants can be in UPPERCASE or lowercase.
Functions
a name (using UPPER or lower case letters) followed by arguments in brackets separated by a comma: for example sqrt(2.3) and log(2,10)
  • tobase(n,b) convert (base 10 number) n to base b (in range 2 to 36). for example tobase(14,2) is 1110
  • trunc(x) truncate x: forget any digits after the decimal point but retain the sign
    trunc(2.9) is 2; trunc(-2.3) = -2 = trunc(-2.9); trunc(2.3) = 2
  • round(x) rounds x to the nearest integer
    round(2.9) = 3; round(-2.3) = -2; round(-2.9) = -3; round(2.3) = 2;
  • abs(x) the absolute value of x: x if x≥0 and -x if x<0
  • sqrt(x) the square-root of x: for example sqrt(2) = 1.414... is the same as 2^0.5
  • mod(x,d) the remainder when x is divided by d. The remainder has the same sign as x
  • powmod(x,p,d) the remainder when xp is divided by d. This should be used for large x, p or d to avoid loss of precision calculating xp when this value is very large. It is equivalent to mod(x^p,d) but is much faster.
Trigonometric functions:
  • degtorad(x) convert the angle x from degrees to radians: for example degtorad(90) is pi/2 = 1.57079632... and cos(toRadians(45))^2 = 0.5
  • radtodeg(x) convert the angle x from radians to degrees: for example radtodeg(arctan(1)) = 45
  • sin(x) the sine of an angle x in radians: for example sin(PI/3)^2 is 0.75
  • cos(x) the cosine of an angle x in radians: for example cos(pi/4)^2 is 0.5
  • tan(x) the tangent of an angle x in radians: for example tan(1) as a CF is [1; 1,1, 3,1, 5,1, 7,1, 9,1, 11,1, 13,1, ...]
  • arcsin(s) gives the angle in radians whose sine is s. The angle returned is between -PI/2 and PI/2 (±1.57079632...) radians.
  • arccos(c) gives the angle in radians whose cosine is c. The angle returned is between 0 and PI radians.
  • arctan(t) gives the angle in radians whose tangent is t. The angle returned is between -PI/2 and PI/2 (±1.57079632...) radians.
Functions related to e:
  • log(x) which is the natural log of x: for example log(E^2) is 2
  • log(b, x) finds log to base b of x: log to base 2 of 8 (=23) is log(2,2^3) = 3
    How many digits has fib(200)? log(10,fib(200)) = 41.44.. to it has 45 digits
  • exp(x) which is E to the power of x; for example exp(3.4) is the same as E^3.4
    exp(1/2) = E^(1/2) = sqrt(E) = [1; 1, 1,1,5, 1,1,9, 1,1,13, 1,1,17, 1,1,21, ...]
    exp(1/3) = E^(1/3) = [1; 2, 1,1,8, 1,1,14, 1,1,20, 1,1,26, 1,1,32, ...]
  • sinh(x) the hyperbolic sine defined as (Ex−E-x)/2
  • cosh(x) the hyperbolic cosine defined as (Ex+E-x)/2 which will be ≥1
  • tanh(x) the hyperbolic tangent defined as sinh(x)/cosh(x). -1≤tanh(x)≤1 for all x
    tanh(1) as a CF is [0;1, 3, 5, 7, 9, 11, 13, ...]
    tanh(1/2) as a CF is [0;2, 6, 10, 14, 18, 22,...]
  • arcsinh(x) the inverse hyperbolic sine defined as the value y for which sinh(y)=x
  • arccosh(x) the inverse hyperbolic cosine defined as the value y for which cosh(y)=x
    only defined if x≥1 and returns NaN otherwise
  • arctanh(x) the inverse hyperbolic tangent defined as the value y for which tanh(y)=x
    only defined if −1≤x≤1
Other functions
  • champ(b), the Champernowne number in base b: see The decimal number 0.12345... .
    The argument is the base of the numbers. champ(10)=0.1234567891011121314... . Bases are 2 to 10 and the resulting sequence (the numbers 0,1,2,... but in base b) is converted to a decimal number. For example: champ(2) is 0.1 10 11 100 101 ... in base 2 which is 0.8622401258680545... as a decimal number. To see the base 2 form, use tobase(champ(2),2)
    See Champernowne numbers in different bases
  • fib(n) The n-th Fibonacci number where
    fib(0)=0, fib(1)=1 and fib(n)=fib(n-1)+fib(n-2). n is an integer and can be negative.
    RULE: fib(n) = (Phi^n-(-phi)^n)/sqrt(5)
  • luc(n) the n-th Lucas number where luc(0)=2, luc(1)=1, luc(n)=luc(n-1)+luc(n-2). n is an integer and can be negative.
    RULE: luc(n) = Phi^n + (-phi)^n
  • gfib(a,b,n) the n-th General Fibonacci number where
    gfib(a,b,0)=a, gfib(a,b,1)=b, gfib(a,b,n)=gfib(a,b,n-1)+gfib(a,b,n-2). n is an integer and can be negative.
    RULE: gfib(a,b,n) = a*fib(n-1) + b*fib(n)
  • primefactors(n) find the prime factors of n
    Will find all the prime factors of n that are less than 1013 (otherwise testing a prime larger than this would take more than 10 seconds or so). Any unresolved divisors will have no prime factors below this limit and will be shown like this. The result is shown as primepower×primepower...
    primefactors(31622816796611496307) = 31622772×3162283
    primefactors(10000021122911) = 10000021122911 is prime
    primefactors(10000021122989) = 10000021122989 has no prime factors <1013
A Continued Fraction (CF) is [ integer part ; fixed part , periodic part ]
The fixed part and the periodic part are a list of whole numbers separated by a comma and either part is optional
A decimal fraction is whole part . fixed digits periodic digits
A decimal fraction for a fraction R/S will have always have a fixed decimal part or a periodic decimal part or both.
3/25 = 0.12
4/33 = 0.12
37/300 = 0.123
A fraction (R ±√N)/S with N>0 and not a square number will always have an infinite decimal fraction with no periodic part
√2 = 1.41421356237309504880168872420969807856967187537694...
A finite Continued Fraction (CF) with no periodic part is always a fraction R/S for integers R and S.
[2; 3, 4] = 30/13
A fraction (R ±√N)/S with N>0 and not a square number will always have a CF with a finite periodic part
√5 = [2; 4]
(−1 + √15)/2 = [1; 2, 3]
(405 + √15)/330 = [1; 4, 5, 2, 3]
Any CF with an undending fixed part is not of the form (R±√N)/S for integers R, N and S.
E = 2.71828... = [2; 1,2,1, 1,4,1, 1,6,1, 1,8,1, 1,10,1, 1,12,1, ... ]
For more information see Decimals and Fractions and Introduction to Continued Fractions.

The roots of a quadratic A x2 + B x + C are the x-values that solve the equation A x2 + B x + C = 0.
If the three coefficients A, B, C are whole numbers (positive, zero or negative) then the roots are of the form
R ± √ N
S
for whole numbers R, N, S as given by "the formula"
x =  −B  ± B2 − 4 A C
2 A

Non-integer values are changed to integers since the roots of T×(A x2 + B x + C) where T is some power of 10 are exactly the same as the roots of A x2 + B x + C.
Roots are shown in their simplest forms in the Results and in their ( R ± √ N ) / S integer form in the Fractions boxes.
Converting the roots separately into CFs shows the pattern in their CFs.
To see the decimal value of roots to the Working Precision, use the Fraction to Decimal conversion button.

Quadratic to Roots:

If you input coefficients for the quadratic then the button will find its roots.
Empty input fields mean x2 + x +
Examples:

Roots to Quadratic:

If you press the , the two values in the Fraction part (one with +, the other with -) are taken as roots of a quadratic whose coefficients A, B, C are then found.

Links to more about the Calculations on this page:


Valid HTML 4.01! © 2003-2023 Dr Ron Knott      enquiry (at) ronknott (dot) com
with thanks to Michael Mclaughlin for his BigNumber.js library (see MIT GitHub licence).