finalreport6 - Benjamin Jones 02/14/08 Final Report...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Benjamin Jones 02/14/08 Final Report Laboratory 6 Program Source Code Header File: // *********************************************************************** // File: findroots.h // // Stats of a list of data - User enters a number to take a root of, the root // to take of that number, a desired precision, and the program will output // the root of that number to the given precision. // // // // Author: Benjamin Jones // Created: 14 February 2008 // Updated: Original // // Assignment: Lab 6 // Compiler: gcc version 4.1.1 // // ************************************************************************ // // Function Organization: // // 2. Calculate the nth root of the number to a given precision // 2.A Set the current value equal to the number to root over the root // 2.B Intialize the new value, as well as the difference comparison // 2.C If nth root is zero (no need to compute) // 2.C.I Exit function returning the nth root // 2.D While the abolute value of the difference of the current value // and the new value is greater than the desired precision // 2.D.I If new value is not zero (not the first time through // the loop) // 2.D.I.a Set current value equal to old value // 2.D.II Set new value equal to the reciprocal of the root we // we are taking multiplied by the quantity of the // current value multiplied by the nth root minus one // added to the quantity of the number we are taking // the root of divided by the current value to the power // of the nth root minus one. // 2.E Find the difference of the current value and the new value // 2.F Return the new value // // ********************************************************************** #ifndef FINDROOT_H
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
#define FINDROOT_H #endif #include <iostream> #include <string> #include <cmath> using namespace std; const int OK = 0; const int NOTOK = 1; // 2. Calculate the nth root of the number to a given precision double findNthRoot(double numberToRoot = 0.0, double nthRoot = 2.0, double desiredPrecision = 10e-9) { // Function calculates the nth root of the number to a given precision
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This lab report was uploaded on 04/18/2008 for the course ECEE 120 taught by Professor Carter during the Winter '08 term at University of Cincinnati.

Page1 / 7

finalreport6 - Benjamin Jones 02/14/08 Final Report...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online