Consider the following R function
is.sqrt <- function(x, y){ if(x^2 == y) TRUE else FALSE }
which answers whether x is the square ro
you can use all.equal in your function, which "tests if two objects are 'nearly' equal"
all.equal
is.sqrt <- function(x, y){ isTRUE(all.equal(x^2,y) } is.sqrt(sqrt(2), 2) # TRUE is.sqrt(sqrt(2), 3) # FALSE