qsqrt: Rational approximation of square roots

View source: R/qsqrt.R

qsqrtR Documentation

Rational approximation of square roots

Description

Returns a rational approximation of the square root of an integer.

Usage

qsqrt(x, n)

qsqrt2(n)

qsqrt3(n)

qsqrtPhi(n)

## S3 method for class 'qsqrt'
print(x, ...)

Arguments

x

the positive integer whose square root is desired

n

a positive integer, the higher the better approximation

...

ignored

Value

The qsqrt function returns a gmp rational number (class bigq) approximating the square root of x. The qsqrt2, qsqrt3, and qsqrtPhi functions return a gmp rational number approximating the square root of 2, 3, and phi (the golden number) respectively. Their value converge more fastly than the value obtained with qsqrt.

Examples

library(Boov)
qsqrt(2, 7)
qsqrt2(7)
qsqrt3(22)
qsqrtPhi(17)

Boov documentation built on Oct. 31, 2022, 5:05 p.m.

Related to qsqrt in Boov...