Learn R Programming

MeshesOperations (version 0.1.0)

qsqrt: 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 qsqrt print(x, ...)

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.

Arguments

x

the positive integer whose square root is desired

n

a positive integer, the higher the better approximation

...

ignored

Examples

Run this code
library(MeshesOperations)
qsqrt(2, 7)
qsqrt2(7)
qsqrt3(22)
qsqrtPhi(17)

Run the code above in your browser using DataLab