Confirm, using DrScheme, that 3/4 is a rational number but not an integer and that the square root of -1 is a complex number but not a real number.
Have DrScheme compute the square of the square root of 2 and subtract 2 from the result. Ideally, the difference should be 0; why isn't it? How big is the difference?
Confirm that the approximation that DrScheme computes as the value of the
procedure call (sqrt 2) is an inexact real number that is also
rational.
Write a Scheme numeral for 1.507 times ten to the fifteenth power, as an exact number. Have DrScheme evaluate the numeral.
Write a Scheme numeral for one-third, as an inexact number. Have DrScheme evaluate the numeral.
Use Scheme to find the reciprocal of 3/5.
Develop a Scheme procedure log10 that takes any positive real
number as argument and returns an approximation to its common (base ten)
logarithm, computing it by the method suggested in the reading. Use your
procedure to confirm that the common logarithm of one million is 6.
Develop a Scheme procedure named != that takes two numbers as
arguments and determines whether they are unequal. Here are a couple of
sample calls:
> (!= 4/7 8/14) #f > (!= -1 1) #t
Contemporary arithmetic textbooks are full of tedious-looking exercises
like ``Find the smallest positive number that is an exact multiple of 1732,
680, and 2520.'' Scheme has primitive gcd (``greatest common
divisor'' and lcm (``least common multiple'') procedures for such
computations.
Have DrScheme find the smallest positive number that is an exact multiple of 1732, 680, and 2520.
Once around the circle is an angle of 360 degrees or, equivalently,
2π radians. Develop a Scheme procedure
degrees->radians that takes the measure of an angle in
degrees and converts it to radians (by multiplying or dividing by an
appropriate conversion factor).
Note: Since π is irrational, the value of a call to this procedure
is almost always an approximation rather than an exact value. You'll
probably find, however, that (degrees->radians 0) is exactly
0.
An integer m evenly divides an integer n if the
remainder left over when n is divided by m is zero. Define a
Scheme predicate evenly-divides? that takes two arguments, both
assumed to be integers (and the second assumed to be non-zero), and returns
#t if the first evenly divides the second and #f if it does
not.
Scheme doesn't provide a cotangent procedure cot. Develop
one, using the fact that the cotangent of a number is the reciprocal of its
tangent. Hint: This procedure has a nontrivial precondition.
Develop and test a Scheme procedure round-to-nearest-hundredth that
takes any real number as its argument and rounds it off to the nearest
hundredth, returning the result.
> (round-to-nearest-hundredth 5/3) 167/100 > (round-to-nearest-hundredth 3.14159) 3.14