Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

the Favorites Bar folder. Or import from anoth e rm to page D Pageview | A Reade Assigment 2 Specifications Due: 011 February, 2020-class time.

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
the Favorites Bar folder. Or import from anoth e rm to page D Pageview | A Reade Assigment 2 Specifications Due: 011 February, 2020-class time. [/R] refers to Kernighan/Ritchie text; [D/D) refers to Deitel/Deitel text. Assignment. Write algorithm and a program to determine which of a sequence of integers is a perfect number and then compute the cube root (V) of each such perfect number. See page 207 in [D/D] for details regarding perfect numbers (Exercise 5.26). The approximation of the cube root (3V) will be done as an infinite series, using the Newton-Raphson Method: VS - *n+1 " Xn- (f(x) / f'(X)) as n goes from 0 to , as dictated by desired accuracy: where S is the perfect numbers Xo is the initial "ques"; f(x) = x - 5 f'(x) - 3x? [derivative of f(x)] See https://en.wikipedia.org/wiki/Newton+27s_method for details. Use only the Newton-Raphson method (above) for your cube root (V), not any c math library functions. Input: Program will prompt the user to provide the desired decimal-place accuracy, in the range of 11-15), inclusive, for the cute root. User prompt must clearly indicate what is a valid input. User input must be validated - ensuring that the value entered is an integer in the above range, Output: Output will include all of the perfect numbers between 1-100,0001 along with an ordered list of their factors to confirm the factors su to the perfect number - see sample output. For each perfect number, the output will also include the initial cube root "ques". the expected value using cbrt() for a similar function). your computed value for the cube root of that number, the required decimal-place accuracy (as indicated by the user). the segured epsilon, and the number of tom o rsto t took to reach the MY TECH 1-888-23 number, the required decimal-place accuracy (as indicated by the user), the required epsilon, and the number of terms Citerations) it took to reach the required decimal-place accuracy. Results should be formatted and displayed so as to allow easy comparison of the computed and expected values. Labels should be included, where appropriate - alignment bar is required. See sample output below. A message must also be displayed to the screen indicating the wornt-case" (approximate but accurate) time for how long we should wait for your results. Requirements: Use only material covered in the first four chapters of [K/R) and first five chapters of [D/D). Arrays are permitted. Style requirements as discussed in class expected. Efficiency should always be considered. Since the above algorithms could both execute large loops, efficiency is paramount. Initially, consider how to identify perfect numbers most efficiently. Additionally, consider the initial guess in the Newton-Raphson method and how to ensure that guess is close without excessive work in order to minimize the follow-on iterations. Always choose the most appropriate loop/decision structures and variable/ constant types. Use of appropriate constants expected. Use CONSTANTS and enumerations where appropriate. LOODU LUWUJLUPPI PLUG VOPUIDIUL JUEGO LUGUE VELUX constant types. Use of appropriate constants expected. Use CONSTANTS and enumerations where appropriate. Functions should focus on a single task and do it well - and use as many functions as dictated by your design - with appropriate return values. Main() should only be the high-level tasks. Pay close attention to the return values and their types. Use allowed Standard c libraries as required - and document. You may also find DBL EPSILON useful. Clearly document your compilation and execution. You may NOT use the math library "cube root" or "pow" function in your computation - directly or indirectly. Use ONLY the delta difference of your running computation to determine when to stop your loop. (Hint: consider when the delta between subsequent computations ceases to meaningfully affect your computation - drops below your epsilon (threshold) - as determined by the required accuracy. ] Submission: Your program must be able to compile/link and execute on PIU SCIS, using gcc. Test it there before you submit. Your source code file name should be meaningful and documented in the first line in your program. Refer to the Canvas documents: "How to Develop a Simple C Program" and "Style Guide" documents for details on required program format and documentation. Review all documents carefully! Algorithms (pseudocode) should be submitted in a separate text file (or .pdf) and included with the Canvas posting and class submission. Print out a copy of your source code and pseudocode and submit in class - signed, stapled and collated in the specified sequence: primary source code (w/main) file and then the pseudocode text file. Submit in class NO LATER THAN the first 15 minutes of class. Sample output for one perfect number would look something like: This may take up to 30 seconds to complete. Perfect number: 6 - 1 + 2 + 3; alignment bar - 1234567890abcdefghij Computed cube root of : 6 = 1.81712... Expected cube root of : 6 - 1.817120592832139 Initial "guess" Required iterations : Required epsilon Desired accuracy 0.0 Noter output above is just an example, values may not be correct. the Favorites Bar folder. Or import from anoth e rm to page D Pageview | A Reade Assigment 2 Specifications Due: 011 February, 2020-class time. [/R] refers to Kernighan/Ritchie text; [D/D) refers to Deitel/Deitel text. Assignment. Write algorithm and a program to determine which of a sequence of integers is a perfect number and then compute the cube root (V) of each such perfect number. See page 207 in [D/D] for details regarding perfect numbers (Exercise 5.26). The approximation of the cube root (3V) will be done as an infinite series, using the Newton-Raphson Method: VS - *n+1 " Xn- (f(x) / f'(X)) as n goes from 0 to , as dictated by desired accuracy: where S is the perfect numbers Xo is the initial "ques"; f(x) = x - 5 f'(x) - 3x? [derivative of f(x)] See https://en.wikipedia.org/wiki/Newton+27s_method for details. Use only the Newton-Raphson method (above) for your cube root (V), not any c math library functions. Input: Program will prompt the user to provide the desired decimal-place accuracy, in the range of 11-15), inclusive, for the cute root. User prompt must clearly indicate what is a valid input. User input must be validated - ensuring that the value entered is an integer in the above range, Output: Output will include all of the perfect numbers between 1-100,0001 along with an ordered list of their factors to confirm the factors su to the perfect number - see sample output. For each perfect number, the output will also include the initial cube root "ques". the expected value using cbrt() for a similar function). your computed value for the cube root of that number, the required decimal-place accuracy (as indicated by the user). the segured epsilon, and the number of tom o rsto t took to reach the MY TECH 1-888-23 number, the required decimal-place accuracy (as indicated by the user), the required epsilon, and the number of terms Citerations) it took to reach the required decimal-place accuracy. Results should be formatted and displayed so as to allow easy comparison of the computed and expected values. Labels should be included, where appropriate - alignment bar is required. See sample output below. A message must also be displayed to the screen indicating the wornt-case" (approximate but accurate) time for how long we should wait for your results. Requirements: Use only material covered in the first four chapters of [K/R) and first five chapters of [D/D). Arrays are permitted. Style requirements as discussed in class expected. Efficiency should always be considered. Since the above algorithms could both execute large loops, efficiency is paramount. Initially, consider how to identify perfect numbers most efficiently. Additionally, consider the initial guess in the Newton-Raphson method and how to ensure that guess is close without excessive work in order to minimize the follow-on iterations. Always choose the most appropriate loop/decision structures and variable/ constant types. Use of appropriate constants expected. Use CONSTANTS and enumerations where appropriate. LOODU LUWUJLUPPI PLUG VOPUIDIUL JUEGO LUGUE VELUX constant types. Use of appropriate constants expected. Use CONSTANTS and enumerations where appropriate. Functions should focus on a single task and do it well - and use as many functions as dictated by your design - with appropriate return values. Main() should only be the high-level tasks. Pay close attention to the return values and their types. Use allowed Standard c libraries as required - and document. You may also find DBL EPSILON useful. Clearly document your compilation and execution. You may NOT use the math library "cube root" or "pow" function in your computation - directly or indirectly. Use ONLY the delta difference of your running computation to determine when to stop your loop. (Hint: consider when the delta between subsequent computations ceases to meaningfully affect your computation - drops below your epsilon (threshold) - as determined by the required accuracy. ] Submission: Your program must be able to compile/link and execute on PIU SCIS, using gcc. Test it there before you submit. Your source code file name should be meaningful and documented in the first line in your program. Refer to the Canvas documents: "How to Develop a Simple C Program" and "Style Guide" documents for details on required program format and documentation. Review all documents carefully! Algorithms (pseudocode) should be submitted in a separate text file (or .pdf) and included with the Canvas posting and class submission. Print out a copy of your source code and pseudocode and submit in class - signed, stapled and collated in the specified sequence: primary source code (w/main) file and then the pseudocode text file. Submit in class NO LATER THAN the first 15 minutes of class. Sample output for one perfect number would look something like: This may take up to 30 seconds to complete. Perfect number: 6 - 1 + 2 + 3; alignment bar - 1234567890abcdefghij Computed cube root of : 6 = 1.81712... Expected cube root of : 6 - 1.817120592832139 Initial "guess" Required iterations : Required epsilon Desired accuracy 0.0 Noter output above is just an example, values may not be correct

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

L A -r- P[N]

Answered: 1 week ago