

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A computer science project for cpsc 244 students in spring 2009. The project involves completing programming tasks related to chapter 6 material, including integrating functions using the trapezoid rule and simpson's rule, and finding square and cube roots using newton's method.
Typology: Study Guides, Projects, Research
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Programming with Functions
ASSIGNED: 7 April 2009 DUE: 21 April 2009 (by the end of class.) VALUE: 54 points
Overview: In this project you will complete programming problems related to Chapter 6 material. For ALL programs
Tasks:
1 σ
2 π
e−^
1 2 ( x−μ σ )
2 ,
where σ is the standard deviation, and μ is the mean. If we set z = (x − μ)/σ and let σ = 1 we get a function (which we will integrate)
y(z) =
2 π
e−^
(^12) z 2 (1)
which when integrated from −∞ to ∞ should equal 1.
(a) Integrate Eqn. (1) using the trapezoid rule (as discussed in class). Use an internal function to calculate needed values of y(z). Input values for a, b, and the number of iterations n. Name this program Chap6_T1a.f90. (b) Integrate the function y(x) = 1/x using the trapezoid rule. Use an internal func- tion to calculate needed values of y(x). Input values for a, b, and the number of iterations n. Also, compare your answer to the exact value of the integral (using the intrinsic LOG(x) function). Name this program Chap6_T1b.f90.
a
f (x)dx ≃
h 3
[f (x 0 ) + 4f (x 1 ) + 2f (x 2 ) + 4f (x 3 ) + · · · + 2(xn− 1 ) + f (xn)].
(a) Integrate Eqn. (1) using the Simpson’s rule. Use an internal function to calculate needed values of y(z). Input values for a, b, and the number of iterations n. Name this program Chap6_T2a.f90. (b) Integrate the function y(x) = 1/x using the Simpson’s rule. Use an internal function to calculate needed values of y(x). Input values for a, b, and the number of iterations n. Also, compare your answer to the exact value of the integral (using the intrinsic LOG(x) function). Name this program Chap6_T2b.f90.
(a) Request that the user input a real number√ R and then use Newton’s Method to find R. Program the function F and the derivative F P rime as module subprograms and import them into your main program using a USE statement. Name this program Chap6_T3a.f90, and name the module SRoot. (b) Request that the user input a real number R and then use Newton’s Method to find √ (^3) R. Program the function F and the derivative F P rime as module subprograms
and import them into your main program using a USE statement. Name this program Chap6_T3b.f90, and name the module CRoot.
Submit the following: