Assignment 1 on Concurrent Programming | CS 361, Assignments of Computer Science

Material Type: Assignment; Class: Concurrent Programming; Subject: Computer Science; University: Drexel University; Term: Unknown 1989;

Typology: Assignments

Pre 2010

Uploaded on 08/19/2009

koofers-user-l1b
koofers-user-l1b 🇺🇸

10 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 361 Concurrent Programming
Assignment 1
Log into your queen UNIX account. Perform the following steps, starting out in your
home directory. The steps are numbered to help you keep track.
The goal of this programming assignment is to write your first Java program, if you have
not already done so.
mkdir asmt1
chmod 700 asmt1
cd asmt1
Write Java classes to integrate functions using “Adaptive Quadrature” method. Adaptive
quadrature is a numerical integration procedure in which the interval of integration is
recursively subdivided until an error tolerance is met for the approximate integral on each
subinterval. The error estimate for a given subinterval is based on the difference between
two different quadrature rules applied on the subinterval. The two quadrature rules used
in this module are the midpoint and trapezoid rules, and the recursion tree can be
traversed in depth-first or breadth-first order, or in any other order you may choose.
a. The midpoint method: evaluate the function at the midpoint of the interval and
multiply it by the width of the sub-interval.
b. The trapezoid method: evaluate the function at the ends of the internal and
compute the average of these 2 values. Multiply that average by the width of the
sub-interval.
Evaluate the midpoint rule, and trapezoid rule, for the current subinterval, as well as the
magnitude of their difference. If the two quadrature rules differ by less than the selected
tolerance, or if the subinterval width falls below some minimum allowed value [make it a
constant 10^(-5) in your program] , then that subinterval is declared "completed".
The number of subdivisions required to converge to within a given tolerance depends on
the nature of the integrand function. In particular, a region where the integrand function
has an abrupt change, sharp peak, cusp, or discontinuity will require many more
subdivisions (and hence function evaluations) than a region where the integrand function
is well behaved. The assigned integrand functions are listed in rough order of difficulty,
from easiest to hardest.
You will need to define an interface class Function with the following methods:
pf3
pf4

Partial preview of the text

Download Assignment 1 on Concurrent Programming | CS 361 and more Assignments Computer Science in PDF only on Docsity!

CS 361 Concurrent Programming

Assignment 1

Log into your queen UNIX account. Perform the following steps, starting out in your home directory. The steps are numbered to help you keep track.

The goal of this programming assignment is to write your first Java program, if you have not already done so.

mkdir asmt

chmod 700 asmt

cd asmt

Write Java classes to integrate functions using “Adaptive Quadrature” method. Adaptive quadrature is a numerical integration procedure in which the interval of integration is recursively subdivided until an error tolerance is met for the approximate integral on each subinterval. The error estimate for a given subinterval is based on the difference between two different quadrature rules applied on the subinterval. The two quadrature rules used in this module are the midpoint and trapezoid rules, and the recursion tree can be traversed in depth-first or breadth-first order, or in any other order you may choose.

a. The midpoint method : evaluate the function at the midpoint of the interval and multiply it by the width of the sub-interval.

b. The trapezoid method : evaluate the function at the ends of the internal and compute the average of these 2 values. Multiply that average by the width of the sub-interval.

Evaluate the midpoint rule, and trapezoid rule, for the current subinterval, as well as the magnitude of their difference. If the two quadrature rules differ by less than the selected tolerance, or if the subinterval width falls below some minimum allowed value [ make it a constant 10^(-5) in your program ] , then that subinterval is declared "completed".

The number of subdivisions required to converge to within a given tolerance depends on the nature of the integrand function. In particular, a region where the integrand function has an abrupt change, sharp peak, cusp, or discontinuity will require many more subdivisions (and hence function evaluations) than a region where the integrand function is well behaved. The assigned integrand functions are listed in rough order of difficulty, from easiest to hardest.

You will need to define an interface class Function with the following methods:

public float evaluate();

Implement the Function interface and then implement following concrete functions:

  1. exp(-x^2) +
  2. (x^3)*exp(x)+
  3. sin(1/x)+3/
  4. sqrt(|x|)+
  5. your choice

Write a driver AdaptiveQuadrature that reads from a command line following arguments:

  • The function to solve (int),
  • lower bound (float),
  • upper bound (float),
  • tolerance (float),

Create three different tests for each function and divert their output into test output files with following inputs:

  1. exp(-x^2) + a. lower bound = -2, upper bound =2 , tolerance = 10^(-2) b. your choice c. your choice

tar xf - < asmt1.tar

Submit your work via webct: log onto webct (webct.drexel.edu) and give the webct userid and password that you received from the instructor. Click on the assignments link of the cs361 home page. Click on the assignment 1 link of the assignments page. Then follow the directions on the resulting page for submitting asmt1.tar.gz. More than one file can be submitted through the “Student file” button, but once you hit the “submit assignment” button webct will not accept anything further.

All submissions are timestamped by the system when they are submitted. Only the latest version of a student file is stored by the system. The older versions of the file are erased.

It is your responsibility to make your portable (eliminating file names that only work on your computer, for example), so that the grader can test the program should they choose to do so.

Grading

7 points correctness, avoidance of awkward or grossly inefficient programming. :"Correctness" in this case includes: a) correctly integrating the example functions, b) correct implementation of the Function interface.

3 points, good documentation -- methods appropriately commented, header information explaining how program works/is to be used)

(Extra credit: up to 3 points, graders' choice)