Question: 1. Warm up. Let's define some functions having to do with circles and spheres. (a) First thing, let us define a function pi (with no

1. Warm up. Let's define some functions having to do with circles and spheres. (a) First thing, let us define a function pi (with no parameters) for , so whenever we need we simply evaluate (pi) We could define it as equal to a constant, as in the following: (define (pi) 3.14) This is a pretty poor approximation: yours should be better. Hint: Scheme has inverse trig functions asin, acos, and atan these will give you the angle (in radians) for a given sine, cosine, or tangent value. You should be able to calculate using one of these. (b) The area of a circle with radius r is mr. Define a function (area-of-circle r) that uses PI that you defined as above. The surface area of a sphere with radius r is 4r. Define a function for (surface-area-of-sphere r) that gives the surface area of a sphere with radius r. This function should use your area-of-circle function The volume of a sphere is volume of a sphere with radis r. This function should use your surface-area-of-sphere (c) (d) 3. Define function for (volume-of-sphere r) that gives the 2. The first three values of a particular sequence are 1, 2,3. The remaining values in the sequence can be calculated as a function of the three preceding values in the sequence sum of the three g values in the sequence as f If n =1; If n = 2; If n = 3; -3-S-2Sotherwise. So, the fourth value in the sequence would be 1- 2+3 2. Write a recursive Scheme function to e the nth value in the sequence. 3. Write a recursive function, named zeno, that computes the sum of the first n terms of the following series frorn Zeno's Dichotomy Paradox. Zn-t + 2 -You may use the built-in exponentiion function (expt x n) which evaluates to r" 4. We can determine whether a non-negative number is even using the following recursive defini- tion: if n 0; (even-nn-int? n)- #1 (even-nn-int? ( n 2)) otherwise. (a) Write a recursive function, named even-nn-int? that determines whether a non-negative number is even or not using the above definition. (Note: do not call it even?, as it would clash with an existing function. Don't use the existing even?, odd?, or modulo functions.) (b) Using even-nn-int?, write a function even-int? that determines whether any integer is even (c) Finally, we define odd-int? that determines whether any integer is odd
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
