Your task for this assignment is to implement a small number of mathematical functions (e* and /x), mimicking, and using them to compute the fundamental constants e and 7. You will also need to write...

1 answer below »
I uses c programming. I need help with these assignment.


Your task for this assignment is to implement a small number of mathematical functions (e* and /x), mimicking , and using them to compute the fundamental constants e and 7. You will also need to write a dedicated test harness comparing your implemented functions with that of the math library's, then analyzing and presenting your findings in a writeup. The test harness should be a program named mathlib-test. The interface for your math library will be given in mathlib.h. You may not modify this file. The following sections will describe the functions that you need to write, and the files that should contain the functions. You are strictly forbidden to use any functions from in your own math library. You are also forbidden to write a factorial () function. Each of the functions you will write must halt computation using an € = 10~'4, which will be defined inmathlib.h. For example, consider approximating the value of e. For sufficiently large k, |x¥| < k!.="" as="" seen="" in="" figure="" 1,="" x*="" dom-="" inates="" briefly,="" but="" is="" quickly="" overwhelmed="" by="" k!,="" making="" the="" ratio="" rapidly="" approach="" zero.="" 6.1="" e.c="" this="" file="" should="" contain="" two="" functions:="" e()="" and="" e_terms().="" the="" former="" function="" will="" approximate="" the="" value="" of="" e="" using="" the="" taylor="" series="" presented="" in="" §3="" and="" track="" the="" number="" of="" computed="" terms="" by="" means="" of="" a="" static="" variable="" local="" to="" the="" file.="" the="" latter="" function="" will="" simply="" return="" the="" number="" of="" computed="" terms.="" 6.2="" madhava.c="" this="" file="" should="" contain="" two="" functions:="" pi_madhava()="" and="" pi_nadhava_terms="" ().="" the="" former="" function="" will="" ap-="" proximate="" the="" value="" of="" 7="" using="" the="" madhava="" series="" presented="" in="" §4.2="" and="" track="" the="" number="" of="" computed="" terms="" with="" astatic="" variable,="" exactly="" like="" in="" e.="" c.="" the="" latter="" function="" will="" simply="" return="" the="" number="" of="" computed="" terms.="" 6.3="" euler.c="" this="" file="" should="" contain="" two="" functions:="" pi_euler()="" and="" pi_euler_terns().="" the="" former="" function="" will="" approxi-="" mate="" the="" value="" of="" x="" using="" the="" formula="" derived="" from="" euler's="" solution="" to="" the="" basel="" problem,="" as="" described="" in="" §4.4.="" it="" should="" also="" track="" the="" number="" of="" computed="" terms.="" the="" latter="" function="" will="" simply="" return="" the="" number="" of="" computed="" terms.="" 6.4="" bbp.c="" ‘this="" file="" should="" contain="" two="" functions:="" pi_bbp()="" and="" pi_bbp_terms="" ().="" the="" former="" function="" will="" approximate="" the="" value="" of="" 7="" using="" the="" bailey-borwein-plouffe="" formula="" presented="" in="" §4.5="" and="" track="" the="" number="" of="" computed="" terms.="" the="" latter="" function="" will="" simply="" return="" the="" number="" of="" computed="" terms.="" 6.5="" viete.c="" this="" file="" should="" contain="" two="" functions:="" pi_viete="" ()="" and="" pi_viete_factors().="" the="" former="" function="" will="" approx-="" imate="" the="" value="" of="" 7="" using="" viete's="" formula="" as="" presented="" in="" §4.6="" and="" track="" the="" number="" of="" computed="" factors.="" the="" latter="" function="" will="" simply="" return="" the="" number="" of="" computed="" factors.="" 6.6="" newton.c="" this="" file="" should="" contain="" two="" functions:="" sqrt_newton()="" and="" sqrt_newton_iters().="" the="" former="" function="" will="" approximate="" the="" the="" square="" root="" of="" the="" argument="" passed="" to="" it="" using="" the="" newton-raphson="" method="" presented="" in="" §5.="" this="" function="" should="" also="" track="" the="" number="" of="" iterations="" taken,="" which="" the="" latter="" function="" will="" return.="" 6.7="" mathlib-test.c="" this="" file="" will="" contain="" the="" main="" test="" harness="" for="" your="" implemented="" math="" library.="" it="" should="" support="" the="" following="" command-line="" options:="" +="" -a:runs="" all="" tests.="" *="" -e:="" runs="" e="" approximation="" test.="" -b:="" runs="" bailey-borwein-plouffe="" 7="" approximation="" test.="" -m:="" runs="" madhava="" x="" approximation="" test.="" -r:="" runs="" euler="" sequence="" 7="" approximation="" test.="" -v:="" runs="" viéte="" zr="" approximation="" test.="" -n:="" runs="" newton-raphson="" square="" root="" approximation="" tests.="" +="" -s:="" enable="" printing="" of="" statistics="" to="" see="" computed="" terms="" and="" factors="" for="" each="" tested="" function.="" «="" -h:="" display="" a="" help="" message="" detailing="" program="" usage.="" the="" expected="" output="" for="" each="" of="" the="" e="" or="" 7="" tests="" should="" resemble="" the="" following:="" ./mathlib-test="" -e="" -b="" -v="" 81828459046,="" m_e="2.718281828459045," diff="0.000000000000000" 3.141592653589793,="" m_pi="3.141592653589793," diff="0.000000000000000" =="" 3.141592653589775,="" m_pi="3.141592653589793," diff="0.000000000000018" note="" that="" the="" newline="" should="" occur="" after="" the="" printed="" difference.="" you="" can="" refer="" to="" the="" reference="" program="" in="" the="" resources="" repostiroy="" for="" the="" example="" output.="" with="" the="" statistics="" option="" enabled,="" the="" output="" should="" resemble="" the="" following:="" $="" ./mathlib-test="" -e="" -b="" -v="" -s="" e()="2.718281828459046," m_e="2.718281828459045," diff="0.000000000000000" e="" terms="18" pi_bbp()="3.141592653589793," m_pi="3.141592653589793," diff="0.000000000000000" pi_bbp()="" terms="11" pi_viete()="141592663589775," m_pi="3.141592653589793," diff="0.000000000000018" rls="" px}="" you="" will="" specially="" test="" your="" sqrt_newton="" ()="" function="" in="" the="" range="" [0,="" 10)="" in="" steps="" of="" 0.1.="" again,="" you="" can="" refer="" to="" the="" reference="" program="" in="" the="" resources="" repository="" for="" the="" example="" output.="" any="" double="" that="" is="" printed="" should="" use="" the="" following="" printf="" ()="" format="" specifier:="" 161f\n",="" pi="" 7="" command-line="" options="" afew="" dud="" universes="" can="" really="" clutter="" up="" your="" basement.="" —neal="" stephenson,="" in="" the="" beginning...="" was="" the="" command="" line="" your="" test="" harness="" will="" determine="" which="" of="" your="" implemented="" functions="" to="" run="" through="" the="" use="" of="" command-line="" option.="" in="" most="" c="" programs,="" the="" main="" ()="" function="" has="" two="" parameters:="" int="" argc="" and="" char="" **argv.="" acommand,="" such="" as="" ./exec="" argl="" arg?="" is="" split="" into="" an="" array="" of="" strings="" referred="" as="" arguments.="" the="" parameter="" argv="" is="" this="" array="" of="" strings.="" the="" parameter="" argc="" serves="" as="" the="" argument="" counter,="" which="" is="" the="" number="" of="" arguments="" that="" were="" supplied.="" try="" the="" following="" code,="" and="" make="" sure="" that="" you="" understand="" it.="" printing="" out="" supplied="" command-line="" arguments.="" #include=""> ETS TYCEY aero [ETT oan for ( i=0; i [EENSRT ORR EIT OPTIONS "pi:" EYEENS [STL LETTS BT while ((opt = getopt (argc, argv, OPTIONS)) PES AE TO Ie case 'p': printf ("-p option.\n"); break; case 'i': printf ("-i option: %s is parameter.\n", optarg); EI pba } Ft This example program supports two command-line options, -p and -i. Note that the option character ‘i’ in the defined option string OPTIONS has a trailing colon. The colon signifies, when the -i option is enabled on the command-line, that getopt () should search for a option argument following it. An error is thrown by getopt () if an argument for a option, or flag, requiring one is not supplied. 8 Deliverables You will need to turn in the following source code and header files: 1. bbp. c: This contains the implementation of the Bailey-Borwein-Plouffe formula to approximate 7 and the function to return the number of computed terms. 2. e.c: This contains the implementation of the Taylor series to approximate Euler's number e and the function to return the number of computed terms. 3. euler.c: This contains the implementation of Euler's solution used to approximate 7 and the function to return the number of computed terms. 4. madhava.c: This contains the implementation of the Madhava series to approximate 7 and the function to return the number of computed terms. 5. mathlib-test.c: This contains the main () function which tests each of your math library functions. 6. mathlib.h: This contains the interface for your math library. 7. newton. c: This contains the implementation of the square root approximation using Newton's method and the function to return the number of computed iterations. 8. viete.c: This contains the implementation of Viéte's formula to approximate 7 and the function to return the number of computed factors. You may have other source and header files, but do not make things over complicated. You will also need to turn in the following: Writing Protion Writing Portion Description 1 Describe how to use your program and Makefile. It should also list and explain any command-line options that your program accepts. Any false positives re- ported by scan-build should be documented and explained here as well. Note down any known bugs or errors in this file as well for the graders. Description 2 describe your design and design process for your program with enough detail such that a sufficiently knowledgeable programmer would be able to replicate your implementation. This does not mean copying your entire program in verbatim. You should instead describe how your program works with supporting pseudocode. Description 3 Graphs displaying the difference between the values reported by your implemented functions and that of the math library’s. Analysis and explanations for any discrepancies and findings that you glean from your testing.
Answered 3 days AfterJan 26, 2023

Answer To: Your task for this assignment is to implement a small number of mathematical functions (e* and /x),...

Aditi answered on Jan 28 2023
35 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here