Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You should know from ECE2020 that a digital representation of certain real numbers is only an approximation. For example, irrational numbers such as , e,

image text in transcribed

You should know from ECE2020 that a digital representation of certain real numbers is only an approximation. For example, irrational numbers such as , e, V2, etc have only a finite number of digits that can be represented in a digital computer. The two main representations that we will use in C++ will be single precision (32-bit) and double precision (64-bits) numbers. In each of the number formats, a certain number of bits is dedicated to the exponent (8 bits for single precision and 11 bits for double precision), the mantissa (23 bits for single precision and 52 bits for double precision), and 1 bit for the sign bit I would like for you to use a C++ program to calculate the roots of the following quadratic equation: 2x2 + 6000002x 6 = 0 Please use the following non-conventional Muller's method for the quadratic equation in your program to solve for the roots. 2c In fact, I would like for you to use a global function that has four parameters that you pass to it (i.e. a flag to indicate if it should return the plus or minus solution, a, b, and c). You should make one function using only float's and the other only double's so that you can compare the results. To calculate the square root, you can use the sqrt(x) function that is a part of the cmath library. To include this in your program you must have the following preprocessor directive. #include The actual exact roots of this equation are X1 =0.001 and X2=-3000. Please compare how your program calculates this with first float types and then with doubles. You can calculate the error given by: % error-100 * (actual-approximation)/actual QUESTION YOU NEED TO ANSWER: Given the fact that both roots can easily be represented with a float, why do you get a couple percent error for one of the roots? In your Labl Using the float data type the roots are directory, please call your source code lab1part2.cc. Possible sample output is as follows x1- x2- % error- % error- Using the double data type the roots are: x1- x2- % error- % error

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Database Systems For Advanced Applications Dasfaa 2023 International Workshops Bdms 2023 Bdqm 2023 Gdma 2023 Bundlers 2023 Tianjin China April 17 20 2023 Proceedings Lncs 13922

Authors: Amr El Abbadi ,Gillian Dobbie ,Zhiyong Feng ,Lu Chen ,Xiaohui Tao ,Yingxia Shao ,Hongzhi Yin

1st Edition

3031354141, 978-3031354144

More Books

Students also viewed these Databases questions

Question

PLEASE WRITE THE MATLAB CODES BRIEFLY

Answered: 1 week ago

Question

2. How should this be dealt with by the organisation?

Answered: 1 week ago

Question

explain what is meant by the term fair dismissal

Answered: 1 week ago