# Given a quadratic equation in standard form, ax2 + bx + c = 0, solutions for x

## Question:

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);

**Related Book For**

## Applied Physics

ISBN: 978-0132109277

10th Edition

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

**Posted Date:**