Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The prototype of the file is: nth.root <- function(a,n,tol) a,n, and tol are all

ID: 3607137 • Letter: T

Question

The prototype of the file is:
nth.root <- function(a,n,tol)
a,n, and tol are all positive real numbers stored in a vector. The vector length should be 1. Note that R does not have a concept of scalars, so we must use vectors of length 1.
If tol is less than 1e-15, then you should use the stop() function and send an error message.
The function returns a vector of length 1. Its value is the nth root of a.
Use Newton’s method discussed in class to calculate your answer. The tol parameter is used to determine the halting condition for the iterative algorithm. If the absolute value of two consecutive iterates is less than tol, the iteration terminates. Return the last iterate. Use a as your first iterate.
Do NOT use a^(1/n) to compute your answer. Do not use any other R function that computes an nth root. Do not load any packages in the file you send to me.
Use the function names and arguments indicated. DO NOT have any tests in your file. The only executable statement is the name = statement. Note that it is not Name =. Also make sure it is not a comment. Make sure your file does not produce a syntax error. Do not call the R sort() function, or any other sorting function in your code.
Given below is an example of computing the cube root of 3456 using a tolerance of 1e-12. > options(digits = 15) > a = 3456 > n = 3 > tol = 1e-12 > z = nth.root(a,n,tol) > z [1] 15.1190525987385

Explanation / Answer

#include using namespace std; int main() { float n1, n2, n3; cout > n1 >> n2 >> n3; if(n1 >= n2 && n1 >= n3) { cout