Question: ) Make my.sqrt and my.sqrt2 functions in your global environment (created in Script 3.3 below) . Use my.sqrt to calculate the following (show the returned
- ) Make my.sqrt and my.sqrt2 functions in your global environment (created in Script 3.3 below). Use my.sqrt to calculate the following (show the returned values or statements): USE R-STUDIO
- (1 Point) 36
- (1 Points) -16
- (1 Point) 6i
- (1 Point) 110
- (1 Point) 0
# Script 3.3 Finding the Square Root # with Guess-Divide-Average
my.sqrt <- function (x) { # Find the square root of a number using the # guess-divide-average method. if(is.numeric(x)& x>=0) { guess=2 my.sqrt2(x,guess) } else print("Invalid parameter!") } # end my.sqrt2
my.sqrt2 <- function(x,guess) { while(abs(guess- x/guess) > 0.001) {guess <-(guess + x/guess) / 2 } return(guess) } # end my.sqrt2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
