Question
Programming language is C++. The code for problem 2 is posted below. Show finished code and an example of the output on PuTTY when done.
Programming language is C++. The code for problem 2 is posted below. Show finished code and an example of the output on PuTTY when done. Use g++ -std=c++17 -Wall -Wextra -pedantic -fsanitize=address,undefined to compile the code on PuTTY.
#include
using namespace std;
/* Calculate cube root using Pade approximation */ double my_cbrt_l(double n) {
double numerator = (101.639 * n * n) + (207.953*n) + 29.7541; double denominator = (-1 * n * n *n) + (42.945* n *n) + (215.165* n) + 92.1357;
double result = numerator / denominator;
return result; }
int main(void) {
double n;
cout
for (auto k : { -100,-10,-1,0,1,10,100 }) { n = M_PI * pow(10.0, k); cout
3. (20 points Modify problem 2 to also print the relative error as a per cent, by adding a column. relative error per cent 100 my cbrt i(n)-cbrt(n) cbrt(n). Line up the columns using setw0, etc. Name your program hw2pr3.cpp
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started