15. Exercise Set 6

Exercise 6.1: Quadratic Roots Function

Given: three real values, a, b, and c, and the formula for the roots of a quadratic equation
x1 = b + (b**2-4ac)**0.5/2a and
x2 = b - (b**2-4ac)**0.5/2a;
Compose: a function of a, b, and c that calculates and returns the roots or some flag values if the roots cannot be calculated.
Click here for a sample answer.

Exercise 6.2: Relaxation Function

Given: a two-dimensional array, A, of real values
Compose: a function of A that performs one relaxation step, returning the new array whose values at each position [i, j] are the average of the values from A of that position and that position's eight nearest neighbors, [i+/-1, j+/-1].
Note: Keep the edges of the input system constant, relax only the elements of the system having eight neighbors, and return only the relaxed subsystem. the portion that has been relaxed.
Click here for a sample answer.

Exercise 6.3: Polynomial Evaluation Program

Given: a two-dimensional array, C, of real valued polynomial coefficients, each row of which contains the coefficients of a single polynomial;
Given: for each row of C, the index of each coefficient's position is the exponent of x for that term;
Given: a one-dimensional array X of real valued polynomial unknowns, with each element corresponding to the unknown for the whole set of polynomials;
Compose: a function of C and X that evaluates each polynomial with each unknown, and returns the two-dimensional array containing in each row the value of each polynomial for one of the unknowns.
Click here for a sample answer.




Previous Section



Next Section



Table of Contents




If you have any questions about this page, or want more information about the Sisal Language Project, contact:
John Feo at (510) 422-6389 or feo@diego.llnl.gov, or Tom DeBoni at (510) 423-3793 or deboni@llnl.gov.

The Sisal Language Project has been approved as a Designated Unclassified Subject Area (DUSA) K19222, as of 07 August, 1991.

LLNL Disclaimer
UCRL-MI-122601