sqrti.Rd
Square root wrapper that keeps answer real if possible, coerces to complex if not.
sqrti(x)
sqrti(1:10) #real
#> [1] 1.000000 1.414214 1.732051 2.000000 2.236068 2.449490 2.645751 2.828427
#> [9] 3.000000 3.162278
sqrti(-10:10) #coerced to complex (compare sqrt(-10:10))
#> [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
sqrti(1i+1:10) #complex anyway
#> [1] 1.098684+0.4550899i 1.455347+0.3435607i 1.755317+0.2848488i
#> [4] 2.015329+0.2480984i 2.247111+0.2225079i 2.457922+0.2034239i
#> [7] 2.652458+0.1885044i 2.833925+0.1764338i 3.004612+0.1664108i
#> [10] 3.166218+0.1579171i