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(MeshesOperations)
qsqrt(2, 7)
qsqrt2(7)
qsqrt3(22)
qsqrtPhi(17)

stla/MeshesOperations documentation built on Oct. 23, 2022, 8:23 a.m.