5. Exercise Set 1

Note: The exponentiation operation "a**b" as described below does not exist in Sisal-1.2. Use instead "exp(a,b)". The normal exponential function is "etothe(b)". Since this is an external function, a "global" declaration is required:
global etothe(b: real returns real)
or
global etothe(b: double_real returns double_real)
Also, since integers and reals cannot be mixed in Sisal, expressions like "a/4" where "a" is real are illegal. Use "a/4.0" instead.

-- D. J. Raymond, 17 Jan 2015.

Exercise 1.1: The Circle

Given: a real value, r, for the radius of a circle;
Compose: a let-in statement that returns the area and circumference of a circle of the given radius.
Click here for a sample answer.

Exercise 1.2: Statistics

Given: four values, a, b, c, and d, all real numbers;
       the formulas for the mean and standard deviation
            mean = (a+b+c+d)/4;
            standard deviation = (((a-mean)**2 + (b-mean)**2 +
                                   (c-mean)**2 + (d-mean)**2) / 3)**0.5
Compose: a let-in statement that returns the mean and standard deviation of the given set of numbers.
Click here for a sample answer.

Exercise 1.3: Cubic Roots

Given: two real values, a, and  b, coefficients of the cubic
            equation x**3 + ax + b = 0;
the formulas for the roots x = C + D, -(C + D)/2 + 3**0.5*(C - D)/2, and -(C + D)/2 - 3**0.5*(C - D)/2, where C = (-b/2 + ((b**2)/4 + (a**3)/27)**0.5)**(1/3), and D = (-b/2 + ((b**2)/4 - (a**3)/27)**0.5)**(1/3);
Compose: a let-in statement that returns the roots of the cubic equation.
Click here for a sample answer.



Previous Section



Next Section



Table of Contents