Question
We will now measure how large k needs to be in the bakhshali function to provide a good approximation of the square root. You will
"We will now measure how large k needs to be in the bakhshali function to provide a good approximation of the square root. You will write a SCHEME function (terms-needed-b x tol) that will evaluate to the number of terms in the infinite sum needed to be within tol, that is, the smallest k such that the difference between x and (square (bakhshali x k)) is less than tol."
This is a follow-up prompt. Earlier, I had to write a recursive Scheme program that found square root estimates using the bakhshali method.
My response to the prompt is below. As far as I and those I've asked can tell, it should work. However, it does not. Why does it not work?
(define (terms-needed-b x tol) (define (square n) (* n n) ) (define (firstv x tol k) (if (>= tol (abs (- x (square (bakhshali x k))))) k (firstv x tol (+ k 1)) ) ) (firstv x tol 0) )
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started