Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given a quadratic equation in standard form, ax2 + bx + c = 0, solutions for x can be determined using the quadratic formula, .

Given a quadratic equation in standard form, ax2 + bx + c = 0, solutions for x can be determined using the quadratic formula, . The values of x can be real or complex. The discriminant, b2 - 4ac, is used to determine the nature of the root(s). If the discriminant is negative, there will be no real roots. If the discriminant is 0, there will be one real root. In the third case, a positive discriminant will yield two real roots. (Real roots are of particular interest in solving physical world problems.)
Write a function that will determine the number of real roots for a quadratic equation as well as calculate any real roots. The function header should be:
int quadraticRoots (double a, double b, double c, double& x1, double& x2);

where a, b, and c represent the coefficients from the standard form of the quadratic equation and x1 and x2 represent the possible real roots.
If the number of real roots is zero, the function should return 0 without assigning values to x1 and x2. If the number of real roots is one, the function should assign the value of the real root to x1 and return 1. If the number of real roots is two, the function should assign the values to x1 and x2 in no particular order and return 2.
Test this function thoroughly.
Circles
The standard form of an equation for a circle is (x - h)2 + (y - k)2 = r2 where (h,k) represents the center of the circle and r is the radius. The y-value of the equation becomes zero at the point of intersection with the x-axis. When the value of 0 is substituted for y, the equation can be simplified to a quadratic equation in standard form.


(x - h)2 + (0 - k)2=r2
(x - h)2 + k2=r2
x2 - 2hx + (h2 + k2 - r2)=0

From here, the value(s) of x can be resolved using the quadratic formula.
Write a function that accepts the center point and radius of a circle and returns how many times the circle crosses the x-axis, if at all. If an intersection occurs, the function should return the x-value(s) as well. This new function should call the quadraticRoots function to determine if the circle crosses the x-axis and if so, where. The prototype for the function should be:
int circleIntersections (double h, double k, double r, double& x1, double& x2);

Step by Step Solution

3.52 Rating (155 Votes )

There are 3 Steps involved in it

Step: 1

Program Editable code include include using namespace std int quadraticRootsNewdouble a double b dou... 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

Recommended Textbook for

Applied Physics

Authors: Dale ewen, Neill schurter, P. erik gundersen

10th Edition

978-0136116332, 136116337, 9780132830096, 978-0132109277

More Books

Students also viewed these Programming questions

Question

Evaluate the integral (4e* + 2 In (2))dx.

Answered: 1 week ago