sqrti: Generalized square root

Description Usage Arguments Author(s) Examples

Description

Square root wrapper that keeps answer real if possible, coerces to complex if not.

Usage

1
sqrti(x)

Arguments

x

Vector to return square root of

Author(s)

Robin K. S. Hankin

Examples

1
2
3
sqrti(1:10)  #real
sqrti(-10:10) #coerced to complex (compare sqrt(-10:10))
sqrti(1i+1:10) #complex anyway

Example output

Attaching package: 'elliptic'

The following objects are masked from 'package:stats':

    sd, sigma

The following object is masked from 'package:base':

    is.primitive

 [1] 1.000000 1.414214 1.732051 2.000000 2.236068 2.449490 2.645751 2.828427
 [9] 3.000000 3.162278
 [1] 0.000000+3.162278i 0.000000+3.000000i 0.000000+2.828427i 0.000000+2.645751i
 [5] 0.000000+2.449490i 0.000000+2.236068i 0.000000+2.000000i 0.000000+1.732051i
 [9] 0.000000+1.414214i 0.000000+1.000000i 0.000000+0.000000i 1.000000+0.000000i
[13] 1.414214+0.000000i 1.732051+0.000000i 2.000000+0.000000i 2.236068+0.000000i
[17] 2.449490+0.000000i 2.645751+0.000000i 2.828427+0.000000i 3.000000+0.000000i
[21] 3.162278+0.000000i
 [1] 1.098684+0.455090i 1.455347+0.343561i 1.755317+0.284849i 2.015329+0.248098i
 [5] 2.247111+0.222508i 2.457922+0.203424i 2.652458+0.188504i 2.833925+0.176434i
 [9] 3.004612+0.166411i 3.166218+0.157917i

elliptic documentation built on May 2, 2019, 9:37 a.m.