Question: My question is with Racket. I need to create a purely functional Racket function log2 to approximate log2(x) using the first n terms of the

My question is with Racket. I need to create a purely functional Racket function log2 to approximate log2(x) using the first n terms of the infinite series for ln(x)

lnx = loge (x) = 2[(x-1)/(x+1) +(1/3)((x-1)(x+1))^3 +(1/5)((x-1)(x-1)) +... ]

and

loga(x) = (logb(x))/(logb(a))

My function should take two parameters, x and the number of terms to compute and it should display an error message if x 0.

So Far I have this, but it is not working and now I am stuck:

(define (log2 x) (/ (log x) (log 2) (cond (> 0 /(/2 (-(*(2 x) 1))) *(/(-(x 1) +(x 1))(exp (-(*(2 x) 1)))))))) (else ('Error')))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!